Skip to content

Fix apply --check remedy dropping scope flags (#1219) - #1325

Merged
Mikola Lysenko (mikolalysenko) merged 5 commits into
mainfrom
agent/v5-apply-check-remedy-scope
Oct 9, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 5 commits into
mainfrom
agent/v5-apply-check-remedy-scope

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

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

Fixes #1219

Summary

When apply --check finds drift, its human report now ends with a remedy that uses the check's own scope:

Run `socket-patch apply --global-prefix '/opt/site packages'` to regenerate them.
Run `socket-patch apply --cwd app` to regenerate them.

Before, the line was always Run \socket-patch apply` to regenerate them.. Run as printed after a -g, --global-prefixor--cwd` check, it acted on a different tree, exited 0 and left the drift in place.

Root cause

apply.rs printed a constant remedy and never looked at args.common. This is the same class of bug as #464, which #777 fixed only for the report-only scan hint.

Change

  • ui::scope_args(common) renders the flags that choose the tree: --cwd, --manifest-path, -g / --global-prefix and --ecosystems, each only when it differs from its default. ui::shell_word quotes each value when needed. It is Fix report-only scan -g hint dropping -g (#464) #777's quoting helper, moved out of scan/render.rs so both hints share it.
  • ui::global_scope_arg is the global-only part. The report-only scan hint now uses it, and its output is unchanged.
  • apply --check prints check_remedy(&args.common).
  • In CLI_CONTRACT.md, the apply --check row now documents the remedy and its scope.
  • --json output is unchanged.

Tests (per issue)

Red before the fix: both integration tests fail with left: ["apply"] against right: ["apply", "--cwd", ".tmp…"] / ["apply", "--global-prefix", "…/global lib/node_modules"]. Green after.

Commands run

  • cargo test -p socket-patch-cli --lib --test apply --test cli_apply_silent --test covgap_commands_scan_mod --test remedy_commands_parse: all passed (remedy_commands_parse caught the first version's apply{} literal; fixed in the second commit)
  • cargo clippy --workspace --all-features -- -D warnings: clean
  • cargo fmt --all -- --check: clean for the changed files (core/src/patch/redirect/upstream/mod.rs has a main-wide fmt diff that this PR does not touch)

🤖 Generated with Claude Code


Generated by Claude Code


Note

Low Risk
User-facing CLI hint text only; apply/check logic and JSON output are unchanged aside from the stderr remedy line.

Overview
Fixes #1219: when apply --check reports drift, the closing remedy no longer suggests a bare socket-patch apply. It now repeats the check’s tree scope (--cwd, --manifest-path, -g / --global-prefix, --ecosystems), shell-quoted where needed, so pasting the line heals the same tree that was audited.

Shared UI helpers implement that: shell_word moves from scan rendering into ui::text, with new global_scope_arg and scope_args on GlobalArgs. Report-only scan hints use global_scope_arg (behavior unchanged). CLI_CONTRACT.md documents the scoped remedy. Unit and integration tests assert remedy text and that running it verbatim fixes drift under --cwd and spaced --global-prefix.

Reviewed by Cursor Bugbot for commit 8a76154. Configure here.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`apply --check` ended its drift report with a fixed "Run `socket-patch
apply`" line. A check run with --cwd, -g/--global-prefix,
--manifest-path or --ecosystems printed a remedy that targets another
tree: run as printed it exited 0 and left the drift in place.

The remedy now repeats the check's scope flags, shell-quoted when
needed, through one shared ui::scope_args helper (the report-only scan
hint's quoting moves to ui::shell_word). Integration tests run the
printed remedy verbatim for the --cwd and --global-prefix lanes and
assert the next check exits 0.

Fixes #1219

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 9, 2026 16:57
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review

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

Stale Bugbot comment from a previous run.

The remedy_commands_parse test reads backticked commands out of source
literals; `socket-patch apply{}` parsed as an unknown subcommand. Build
the command first and interpolate it whole.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run


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 8a76154. Configure here.

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 4b8e31d Oct 9, 2026
53 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/v5-apply-check-remedy-scope branch October 9, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants