Skip to content

fix(cli): stop permission-denied runtimes reporting starting - #16697

Closed
brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/3813-sandbox-pipe
Closed

brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/3813-sandbox-pipe

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​130 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​128
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36

ELI5

When a restricted Windows account cannot open Orca's named pipe, the CLI currently throws away the permission error and reports that the already-running app is still starting. This change preserves the OS error and returns an existing terminal status instead, so callers do not wait forever for a startup that already finished.

What Changed

  • Preserve EPERM / EACCES, errno, syscall, and transport kind when a local runtime connection is denied.
  • Surface permission denial as runtime_permission_denied without recommending an Orca restart that recreates the same permissions.
  • Project a live but permission-denied runtime as stale_bootstrap / not_running instead of starting / starting.
  • Exercise the real RuntimeClient.getCliStatus() failure path for both permission-denied and transient connection failures.

Why

Windows Codex sandboxes run commands under a separate account. That account can discover the runtime metadata and live PID but cannot open the default duplex named pipe, so PID-only classification leaves orca status on starting forever. Keeping the existing runtime-state enum avoids a mixed-version contract change while the new local error code and structured data preserve the actual cause.

Linked Issue

Addresses #13539 (the independently fixable diagnostics/status half of STA-3813). The native least-privilege named-pipe reachability half remains open.

Visual Proof

N/A — this changes CLI transport errors and JSON/status projection only; there is no rendered Electron UI change.

Testing

  • I manually tested these changes locally — no Windows Codex sandbox was available in this macOS workspace; the original EPERM/-4048 reproduction is recorded on the linked issue.
  • Automated tests added/updated.

Verified with Node 24.19.0:

  • pnpm test src/cli/runtime/status.test.ts src/cli/runtime/transport.test.ts — 20 passed.
  • pnpm run check:code-quality:changed — passed with zero findings across four changed files.
  • pnpm tc:cli — passed.
  • git diff --check — passed.

AI Disclosure

Review

  • Security: does not broaden a pipe DACL, publish another endpoint, expose the auth token, or grant pipe-instance creation rights.
  • Compatibility: retains the existing CliRuntimeState union; the new error data is local-CLI-only and additive. Remote wire framing, SSH/WSL host ownership, folder workspaces, mobile contracts, Git providers, and Git commands are unchanged.
  • Performance/resources: adds bounded error metadata and one constant-time classification on an existing failure path; no polling, timers, listeners, subprocesses, or retained state are added.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The current Node named-pipe client opens duplex with generic write access, whose pipe mapping includes the create-instance-equivalent bit. The linked issue explicitly excludes granting that right, and the offline sandbox blocks a loopback TCP fallback, so native least-privilege reachability remains separate from this safe diagnostics fix.

Checklist

  • This PR is small and focused.
  • I explained what changed and why (including ELI5).
  • Before/after screenshots or videos attached for UI changes, or N/A with reason.
  • Self-reviewed for correctness, security, and performance.
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A).
  • Full pnpm lint, repository-wide typecheck/test, and build were not run locally; focused tests, changed-code quality, and CLI typecheck passed, with CI expected to cover the wider repository.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

Next included review available in 21 minutes.

View limit details

Limit details: You’ve used all 10 included reviews 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 81f81f09-67f4-4c08-9a44-cda7026882b4

📥 Commits

Reviewing files that changed from the base of the PR and between 94e7586 and 1d4d167.

📒 Files selected for processing (4)
  • src/cli/runtime/status.test.ts
  • src/cli/runtime/status.ts
  • src/cli/runtime/transport.test.ts
  • src/cli/runtime/transport.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 63a65a17-a17c-4d88-a891-7c24ae9f8390

📥 Commits

Reviewing files that changed from the base of the PR and between 3ebff2c and b64b289.

📒 Files selected for processing (2)
  • src/cli/runtime/status.test.ts
  • src/cli/runtime/status.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The runtime transport now classifies EPERM and EACCES connection failures as runtime_permission_denied and preserves transport error metadata. Other connection failures remain runtime_unavailable. CLI status handling maps permission-denied failures to stale_bootstrap and not_running, while other failures during a running process remain starting. Tests cover both transport error mapping and CLI status projection.

