Repository navigation
Stop tests from starting a real agent CLI unless asked - #23824
brennanb2025 wants to merge 5 commits into
Conversation
Tests that start the real Claude, Codex or Hermes CLI now skip unless ORCA_RUN_REAL_AGENT_TESTS=1, checked before any availability probe runs, so a broad local vitest run no longer starts the developer's real agent against their own config and account. The Codex contract CI job sets the variable and turns a missing opt-in into a red test.
…-tests-opt-in # Conflicts: # src/main/codex/codex-index-heal-binary-contract.test.ts
Revert the Claude real-CLI suites to main and make the helper's existing realClaudeAvailable/realClaudeAuthenticated false without the opt-in, so their gates skip with zero edits. The other suites get a one-condition change instead of new hooks.
The two tests/tools OMP probes start an installed OMP binary and are collected by the unit Vitest config, but skipped only on ORCA_OMP_PROBE_BINARY. Require ORCA_RUN_REAL_AGENT_TESTS=1 as well, like the other binary-gated real-agent tests, and add it to their documented run commands.
Review status: ready for maintainer review (still a draft; not merged)What this PR fixes. Tests that start a real agent program (Claude, Codex, Hermes, OMP) used to run whenever that program was installed and signed in. A broad local test run could therefore start the real Claude against the developer's own Review loops: 2; the second found nothing.
Checked
Not run on purpose
Not caused by this PR
Possible follow-up (out of scope): nothing stops a future test from starting a real agent without calling the opt-in check. A small ratchet test, or a |
|
| # instead of a green no-op. | ||
| ORCA_CODEX_CONTRACT_REQUIRED: '1' | ||
| # Why: real-agent tests skip unless opted in; this job exists to run one. | ||
| ORCA_RUN_REAL_AGENT_TESTS: '1' |
There was a problem hiding this comment.
CI opt-in lacks test coverage The workflow test checks the Codex contract job’s binary, version, and required guard, but not this new opt-in. If a later workflow edit removes it, that test will still pass; the missing setting will surface only when the conditional Codex job runs and fails. Please assert
verify.env.ORCA_RUN_REAL_AGENT_TESTS alongside the other required settings.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughA shared helper enables real-agent tests only when Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Ordinary test runs avoid starting real agent CLIs, while the documented intentional runs remain enabled. No merge-blocking issue is identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new opt-in reduces accidental use of developers’ agent accounts during ordinary test runs. The dedicated CI contract test remains enabled. No expansion of application privileges was found, but not every possible test path was verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 9 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This test-only PR adds a single opt-in switch, ORCA_RUN_REAL_AGENT_TESTS=1, and threads it through every Vitest test that starts a real agent CLI, so a broad local run no longer touches a developer's installed Claude/Codex/Hermes/OMP.
- New shared switch —
src/main/real-agent-tests-opt-in-test-support.tsexportsREAL_AGENT_TESTS_ENVandrealAgentTestsEnabled(), which treats only'1'as enabled. - Claude availability gate —
claude-real-cli-availability-test-support.tsshort-circuits before its--versionprobe, sorealClaudeAvailable/realClaudeAuthStatus/realClaudeAuthenticatedall come out false and the twoclaude-structured-real-cli*suites skip unchanged through their existingdescribe.skipIf. - Per-test gates — supervised-stop, the Codex binary contract, the Codex real-PTY integration test, and the Hermes real-CLI test each add the check to their existing condition; both OMP probes and their
.mdrun instructions do too. - CI contract — the Codex index-heal job sets the opt-in, and its
ORCA_CODEX_CONTRACT_REQUIRED=1guard now fails red when either the binary or the opt-in is missing.
I verified the new helper test passes, that the gated suites skip without the variable, and that the CI guard fails red under ORCA_CODEX_CONTRACT_REQUIRED=1 with no opt-in. An independent sweep of Vitest-collected tests found no other test that starts a real agent CLI, so the enumeration in the description holds.
ℹ️ Nitpicks
config/scripts/codex-index-heal-contract-workflow.test.mjsasserts the job'sORCA_CODEX_CONTRACT_REQUIREDbut not the newORCA_RUN_REAL_AGENT_TESTS, so that workflow-contract test alone would not catch the opt-in being dropped from CI. Not blocking — the contract's ownREQUIREDguard already fails red if the opt-in disappears.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Closing as superseded by #23702, which gates the real Claude CLI suites (the ones that were starting the real The other tests this PR touched were already opt-in behind their own variables (Claude supervised-stop, the Codex index-heal contract, the Codex real-PTY repro, and the OMP lifecycle tests via |

