Repository navigation
Description
[agent] Filed by the architecture refactor routine. Checked on main at cfc870f with the built binary, git 2.43.0, npm 10.9.9 and cargo 1.97.0.
Kind: bug. An error is read as "not a repository", and the run reports success for a tree git will not commit.
Problem
Every vendored backend asks git whether it would commit what the run writes, and refuses vendor_artifact_gitignored when a rule such as vendor/ or .socket/ covers .socket/vendor/. The question starts with git rev-parse --is-inside-work-tree. When the checkout belongs to another user, git answers every command with fatal: detected dubious ownership in repository and exit 128, which is also its exit code outside a repository. The probe reads 128 as "not a work tree" and skips the check without a word.
A root process over a checkout owned by another uid is the case core utils/repo_root.rs (lines 431 to 435) calls common: a container with the project bind-mounted, where the owner commits from the host.
CLI_CONTRACT.md (line 2612) says of vendor_artifact_gitignore_unchecked: "git is installed but could not answer the ignore check for the written vendored directory (it failed to start, ran past 30 s, or rev-parse / check-ignore exited with an error)", and "Git absent, or a project outside any work tree, raises nothing". This project is inside a work tree and rev-parse exited with an error.
Evidence
A real npm project (left-pad 1.3.0 from the registry, one patch record and blob) whose .gitignore holds node_modules/ and vendor/, vendored against the repository's fixture vendor service. Two copies of it, the second after chown -R 1000:1000, both run as root:
$ socket-patch vendor --json # the checkout is the invoking user's
"status": "partialFailure"
events: failed, vendor_artifact_gitignored: git would not commit the vendored artifact at .socket/vendor/npm/<uuid> (.gitignore:2:vendor/ …)
$ ls .socket
blobs manifest.json # nothing written
$ git rev-parse --is-inside-work-tree # the checkout is another user's
fatal: detected dubious ownership in repository at '…' # exit 128
$ socket-patch vendor --json
"status": "success", summary.applied 1, "warnings": []
$ ls .socket
blobs manifest.json vendor
Then the owner commits what the run asked for and CI installs it:
$ git add -A && git commit -qm vendor && git status --short --ignored | grep '^!!'
!! .socket/vendor/
!! node_modules/
$ git clone -q . ../clone && cd ../clone && npm ci
npm error code ENOENT
npm error path …/.socket/vendor/npm/<uuid>/left-pad-1.3.0.tgz # exit 254
The same two copies of a real Cargo project (cfg-if 1.0.4, .gitignore with /target and vendor/):
$ socket-patch vendor # the invoking user's checkout
Error: git would not commit the vendored artifact at .socket/vendor (.gitignore:2:vendor/ .socket/vendor/); remove the rule that ignores .socket/ (or .socket/vendor/) and vendor again # exit 1
$ socket-patch vendor # another user's checkout
Vendored 1 package.
Next steps:
1. Commit .socket/vendor/ and the updated lockfiles to make the patches portable. # exit 0
What is not affected: a file rule such as *.tgz or *.jar, because the !* .gitignore written into the uuid directory overrides it whether or not git answered. The rules that get through are the ones that file cannot override (a directory rule over .socket/ or vendor/) and the ledger's file rules.
Where
- core
vendor/npm_dir.rs,ignoring_rule_lines(lines 950 to 983):rev-parseexiting 128 returnsOk(None)(line 968), the answer for "no rule matches". Every caller goes through it: the per-package checks of the npm family, NuGet, PyPI, the JVM trees and platform gems, the run-levelledger_gitignore_refusal(corevendor/state.rs, line 1067) and agent mode'smanifest_gitignoredwarning. ledger_gitignore_refusalalso drops a real error on purpose (.ok()??, line 1075), so Cargo, Go, Composer and a plain gem have no warning to give at all.vexalready says so in the same situation: corevex/product.rs(lines 544 to 551) warns "git checkout … is owned by another user; not reading its remote origin for the top-level product (git refuses it too, see safe.directory)".
Planned fix
Tell the two cases apart with the lookup the CLI already has: when repo_root::find_git_repo finds a checkout around the project and rev-parse exits 128, git could not answer. Then:
- the per-package checks raise
vendor_artifact_gitignore_unchecked, as the contract says, with git's reason in the detail; - the run-level ledger check raises the same warning instead of nothing, so every backend is covered;
- agent mode's manifest check does the same.
A unit test can make the checkout untrusted without chown: GIT_TEST_ASSUME_DIFFERENT_OWNER=1 in the probe's environment.
Not proposed: passing -c safe.directory=… to make git answer. The ledger check reads the index, and git's refusal exists because a repository's own configuration can run commands.
Behavior change: a warning where there was none. No exit code changes.
Generated by Claude Code
Activity
refactor: #2348, #2349 and #2351 filed; ignore rules ran