Repository navigation
Report a kept or failed vendored revert of scan --prune truthfully - #2246
Conversation
Refs #1910. Assisted-by: Claude Code
A revert that keeps its artifact keeps it for one of two reasons: the lock drifted, or the recorded wiring was restored while another project file still installs from the artifact. VendoredBackend::revert told them apart inline, so a caller that reverts without it could not. KeepCause::of holds that rule. No behavior change. Refs #1910. Assisted-by: Claude Code
The prune GC reverts vendored entries by hand and reported two outcomes wrongly. A revert that restored its recorded wiring but kept the artifact because another project file still installs from it was reported as a drift: "lock entries were re-resolved since vendoring ... undo the drift and re-run vendor --revert". Nothing had drifted, the lock had just been restored, and the warning that names the file to fix was dropped. remove and rollback have told the two keeps apart since #1184. The pass now classifies a keep with the same rule, words it from the same text, and carries vendor_revert_residual_reference into its warnings. A revert the backend refused was reported by purl alone, under a comment saying the backend had printed its error. Nothing printed it. The reason now follows the purl in the human line and in the reason of the vendor_revert_failed event. Event codes, actions and counts are unchanged. A drift keep reads as before. Refs #1910. Assisted-by: Claude Code
A keep for a residual reference restored the lock, so the reinstall advisory a backend raises with it (Bun, vlt) applies. The pass dropped it with every kept revert; it now drops it only for a drift keep, which restored nothing. The forwarded vendor_revert_residual_reference detail names a uuid dir, not a package, so two such keeps could not be told apart. The entry's purl now leads the detail. The reason of a failed revert can quote the committed ledger: the human line prints it without control characters. The contract and two doc comments said backends cannot see a keep on a dry run. The prune preview runs no revert at all; they say that now. Refs #1910. Assisted-by: Claude Code
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Residual-reference keeps are no longer described as lock drift. When a revert restores recorded wiring but another project file (e.g. an exported Failed reverts now carry the backend’s reason in both the human Implementation consolidates duplicate classification in Reviewed by Cursor Bugbot for commit d46d2e1. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d46d2e1. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does. Part of #1910. When Risk: low. Reporting only: event codes, actions, counts and exit codes stay the same, and the drift-keep text is byte-identical. A script matching the old drift sentence on a reference keep would see a new sentence. Look here
Verified. Read the whole diff against the description. The ledger, manifest and orphan-sweep decisions in both legs of Changes I made. None. Open questions. None. The description lists three follow-ups left out on purpose (a third keep cause for a removed dependency, two remedies named, warning order); none blocks this PR. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed KeepCause::of against the inline rule it replaces, and the forwarded residual-reference warning, which appears once. A keep with both drift and a residual reference still reports as drift. No findings.
LLM Description written by Claude Code
Part of #1910. This PR takes the two user-visible defects of that issue; what stays open is listed at the end.
Problem
scan --prunereverts vendored entries whose patch left the manifest or whose dependency left the lock. It reports two outcomes of that revert wrongly, to anyone who prunes a vendored project (by hand or in CI):uv exportorpip freezerequirements file, for example), the artifact and the ledger entry are kept. The pass says the lock was re-resolved and tells the user to undo a drift and runvendor --revert. Nothing drifted, the lock was just restored, and the file to fix is never named: thevendor_revert_residual_referencewarning is dropped.removeandrollbackhave told the two keeps apart sinceremoveandrollbackcall a vendored PyPI residual-reference keep "lockfile wiring drifted", and their "re-runscan --mode vendoredto normalize, then remove" remedy loops (Pipenvpipenv requirementsexport) #1184, andCLI_CONTRACT.mdsays this keep "is a keep too, but not a drift".Evidence on
main(332b3e8)apply_gc_names_the_file_that_still_installs_a_kept_wheel(in this PR,scan/gc.rs) seeds a requirements project whose patch left the manifest, withrequirements-prod.txtstill installing from the vendored wheel. Run onmain:The test's earlier assertions pass on
main: the same pass rewroterequirements.txtback tosix==1.16.0. So "lock entries were re-resolved" and "retained" are both false. The--jsonevent said the same (reason: "lock entries were re-resolved since vendoring, …") with nowarnings.A revert the backend refuses, on
main:Fix
KeepCause::ofholds the rule that tells a drift keep from a residual-reference keep.VendoredBackend::revert(behindremove,rollback,vendor --revert) and the prune GC both call it.note_unreclaimed: a keep with its cause, a failure with the backend's reason. Both of its legs had their own copy of that classification.removeandrollbackuse (KeepCause::reason/remedy), and itsvendor_revert_residual_referencewarning joins the pass's warnings, led by the entry's purl.After, same fixture:
Deleted
The two hand-written keep/failure branches in
run_vendor_gc, the inline classification inVendoredBackend::revert, and the comment that claimed the error had been printed.Behavior change
Reporting only; which entries are reverted, kept or failed is untouched, and so are event codes, actions, counts and exit codes.
GC: keptline instead of the drift line; thereasonof itsskipped/vendor_revert_keptevent says the cause and the remedy;warnings[]gainsvendor_revert_residual_reference. A reinstall advisory the backend raised with it (Bun, vlt) is no longer dropped, since that revert did restore the lock.reasonof thevendor_revert_failedevent.CLI_CONTRACT.md'sscan --pruneparagraph is updated to match.Risk
Low. A consumer that matched the old drift sentence on a reference keep sees a different sentence; one that keyed on
errorCodesees no change.Verification
cargo clippy -p socket-patch-cli --all-targets --all-features -- -D warnings: clean.cargo test -p socket-patch-cli --lib: 1070 passed.scan,in_process_scan,in_process_vendor,scan_vendor_e2e,scan_vendor_requirements_unwired,vendor_revert_tamper_e2e,cli_scan_silent,in_process_rollback_vendored,manifest_path_ledger_root: 575 passed.cfg(windows)orcfg(unix)code changed.Review
/code-review highon the diff returned six findings. Fixed: the dropped reinstall advisory of a reference keep, the forwarded warning that named no package, the unsanitized failure reason on the human line, and a wrong sentence about the preview in the contract and two doc comments. Not fixed here:remove,rollbackandvendoras well as here. A third cause changes the output of all four commands, so it is a change of its own; it is recorded as a lead for this routine.scan --prune). Both work. The warning's text is the backend's and is shared by every command that reverts.maintoo.Diff
git diff --stat: 4 files, +456 −91. Production +146 −73 (about half of it doc comments), tests +309 −17, contract +1 −1.Still open on #1910
Moving the pass onto
VendoredBackend::revertwholesale, reporting the orphan dirs a lockfile still points at, and the Go undo warnings. None of them is verified yet.https://claude.ai/code/session_011f9aeS32WBD64v7i9wx8J6
Generated by Claude Code