Skip to content

fix(vscode): accept root-anchored agent-loop redirects (#4220) - #4222

Merged
EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-a6hygs
Sep 27, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-a6hygs

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

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. The vscode job on main has been red on the real-server smoke test since c176e3be6.

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. validatedAgentLoopCommand splits the command at its last > and checks the tail with the new pure helper redirectTargetMatches (packetJson.ts). It refuses any > in the part before the redirect and runs the includes checks on that part. The helper mirrors the server's shell_arg quoting (bare [A-Za-z0-9._/:-]+ or single-quoted). The accepted roots are the session workspace root and its realpath, because the server reads its cwd back from the OS, which resolves symlinks (macOS /tmp → /private/tmp, symlinked homes). Comparison goes through the existing normalizePath, so Windows drive-letter case and separators compare equal.

Closes #4220.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-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-a6hygs
Stack parent or prerequisite PR: none. #4218 is red on the same vscode smoke test and will port this change.
Proposed replacement of PR: none. No open PR references #4220 (searched before opening).

Scope

Scope Classification

  • One production behavior

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 vscode job's real-server smoke test passes with the server's anchored commands.

Non-goals: changing the server's anchoring; agent_repair and agent_receipt, which carry no > redirect and were unaffected.

Support-tier Impact

  • none

Policy Impact

  • none

Decisions recorded:

  • Accept the legacy relative form too. An older server still emits it, and the check is only about which file the redirect writes.
  • Reject .. segments even when they would resolve back to the same file. The server lexically cleans the path, so a .. never comes from it.
  • Accept 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.
  • A path containing ' is rendered by the server as '\'', which the existing backslash check refuses. That stays fail-closed.

Proof

cd editors/vscode && npm ci && npx tsc -p .          # exit 0
node scratch/helper.js                               # helper cases pass (same cases as the committed helper test)
cargo xtask precommit                                # exit 0

Flip proof in CI (full-ci label), bound to commits:

  • 02ada14 (tests and helper only, client not wired): vscode job 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): vscode job 108562182682 green, smoke test included.
  • 25e7a50 (second-redirect hardening, from an independent review): vscode job 108564082191 green. A new negative, > other > <root>/<artifact>, would have been accepted before this commit.
  • cargo xtask precommit exit 0 locally, on both the fix and the hardening.

Result, failures, or skipped proof:

  • The Electron suite cannot run in the authoring container (the VS Code download host is blocked), so the committed tests are proven by the hosted vscode job only.
  • Review: gemini-code-assist is out of quota and CodeRabbit is rate-limited, so review from both is missing, not clean. An independent Claude review found nothing blocking. Its non-regression findings are filed as VS Code agent-loop copy validation still refuses some real server commands and checks the pre-redirect body loosely #4225: quoted paths with &, ;, | or ' are still refused, a quoted --base never 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

  • Tests: editors/vscode/test/suite/extension.test.ts (copyAgentLoopCommand accepts redirects anchored at the session root (#4220), redirectTargetMatches mirrors the server redirect quoting (#4220))
  • Code: editors/vscode/src/client.ts (AGENT_LOOP_COMMAND_CONTRACTS, validatedAgentLoopCommand, agentLoopRedirectRoots), editors/vscode/src/packetJson.ts (redirectTargetMatches)

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new non-Rust programming files.
  • No new generated, dependency, process-spawn, or network surfaces.

Extension changes:

  • cd editors/vscode && npm ci
  • TypeScript compile (npx tsc -p .)

🤖 Generated with Claude Code

https://claude.ai/code/session_01GdEuTL3iZySyG5F2FGAfzY

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
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven added the full-ci Run required, advisory, and release-like CI lanes. label Sep 27, 2026 — with Claude
@EffortlessSteven EffortlessSteven self-assigned this Sep 27, 2026
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 15 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d594d1f2-d1ab-4f61-8b87-eb82646e19b4

📥 Commits

Reviewing files that changed from the base of the PR and between c989c30 and 25e7a50.

📒 Files selected for processing (3)
  • editors/vscode/src/client.ts
  • editors/vscode/src/packetJson.ts
  • editors/vscode/test/suite/extension.test.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Copy link
Copy Markdown
Member Author

Flip proof, first half. On 02ada14 (tests and helper only, client not wired), the vscode job (job 108561360633) failed as designed with 186 passing and 2 failing:

  1. Extension Smoke › real server surfaces seam diagnostic, hover provider, and agent actions: timed out waiting for clipboard text. This is the failure main has had since c176e3be6.
  2. copyAgentLoopCommand accepts redirects anchored at the session root (#4220): the clipboard was [], not the four anchored commands (… --json > /home/runner/work/ripr-swarm/ripr-swarm/target/ripr/workspace/target/ripr/agent/agent-packet.json, and so on).

redirectTargetMatches mirrors the server redirect quoting (#4220) passed. f6c275f wires the client and is running now.

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

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

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
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 27, 2026 06:30
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

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.

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 test redirectTargetMatches mirrors the server redirect quoting (#4220) and failed the integrated copyAgentLoopCommand accepts redirects anchored at the session root (#4220) exactly as the PR predicted (clipboard []). Wired run on f6c275f had not landed a green receipt at the time of the seeded thread; recommend waiting for the hosted vscode job before merging rather than relying on the unit test alone, given that the integration test depends on serverShellArg mirroring the server's actual shell_arg output.
  • Confirm electron suite cannot run in the authoring container; committed tests are proven only by the hosted vscode job. 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 with hasUnsafeShellMetacharacter refusing backticks/semicolons/pipes, and the contract's inputs contain no quoted >; the comment 'One redirect only' matches the server's contract. The unit test rejects extra but 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 vscode job 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.

Copy link
Copy Markdown
Member Author

Reply to the ub-review findings (review 5329203534):

  • C:foo bare tail (packetJson.ts:48): does not reproduce. A bare tail other than the artifact itself must pass path.isAbsolute, and then equal normalizePath(path.join(root, artifact)). C:foo and C:target/ripr/agent/agent-packet.json are drive-relative, so path.win32.isAbsolute is false for both. Checked against the compiled helper: redirectTargetMatches('C:foo', artifact, ['/work/repo']) and redirectTargetMatches('C:' + artifact, …) both return false. No change.
  • The green half has receipts on the current head. vscode is green on f6c275f (job 108562182682) and on 25e7a50 (job 108564082191), including the real-server smoke test. That smoke test runs the actual server, so it does not depend on the test's serverShellArg mirror. Every other check on 25e7a50 is green as well.
  • The helper handles only the server's two quoting forms. That is intended: any other tail is refused (fail-closed), and the real-server smoke test fails if the server's rendering changes.

Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exact-head review of 25e7a50: REVIEW_READY, no blockers.

Inspected:

  • Diff: the full diff (3 files).
  • Semantic owner: validatedAgentLoopCommand, its only caller copyAgentLoopCommand, and the server producer anchored_redirect_target / display_path / shell_arg in crates/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 vscode job was red on 02ada14 (tests only) and is green on f6c275f and 25e7a50, including the real-server smoke test.
  • Platforms: Windows drive-letter case goes through normalizePath. Drive-relative C:foo is 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

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

Labels

full-ci Run required, advisory, and release-like CI lanes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code agent-loop copy commands silently refuse root-anchored redirects since #3938

2 participants