ELI5
Some of Orca's tests start the real Claude, Codex, Hermes or OMP program installed on your computer. Until now the Claude and Hermes ones ran automatically whenever that program was installed and signed in, so any broad local test run started your real agent against your own config and account. After this PR, every test that starts a real agent stays off unless you turn it on with
ORCA_RUN_REAL_AGENT_TESTS=1.What Changed
Problem. The two Claude "real CLI" test files decided whether to run by asking
claude --versionandclaude auth status. On any machine with Claude installed and signed in, a broadvitestrun (a directory, or a command whose file list came out empty and so ran the whole suite) started the real Claude against the developer's real~/.claude, wrote session folders there and made real API calls on their account. This has happened six times on the maintainer's machine in two days, from agents whose instructions explicitly banned it; the latest was a shell word-split that leftvitestwith no file arguments, so it ran the full suite for 13 minutes. Instructions cannot fix this, so the tests themselves must be opt-in.What is different for developers. Tests that start a real agent now skip by default, through the same skip conditions they already had. To run them on purpose, set the variable, e.g.
ORCA_RUN_REAL_AGENT_TESTS=1 pnpm exec vitest run --config config/vitest.config.ts src/main/claude/claude-structured-real-cli.test.ts.Mechanism. One new test-only module,
src/main/real-agent-tests-opt-in-test-support.ts, owns the variable name and the check. The shared Claude availability helper checks it before it runs any probe, so without the variable nothing is spawned, not evenclaude --version, and its existingrealClaudeAvailable/realClaudeAuthenticatedexports come out false. The Claude suites' existingdescribe.skipIf/it.skipIfgates then skip them with no edits to those files. Every other suite gets the check added to the condition it already skips on.Every test that starts a real agent CLI, and how each is now gated:
src/main/claude/claude-structured-real-cli.test.ts(real Claude, real account): was ungated; now skips through the shared Claude helper (file unchanged).src/main/claude/claude-structured-real-cli-fold.test.ts(real Claude, real account): was ungated; now skips through the shared Claude helper (file unchanged).src/main/hermes/hook-service.test.ts, test "is visible to the real hermes CLI when hermes is installed" (runs the realhermesbinary from PATH): was ungated; now returns early without probing, the same way it already did when Hermes is not installed.src/main/claude/claude-supervised-stop-real-cli.test.ts(real Claude): already neededORCA_REAL_CLAUDE_SUPERVISED_STOP=1plusORCA_REAL_CLAUDE_BIN; now also needs the new variable.src/main/codex/codex-index-heal-binary-contract.test.ts(real Codex binary, throwawayCODEX_HOME): already neededORCA_CODEX_CONTRACT_BINARY; now also needs the new variable.src/main/runtime/orchestration-codex-real-pty.integration.test.ts(real Codex in a PTY): already neededORCA_REPRO_CODEX_BINARY; now also needs the new variable.tests/tools/omp-close-lifecycle.test.mjsandtests/tools/omp-relay-close-lifecycle.test.mjs(real OMP binary in a PTY, throwawayHOME; collected by the unit Vitest config): already neededORCA_OMP_PROBE_BINARY; now also need the new variable, and their run instructions (omp-close-lifecycle.md,omp-relay-close-lifecycle.md) include it.CI. Only one workflow runs a real agent on purpose: the Codex index-heal contract job in
.github/workflows/pr.yml. It now setsORCA_RUN_REAL_AGENT_TESTS: '1', so its behaviour is unchanged. Its existing "required" guard (ORCA_CODEX_CONTRACT_REQUIRED=1) now also fails red if the opt-in is missing, so the job cannot pass by silently skipping. No CI job runs the Claude or Hermes real-CLI tests.Why
Six incidents show that telling agents "never run these" does not hold; a missing file argument or a directory run is enough. Making the tests opt-in removes the failure at its source instead of relying on every caller.
One variable checked in a shared module, rather than a file-name exclude in the Vitest config: an exclude would also block deliberate named runs, and it only catches files whose names match the pattern, so the Hermes test (inside an ordinary
hook-service.test.ts) would still run. The check sits in the Claude helper before its probes, so the gate also stops the--versionandauth statusspawns, not just the sessions.The three tests that already had their own switch keep it, since it also supplies the binary path; the new variable is added on top so there is one switch that covers every real-agent test.
Skips carry no per-test message naming the variable: adding one meant moving the Claude suites to per-test skip hooks, which re-indented about 500 lines for a message. The variable is named in the helper comments and in this PR instead.
Linked Issue
None: found by the maintainer; no issue was opened.
Visual Proof
N/A: test-only change with no app behaviour or UI difference.
Testing
New
src/main/claude/claude-real-cli-availability-test-support.test.ts: with the variable unset, the Claude helper reportsrealClaudeAvailableandrealClaudeAuthenticatedfalse andnode:child_processspawn/spawnSyncare never called; with it set, the (mocked) probe runs--versiononce. The command resolver is mocked to a nonexistent path so no real CLI can start even if a mock failed. Ablation: removing the check from the helper makes the first test fail.hook-service.test.ts,codex-index-heal-binary-contract.test.tsandorchestration-codex-real-pty.integration.test.tsrun by name with all opt-in and binary variables unset: real-agent tests skip, the rest pass.Contract guard:
ORCA_CODEX_CONTRACT_REQUIRED=1with a nonexistent binary and no opt-in fails red ("needs ORCA_CODEX_CONTRACT_BINARY and ORCA_RUN_REAL_AGENT_TESTS=1"); the contract cases skip.The two OMP probes, run by name with
ORCA_OMP_PROBE_BINARYpointed at a nonexistent path and no opt-in: both skip.Not run locally, on purpose: the three
*real-cli*Claude files themselves, because running them is the hazard this PR removes. Two of them are unchanged and skip through the helper covered above;tc:nodepasses.tc:node, oxlint on changed files, andpnpm run check:code-quality:changed -- origin/mainpass. macOS only.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Scope: 12 files, +118/−14: test files, one test-only module, the two OMP probes' run instructions and one CI environment line; no app code changes, so no effect on SSH, Windows, Linux, mobile or wire compatibility.
Not changed: the five Playwright end-to-end specs that start a real agent TUI already have their own switch and are not reachable from a Vitest run:
terminal-windows-codex-multiline-pasteandterminal-codex-local-typing-latency(ORCA_E2E_REAL_CODEX),chinese-ime-chat-input-repro(ORCA_E2E_REAL_CODEX_IME),terminal-opencode-emoji-table-rendering(ORCA_E2E_REAL_OPENCODE), andssh-codex-display-artifacts-repro(ORCA_E2E_REAL_REMOTE_CODEX, Codex inside a Docker SSH host).config/scripts/run-codex-real-account-validation.mjsis a manual script; its test only checks the harness and starts no agent.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)