remove <target> reports success over a vendored package whose ledger entry is lost: the lockfile keeps installing the patched artifact and the patch record is deleted
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
Direção de pesquisa
Start with crates/socket-patch-cli/src/commands/rollback.rs and remove.rs, then inspect the failing cases in tests/in_process_vendor.rs and the relevant state discovery rules in CLI_CONTRACT.md. Trace how each command identifies unowned vendor directories and checks them before writing. Done means scoped remove and rollback refuse affected targets with the missing-ledger guidance, preserve the manifest record, and keep unrelated targets working.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
[agent] Found by the architecture refactor routine (ledger discussion #2244, lead L37), on main at cfc870f.
Problem
A lockfile still installs a package from .socket/vendor/<eco>/<uuid>/, and the vendor ledger has no entry for it. The contract names how a project gets there: a git merge that kept one side of .socket/vendor/state.json (#991), or a state.json that was deleted or never committed.
An unscoped rollback refuses that state with vendor_ledger_missing, exit 1, and writes nothing (#1739 for #991). remove <target> and rollback <target> do not ask the same question, and give four other answers. The worst one is a success:
$ socket-patch remove pkg:npm/[email protected] --yes
1 package already in original state
Removed 1 patch from manifest:
- pkg:npm/[email protected]
Manifest updated at <project>/.socket/manifest.json
Removed 2 unused blobs (65 B freed) (exit 0)
$ grep -A2 '"node_modules/left-pad"' package-lock.json
"node_modules/left-pad": {
"version": "1.3.0",
"resolved": "file:.socket/vendor/npm/9f6b2c4e-1d3a-4f6b-8c2d-7e5a9b1c3d5f/left-pad-1.3.0.tgz",
The patch is reported removed and the package original. The lockfile still installs the patched tarball, and the record that described it is gone.
Who it hurts
- Someone removes a patch, perhaps because it broke the build, and is told it is gone.
npm cikeeps installing the patched package. - After that
listno longer shows the patch, a secondremovesays "No patch found", andvexcan no longer attest the package without the patch API (record_unavailable). Onlyvendor --checkandrepairstill see the wiring. - In a project with no manifest (every
scan --mode vendoredproject) the same commands exit 1 and write nothing, but say there is no patch, whererollbacknames the lost ledger and the way out.
Evidence on main
The binary is built from cfc870f. The projects are files only: a lockfile, the installed copies and, where stated, a manifest. vendor or scan --mode vendored ran first against the repository's prebuilt-artifact fixture (tests/prebuilt_common), and then one ledger entry or the whole state.json was removed. In every row the lockfile still names the artifact afterwards.
A project with a manifest (agent mode, then socket-patch vendor), two vendored npm packages:
| Ledger | Command | Result |
|---|---|---|
| entry lost, or file deleted | rollback |
exit 1, vendor_ledger_missing, nothing written |
| entry lost, or file deleted | vendor --check |
exit 1, vendor_ledger_missing |
| entry lost, or file deleted | rollback pkg:npm/[email protected] |
exit 0: "Rolled back 1 package: pkg:npm/[email protected] (already original)", "Removed 1 patch from manifest.", and the vendor_orphan_still_wired warning |
| entry lost, or file deleted | remove pkg:npm/[email protected] --yes |
exit 0, the output above, no warning |
Under --json the remove is "status": "success" with a removed event for the purl and no warnings. A requirements.txt project and a Cargo project give the same remove result (exit 0, the wiring kept, plus a rollback_not_installed skip).
What the other commands say after that remove:
$ socket-patch list # the patch is no longer listed
Found 1 patch:
Package: pkg:npm/[email protected]
$ socket-patch remove pkg:npm/[email protected] --yes
Error: No patch found matching identifier: pkg:npm/[email protected] (exit 1)
$ socket-patch vendor --check
vendor_ledger_missing: a lockfile references a vendored npm artifact under .socket/vendor/npm/ but the vendor ledger (.socket/vendor/state.json) has no entry for it; restore state.json from version control (exit 1)
$ socket-patch vex --output - --product pkg:generic/[email protected]
Warning: omitting pkg:npm/[email protected] from VEX: a lockfile wires the patch, but no local record exists and the patch API could not supply one (…) (record_unavailable)
A project with no manifest (scan --mode vendored):
| Ledger | Command | Result |
|---|---|---|
| entry lost | rollback |
exit 1: "Lockfiles reference .socket/vendor/npm/9f6b2c4e-…/, which the vendor ledger (.socket/vendor/state.json) has no entry for, so rollback cannot unwind them; restore the missing entries …" |
| entry lost | rollback pkg:npm/[email protected] |
exit 1: "No patch found matching identifier: pkg:npm/[email protected]" |
| entry lost | remove pkg:npm/[email protected] --yes |
exit 1: "No patch found matching identifier: pkg:npm/[email protected]" |
| file deleted | rollback, rollback pkg:npm/[email protected] |
exit 1: "Lockfiles still reference .socket/vendor/ artifacts but the vendor ledger is missing — restore .socket/vendor/state.json from version control, then roll back (…)" |
| file deleted | remove pkg:npm/[email protected] --yes |
exit 1: "No patches in this project; nothing to remove." |
Cause
One rule, "a lockfile reference into .socket/vendor/<eco>/<uuid>/ that no ledger entry owns cannot be unwound", is asked in two places of crates/socket-patch-cli/src/commands/rollback.rs and nowhere in remove.rs:
- the missing-ledger early exit (line 2040), which
rollbackreaches only when the project has no manifest; unledgered_vendor_wiring(line 1080), guarded by!scoped(line 2220).
The guard is right for a target that names another package: that run does not own the wiring. It also lets through a target that names the very package the unowned directory holds. With a manifest record for it the agent leg then finds the installed copy original and reports the patch rolled back. remove has neither check: its no-state exit (remove.rs line 614) and its unmatched-target error (line 793) never read the lockfiles.
Earlier fixes of the same class, each for one command or one cause: #1739 for #991 (unscoped rollback), #2250 for #2249 (remove and rollback <target> over a ledger that cannot be read, where the contract now says such a target "is never 'not found' while the ledger cannot be read, since the ledger may hold it").
What settles the expected behavior
CLI_CONTRACT.md, rollback's state discovery: "A project whose lockfiles still reference.socket/vendor/artifacts but whose vendor ledger is missing errors asking for.socket/vendor/state.jsonto be restored from version control first", and the error table: "vendor_ledger_missing| rollback | Lockfiles reference.socket/vendor/artifacts but the vendor ledger is missing, or (unscoped run) has no entry for a referenced uuid dir (#991)". With a manifest present and the ledger file deleted,rollback <target>exits 0 today.- The same section, on why the unscoped run refuses: "reverting the rest would exit 0, leave that package wired and delete the ledger". The scoped
removedoes that to the manifest record. - The charter's rule that success is never reported for work that did not happen.
Planned fix
One function answers "which unowned vendor directories does this run's target reach", and rollback and remove both call it before any write:
- A target that selects a manifest record whose uuid an unowned lockfile reference carries: refuse with
vendor_ledger_missing, naming the directory and the remedyrollbackalready prints. Nothing is restored and no record is dropped. - A target that selects nothing while an unowned reference exists:
vendor_ledger_missingin place of "No patch found", as #2250 did for the unreadable ledger. removein a project whose only state is that wiring: the messagerollbackgives, in place of "No patches in this project; nothing to remove."- A target that names another package keeps working, as the contract says.
Tests, failing on main: the first table's remove and rollback <target> rows over the npm fixture of tests/in_process_vendor.rs, and the second table's three bold rows.
One open point: the contract's error table lists vendor_ledger_missing for rollback only. Giving remove the same code is the sibling's rule and adds a row to that table.
Not checked
- Hosted pins beside the unowned wiring.
--ecosystemsnarrowing and--global.- JVM artifacts, which keep their own tree layout.
Generated by Claude Code
- Linguagem predominante
- Rust
- Estrelas
- 9
- Forks
- 2
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 313
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
SocketDev/socket-patch#2306 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit bug priority:p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
SocketDev/socket-patch#2296 ·
Mantenedores costumam responder em até 1 dia
-
agent:needs-human agent:triaged ci-janitor priority:p1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
SocketDev/socket-patch#2270 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit bug priority:p1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
SocketDev/socket-patch#2259 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
SocketDev/socket-patch#1860 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-patch
Issues semelhantes
-
Tighten observation-contract prose for trailing-archive fallback and spent-scan coverage noteAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
storytold/craft-launcher#1671 ·
Mantenedores costumam responder em até 1 dia
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100