Skip to content

Fix vex remedy for an unpatched hosted gem (#2219) - #2221

Merged
Mikola Lysenko (mikolalysenko) merged 6 commits into
mainfrom
agent/fix-vex-hosted-gem-remedy
Nov 25, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 6 commits into
mainfrom
agent/fix-vex-hosted-gem-remedy

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-fable-5-2

Fixes #2219

Summary

When socket-patch vex can attest nothing because the installed copies are
still the upstream ones, it ends with one remedy for every ecosystem:
"Reinstall from the lockfile (hosted or vendored patches) or run
socket-patch apply". For a hosted gem neither works. Bundler keeps a gem
it has already installed whatever source the lock names, so bundle install
changes nothing, and bundle pristine on Bundler 2.6+ removes the gems and
then fails on the lock's checksum, which leaves the project unable to
install. Every machine other than the one that ran the scan gets this
message after it pulls the hosted Gemfile.lock onto an existing install.

For a hosted gem vex now says:

The patched packages are hosted gems whose installed copies are still the
upstream builds. Bundler keeps a gem it has already installed, so
bundle install, bundle install --redownload and bundle pristine do
not bring in the patched gem. Run socket-patch scan to replace the
installed copies (for a gem home outside the project, run
bundle config set --local path vendor/bundle && bundle install instead,
or add --gem-refresh-shared to the scan), then run socket-patch vex
again.

Only the human hint under the error changes. Exit codes, --json output and
what is attested are the same.

Root cause

nothing_attested_hint in crates/socket-patch-cli/src/commands/vex.rs saw
only the omission tags, so it could not tell a hosted gem from any other
package that is not_applied.

The change

  • VexGenError carries the omitted purls that a hosted pin wires.
  • StaleHostedGems::among picks the gems among them and decides the remedy:
    • a project with no other patch state: socket-patch scan (a scan with no
      --mode is a hosted one there, and it replaces the installed copies);
    • a project that also holds agent-mode or vendored patches: a scan with no
      --mode keeps that mode or stops with mode_ambiguous, and
      --mode hosted would move the other patches, so the hint names the files
      to remove before bundle install. This is the remedy the
      redirect_gem_stale_install warning already gives;
    • a gem that the manifest records under the pin's own patch keeps the
      general remedy, since apply patches it in place. A record of another
      patch, which the pin superseded, does not (review note, fifth commit).
  • Every other package keeps today's wording. A project with both kinds gets
    both sentences, each with its own count.
  • CLI_CONTRACT.md and docs/usage.md describe the new line.

Evidence

Test Covers
e2e_redirect_gem_stale_install: standalone_vex_sends_a_stale_hosted_gem_to_the_scan_that_replaces_it #2219 end to end: machine A scans, machine B takes the Gemfile and Gemfile.lock over an upstream install, vex exits 1 and names the scan, the scan with no --mode replaces the copy and its archive and leaves the pair alone, vex then attests the gem. Also the mixed-mode project, which is told which files to remove
vex::tests::nothing_attested_sends_a_hosted_gem_to_the_scan_not_to_a_reinstall the exact wording of both remedies, the mixed counts, and that a gem that is not installed keeps its own hint
vex::tests::stale_hosted_gems_are_the_unrecorded_gems_on_a_hosted_pin which packages count, and when a scan with no --mode is a hosted one

Before the fix the end-to-end test failed on the old line ("Reinstall from
the lockfile (hosted or vendored patches) or run socket-patch apply").

Run locally:

  • cargo test -p socket-patch-cli --lib: 1053 passed
  • cargo test -p socket-patch-cli --test e2e_redirect_gem_stale_install: 63 passed
  • cargo test -p socket-patch-cli --test e2e_vex --test e2e_vex_redirect --test e2e_embedded_vex: 15, 28 and 35 passed
  • cargo clippy --locked --workspace --all-features -- -D warnings: clean
  • cargo fmt -p socket-patch-cli -- --check: clean
  • cargo test -p socket-patch-cli --test command_module_layering: 4 passed (it failed in CI on the second commit, where vex named a scan type; the third commit asks through a helper in commands/mod.rs)

The tests lay the gems down by hand, as the rest of this suite does, so no
real Bundler ran here. The Bundler behavior the hint describes comes from the
issue's own runs on Bundler 4.0.18 and 2.5.22 and from docs/ecosystems.md.

Review

/code-review high reported four findings. Three are fixed in the second
commit (the scan named in a project where it is not a hosted one, a gem the
manifest also records, and the word "here" for a run with --cwd).

Cursor Bugbot reported one finding: the manual remedy did not say what it
does in a gem home outside the project. Fixed in the fourth commit, which
names the project-local install for that case.

Not fixed here: when at least one other patch attests, vex exits 0 and
prints only the Warning: omitting ... (not_applied) line, with no remedy
for any ecosystem. That is how the hint has always worked (it is printed only
under "nothing to attest"), and adding a remedy to a successful run changes
more output than this issue asks for. It is worth its own issue.

https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn


Generated by Claude Code

Empty commit to open the draft pull request that claims the issue.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn
When nothing can be attested because the installed copies still hold
their original files, vex ends with one remedy for every ecosystem:
"Reinstall from the lockfile (hosted or vendored patches)".

For a hosted gem that cannot work. Bundler keeps a gem it has already
installed whatever source the lock names, so bundle install changes
nothing, and bundle pristine on Bundler 2.6+ removes the gems and then
fails on the lock's checksum. This is what a second machine sees after
it pulls the hosted Gemfile.lock onto an existing install (#2219).

The hint now learns which omitted packages a hosted pin wires. A gem
among them is told to run socket-patch scan, which replaces the
installed copy, and names the two options for a shared gem home. Every
other package keeps the reinstall wording.

The end-to-end test runs the flow: pull the hosted pair onto an
upstream install, vex names the scan, a scan with no --mode replaces
the copy and leaves the pair alone, and vex then attests the gem.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn
Review of the previous commit found three gaps in the new hint.

A scan with no --mode is a hosted one only in a project with no other
patch state. With agent-mode patches in the manifest it stays in agent
mode and replaces no gem, and beside a vendor ledger it stops with
mode_ambiguous. The hint now asks the project's own mode resolution,
and there it names the files to remove before bundle install, the
remedy the stale-install warning already gives.

A gem the manifest records as well as the lock keeps the general
remedy: apply patches it in place.

The hint said to run the scan "here", which is wrong for a vex run
with --cwd. The word is gone.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 24, 2026 17:46
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


Generated by Claude Code

@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Behavior change is limited to stderr hint text under no_applicable_patches; exit codes and JSON envelopes are unchanged, with broad test coverage.

Overview
When socket-patch vex cannot attest anything because installed copies are still upstream, the human-only “nothing attested” hint no longer tells hosted Ruby gems to reinstall from the lockfile or run apply.

VexGenError now carries which omitted PURLs are on a hosted pin; StaleHostedGems::among filters not_applied gems that are hosted, unrecorded in the manifest, and checks whether a bare socket-patch scan would run in hosted mode. nothing_attested_hint splits remedies: npm/etc. still get reinstall/apply; stale hosted gems get socket-patch scan (with shared-home / LOCAL_PATH_REMEDY options) or, in mixed agent/vendored projects, explicit gemspec/cache removal plus bundle install. Manifest-recorded gems keep the general remedy.

Docs (CLI_CONTRACT.md, docs/usage.md) match the new stderr text. LOCAL_PATH_REMEDY is exported from gem_refresh.rs for reuse in hints. Unit and e2e tests cover wording, detection logic, and the #2219 multi-machine flow.

Reviewed by Cursor Bugbot for commit 3b0fe94. Configure here.

@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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3b0fe94. Configure here.

The command_module_layering test failed in CI: vex named
scan::ScanMode to ask whether a scan with no --mode is a hosted one,
which adds a vex -> scan edge and closes a cycle through apply and
agent_download.

The question moves to commands::bare_scan_is_hosted, beside
bare_scan_looks_below, so vex imports no command module for it.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn
Bugbot review: where a scan with no --mode is not a hosted one, the
hint names the files to remove before bundle install, but it did not
say what that does in a gem home outside the project. Bundler then
installs the patched gem there, where other projects may load it.

The sentence now names the project-local install for that case, as
the scan branch of the same hint does.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. When socket-patch vex can attest nothing because a hosted gem's installed copy is still the upstream build, the hint under the error no longer says "reinstall from the lockfile" (Bundler keeps an installed gem, and bundle pristine on 2.6+ breaks the install). It names socket-patch scan instead, or the files to remove where a bare scan would not run in hosted mode. Only the stderr hint changes. Exit codes, --json and the VEX document are the same.

Risk: low. The change is in human-readable stderr text on an error path. The one new I/O is a manifest/vendor-state read, done only when a hosted gem is among the omitted purls, and any read error falls back to the conservative "remove these files" wording.

Look here

Verified

Changes I made: none.

Open questions: none. The description notes a separate follow-up: a run that attests something prints no remedy for its omitted packages. That is unchanged behavior and out of scope here.


Generated by Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[agent] Approving; one inline note on a missed path.

Review note: a gem the manifest records was always left to the general
remedy, which names socket-patch apply. That is right only when the
record is the patch the hosted pin delivers. Where the pin superseded
an agent-mode record of another patch, apply installs the old patch's
files and vex still cannot attest the pin's.

The hint now carries each hosted pin's patch uuid and exempts a gem
only when the manifest record has the same one.

Assisted-by: Claude Code:claude-fable-5-2
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f9aeQ4rKnRJHYWRr5aMyn
Merged via the queue into main with commit 2b6eb13 Nov 25, 2026
101 checks passed
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