Skip to content

Fix agent vex checking only one installed copy (#516) - #517

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agent/fix-vex-agent-all-copies
Oct 2, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agent/fix-vex-agent-all-copies

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #516

Root cause

vex resolves every installed copy of each manifest PURL (find_manifest_package_copies_reusing), but then collapse_to_first dropped all but the first before the agent-record hash check (applied_patches_with_vendor). apply patches every copy, and hosted PURLs were already judged against every copy (HostedCopies). Agent records were not. So when a later install adds a fresh, unpatched nested copy of the same name@version, vex attested not_affected whenever the first crawled copy happened to be patched.

Change

  • vex::verify::applied_patches_with_copies (new) takes purl -> Vec<PathBuf>, meaning every installed copy. An installed-tree record verifies only when every copy verifies, and the first failing copy's tag wins, using the same verify_every_copy helper that HostedCopies now shares. An empty list means package_not_found. The vendored drift probe (vendored_tree_out_of_sync) flags the PURL when any copy is out of sync. applied_patches_with_vendor stays as a one-copy wrapper, so its existing callers and tests are unchanged.
  • commands/vex.rs passes the full copy map instead of collapse_to_first(...).
  • CLI_CONTRACT.md's verification table states the every-copy rule for agent records.

Hosted, vendored and Go-redirect evidence are unchanged; each already has its own copy selection. The npm, PyPI and gem wrappers only dispatch to the binary, so they need no change.

Test evidence

Issue Regression test Red before fix → green after
#516 e2e_vex::verify_mode_requires_every_installed_copy_patched: two nested copies of dup-pkg@1.0.0, one patched; both crawl orders must omit the PURL (not_applied, non-zero exit), and all copies patched must attest Red: with commands/vex.rs reverted to collapse_to_first, the test panics at e2e_vex.rs:965 (patched-first order attested). Green with the fix.
#516 (core) vex::verify::tests::every_installed_copy_must_verify, empty_copy_list_is_package_not_found, vendored_drift_probe_checks_every_installed_copy Green

Commands run locally:

  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test -p socket-patch-core --lib vex::verify: 36 passed.
  • cargo test -p socket-patch-cli --all-features --test e2e_vex --test e2e_vex_vendor --test e2e_vex_redirect --test covgap_commands_vex: all passed.
  • cargo test --workspace --all-features --no-fail-fast: 9472 passed, 12 failed. All 12 failures are write-failure and permission fixtures (chmod 0o555 / unremovable-file tests in covgap_commands_vendor, in_process_redirect, repair, and four core lib tests). They can't fail as uid 0, which is what this sandbox runs as, and none of them touch vex. CI runs them as a non-root user.
  • cargo fmt --check on the touched files is clean. main itself isn't rustfmt-clean (about 460 diffs) and CI doesn't run fmt, so this PR formats only its own hunks.

CI note: Poetry 1.0.10 (macOS) crlf/hosted failed rescanIdempotent once. That's a hosted rescan against the live patch API, a path this diff doesn't touch. It passed on the one re-run.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZjqW5PYJWkPpisnhaS4zi


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
When a project holds several installed copies of the same
package@version (npm nests duplicates, and a later install can add a
fresh unpatched one), `vex` only hashed the first copy it found. It
could then attest a patch as not_affected while another copy that a
dependent loads was still unpatched.

Agent-mode records are now attested only when every installed copy
matches the patched bytes, the same rule `apply` follows when it
patches and that hosted records already use. The vendored drift
warning also checks every copy.

Fixes #516

Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 2, 2026 00:54
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for 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 0f45d24. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 2, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review — head 0f45d24e6bbc0217d4bb296584ab92fe0a772018.

  • CI: all check runs green on the head (0 failing; only skipped/conditional jobs not run). Mergeable, up to date with main.
  • Bugbot: reviewed 0f45d24 — no issues found. No open review threads.
  • Reviewer focus: vex::verify::applied_patches_with_copies now requires every installed copy of an agent-record PURL to verify (first failing copy's tag wins); commands/vex.rs stops collapsing to the first crawled copy. Regression test: e2e_vex::verify_mode_requires_every_installed_copy_patched.

Generated by Claude Code

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Reviewed 0f45d24e6bbc0217d4bb296584ab92fe0a772018. Recommendation: ready to merge from a code-review perspective.

No actionable correctness or security regressions found. The CLI passes all discovered copies through verification; empty copy lists fail closed, hosted/vendor precedence stays intact, and the vendor drift warning covers later copies.

Validation: cargo test -p socket-patch-core --lib vex::verify: 36 passed. cargo test -p socket-patch-cli --test e2e_vex verify_mode_requires_every_installed_copy_patched: Passed, including both crawl orders and the all-patched control. Full workspace matrix not rerun.

@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Second review pass of 0f45d24e6bbc0217d4bb296584ab92fe0a772018: ready from code review. Every-copy agent verification still fails closed for empty or partly unpatched copy sets. Hosted/vendor precedence and the single-copy API wrapper are preserved. Current main has no competing edits to the changed verification/CLI paths; its PyPI multi-copy apply fix aligns with this requirement.

The head is unchanged from the prior review, discussions introduce no unresolved finding, and it merges cleanly with current main 73b17db5. Prior exact-head validation: 36 core vex::verify tests and the real CLI every-installed-copy regression passed, including both crawl orders and the all-patched control. No duplicate broad test run or code changes were needed for this pass.

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

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

3 participants