Skip to content

[AI-1292] Unattended review-flow reviewer auto-approves its kcap MCP tools - #304

Merged
alexeyzimarev merged 12 commits into
mainfrom
tonyyoung/ai-1292-reviewer-auto-approve
Jul 10, 2026
Merged

alexeyzimarev merged 12 commits into
mainfrom
tonyyoung/ai-1292-reviewer-auto-approve

Conversation

@realtonyyoung

Copy link
Copy Markdown
Collaborator

Problem

A daemon-hosted review-flow reviewer (Codex) is launched unattended (--ask-for-approval never), but Codex still fires a PermissionRequest hook for MCP tool calls even under that flag. LocalPermissionBridge auto-approved only submit_review_result; every other MCP tool call routed to server.RequestPermissionAsync — an interactive UI prompt with no human present. Now that the code-review flow whitelists kcap-review for the reviewer, its first get_pr_summary call blocked the flow until someone manually clicked Allow, defeating the "unattended reviewer" promise. (Requester-independent: the code-review reviewer is always Codex; Claude reviewers avoid it via bypassPermissions.)

Surfaced during the AI-1224 MCP-autoconfig E2E.

Fix

An unattended review-flow launch mints a per-reviewer LocalPermissionBridge token (CSPRNG, its own listener prefix) bound to the launch's read-only kcap allowlist, and gives the reviewer that token's URL as KCAP_DAEMON_URL. Requests on a reviewer token auto-approve the reviewer's kcap tools; the shared (interactive) token is unchanged.

Design highlights (spec went 5 rounds with the Codex spec-review flow — docs/superpowers/specs/2026-07-09-reviewer-auto-approve-design.md):

  • Daemon-originated trust. The "unattended" signal is a secret token only the reviewer process holds — an interactive agent (which knows only the shared token) can't claim it. No body flag / fixed path segment.
  • Server-granularity, read-only contract. Auto-approval is bounded to ReviewFlowAutoApprovableServers (kcap-review, kcap-sessions) — the reviewer's Codex MCP config already confines its callable tools to the launch allowlist. kcap-memory (writes) / kcap-flows (flow-starting) are not auto-approvable.
  • Request classification order: validate the token (unknown/revoked → 404) → validate the body (missing session_id/tool_name → 400) → submit_review_result (any live token, unchanged) → reviewer token (bare Codex name → allow; server-qualified → must be in the bound allowlist, else deny outright — never defer to a prompt that would hang).
  • Fail fast, not hang. An invalid reviewer allowlist fails the launch (LaunchFailedAsync); it never falls back to the shared token.
  • Lifecycle. Token revoked on every teardown path (early-return, catch, and CleanupAgentAsync after the process exits). Concurrent reviewers get independent tokens.
  • Secrecy. Token is CSPRNG, never logged, and rides in KCAP_DAEMON_URL which PtyEnvScrub already scrubs.

Tests

29 new tests, all green in isolation (repeatedly):

  • KcapMcpRegistryReviewFlowTests (8) — resolver accept/reject + static classification guard.
  • LocalPermissionBridgeTests (+10, 33 total) — reviewer-token auto-approve (bare + qualified), out-of-allowlist deny, malformed/missing body → 400, shared-token unchanged (no escalation), revoked → 404, concurrency, token-never-logged.
  • AgentOrchestratorVendorTests (+4, 45 total) — mint on ReviewFlow + revoke on cleanup, Default → no token, invalid allowlist → fail-fast, KCAP_DAEMON_URL scrubbed.

