Fix store-copy fold dropping copy writes (#756, #772) - #774
Open
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Open
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
This was referenced Oct 4, 2026
When a package has more than one pnpm or vlt peer-variant store copy, apply and rollback already patch (or restore) every copy, but they only reported what happened to the first one. A run that fixed only a twin copy said "already patched" (applied: 0), and a rollback that restored only a twin said "already original" (rolledBack: 0). Apply and rollback now share one store-copy fan-out and one fold, which merges each copy's per-file records into the result under the copy's on-disk path. The two private folds, which had drifted on which advisories they kept, are gone; both directions now carry only the ownership advisory from a copy. Fixes #756, #772. Assisted-by: Claude Code:claude-opus-5-5
End-to-end regression for #756 through the real binary, on hand-built pnpm and vlt store layouts: apply that patches only a twin copy reports it as applied, and rollback that restores only a twin counts it as rolled back. Documents the copy-qualified file paths in CLI_CONTRACT. Assisted-by: Claude Code:claude-opus-5-5
Mikola Lysenko (mikolalysenko)
marked this pull request as ready for review
October 4, 2026 10:58
Collaborator
Author
|
BugBot review Generated by Claude Code |
Under --force, a store twin missing a patched file skips it and still succeeds. The fold already dropped that copy's "all files skipped" note, but it carried the skipped file's NotFound record, so a package whose primary copy was already patched was reported as "applied" with no files instead of "already patched". Those records now stay with the copy, like its note. Assisted-by: Claude Code:claude-opus-5-5
Collaborator
Author
|
BugBot review Generated by Claude Code |
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 9114533. Configure here.
Collaborator
Author
|
Ready for review. Head is
Generated by Claude Code |
Tanmay Singla (Tanmay182003)
approved these changes
Oct 5, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #756
Fixes #772
Summary
When a package has more than one pnpm or vlt peer-variant store copy, agent-mode
applyandrollbackalready patch or restore every copy, but they only reported what happened to the copy the package resolved to. A run that fixed only a twin copy saidalready_patched/applied: 0. A rollback that restored only a twin saidalready_original/rolledBack: 0. Both now report what they actually did.Root cause
apply_package_patchandrollback_package_patcheach had a private copy of the store-copy fan-out and offold_copy_result. Both folds kept only success/error state and dropped the copy's per-file records (files_patched/files_rolled_back,files_verified,applied_via). The CLI classifies events and tallies from those records, so a write that landed only in a twin was invisible. The two folds had also drifted: apply carried only the ownership advisory from a copy, rollback carried any advisory.Change
patch/store_copies.rs: onefan_out(primary, then everyfind_store_peer_variant_copiescopy forpkg:npm/purls) and onefoldover a smallCopyFoldtrait implemented byApplyResultandRollbackResult.<copy>/index.js), withapplied_viacarried for apply. A failed copy still fails the result, with the samestore copy … failed to <verb>note.--forceskips (NotFoundrecords) are not carried, for the same reason its all-skipped note is not: they describe that copy alone (Bugbot finding, fixed in 9114533).fold_copy_resultfunctions and duplicated loops are deleted (grep -rn fold_copy_result crates/is empty).files[].path(andfilesRolledBack/filesVerified).No wrapper changes are needed:
npm/,pypi/andgem/only dispatch to the binary.Per-issue tests
patch::store_copies::regression_tests::apply_reports_a_write_to_an_unpatched_twin_copyfiles_patchedis[])…::apply_dry_run_carries_an_unpatched_twin_verify_record…::rollback_reports_a_restore_of_a_patched_twin_copyfiles_rolled_backis[])applytest binary:in_process_npm_multicopy::apply_and_rollback_report_a_write_to_only_a_store_twin"applied":0,"skipped":1, eventskipped/already_patched(the exact symptom in the issue)applied: 1, eventapplied; rollbackrolledBack: 1,alreadyOriginal: 0…::apply_over_patched_twins_stays_already_patched,…::rollback_over_original_twins_stays_already_original,…::apply_force_skip_in_a_twin_keeps_an_already_patched_primary,patch::apply::tests::store_copy_fold_carries_ownership_advisories_and_failures,patch::rollback::tests::store_copy_fold_carries_advisories_and_failures,test_rollback_package_patch_new_file_deleted_in_every_pnpm_peer_variant_copy(now also asserts that the heal is reported)Evidence
cargo clippy --workspace --all-features -- -D warnings: clean.rustfmt --checkon every touched file: clean. Runningcargo fmt --allonmainalready reformats ~130 unrelated files, so I formatted only the touched code.cargo test -p socket-patch-core --all-featuresgives 4847 passed and 4 failed. All 4 are permission-based tests that cannot fail a write when running as root, which the sandbox does. They are in untouched files and are green in CI.cargo test -p socket-patch-cli --all-features --lib --bins --test apply --test rollback --test cli --test scan --test get: all green locally.🤖 Generated with Claude Code
Generated by Claude Code