Repository navigation
fix(vscode): accept root-anchored agent-loop redirects (#4220) - #4222
Conversation
Since #3938 the server anchors `> file` redirect targets at the resolved `--root`, so for `--root .` the packet, brief, after-snapshot and verify commands end in `> <cwd>/<artifact>`. Add `redirectTargetMatches`, which mirrors the server's `shell_arg` quoting and accepts only the legacy relative artifact or that artifact under a given root, plus a controller test that feeds the anchored form. The controller is not wired to the helper yet, so the anchored test fails on this commit by design. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GdEuTL3iZySyG5F2FGAfzY
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedNext included review available in 15 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The packet, brief, after-snapshot and verify contracts required the fixed text `> target/ripr/...`, so after #3938 anchored the redirect at the server's cwd every copy was refused. Those contracts now check the redirect tail with `redirectTargetMatches` against the session workspace root and its realpath (the server reads its cwd back from the OS, which resolves symlinks), and run the `includes` checks on the part before the redirect. A different root, file, `..` segment or trailing token is still refused. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GdEuTL3iZySyG5F2FGAfzY
|
Flip proof, first half. On
Review providers: gemini-code-assist is out of daily quota and CodeRabbit is rate-limited, so review from both is missing, not clean. Generated by Claude Code |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
`validatedAgentLoopCommand` split at the last ` > `, so `... --json > other > <root>/<artifact>` passed and would truncate `other`. Refuse any `>` before the checked redirect, and add that case to the anchored controller test's negatives. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GdEuTL3iZySyG5F2FGAfzY
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- editors/vscode/src/packetJson.ts:48 — redirectTargetMatches' bare-form regex /^[A-Za-z0-9._/:-]+$/ accepts a Windows-drive-like token such as
C:followed by a non-slash (e.g.C:foo) because:is in the class; add a leading-segment anchor requiring the first char or the char after:to be/(or a path.sep-aware check) so a bare 'C:' tail cannot be matched as${root}/${artifact}after path.join.
Verification questions
- Confirm redirectTargetMatches only handles the server's two quoting forms (bare and single-quoted); double-quoted or backslash-escaped tails would fall through and be rejected as fail-closed, but the client's contract comment claims it 'mirrors' the server's shell_arg - any future server-side addition would silently break copy without a test catching it.
- Confirm flip proof on
02ada14(tests+helper only) passed the unit testredirectTargetMatches mirrors the server redirect quoting (#4220)and failed the integratedcopyAgentLoopCommand accepts redirects anchored at the session root (#4220)exactly as the PR predicted (clipboard[]). Wired run onf6c275fhad not landed a green receipt at the time of the seeded thread; recommend waiting for the hostedvscodejob before merging rather than relying on the unit test alone, given that the integration test depends onserverShellArgmirroring the server's actualshell_argoutput. - Confirm electron suite cannot run in the authoring container; committed tests are proven only by the hosted
vscodejob. The wired-commit CI result was not present in the seeded thread when this lane ran, so green-after-wire is still a queued proof, not a receipt.
Refuted
- redirectTargetMatches lets a redirect write outside the session workspace because path.join is unchecked.; refuted because: The helper rejects
..segments before normalization and requires path.isAbsolute(target), then matches against normalizePath(path.join(root, artifact)) only when target ends at the artifact under a known root. Cross-checkout writes are out of scope. - The second-redirect guard
if (body.includes('>'))is too strict because a legitimate command might contain>inside a quoted argument (e.g. a shell redirect comparison).; refuted because: Commands are produced by the server withhasUnsafeShellMetacharacterrefusing backticks/semicolons/pipes, and the contract's inputs contain no quoted>; the comment 'One redirect only' matches the server's contract. The unit test rejectsextrabut not an embedded>; however, no current command emits one and the rejection is fail-closed.
Parked follow-ups
- No static/executable proof exists for the real-server smoke test in this packet; the PR's flip proof relies on the hosted
vscodejob whose result is not embedded in the seeded thread (only the red half on 02ada14 is documented). The green half on f6c275f is asserted but not received. Trust impact is bounded because the unit + controller tests cover the matcher exhaustively, but a reviewer cannot independently confirm the acceptance criterion from this packet alone.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
- Server rendering assumptions (shell_arg quoting, forward slashes, --root cwd anchor) match the helper, but live server-side proof is only via the hosted vscode job.
|
Reply to the ub-review findings (review 5329203534):
Generated by Claude Code |
EffortlessSteven
left a comment
There was a problem hiding this comment.
Exact-head review of 25e7a50: REVIEW_READY, no blockers.
Inspected:
- Diff: the full diff (3 files).
- Semantic owner:
validatedAgentLoopCommand, its only callercopyAgentLoopCommand, and the server produceranchored_redirect_target/display_path/shell_argincrates/ripr/src/agent/loop_commands.rs. - Tests: the anchored controller test covers 4 accepted and 5 rejected cases; each negative differs from an accepted target only in the redirect tail. The helper unit test covers quoting, the realpath root and
... - Oracle: the
vscodejob was red on02ada14(tests only) and is green onf6c275fand25e7a50, including the real-server smoke test. - Platforms: Windows drive-letter case goes through
normalizePath. Drive-relativeC:foois refused, checked against the compiled helper. A\\?\prefix is refused, which is fail-closed. - CI and merge state: every check on this head is green, and the merge state is clean.
Missing review: gemini-code-assist (daily quota) and CodeRabbit (rate limit) did not review this PR. That is review missing, not a clean review. An independent Claude review found nothing blocking; its one hardening item landed in 25e7a50, and its pre-existing findings are filed as #4225. The ub-review C:foo finding does not reproduce (see the comment above).
Generated by Claude Code
Requested by Steven · project thread
Summary
Before: since #3938, the server ends the packet, brief, after-snapshot and verify commands in
> <cwd>/<artifact>. The VS Code client still required the relative text> target/ripr/..., so all four copy actions showed "No ripr agent loop command is available" and copied nothing. Thevscodejob on main has been red on the real-server smoke test sincec176e3be6.After: the client accepts the redirect tail when it is exactly the contract's target artifact, either relative (legacy) or joined to the session workspace root (the server's cwd). It rejects any other root, any other file, a
..segment, a trailing token, or an extra>ahead of the checked redirect.How: each of the four contracts drops its fixed redirect needle and sets
redirectsToTargetArtifact.validatedAgentLoopCommandsplits the command at its last>and checks the tail with the new pure helperredirectTargetMatches(packetJson.ts). It refuses any>in the part before the redirect and runs theincludeschecks on that part. The helper mirrors the server'sshell_argquoting (bare[A-Za-z0-9._/:-]+or single-quoted). The accepted roots are the session workspace root and itsrealpath, because the server reads its cwd back from the OS, which resolves symlinks (macOS/tmp→/private/tmp, symlinked homes). Comparison goes through the existingnormalizePath, so Windows drive-letter case and separators compare equal.Closes #4220.
Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Governing issue or accepted claim: #4220 (regression from #3938 / #3872)
Acceptance delta (one sentence): VS Code copies the server's root-anchored agent-loop commands again, and still refuses any redirect that does not write the contract's artifact under the session root.
Candidate Relationships
Candidate branch:
claude/project-thread-a6hygsStack parent or prerequisite PR: none. #4218 is red on the same
vscodesmoke test and will port this change.Proposed replacement of PR: none. No open PR references #4220 (searched before opening).
Scope
editors/vscode. The server contract from fix(first-pr,lsp,loop): anchor funnel redirect targets at resolved --root (#3872) #3938 stays as is.Scope Classification
Production delta: agent-loop copy validation accepts root-anchored redirects.
Evidence/support delta: controller test with anchored commands (4 accepted, 5 rejected) and a direct helper test.
Single acceptance criterion: the
vscodejob's real-server smoke test passes with the server's anchored commands.Non-goals: changing the server's anchoring;
agent_repairandagent_receipt, which carry no>redirect and were unaffected.Support-tier Impact
Policy Impact
Decisions recorded:
..segments even when they would resolve back to the same file. The server lexically cleans the path, so a..never comes from it.realpath(workspaceRoot)in addition to the root VS Code reports. Rejected alternative: accepting any absolute path ending in/<artifact>, which would let a payload redirect into another checkout.'is rendered by the server as'\'', which the existing backslash check refuses. That stays fail-closed.Proof
Flip proof in CI (
full-cilabel), bound to commits:02ada14(tests and helper only, client not wired):vscodejob 108561360633 red, 186 passing and 2 failing. The failures were the new anchored controller test (clipboard[]) and the real-server smoke test that has been red on main.f6c275f(client wired):vscodejob 108562182682 green, smoke test included.25e7a50(second-redirect hardening, from an independent review):vscodejob 108564082191 green. A new negative,> other > <root>/<artifact>, would have been accepted before this commit.cargo xtask precommitexit 0 locally, on both the fix and the hardening.Result, failures, or skipped proof:
vscodejob only.&,;,|or'are still refused, a quoted--basenever matches, and$(...)in the pre-redirect body is not refused.Claim Boundary
May claim: VS Code copy actions for packet, brief, after snapshot and verify work against a post-#3938 server. Must not claim: anything about the commands' runtime results.
Rollback
Revert the PR; the client goes back to refusing anchored commands (the current main behavior).
Spec-Test-Code Traceability
editors/vscode/test/suite/extension.test.ts(copyAgentLoopCommand accepts redirects anchored at the session root (#4220),redirectTargetMatches mirrors the server redirect quoting (#4220))editors/vscode/src/client.ts(AGENT_LOOP_COMMAND_CONTRACTS,validatedAgentLoopCommand,agentLoopRedirectRoots),editors/vscode/src/packetJson.ts(redirectTargetMatches)Static Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
Extension changes:
cd editors/vscode && npm cinpx tsc -p .)🤖 Generated with Claude Code
https://claude.ai/code/session_01GdEuTL3iZySyG5F2FGAfzY