Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(claude): Plan mode asks before writes in Auto and Full access #17963

Mergedmaxwellyoung(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/17963/headmerged by juliusmarminge View on GitHub

T3-selected Claude Plan mode silently allowed permission callbacks in Auto and Full access, so a requested write could run without client approval. Plan now uses the existing approval flow for tools the CLI sends for permission, including writes, regardless of runtime mode. Read-only pre-approvals remain unchanged. A never approval policy denies immediately; proposed plans are still captured before that denial.

Credit to @maxwellyoung for the original fix in #17963. Maintainer takeover preserves the contributor commits and merges current main. Independent implementation review retained the minimal production fix; tests were reduced from 30 generated cases to 4 behavior cases in the existing adapter suite.

Validation at eb7110b:

  • Exact-main negative control: three regression cases fail, plan-capture control passes. Fixed adapter suite: 290/290 pass.
  • Scoped server typecheck, lint and formatting pass. Lint retains one pre-existing unused layer warning outside the diff.
  • Real SDK 0.3.276 / Claude CLI 2.1.303: Auto Plan accept creates the native Write marker only after approval; Full access Plan decline keeps it absent.
  • Integrated web client, isolated worktree state: Full access Plan prompts, clicking Approve creates the file and resolves the request; a fresh Auto Plan thread prompts, clicking Decline leaves the file absent and resolves the request. Both runs complete. These use a deterministic loopback Anthropic model response requesting native Write with the production SDK, CLI, adapter, orchestration and client response path. They do not claim that a remote model follows Plan instructions.

Red/green and live verification details. This is a server permission correction; before/after behavior is established by the negative control, with head-client captures below.

Full access Plan, native Write blocked awaiting approval:

Full access Plan client approval

Auto Plan, native Write blocked before declining:

Auto Plan client approval

Not verified: macOS, Windows, Electron desktop, iOS, Android, remote/relay/tunnel connections, or native permission routing for every non-write tool. Custom Claude launch-argument permission overrides and Claude-initiated EnterPlanMode during a T3 Build turn remain outside this correction. Other provider adapters are unchanged. Permission changes require maintainer review before merging.

One parallel adversarial review round (Opus and Sol) found no blocking code issues.

Prepared through T3 Code / Codex by gpt-6.1-sol (implementation), gpt-6-astra (tests), with independent Claude Opus 5.5 and gpt-6-sol adversarial reviews. Unmerged.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — The production change alters Claude Plan-mode execution in Auto and Full access from immediate allowance to an approval gate for writes and commands. Because this controls whether significant side effects occur, human review is warranted despite the focused implementation and regression tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Warning

      Review limit reached

      Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

      Next included review available in 3 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      Review configuration:

      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 40c1408e-b035-4cc1-8260-3e5808cdd842
      📥 Commits

      Reviewing files that changed from the base of the PR and between eb7110b1b061affa34e31222759c2537197c1c6b and f5ed3c9aa792d2de5f3ab2b789b878bb089b3214.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 01422ac6-5a69-411e-9de8-5d8151740678
      📥 Commits

      Reviewing files that changed from the base of the PR and between b2fa07bde58462724b1bd464096c73111e3b2607 and eb7110b1b061affa34e31222759c2537197c1c6b.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

      📝 Walkthrough

      Plan-mode tool requests now use the permission callback in all runtime modes. When approvals are disabled, the callback denies the request. Tests cover approval decisions and proposed-plan capture.

      Changes: Plan-mode approval handling

      Layer / File(s)Summary
      Plan-mode permission policy
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
      The query policy always installs the permission callback in Plan mode. When approvals are disabled, the callback denies the tool request with a specific message and tool-use ID.
      Approval and plan-capture tests
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      Tests cover Edit and Bash approval requests across runtime modes, acceptance and cancellation, denial when approvals are disabled, and proposed-plan capture. The harness records runtime-request and plan-update events.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~15 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: jieyuexing

      Merge Risk: ⚪ Minimal · up to eb711

      Plan mode in Auto and Full access now asks for approval before file writes, and writes are denied when approvals are disabled. The change is narrow and covered by regression tests. No merge-blocking risk was found.

      Security architecture risk: 🔵 Low · up to eb711

      This change strengthens approval checks for planning-time writes without expanding execution privileges. Remaining uncertainty concerns cancellation and shutdown while approval is pending.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The affected sensitive outcomes are file modifications and shell execution requested during Plan-mode turns. Their maximum asset exposure depends on the existing provider session's tools, environment and permissions, not merely its working directory. The change adds an authorization gate; it does not establish a new sandbox or reduce the privileges of an approved command.

      Trust Boundaries and Controls

      • observed — Tool names and inputs arriving from the native execution path no longer suffice to authorize ordinary Plan callback requests. The adapter denies requests without an active turn, denies when approvals are disabled, and otherwise requires an approval decision. Tests exercise Auto Edit acceptance, Full access Bash cancellation and direct denial with approvals disabled.

      Resilience and Maintainability Implications

      • observed — The existing decision wait converts a winning abort into cancellation and removes the pending entry when the wait completes. Responses for absent entries fail. Interruption and session close delegate to the native runtime without explicitly draining pending approvals, so complete shutdown and accept-versus-abort ordering guarantees remain unproven. These mechanics are unchanged by this PR.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the Claude Plan mode fix and the affected Auto and Full access modes.
      Description checkPassedThe description covers the problem, implementation, scope, verification results, limitations, review context, and test evidence. It also documents the required approval behavior and links supporting e…
      Linked Issues checkPassedIssue #15503 requires Claude Auto + Plan to avoid silent authorization of file writes and file-modifying shell commands. The PR always installs Claude's permission callback for Plan mode, including Au…
      Out of Scope Changes checkPassedThe production change is limited to Claude Plan-mode permission callback installation and approval handling in ClaudeAdapterV2.ts. The test changes capture relevant runtime and plan events and cover…
      Full details: Description check

      Explanation

      The description covers the problem, implementation, scope, verification results, limitations, review context, and test evidence. It also documents the required approval behavior and links supporting evidence.

      Full details: Linked Issues check

      Explanation

      Issue #15503 requires Claude Auto + Plan to avoid silent authorization of file writes and file-modifying shell commands. The PR always installs Claude's permission callback for Plan mode, including Auto and Full access. The callback routes approval-required tools through the existing approval flow and denies them when approvalPolicy === "never". The adapter tests cover Edit and Bash requests, approval and cancellation, pending request behavior, unchanged file contents, and preserved ExitPlanMode handling. The PR does not intentionally permit silent Plan-mode writes, so the issue's conditional UI and documentation requirement does not apply.

      Full details: Out of Scope Changes check

      Explanation

      The production change is limited to Claude Plan-mode permission callback installation and approval handling in ClaudeAdapterV2.ts. The test changes capture relevant runtime and plan events and cover the affected behavior and preserved control paths in ClaudeAdapterV2.test.ts. These changes support issue #15503. No unrelated product area, provider, UI, or documentation change is shown.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsmacroscope-review

    5. @coderabbitai Thanks for raising pending approvals on interruption. I checked the path: awaitClaudeApprovalDecision races the decision against the callback's abort signal and resolves to cancel, which becomes a deny. Its ensuring drops the request from pendingRuntimeRequests, so a later respondToRuntimeRequest fails with "No pending Claude runtime request" and can't allow the write. Supervised mode already uses this path; this PR just routes Auto and Full access Plan writes into it.

      b2fa07b adds regressions for that case: Auto and Full access, Edit and Bash, abort while the approval is pending. Each one gets a deny, the late accept is rejected, and the file is unchanged. Adapter suite: 217/217 with the fix. The original adapter fails 16, the 4 new cases among them, because it allows the write without asking.

    6. Tip

      For best results, initiate chat on the files or code changes.

      🧩 Analysis chain

      🏁 Script executed:

      #!/bin/bash
      set -euo pipefail
      fd -t f '^ClaudeAdapterV2(\.test)?\.ts$'
      ast-grep outline apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts --items all --match 'awaitClaudeApprovalDecision|respondToRuntimeRequest|canUseToolEffect' --view expanded
      ast-grep outline apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts --items all --match 'plan|Plan|abort|Abort' --view expanded
      rg -n -C 18 'awaitClaudeApprovalDecision|No pending Claude runtime request|pendingRuntimeRequests\.delete' apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
      rg -n -C 30 'late accept|abort while|abort.*pending|pending.*abort|file is unchanged|controller\.abort|abortController\.abort' apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts

      Length of output: 11463


      @maxwellyoung Thanks for the clarification and regression tests. The inspected code confirms that abort cancels the approval and cleanup removes the pending request. A later acceptance cannot authorize the write.

      The four new cases cover Auto and Full access with both Edit and Bash. They check denial, rejected late acceptance, and unchanged file contents. I did not rerun the suite.

      The existing cancellation path already handles my concern. I withdraw the finding.


      ✏️ Learnings added
      Learnt from: maxwellyoung
      URL: https://github.com/pingdotgg/t3code/pull/17963
      
      Timestamp: 2026-10-11T06:25:48.584Z
      Learning: In apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, awaitClaudeApprovalDecision races the approval decision against the callback AbortSignal and returns cancel on abort. Its caller uses Effect.ensuring to remove the request from pendingRuntimeRequests, and respondToRuntimeRequest rejects later responses to that request. Auto and Full access Plan-mode writes use this existing approval cancellation path. Regression tests in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts cover pending approval aborts for Edit and Bash in both runtime modes, including denial, rejected late acceptance, and unchanged file contents.

      Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


      If you found this review helpful, would you consider giving us a shout-out on X?

      Thank you for using CodeRabbit!

      You are interacting with an AI system.

    7. juliusmarminge assignedjuliusmarminge

    8. Taking over this one as maintainer for batch claude-09. I will preserve your commits, merge current main, simplify the regression coverage, and validate Plan-mode callbacks against the real SDK and approval path before publishing. Thanks for tracing the Auto and Full access behavior.

    9. juliusmarminge merged thisb494887

    10. juliusmarminge closed this

Sign in to join this conversation.