Skip to content

Vendored scan exits 0 when .gitignore covers .socket/vendor/state.json, so the commit silently drops the ledger and every other checkout's rollback fails with vendor_ledger_missing #1638

Open

Description

[agent] Found by the scheduled pnpm bug-hunt routine (ledger #303).

Summary

Vendored mode checks git's ignore rules for the artifact's uuid directory (vendor_artifact_gitignored, #831 / #1061) and re-includes the tarball against file rules such as *.tgz. It never checks the vendor ledger .socket/vendor/state.json. In a project whose .gitignore matches the ledger (state.json, *.json, **/state.json, …), scan --mode vendored:

  • exits 0 with no warning;
  • prints "Commit .socket/vendor/, package.json, pnpm-lock.yaml, …".

git add .socket then silently leaves state.json out and exits 0. The tarball, its .gitignore, .gitattributes and socket-patch.vendor.json are all committed, so installs still land the patched bytes. Every other checkout (a teammate, CI, a fresh clone) has the lock wiring but no ledger.

Impact

In any checkout other than the one that ran the scan:

The patch can't be undone with the tool anywhere except the original working copy. vex still attests, because the lock wiring and the artifact are present, so nothing points at the missing ledger until someone tries to roll back.

Expected vs actual

  • Expected: docs/usage.md:96 says "Commit .socket/vendor/, including state.json… The ledger stores patch records, artifact fingerprints, and reversal information." docs/development.md:48 says "A ledger is required for repair and managed reversal; discovering a reference is not enough to rebuild it." The artifact gets a pre-write gitignore refusal or a re-include for the same reason. The ledger should get the same protection: re-include it (as <uuid>/.gitignore does for the tarball), or refuse or warn before writing.
  • Actual: exit 0, no warning, and the ledger is silently left out of the commit.

Repro (pnpm 12.14.0, Linux)

# Project with left-pad@1.3.0 and a patch available for it (I used a local mock of the patch API).
mkdir p && cd p && git init -q
echo '{"name":"led","version":"1.0.0","dependencies":{"left-pad":"1.3.0"}}' > package.json
pnpm install
printf 'node_modules\nstate.json\n' > .gitignore
git add -A && git commit -qm init
socket-patch scan --mode vendored          # exit 0, "Vendored 1 package. Commit .socket/vendor/ ..."
git add .socket package.json pnpm-lock.yaml pnpm-workspace.yaml   # exit 0; state.json silently skipped
git commit -qm vendored
git clone -q . ../clone && cd ../clone
pnpm install --frozen-lockfile             # exit 0, patched bytes land
ls .socket/vendor/state.json               # No such file
socket-patch rollback                       # exit 1: vendor_ledger_missing ("restore ... from version control")
socket-patch list                           # "No patches in this project"

OS × version

All cells below are on Linux, Node 22.22.0. Each was run at least twice on main 7d3086f with state.json and *.json rules. The 5.0.1 release was run once per cell.

pnpm socket-patch scan exit / warning ledger in clone clone frozen install clone rollback
9.15.9 main 7d3086f 0 / none missing 0, patched 1, vendor_ledger_missing
10.34.7 main 7d3086f 0 / none missing 0, patched 1
12.14.0 main 7d3086f 0 / none missing 0, patched 1
10.34.7 / 12.14.0 release 5.0.1 (npm) 0 / none missing 0, patched 1

Not bisected. The release 5.0.1 behaves the same, and there is no ledger-path probe anywhere in the code.

Probe runs on macOS and Windows: none. Probe branches are on hold until the stale bughunt/pnpm/* branch can be deleted (see ledger #303). The code path is OS-independent.

Suspect code

  • crates/socket-patch-core/src/vendor/npm_common.rs:226 and :259: npm_tarball_gitignore_preflight / stage_patch_pack probe only format!("{uuid_dir_rel}/").
  • crates/socket-patch-core/src/vendor/state.rs:848 (save_state, path VENDOR_STATE_REL at :44): writes the ledger with no npm_dir::gitignored probe.

This isn't specific to pnpm. Every vendored backend writes the same ledger, so npm, yarn, bun and vlt (and probably maven / nuget) behave the same way. I reproduced it only with pnpm.

Activity

  1. mikolalysenko commented on Oct 18, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Same gap in agent mode, with a worse outcome: the patch is silently not applied in CI.

    .gitignore has manifest.json, or *.json + !package.json. scan --mode agent exits 0 and writes .socket/manifest.json plus .socket/blobs/*. git add .socket commits the blobs and silently skips the manifest (git status --ignored shows !! .socket/manifest.json). In a fresh clone, after pnpm install --frozen-lockfile, the documented CI step socket-patch apply prints "No patch manifest found; nothing to apply." and exits 0 (--json status noManifest). The installed left-pad/index.js stays upstream. vex exits 2, so it doesn't attest anything false, but nothing fails the pipeline.

    pnpm socket-patch rule clone: manifest / blobs clone apply installed bytes
    9.15.9 main 7d3086f manifest.json missing / 2 exit 0, "nothing to apply" upstream
    12.14.0 main 7d3086f manifest.json (2 runs), *.json + !package.json (1 run) missing / 2 exit 0, "nothing to apply" upstream

    The suspect is the same: no npm_dir::gitignored-style probe for the state files the CLI asks you to commit (.socket/manifest.json as well as .socket/vendor/state.json).


    Generated by Claude Code

  2. mikolalysenko commented on Oct 20, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triaged: priority:p1 (pnpm / npm family). Confirmed on main 14eee88. The only gitignore checks (npm_dir::gitignored) are against the artifact dirs (npm_common.rs:226/259, vlt_lock.rs:764, bun_binary.rs:983, …). Nothing checks .socket/vendor/state.json (vendor/state.rs:44) or .socket/manifest.json before telling the user to commit them. Not a duplicate of the ledger-merge issues (#991, #1610), which are about a ledger that is committed.


    Generated by Claude Code

  3. mikolalysenko commented on Oct 20, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue (shared root cause: the CLI never checks git's ignore rules for the state files it tells you to commit, .socket/vendor/state.json and .socket/manifest.json). Branch: agent/fix-committed-state-gitignored. Claim-ID: 2026-10-20T16:20:53Z-eaedee


    Generated by Claude Code

  4. mikolalysenko commented on Oct 20, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Fix in progress: #1640 (draft).


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions