GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||
GeezerVison is showing github.com — Fix npm v2 revert half-reverting the lock (#1937) by mikolalysenko · Pull Request #1938 · SocketDev/socket-patch Conversation
|
| Test | Without fix | With fix |
|---|---|---|
vendor::npm_lock::tests::v2_revert_restores_a_resolved_less_mirror_node_with_our_integrity |
drift warning, artifact kept | lock byte-identical to pre-vendor, artifact gone |
vendor::npm_lock::tests::v2_revert_keeps_the_packages_twin_of_a_drifted_mirror_node |
packages entry reverted (half-revert) |
lock untouched |
vendor::npm_lock::tests::v2_revert_keeps_the_packages_twin_of_a_re_resolved_mirror_node |
packages entry reverted |
packages stays wired |
vendor::npm_lock::tests::v2_revendor_of_a_resolved_less_mirror_node_records_no_original |
original = patched node |
original: None |
vendor::npm_lock::tests::v2_revert_does_not_blame_a_converged_packages_twin |
(new gate behavior) | one drift warning, for the mirror only |
e2e e2e_vendor_npm_build::npm_v2_revert_after_npm_install_restores_both_lock_halves (real npm 10.9.9, --lockfile-version 2; rollback, remove <purl>, vendor --revert, re-vendor + vendor --revert) |
rollback exits 1 rollback_failed; re-vendor case leaves the mirror on the patched integrity |
all exit 0, both halves restored, artifact removed |
Commands run locally:
cargo fmt --all -- --check: cleancargo clippy --workspace --all-features -- -D warnings: cleancargo test -p socket-patch-core --all-features --lib vendor::npm_lock: 122 passedcargo test -p socket-patch-cli --all-features --test e2e_vendor_npm_build -- npm_v2_revert_after_npm_install: passed. Red on the base code: rollback_failed; red without the vendor-side change: the mirror node was left on the patched integrity.cargo test -p socket-patch-core --all-features: 7000 passed, 4 failed. The 4 also fail on main in this container, because it runs as root and root ignores read-only and unremovable permissions: pypi_poetry::wire_write_failure_maps_error_and_leaves_lock_untouched, pypi_requirements::wire_failure_rolls_back_already_written_files, copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry.cargo test -p socket-patch-cli --all-features --lib --test e2e_vendor_npm_build: 940 + 44 passedcargo test --workspace --all-features could not finish locally: building every integration-test binary ran out of this session's disk allowance (No space left on device). CI runs the full matrix.Per-issue checklist:
npm install, yet half-revert the lock: packages goes back to the registry while the legacy mirror keeps the patched integrity, and npm 6 then fails EINTEGRITY #1937: rollback / remove / vendor --revert after npm install on a v2 lock (e2e plus unit test); no half-revert when one half really drifted (two unit tests); re-vendor remedy path (unit plus e2e)./code-review high), not changedintegrity as an exact string. That is what Vendored npm vex and vendor --check fail after any npm 7–10 npm install on a lockfileVersion 2 lock, because npm drops resolved from the legacy mirror and #813 treats that as an unpatched npm 6 install (regression) #879's vex rule does too (pins_a_wired_ref compares the SRI strings exactly), so revert and vex agree.legacy_pointer_packages_key maps /dependencies/ws/dependencies/x to node_modules/ws/node_modules/x, not packages/ws/node_modules/x. lock_inventory uses the same pre-existing convention. For a nested dependency of a workspace member, the twin gate falls back to the previous per-record behavior: no regression, but no gate either. Possible follow-up.vendor_lock_entry_drifted code. That is the same code RevertOutcome::drift_skipped uses to keep state, so the two can't disagree.Only Rust core and CLI tests change. The npm, PyPI and gem wrappers only dispatch the binary.
https://claude.ai/code/session_011f9aeNkhAFT7jRyt8GURGB
Note
Medium Risk
Changes npm lock revert and re-vendor wiring logic on a critical path; behavior is heavily tested but incorrect twin pairing could still leave locks inconsistent in edge cases.
Overview
Fixes half-reverts of npm lockfileVersion 2 locks after a normal npm install (npm 7–12), which strips resolved from the legacy dependencies mirror while leaving the vendored integrity.
Revert now treats a mirror node with no resolved but the recorded vendored integrity as still ours (same rule as vex / vendor --check, #879), so rollback, remove, and vendor --revert can restore both the packages entry and its mirror and remove the artifact. A TwinGate dry-run skips rewriting one half when the other half would be drift-kept, avoiding a self-inconsistent lock (npm 6 EINTEGRITY).
Re-vendor treats that mirror shape as already wired and does not snapshot the patched node as original; carry_forward_wiring keeps the true pre-vendor state.
Adds focused unit tests in npm_lock.rs and an e2e case exercising rollback, remove, revert, and re-vendor after npm install.
Reviewed by Cursor Bugbot for commit f6f0ee6. Configure here.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Assisted-by: Claude Code:claude-opus-5-5
After vendoring a lockfileVersion 2 project, a plain `npm install` (npm 7-12) re-saves the lock and drops `resolved` from the legacy `dependencies` mirror node, keeping only `version` and the patched `integrity`. `rollback`, `remove` and `vendor --revert` called that node drift, yet still restored the `packages` entry it mirrors. They exited 1 (or reported "Kept 1 drifted package") over a lock that disagreed with itself, kept the artifact, and npm 6 then failed with EINTEGRITY. A resolved-less mirror node carrying the vendored integrity now counts as ours, the same rule `vex` and `vendor --check` use since #879, so all three commands restore both lock halves and remove the artifact. When a mirror node or its `packages` entry really did drift, neither half is rewritten any more, and the kept half gets a warning naming the drifted one. Fixes #1937 Assisted-by: Claude Code:claude-opus-5-5
Re-running `vendor` or `scan` after `npm install` dropped a v2 mirror node's `resolved` recorded that patched node as its pre-vendor original, so a later revert put the patched integrity back while restoring the `packages` entry to the registry: the same half-reverted lock. The node now counts as already vendored, and its original carries over from the earlier record. The twin gate now only holds back a record the revert would rewrite, so an entry the user already restored is not reported as left alone, and v3 locks skip the dry pass entirely. Refs #1937 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
bugbot run Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
✅ 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 f6f0ee6. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ready for review — burn-down agent.
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Final review briefWhat it does: After vendoring an npm lockfileVersion 2 project, a plain Risk: medium. It changes the npm lock revert path, which deletes artifacts. The new ownership rule is narrow (an exact integrity match), and the twin gate only holds records back, never forward, so when it is wrong it keeps the vendored state rather than losing data. Look here:
Verified:
Changes I made: none. Open questions (not blocking, follow-up material):
Auto-merge (squash) is armed, so approving sends this straight to the merge queue. Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
[agent] On the final review brief's open questions: both stay out of this PR, as follow-ups.
Generated by Claude Code |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
[agent] Reviewed f6f0ee669789151fd730556d451e2a336e0991e2. Checked atomic npm v2 twin restoration and ownership after npm drops legacy resolved fields. No major correctness issues found. Validation: source and regression-test review plus the available exact-head CI checks; no local test pass is claimed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Vendored npm rollback / remove / vendor --revert on a lockfileVersion 2 lock fail after anynpm install, yet half-revert the lock: packages goes back to the registry while the legacy mirror keeps the patched integrity, and npm 6 then fails EINTEGRITY
There was an error while loading. Please reload this page.