Repository navigation
Fix reporting of an installed gem that matches no variant (#2231) - #2237
Conversation
Refs #2231. Assisted-by: Claude Code:claude-fable-5-2
Failing tests for #2231: an installed gem whose file matches neither hash of its qualified record is reported by apply as not installed (lockfile-only note, package_not_installed, "not found on disk"), and apply --check offers an apply that cannot change the copy. Assisted-by: Claude Code:claude-fable-5-2
A gem or PyPI copy whose files match no manifest record of its release is left untouched, as before, but apply never marked its records as seen on disk. They fell through to the unmatched list, so the run called an installed gem lockfile-only, package_not_installed and "not found on disk". apply now gives the copy its own failed result (no_matching_variant, keyed by the base purl, as apply --check reports it) whose text names the copy, the file that differs and, for a gem, bundle pristine. The records of the release are no longer reported as not installed. apply --check no longer ends with an apply remedy that cannot change such a copy. rollback no longer says a file at neither hash was "modified after patching", and names the ways out. Fixes #2231. Assisted-by: Claude Code:claude-fable-5-2
Review fixes for the no-matching-variant report: - Only a copy that holds a file of the patch with other content is reported as installed (no_matching_variant). A copy that holds none of the files its records are matched by stays package_not_installed, as the JRuby missing-file test pins. - Build the apply --check remedy command before quoting it, so the remedy-command scan reads a real command. - Move reinstall_remedy to ui: rollback importing it from agent_download made the two command modules import each other. - The rollback message names no cause: a file at neither hash may be another build's, not an edit. Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview
Docs ( Reviewed by Cursor Bugbot for commit cb3d8b0. 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 cb3d8b0. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does. Fixes #2231. When an installed gem (or PyPI) copy holds a patched file whose content matches no release variant in the manifest (an edited copy, or another build), Risk: low. It changes messages and JSON codes only. One JSON change is visible: such a copy is now Look here
Verified. I read the whole diff against the description and #2231. A copy that holds none of the files its records are matched by still stays Changes I made. None. Open questions. One nit, not blocking: the rollback hint prints a literal Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed; no major findings.
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2231
Summary
In agent mode, a gem whose installed file matches neither hash of its
?platform=…record (edited in place, or rebuilt by a private gem server)is correctly left untouched. But every command described a different
problem:
apply/scansaid the gem was "not installed on this host" and"not found on disk",
apply --jsonreportedpackage_not_installed,apply --checksaid to runsocket-patch apply, androllback/removesaid the file was "modified after patching".
No patching behavior changes: the same copies are left untouched and
the same runs exit 1. Only what the run reports changes.
apply,scan --mode agentno matching variant found, then "not installed on this host (resolved by the project lockfile; skipped)", "1 not found on disk"bundle pristine <gem>; summary says1 failed, 0 not found on diskapply --jsonskipped/package_not_installedbesidepartialFailurefailed/no_matching_variant, keyed by the base purl (the codeapply --checkalready used)apply --checksocket-patch applyto regenerate them."applyleaves the copy as it is and namesbundle pristine <gem>; the closingapplyremedy is printed only when some other drift needs itrollback,removerollbacklists the two ways out: reinstall (bundle pristine <gem>) and roll back again, orremove <purl> --skip-rollbackOutput after the change, for the issue's project (
rackwith a debug edit):Root cause
The release-variant loop of
apply(gem and PyPI) fails a primary copythat no record matches, but never marked the base's records as seen on
disk and pushed no result for the copy. The records fell through to the
"unmatched" list, where a
Gemfile.lockthat resolves the gem turns theminto the calm lockfile-only skip. The other two messages were written for
a different state: the
--checkremedy assumesapplyheals every drift,and rollback's
HashMismatchtext assumes the file was patched first.What changed
apply.rs: a copy that holds a patched file with content no record wasmade for gets its own failed result (
no_matching_variant, base purl),and the base's records are marked matched. A copy that holds none of
the files its records are matched by is unchanged
(
package_not_installed, exit 1): an existing JRuby test pins that aqualified record cannot be told to belong to such a copy.
apply --check: theno_matching_variantdrift carries its own remedyand no longer triggers the closing
applyline.rollback: rewordedHashMismatchmessage (core) and a ways-out blockunder
Failed to roll back:.reinstall_remedymoved fromagent_downloadtouisorollbackcan use it without an importcycle.
CLI_CONTRACT.md: newno_matching_variantrow forapply, and the--check,package_not_installedand rollback rows updated.Reviewer notes
cli_gem_variant_mismatch_policy.rs. They pinned "nofailedevent"for a no-variant miss, to tell it apart from a variant that was tried
and refused. That is the reported bug: the only event was
package_not_installed. They now require onefailed/no_matching_variantevent (a tried-and-refused variant staysapply_failed) and nopackage_not_installed. The fail-closedassertions (exit 1, file bytes untouched) are unchanged.
quoted the old sentence were updated.
scan/get --mode agentshould pick the new code up through thenested apply's failures (a base-purl failure covers a qualified record
in
apply_key_covers). That is from reading the code; no test heredrives it through
scan.Evidence
Red first (commit
d631e8f, tests only, against unfixedmain): the fourapply /
--checktests ingem_unmatched_copy_reporting.rsfailed; therollback test was run red before its fix as well.
cargo clippy --locked -p socket-patch-core -p socket-patch-cli --all-features -- -D warnings(CI's command)cargo fmt --checkon both cratescargo test -p socket-patch-corecargo test -p socket-patch-cli --libplus 25 suites (apply,rollback,remove,get,scan,vex, the in-process gem / PyPI / rollback / get suites,e2e_gem_native_ext_build,command_module_layering,remedy_commands_parse, …)cargo test -p socket-patch-cli --test e2e_gem_native_ext_build -- --ignored(real Ruby 3.3.6, Bundler 4.0.18)The remaining CLI suites were not run locally: building every test
target exhausted the sandbox disk. An earlier full run, before the review
fixes, got through 60 test binaries and failed only the four tests the
review fixes address. CI runs the rest.
Which test covers what (all in
crates/socket-patch-cli/tests/apply/gem_unmatched_copy_reporting.rs):applyoutput:edited_gem_is_reported_as_installed_with_other_contentapply --json:edited_gem_is_a_failed_event_not_a_not_installed_skipapply --check:check_does_not_offer_apply_for_a_copy_apply_leaves,check_keeps_the_apply_remedy_for_a_drift_apply_healsrollback/remove:rollback_names_the_ways_out_of_a_copy_it_refuses(also shows the rollback passing once the published file is back)
Review findings not fixed
/code-review highreported nine findings; seven are fixed incb3d8b0.Two are left:
apply --checkon a bare gem record beside a second build of theversion still reports
hash_mismatchwith theapplyremedy, whileapplynow reports that copy asno_matching_variant. This ispre-existing and sits in how
--checkgroups unqualified records, adifferent code path from this fix. Follow-up.
failed result for the whole base, so
0 of 3 targeted patches … 1 failedleaves two records in no bucket. Counting per record would keyevents by variant purl, which conflicts with the base-purl key
--checkuses. Documented onNoVariantCopy.Follow-ups
apply_maven_base) has its own "no matching variantfound" branch with the old reporting. Not touched here.
https://claude.ai/code/session_011f9aeNixDrp2Etjezc2gZq
Generated by Claude Code