Skip to content

Fix admission of later Claude question rows and real CLI verification - #25119

Merged
nwparker merged 5 commits into
mainfrom
nwparker/claude-question-row-admission-real-cli
Oct 4, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/claude-question-row-admission-real-cli

Conversation

@nwparker

@nwparker nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​236 $\color{#cf222e}{\Huge{\mathbf{−}}}$​85 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​151
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​20

ELI5

When saving a question with several journal rows, refusing one row should not prevent Orca from trying the remaining rows. This fixes that behavior and repairs the real-Claude test setup that had hidden verification behind skips or selected a different account home.

What Changed

Each row now reaches the existing journal sink before its acceptance is accumulated. The prompt stays closed unless every row is accepted. Existing ownership tests cover refusal of the first row, the second row, and neither row.

Real-Claude verification now reads a complete account JSON object after configuration warnings, preserves the explicitly selected profile only with the existing opt-in, and passes the probed launch environment to handshake sessions. The filesystem write guard remains active. Authenticated tests use the probed environment; the signed-out test explicitly uses an empty launch environment so ambient API keys or OAuth tokens cannot restore authentication.

Why

This extends the existing admission and account-home mechanisms. It preserves prompt ownership and avoids introducing another writer or account selector. The ordinary producer currently groups questions into one row; the reproduced production defect concerns the supported multirow producer contract.

Linked Issue

Repairs the question-row admission finding on #25031, credited to that review. This stays separate from the OpenCode installer change.

Visual Proof

N/A — this changes journal admission and test setup; no rendered interface changes.

Testing

  • Existing multirow test reproduces 1 failure before the fix; all refusal cases pass afterward.
  • 74 focused tests across 7 files pass.
  • Required genuine installed Claude CLI suites: all 8 genuine cases and 2 intercepted authentication-isolation controls across 2 files pass, with no skips, using the existing authorized login and private background test environment.
  • Node typecheck, full owned-file lint/format, all six changed-code gates plus SAFETY and official configured whole-repository anti scan pass.

Validation ran on macOS with Claude 2.1.289. A causal control fails against the old signed-out environment behavior while intercepting before CLI spawn; no dummy token reaches a provider. Platform-neutral journal logic and existing host-owned sinks preserve SSH/folder behavior; no wire or filesystem authority changed. CI will cover other platforms. Earlier skipped/failed harness attempts and raw before/after receipts are retained.

Review

Production ownership is the journal service and its existing test. The five test-harness files are separately mapped verification repairs. All 32,334 other files match main 5df67eff. Independent review checks the seven production/test postimages, the genuine CLI results and every raw qualification log. Earlier skipped or failed setup attempts are retained separately; they do not count as passing verification.

Agent skill upstream boundary

  • Not applicable; no upstream skill content is copied or translated.

Checklist

  • Scope and before/after behavior explained.
  • Source and failure boundaries reviewed.
  • Cross-platform, SSH/folder and backwards compatibility considered.
  • Automated regressions and required real CLI checks completed; CI will cover the full build and other platforms.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d08e344a-da76-4ca2-8291-23f6e6a00ecc
📥 Commits

Reviewing files that changed from the base of the PR and between af4a863 and f4187be.

📒 Files selected for processing (1)
  • src/main/claude/claude-structured-real-cli.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/claude/claude-structured-real-cli.test.ts

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


📝 Walkthrough

Walkthrough

The changes update inherited environment cleanup and launch configuration for real Claude CLI tests. Auth-status parsing now allows warning lines before a valid account report and rejects malformed or ambiguous output. Grouped-prompt tests cover row admission, prompt bindings, write and card outcomes, and cancellation backpressure.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f4187

The signed-out control remains isolated from the selected Claude account, and no merge-blocking issue was identified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to af4a8

Question handling still requires every row to be accepted before opening a prompt. Explicitly enabled verification now passes login credentials into its signed-out check, potentially weakening that check. The identified exposure is limited to verification runs.

Retained concerns

  • Low · security · inferred: The shared launch helper now explicitly forwards authentication credentials to the signed-out control as well as authenticated verification. When those variables are populated, its temporary configuration directory may no longer establish the intended unauthenticated identity, weakening the authentication-boundary proof.
Security review details

Security Blast Radius

  • inferred — The identified credential-isolation concern is conditional on an explicitly enabled verification run with populated authentication variables. Its directly evidenced scope is the installed CLI process and the credentials supplied by that runner, not a new remotely reachable production interface.

Security Findings and Attack Paths

  • inferred — The signed-out control calls the same credential-forwarding factory as authenticated cases. A configured authentication token or API key can therefore reach that child despite its empty temporary profile. Source establishes credential propagation; it does not establish the resulting authentication behavior for every supported CLI credential type.

Trust Boundaries and Controls

  • observed — The filesystem write guard remains an in-process control over Node filesystem operations. Spawned child processes are explicitly outside its scope, so it cannot independently enforce filesystem isolation for the real CLI. The new exact opt-in exception preserves the selected Claude profile without disabling that guard.

Resilience and Maintainability Implications

  • observed — Partial row admission does not satisfy the prompt's write-completion condition. The focused cases check refusal of either row, ordered admission attempts, retained identity bindings, and absence of openCards after a refusal. Concrete sink atomicity and idempotency remain delegated to its existing contract.

Hardening Proposals

  • proposed — Give the deliberately signed-out control a credential-free launch environment distinct from authenticated verification, and assert that authentication variables are absent at the child-process boundary.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: fixing admission of later Claude question rows and improving real CLI verification.
Description check ✅ Passed The description covers the required sections with a clear change summary, rationale, testing details, and an N/A visual-proof explanation. The linked reference points to a pull-request discussion rath…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7c940d10-1a0a-450b-b986-65a5db2a5957
📥 Commits

Reviewing files that changed from the base of the PR and between 5df67ef and af4a863.

📒 Files selected for processing (7)
  • config/scripts/vitest-real-agent-home-write-guard.test.ts
  • config/scripts/vitest-real-agent-home-write-guard.ts
  • src/main/claude/claude-real-cli-test-gate.test.ts
  • src/main/claude/claude-real-cli-test-gate.ts
  • src/main/claude/claude-structured-journal-prompts.ts
  • src/main/claude/claude-structured-prompt-ownership.test.ts
  • src/main/claude/claude-structured-real-cli.test.ts

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

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

✅ No new issues found.

Reviewed changes

This PR fixes a latent journal-admission short-circuit for grouped Claude question rows and repairs the real-CLI verification harness so the installed-binary suites run against the explicitly selected profile instead of silently skipping.

  • Every grouped question row is offered to the sink — ClaudeJournalPrompts.handle hoists tryAppendItem(...) out of admitted &&= ..., so a refusal no longer short-circuits later rows while bindPromptItemId still bound them. admitted still ANDs across rows, so the card opens only when all rows are accepted; the appendItem fallback is unchanged (src/main/claude/claude-structured-journal-prompts.ts:96).
  • Ownership test parametrized over refusal position — the grouped-batch test refuses row 0, row 1, or neither, asserts both rows reached tryAppendItem, the non-refused rows landed, and the card stays closed unless all rows were admitted. It goes red against the pre-fix short-circuit.
  • Auth probe tolerates leading CLI warnings — parseAuthStatus skips non-JSON lines ahead of the account report and rejects ambiguous output (a JSON value before the object, a second object, an array, trailing text) (src/main/claude/claude-real-cli-test-gate.ts).
  • Write guard keeps the opted-in Claude profile — clearInheritedAgentStateEnv is extracted and preserves CLAUDE_CONFIG_DIR only when ORCA_REAL_CLAUDE_CLI_TEST=1; the guard itself stays active, which the new test pins by asserting a real-home rmSync still throws.
  • Real handshake sessions receive the probed launch env — claude-structured-real-cli.test.ts passes env: realClaudeLaunchHome().env, matching the fold suite. The connection strips an inherited CLAUDE_CONFIG_DIR and auth vars, so supplying both env and claudeConfigDir is what makes the child use the pinned home.

The production change faithfully applies the requested fix from #25031 (discussion_r4175489764). The only nuance worth carrying forward is that attempting all rows after a refusal can, when two rows differ enough in size to straddle the watermark, leave a later row in the journal with no open card — that is inherent to the requested behavior rather than introduced here.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review at af4a863 — a single test-only commit (f4187be) that keeps the signed-out real-CLI control unauthenticated.

  • Signed-out control strips inherited credentials — the unauthenticated-startup test now passes an empty launch env, so the connection's auth-stripping is not undone by realClaudeLaunchHome().env carrying the developer's ANTHROPIC_API_KEY/CLAUDE_CODE_OAUTH_TOKEN.
  • realAdapter gains an env parameter — defaults to realClaudeLaunchHome().env, leaving the authenticated real-CLI suites unchanged while the signed-out control can opt out.
  • New isolation test — spies on openClaudeStreamJsonConnection and asserts the child environment keeps the inherited auth keys in authenticated mode and drops them in signed-out mode, which is what pins the new parameter.

The change addresses the CodeRabbit finding at claude-structured-real-cli.test.ts:38 (thread 4175661443, already resolved). I ran the focused file (2 passed, 7 gated skips) and tsc --noEmit -p config/tsconfig.node.json (exit 0).

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 3575895 into main Oct 4, 2026
32 checks passed
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.

1 participant