Merge Risk: ⚪ Minimal · up to b64b2

This localized CLI change preserves permission errors and reports the existing runtime status instead of incorrectly showing startup; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing permission-denied runtimes from being reported as starting.
Description check ✅ Passed The description is complete and focused. It explains the problem, changes, rationale, linked issue, lack of visual changes, testing results, security and compatibility considerations, and the limits o…
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.
Full details: Description check

Explanation

The description is complete and focused. It explains the problem, changes, rationale, linked issue, lack of visual changes, testing results, security and compatibility considerations, and the limits of local validation. The linked issue is identified, and the unchecked full-repository checks are clearly disclosed.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c37bb54-51b9-4596-9172-fb3be6474157

📥 Commits

Reviewing files that changed from the base of the PR and between 88ecc73 and 3ebff2c.

📒 Files selected for processing (4)
  • src/cli/runtime/status.test.ts
  • src/cli/runtime/status.ts
  • src/cli/runtime/transport.test.ts
  • src/cli/runtime/transport.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Comment thread src/cli/runtime/status.ts Resolved
Comment thread src/cli/runtime/transport.ts Resolved
@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Review verification for exact head b64b2890f25138f3dbaea47a17c828cee88b689a: I reviewed the cumulative diff from base 88ecc739e3ee7a261e978f28dd0bb129b832ca1c through correctness/root-cause and Windows/SSH/contract/performance lenses, including two independent review-only passes. No in-scope issues remain: transport EPERM/EACCES, errno, syscall, and transport kind are preserved; PID-probe EPERM/EACCES remains evidence that the process is live; and a permission-denied status keeps reachable: false while leaving the waiting vocabulary as stale_bootstrap / not_running. The performance audit found only bounded error-path metadata and constant-time classification, with no new polling, subprocess, retained state, listener, or hot-path work. This remains only the diagnostics/status half of STA-3813: no named-pipe DACL, fallback endpoint, native reachability claim, remote-wire change, or SSH execution-host substitution is introduced.

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

QA/blocker evidence for exact head b64b2890f25138f3dbaea47a17c828cee88b689a: on the paired Windows high-spec host with Node 24.18.0, a failing-first build of base 88ecc739e3ee7a261e978f28dd0bb129b832ca1c under codex exec --sandbox read-only returned app.running: true with runtime/graph starting; the exact-head build returned app.running: true, runtime stale_bootstrap, graph not_running, and a separate read-only orchestration call returned runtime_permission_denied with transportKind: named-pipe, osErrorCode: EPERM, osErrorNumber: -4048, and syscall: connect. This proves the diagnostics slice fixes the permanent-wait signal while the native pipe remains unreachable. The current Codex 0.149.1 sandbox fell back from a denied PowerShell launch to cmd and full-path whoami.exe reported awin\\neil, so this rerun does not independently prove the historical CodexSandboxOffline identity even though it reproduces the denied sandbox pipe path; the named-principal reproduction remains recorded on STA-3813.

Local verification passed focused runtime tests 22/22, adjacent CLI/error tests 12/12, tc:cli, changed-code quality with zero findings on Node 24, oxfmt --check, max-lines ratchet, and git diff --check. Windows exact-head build, focused tests, and tc:cli passed with 19 tests passed and 3 platform-inapplicable skips. Exact-head GitHub CI has 54 reported checks with no failures or pending jobs; the four skipped aggregators are expected, while Windows package/native smoke and all required Node 24/26, static-analysis, typecheck, Git compatibility, wire compatibility, and shell gates passed. Electron/CDP and screenshots are N/A because the four-file CLI diff has no renderable UI surface. Merge gate is clear for this focused diagnostics PR, but STA-3813 must remain open because native least-privilege named-pipe reachability and its DACL/client design are intentionally not fixed here.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing as superseded: a merged PR already covers this change. #22341 (9af6a3d) makes EPERM/EACCES on the runtime socket/pipe a runtime_access_denied error (src/cli/runtime/runtime-access-denied.ts), so status no longer reports 'starting'. Same fix, same

(Stale-PR cleanup 2026-10-20, approved by Brennan. Reopen if something here is still missing on main.)

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