Notes for review

  • Contract guard scope: implemented as the static classification check (adding an auto-approvable server without a tool classification trips CI). The live tools/list cross-check (catching a new mutating tool added to an already-classified server) is left as a follow-up rather than spawning MCP servers in a unit test — happy to add it if you'd prefer it in-scope.
  • Local full-suite instability: the full daemon unit suite is flaky on my machine under parallel load (a SIGSEGV at startup on one run, a pre-existing TimeoutException in an unrelated Fake_records_… test on another, and loopback-port contention). This is pre-existing native/PTY suite instability, not from this pure-managed-code change; the new tests are green in isolation. CI is the authoritative full-suite check.
  • Touches the daemon flow/permission internals (Alexey's area) — his review comes after the Codex code-review cycle.

Closes AI-1292.

realtonyyoung and others added 11 commits July 9, 2026 10:13
…tools

An unattended review-flow reviewer auto-approves its kcap-owned MCP tools via a
per-reviewer LocalPermissionBridge token (daemon-originated secret → secure,
race-free), alongside the unchanged unconditional submit_review_result carve-out.
Daemon-only; requester-independent; interactive sessions unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- token secrecy: CSPRNG, unique, unlogged; note PtyEnvScrub already scrubs KCAP_DAEMON_URL
- explicit request-classification order: validate live token BEFORE tool carve-outs
- drop spoofable tool-name "kcap-owned" filter; token+MCP-config-lock is the authorization
- bound each reviewer token to its launch allowlist (not a global kcap set)
- add Lifecycle & concurrency (revoke-after-exit, concurrent reviewers, relaunch, submit-vs-teardown)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- explicit body parse/validation step before any approval; reviewer-token approval
  requires a well-formed tool-call (non-empty tool_name); malformed/missing → 400
- enforce the token-bound allowlist: orchestrator computes the post-strip allowlist ONCE
  (shared by MCP config + token registration), asserts kcap-owned + non-flow-starting
  before minting (else fall back to shared token); bridge enforces server-qualified names
- broaden secrecy to real leak surfaces (transcript, run metadata, launch logs, recorded env)
  + matching absence assertions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- invalid allowlist on a ReviewFlow launch now FAILS FAST (LaunchFailedAsync, no reviewer),
  never a shared-token fallback that would hang the unattended reviewer
- make server-level granularity a deliberate, documented security contract (bare Codex names
  + no-hang requirement); reject exact-per-tool binding (would hang on an un-curated tool);
  add a contract guard test: review-flow-eligible kcap servers expose only read/submit tools
- add missing/empty session_id body-validation tests (reviewer + shared token)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- reviewer token + out-of-allowlist server-qualified call → DENY directly (deny decision +
  diagnostic), never fall through to RequestPermissionAsync (that would hang the unattended
  reviewer); shared-token prompt path unchanged; a reviewer token never reaches the prompt step
- back the server-level safety contract with an explicit, machine-checkable unattended-safe
  tool classification; guard derives the eligible server set from the flow catalog ∩
  KcapMcpRegistry and checks each server's actual tools/list against that classification

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…fication + resolver

Read-only ReviewFlowAutoApprovableServers (kcap-review, kcap-sessions), an explicit
ReviewFlowUnattendedSafeTools classification, and TryResolveReviewFlowAllowlist (fail
on any unknown/flow-starting/write server). Foundation for the reviewer-token auth.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…in LocalPermissionBridge

Live-token registry (shared + per-reviewer tokens, each with its own listener prefix + bound
read-only allowlist). CSPRNG tokens. Request classification: validate token then body; auto-approve
submit_review_result (any live token, unchanged) and kcap tools on a reviewer token (bare → config-lock
bounded; server-qualified → must be in the bound allowlist, else DENY not defer); shared token unchanged.
Reviewer token never logged. +10 tests (33/33).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eview-flow launches

On a ReviewFlow launch (bridge listening), resolve the read-only allowlist and mint a per-reviewer
token, threading its URL as the reviewer's KCAP_DAEMON_URL; an invalid allowlist fails the launch
fast (never a shared-token fallback that would hang). Revoke on every teardown path (early-return,
catch, and CleanupAgentAsync after exit). AgentInstance carries the token. +4 orchestrator tests
(45/45, stable).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…PtyEnvScrub

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ll-suite load

Verify mint/revoke via a ReviewerTokenCountForTest seam + deterministic CleanupAgentForTest
instead of real HTTP round-trips (a 5s-timeout-under-load risk); drop the port bind from the
Default-launch test (no mint happens there). Fewer loopback binds → no "Address already in use"
contention in the full parallel suite. Green 45/45 in isolation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jul 9, 2026

Copy link
Copy Markdown

AI-1292

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Unattended ReviewFlow: mint per-reviewer bridge token to auto-approve kcap MCP tools

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Mint a per-reviewer LocalPermissionBridge token for ReviewFlow to auto-approve read-only kcap
 tools.
• Fail fast on non-auto-approvable allowlists; never fall back to interactive prompts that would
 hang.
• Add registry contract/allowlist resolution plus unit tests for bridge behavior, wiring, and
 secrecy.
Diagram

graph TD
AO["AgentOrchestrator"] --> MR["KcapMcpRegistry"] --> AO
AO --> LPB["LocalPermissionBridge"] --> DEC{"Token class?"}
AO --> REV(["ReviewFlow reviewer"])
AO --> INT(["Interactive agent"])
REV --> LPB
INT --> LPB
DEC -->|"reviewer token"| AA["Auto-approve / deny"]
DEC -->|"shared token"| SRV["Server permission prompt"]
subgraph Legend
  direction LR
  _svc["Service"] ~~~ _agent(["Agent"]) ~~~ _dec{"Decision"}
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Session-id keyed auto-approval registry
  • ➕ No extra URL/token to mint and manage
  • ➖ Race: first tool call can arrive before daemon learns session_id
  • ➖ session_id is not secret; interactive agents could spoof unattended status
2. Agent-supplied unattended flag (body field or fixed path)
  • ➕ Simpler request classification logic
  • ➖ Violates daemon-originated trust: any agent with shared token could claim unattended status
  • ➖ Expands blast radius if misused
3. Per-tool allowlist enforcement in the bridge
  • ➕ Tighter granularity than server-level allowlist
  • ➖ Codex sends bare tool names (no server qualifier), so enforcement is unreliable/spoofable
  • ➖ High risk of future hangs when new tools are added but not curated

Recommendation: Keep the PR’s approach (per-reviewer CSPRNG token bound to a read-only server allowlist). It cleanly satisfies daemon-originated trust, avoids session_id timing races, preserves interactive behavior via the shared token, and prevents unattended hangs by denying out-of-allowlist qualified calls and failing fast on invalid allowlists.

Files changed (8) +1163 / -29

Enhancement (1) +70 / -0
KcapMcpRegistry.csDefine ReviewFlow auto-approvable servers and allowlist resolver +70/-0

Define ReviewFlow auto-approvable servers and allowlist resolver

• Adds a read-only server set for unattended ReviewFlow auto-approval, an explicit unattended-safe tool classification map, and a resolver that canonicalizes/dedupes allowlists while rejecting unknown, flow-starting, or non-auto-approvable servers.

src/Capacitor.Cli.Core/KcapMcpRegistry.cs

Bug fix (2) +217 / -27
AgentOrchestrator.csMint/revoke reviewer bridge token for ReviewFlow launches +60/-6

Mint/revoke reviewer bridge token for ReviewFlow launches

• For LaunchKind.ReviewFlow, validates the MCP allowlist via KcapMcpRegistry, registers a dedicated LocalPermissionBridge token URL as the runtime’s DaemonBridgeUrl, and stores it on AgentInstance for teardown. Ensures fail-fast behavior on invalid allowlists and revokes tokens on all cleanup paths.

src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs

LocalPermissionBridge.csAdd per-reviewer token registry and unattended request classification +157/-21

Add per-reviewer token registry and unattended request classification

• Replaces the single-token model with a shared token plus a live reviewer-token registry, minted via CSPRNG. Classifies requests by token before approval logic, auto-approves reviewer-token tool calls (and submit_review_result), denies out-of-allowlist server-qualified calls to avoid unattended hangs, and keeps shared-token behavior prompting via server round-trip.

src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs

Tests (3) +388 / -2
AgentOrchestratorReviewerTokenTests.csTest ReviewFlow token minting, fail-fast validation, and revocation wiring +119/-0

Test ReviewFlow token minting, fail-fast validation, and revocation wiring

• Adds orchestrator-level tests asserting ReviewFlow launches mint a dedicated bridge token (distinct from BaseUrl), revoke it on cleanup, do not mint tokens for Default launches, fail fast on non-auto-approvable allowlists, and confirm KCAP_DAEMON_URL is scrubbed.

test/Capacitor.Cli.Tests.Unit/AgentOrchestratorReviewerTokenTests.cs

KcapMcpRegistryReviewFlowTests.csTest ReviewFlow allowlist resolution and classification guardrails +80/-0

Test ReviewFlow allowlist resolution and classification guardrails

• Adds unit tests covering case-insensitive resolution, deduping, rejection of write/flow-starting/unknown servers, null/empty allowlist handling, and static guard assertions that auto-approvable servers are classified.

test/Capacitor.Cli.Tests.Unit/KcapMcpRegistryReviewFlowTests.cs

LocalPermissionBridgeTests.csAdd reviewer-token auto-approve/deny behavior and secrecy tests +189/-2

Add reviewer-token auto-approve/deny behavior and secrecy tests

• Extends bridge tests to cover reviewer-token auto-approval for bare and qualified tool names, deny behavior for out-of-allowlist qualified calls, 400s for malformed/missing fields, no escalation for shared token, 404 after revocation, concurrent token independence, and token-not-logged assertions.

test/Capacitor.Cli.Tests.Unit/LocalPermissionBridgeTests.cs

Documentation (2) +488 / -0
2026-07-09-reviewer-auto-approve-plan.mdAdd implementation plan for per-reviewer auto-approve tokens +231/-0

Add implementation plan for per-reviewer auto-approve tokens

• Introduces a step-by-step execution plan covering registry changes, bridge token registry/classification, orchestrator wiring, secrecy checks, and test strategy for AI-1292.

docs/superpowers/plans/2026-07-09-reviewer-auto-approve-plan.md

2026-07-09-reviewer-auto-approve-design.mdAdd design spec for unattended reviewer MCP auto-approval +257/-0

Add design spec for unattended reviewer MCP auto-approval

• Documents the problem, security constraints, token-based design, request classification order, lifecycle/concurrency handling, and alternatives considered for AI-1292.

docs/superpowers/specs/2026-07-09-reviewer-auto-approve-design.md

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Bare tools auto-approved ✓ Resolved 🐞 Bug ⛨ Security
Description
IsReviewerToolAllowed returns true for any non-mcp__... tool name on a reviewer token,
regardless of vendor, so a ReviewFlow launch (or any request) using a reviewer token with a vendor
that sends bare tool names (e.g. Claude’s built-ins) would have those tools auto-approved without
allowlist enforcement. This makes the reviewer-token security boundary depend on the Codex MCP
config-lock assumption, but the orchestrator mints reviewer tokens for ReviewFlow launches without
checking vendor.
Code

src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[R403-407]

+    static bool IsReviewerToolAllowed(string toolName, string[] boundAllowlist) {
+        const string prefix = "mcp__";
+
+        if (!toolName.StartsWith(prefix, StringComparison.Ordinal)) return true;   // bare name → config-lock bounded
+
Evidence
The reviewer-token allow check currently returns true for any tool name that is not mcp__..., and
the orchestrator mints reviewer tokens for ReviewFlow launches without vendor gating; existing tests
also show Claude requests can use bare tool names like Bash, which would be auto-approved if sent
on a reviewer token.

src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[393-420]
src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[396-422]
test/Capacitor.Cli.Tests.Unit/LocalPermissionBridgeTests.cs[136-162]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Reviewer-token auto-approval currently treats *any* non-`mcp__...` tool name as allowed. That is only safe under the specific assumption that the requester is Codex and its MCP config-lock constrains callable servers; for other vendors (or future behavior changes), bare tool names can correspond to non-kcap / mutating built-in tools.

## Issue Context
- Reviewer tokens are minted for `LaunchKind.ReviewFlow` without checking the vendor.
- `IsReviewerToolAllowed` unconditionally allows bare tool names (`!toolName.StartsWith("mcp__")`).

## Fix Focus Areas
- src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[396-422]
- src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[306-325]
- src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[393-420]

## Suggested fix
1. Make bare-name auto-approval conditional on the requesting vendor being `codex`:
  - Pass `vendor` into `IsReviewerToolAllowed(...)` (or handle inline) and:
    - If `vendor == "codex"`: allow bare names (existing behavior).
    - If `vendor == "claude"`: require a server-qualified `mcp__<server>__<tool>` name and enforce `<server>` ∈ bound allowlist; otherwise deny.
2. Defense-in-depth in the orchestrator: only mint/register reviewer tokens for ReviewFlow launches when `cmd.Vendor` is `codex` (or when the vendor is known to be constrained by an equivalent config-lock).
3. Add/adjust unit tests to prove that on a reviewer token a Claude bare tool name like `"Bash"` is **denied** (and does not round-trip to `server.RequestPermissionAsync`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. AI-1292 in comments ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
New/modified code comments include Linear issue identifiers (e.g., AI-1292, AI-1139), which
violates the policy against embedding Linear IDs in source comments. This can leak internal tracker
references and makes public-friendly references inconsistent.
Code

src/Capacitor.Cli.Core/KcapMcpRegistry.cs[R28-36]

+    // ── AI-1292: unattended review-flow reviewer auto-approval ──────────────────────────
+    //
+    // A hosted review-flow reviewer runs unattended, so any MCP tool it calls must be
+    // auto-approved (there's no human to answer a prompt). Authorization is a per-reviewer
+    // bridge token (see LocalPermissionBridge); this registry defines WHICH servers/tools that
+    // auto-approval may cover. The unit is the SERVER (bare Codex tool names carry no server,
+    // and an exact tool-name gate would HANG the reviewer on an un-curated tool). The set is
+    // therefore restricted to READ-ONLY kcap servers whose every tool is safe to run unattended
+    // — deliberately excluding the write server `kcap-memory` and the flow-starting `kcap-flows`.
Evidence
PR Compliance ID 6 forbids Linear identifiers (AI-###) in code comments. The cited added/modified
comment blocks contain AI-1292/AI-1139, directly matching the failure criteria.

CLAUDE.md: Do Not Use Linear Issue Numbers in Code Comments
src/Capacitor.Cli.Core/KcapMcpRegistry.cs[28-36]
src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[38-41]
src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[39-44]
src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[300-308]
test/Capacitor.Cli.Tests.Unit/LocalPermissionBridgeTests.cs[571-572]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Code comments added/modified in this PR contain Linear issue identifiers (e.g., `AI-1292`, `AI-1139`), which is disallowed.

## Issue Context
Compliance requires that comments do not include Linear IDs. If a reference is needed, prefer a GitHub issue reference (e.g., `#255`) or remove the identifier entirely.

## Fix Focus Areas
- src/Capacitor.Cli.Core/KcapMcpRegistry.cs[28-36]
- src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[38-41]
- src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[39-44]
- src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[300-308]
- test/Capacitor.Cli.Tests.Unit/LocalPermissionBridgeTests.cs[571-572]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Reviewer body fields under-validated ✓ Resolved 🐞 Bug ≡ Correctness
Description
Reviewer-token requests only reject session_id when null and tool_name when null/empty, so
whitespace (and some empty-after-normalization) values can still reach the reviewer-token
auto-approve/deny logic. This violates the design requirement that reviewer-token requests must have
non-empty session_id and tool_name before any auto-approval decision.
Code

src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[R306-324]

+            } else if (isReviewer) {
+                // AI-1292: an unattended review-flow reviewer. Its Codex MCP config confines it to
+                // the bound (read-only) kcap servers, so a tool call arriving on its token is an
+                // auto-approvable kcap tool. A reviewer request MUST carry a tool to classify; an
+                // out-of-allowlist server-qualified call is an authorization failure we DENY
+                // outright — never deferred to a prompt no human can answer (that would hang).
+                if (string.IsNullOrEmpty(toolName)) {
+                    context.Response.StatusCode = 400;
+                    context.Response.Close();
+
+                    return;
+                }
+
+                if (IsReviewerToolAllowed(toolName, reviewerAllowlist!)) {
+                    decision = new PermissionDecision("allow", null, null);
+                } else {
+                    LogReviewerToolDenied(logger, sessionId, toolName);
+                    decision = new PermissionDecision("deny", null, null);
+                }
Evidence
The design states reviewer-token requests must have non-empty session_id and tool_name before
any auto-approval, but the implementation only checks sessionId is null and uses
IsNullOrEmpty(toolName); whitespace values can pass and reach the auto-approval path.

docs/superpowers/specs/2026-07-09-reviewer-auto-approve-design.md[117-123]
src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[274-325]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Reviewer-token requests can currently be processed (and even auto-approved) with malformed-but-non-null fields:
- `session_id` is only checked for null, so `""`, whitespace, or values that become empty after dash stripping can pass.
- `tool_name` uses `IsNullOrEmpty`, so whitespace-only values pass and are then treated as a bare name (auto-allowed).

This contradicts the reviewer-token request classification contract that requires a non-empty `session_id` and `tool_name` before any auto-approval.

## Issue Context
Design/spec explicitly requires non-empty `session_id` and `tool_name` before steps 3–4 (auto-approval) are reachable.

## Fix Focus Areas
- src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs[274-333]
- docs/superpowers/specs/2026-07-09-reviewer-auto-approve-design.md[117-123]

## Suggested fix
1. Tighten validation:
  - After computing `sessionId = ...Replace("-", "")`, reject if `string.IsNullOrWhiteSpace(sessionId)` (400).
  - In the `isReviewer` branch, reject if `string.IsNullOrWhiteSpace(toolName)` (400) instead of `IsNullOrEmpty`.
2. Add a unit test for reviewer token:
  - `session_id: "----"` (or `" "`) returns 400.
  - `tool_name: " "` returns 400.
3. Ensure these validations happen before any reviewer-token allow/deny decision is made (so malformed requests never get auto-approved).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Verbose reviewer-token explanation comment ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
New comments are lengthy and repeat design details inline, reducing readability and increasing
maintenance overhead. This violates the guideline to keep comments minimal and let code
structure/naming convey intent.
Code

src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[R396-400]

+            // AI-1292: an unattended review-flow reviewer must auto-approve its kcap tool calls (no
+            // human is present). Mint a dedicated bridge token bound to the launch's read-only kcap
+            // allowlist and give the reviewer that token's URL as KCAP_DAEMON_URL. An invalid
+            // allowlist fails the launch FAST — never a shared-token launch that would hang on a
+            // prompt no one can answer. Non-review-flow launches keep the shared (interactive) token.
Evidence
PR Compliance ID 5 requires concise, self-explanatory comments. The cited blocks are multi-line
explanatory narratives that could be reduced to a short summary (with a link to the design doc if
needed).

CLAUDE.md: Keep Comments Minimal and Self-Explanatory (Prefer Clear Code Over Verbose Comments)
src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[396-400]
src/Capacitor.Cli.Core/KcapMcpRegistry.cs[28-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Several newly-added comments are verbose and restate design/spec rationale inline rather than staying concise.

## Issue Context
Compliance asks for minimal, self-explanatory comments. Consider shortening to a brief summary and (if needed) linking to the design/spec doc instead of embedding multi-line rationale.

## Fix Focus Areas
- src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs[396-400]
- src/Capacitor.Cli.Core/KcapMcpRegistry.cs[28-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread src/Capacitor.Cli.Core/KcapMcpRegistry.cs Outdated
Comment thread src/Capacitor.Cli.Daemon/Services/AgentOrchestrator.cs Outdated
Comment thread src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs Outdated
Comment thread src/Capacitor.Cli.Daemon/Services/LocalPermissionBridge.cs
…n, comments)

- Security (bare tools auto-approved): gate the reviewer-token MINT on cmd.Vendor==codex, and make
  the bridge vendor-aware — a bare tool name is auto-approved ONLY for codex (config-lock bounded);
  any other vendor's bare name (e.g. Claude's built-in Bash) is DENIED. +tests (claude bare→deny,
  claude ReviewFlow→no token minted).
- Correctness (under-validated body): reject whitespace/empty session_id and reviewer tool_name
  (IsNullOrWhiteSpace) before any auto-approval. +tests (whitespace session_id/tool_name → 400).
- Rule: strip Linear issue IDs from new code comments; trim the verbose ones. Spec updated to the
  codex-gated model.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants