Skip to content

Run supported Mac chats and background agents under Orca Agents - #41917

Merged
brennanb2025 merged 43 commits into
mainfrom
brennanb2025/orca-agents-chat-process
Nov 18, 2026
Merged

brennanb2025 merged 43 commits into
mainfrom
brennanb2025/orca-agents-chat-process

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

On macOS, Claude and Codex chats were started by the Orca app itself, so macOS charged their memory and privacy access to Orca. This starts supported local chats and background agent tasks under the signed Orca Agents helper instead, the way terminal agents already run, while Orca keeps owning every chat. It changes where macOS attributes the processes; it does not reduce total memory use.

Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​266 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​266
Prod 44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​973 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​905

What Changed

  • Before: the desktop app started each chat's native process owner (orca-provider-exec) itself. After: on supported macOS builds, the Orca Agents helper starts that same native owner. Its seven pipes connect straight back to a private, per-launch socket folder in the app, and the helper closes its own copies, so only Orca holds them. Ownership, Stop, output, exit codes and cleanup are the same as a direct launch.
  • Because the helper holds no chat pipes, restarting or losing the helper no longer ends running chats.
  • Before each hosted launch, Orca checks that the helper is current and signed, and asks the helper to list the chat's folder. If anything fails, is denied or times out, the chat launches directly as before. The whole hosted attempt has a 5-second budget, so a slow helper still leaves a direct launch enough of the 15-second startup deadline. If the helper's start fails before Orca attaches the chat (no process, lost reply, missing pipes), the chat launches directly. The owner can't run the CLI until Orca opens its gate, so nothing ever runs twice.
  • A confirmed helper denial uses the existing folder-access notice when Orca itself can read the folder; a later readable result from the same helper clears it, and stale or abandoned checks can't bring it back. That verdict telemetry no longer blocks the main process.
  • The helper's process-growth monitor skips hosted chat owners. Daemon protocol goes to v59 (v58 was used only by ad hoc builds of an earlier design).
  • Linux, Windows, remote/server launchers, unsigned builds and older helpers keep launching directly.

Why

macOS attributes a process's memory and privacy access to its responsible app. Starting chats under the same signed helper as terminal agents gives them the same attribution, while main's native owner keeps a single process-ownership model.

Testing

  • Signed build QA (v1.4.262-adhoc.20261117181458, head 81026e0, M4Air): 7/7 pass: chats run hosted under Orca Agents, Stop, tab close, helper restart with chats surviving, graceful quit, GUI crash cleanup with history intact, and commit-message generation hosted. On this Mac, all chats ran hosted, a new-helper Codex chat read Documents and replied, and protected-folder probes passed with no notice. Median CLI start: Claude 72 ms (was 177), Codex 124 ms (was 179).
  • 150-chat capture (M4Air, candidate vs main): product memory p50 3451.4 vs 3437.6 MiB, peak 3515.8 vs 3580.6 MiB; chat switch p50 104.9 vs 104.2 ms; typing p95 29.6 vs 30.3 ms; about 11.4 s to app ready and about 77 s to 150 active chats in both; history reconciled 1305/1305; clean quit with no survivors. The two runs used different harness versions, so they are close but not a strict pair.
  • Skipped (approved): the real-Mac rows that turn off Documents for Orca and re-allow it. Running them on this account would change the operator's own Orca permissions. Their logic is covered by tests that fail if the behavior is reverted: a denied, unanswered or failed hosted start launches directly and replies once with the real native owner; the folder notice ignores stale, abandoned and replaced-helper denials. Follow-up: STA-15877, to run them on a disposable macOS user or VM.
  • Commits after the QA head change only the pre-attach fallback, timing budget and folder-verdict ordering. Integration tests with the real native owner and host spawn cover them.
  • Independent reviews of every repair, perf-scans of the final heads, and check:changed on Omarchy. Its only failure is a ratchet row in three federation files this PR doesn't touch, which main has already fixed.

Risk

Level: High. This moves where the chat's native owner process starts. The app still holds every pipe and keeps main's ownership checks, so a mistake would show up as a failed or slower start, which falls back to a direct launch, rather than lost ownership. A plain revert restores direct launching with no data migration.

Known limits: the folder check covers only the chat's working folder at launch, not other protected folders or later revocations. A helper denied LAN access isn't routed around. A helper that hangs costs each new chat up to 5 s before launching directly.

@brennanb2025

brennanb2025 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

HOLD / NOT READY — Brennan requires safe direct fallback and the existing permission notice when the host cannot read a chat folder.

Current repair: source review and CI passed; signed denial QA remains pending. Actual-host working-folder preflight and direct fallback are implemented at c313898; desktop composition supplies the existing notice callback. Both continuing independent reviewers passed this source. Current-head CI completed all88checks (72success/16skip), including all12unitshards, typecheck, cross-version contracts and packagedWindowsserve. Main merge41dfbb45021 includes #42245 and #42270. The same performance role passed the final callback/pidPath source delta with no supported blocker; added launch cost remains unmeasured. Authorized exact-source signed build43571507299 succeeded and published v1.4.259-adhoc.20261114073214; its release body links exactc313. Signature/DR and execution verification are being performed by the isolated QA lead before final-head launch. Gate5637 backed off before any app; retry5638 admitted this Mac. An isolated ClaudeOpusmedium lead with Codexhigh driver is preparing a signed14d-to-repair upgrade and one matched launch comparison; actual denial rows stay blocked pending isolated state. Required signed fresh-grant/revoked denial QA needs isolated permission-state preparation; no shared grant changes or native OS input have been performed. The pre-push canonical check was invoked but stopped after exact CI passed under ProcesscutC; no local fullPASS is claimed. No readiness marker applies.

Earlier completed evidence (unchanged flows only):

Supported local macOS chats now start under the independent Orca Agents process, alongside terminal agents, so their memory is attributed separately from Orca. Chats still stop with Orca. This changes attribution, not total memory use.

Review: the continuing independent Claude Opus-medium and Codex-high reviewers passed the final source and native execution evidence at051267b120805f0b33a42a7f425e01cd00579439. Earlier output, recovery, identity, refusal and wake repairs retain their completed reviews. Documentation-only1f004a50 adds connection/ping fallback wording. The necessary main merge preserves ordinary native-executable launch optimization and the independently audited owned-child boundary. The native startup-failure P1 is fixed in de87f9b, with both independent source and execution reviews covering merged head051267b120805f0b33a42a7f425e01cd00579439. Both initial performance screens and separate performance ownership are complete. All seven binding rulings remain recorded, original P1/repeat classifications are retained, and ruling-check passed10findings/7rulings.

The repair preserves final output and backpressure, derives proven child death rather than keeping a duplicate exit flag, delivers a known no-start outcome before a launch-refusal error, and remembers a legitimate death wake that arrives during observation. It retains failed-open Claude ownership, reads Pi readiness once and forwards a direct child’s stdin failure without inventing process death. Protocol58 selects corrected provider launches; older terminal hosts remain usable. A generic spawn-wrapper exception does not establish that no process started, so it never permits a duplicate fallback.

Executed evidence: exact14d7349 CI completed all72checks (54success/18skip), including typecheck, all12unitshards, packaged Windows Electron/orcad switch, cross-version contracts and the owning lifecycle files. The population fixture initially received array indexes as mocked PIDs; one callback-only correction preserves every production check and assertion. Prior H1 Node29/29 and Bun11/11 pass; restoring the old exit flag fails the active/idle regression. The forced-Stop trace retains actual SIGTERM exit, root absence, childECONNRESET and actual SIGTERM close. No production error suppression.

Signed QA5514: previous releasefcb620d21964567bcb0df5eef531183667a1abd3 → signed14d7349 releasev1.4.259-adhoc.20261114001555, ZIPsha25620ff2a99a761272edaef36f6626f573f89a6ee37d56a8ab75cfb470b8b8f81f7. DeveloperID/notarization and main/helper designated-requirement equality verified before launch. macOS27.2(26B123), AppleM4 nativearm64. The approved isolated LaunchServices open -n -g -j Finder/Dock equivalent is a narrow launch-recipe exception; parentPID1/self-responsibility and separate host coalition were independently recorded.

Actual Claude and Codex tool results and replies passed ownDocuments marker, FDA Mail/Safari count-only reads and realrouter HTTP301/TCP80 on the direct baseline, upgraded hosted chats and after two normal service restarts. All8access results were inspected. Continuous16:27:56–17:07:18 privacy capture records existing FDAgrant allowed for each responsible host and no captured LocalNetwork prompt/denial. Native on-screen prompt visibility is UNTESTED; successful existing-grant access is not a clean first-use guarantee. No grants changed/reset.

Actual idlehostSIGKILL ended each CLI/supervisor within170ms; ordinary next sends returned realClaude/Codex replies through a replacement host. Normal service restarts and final gracefulGUIquit have recorded realOSexit order and no orphaned CLI/supervisor. Completed idleturns correctly keep done status and an enabledcomposer without a newfailurebanner. Legacy56terminals alongside a current58chat host are intended. AllownedQAprocesses and labels stopped; gate5514released and leadquit/terminalclosed. Realagent/ghconfig hashes unchanged except a hash-only .claude.json change of undetermined cause.

A local partial Buncheck timedout once awaiting a providerexit with inconsistent test-title/frame attribution. It remains unexplained and unpassed; CI independently passed the exact owning file in3236ms (Bun1.4.4/Node24.22.3), and signed normal lifecycle exit chronology passed. GreenCI does not explain the local timeout. Duplicate localcheck stopped under ProcesscutC after greenCI; no broad rerun. Delayed pending-start/Stop was unavailable through UI without injection; owning production regressions cover the precise refusal/final-sleep schedule. No fabricatedUIpass.

Benchmark carries for unchanged measured paths: same19byte request, models/repo, three repetitions; medianClaude spawn/firstreply151/1908ms direct vs83/1846ms hosted; Codex252/4321ms vs138/3319ms. Signed transport delivered allbytes9/9percell including2MiB; no total-memory reduction claim. Earlier normalStop/Clear/savedhistory/reopen/GUIcrash/generation/discovery/backfill and WindowsPi rounds carry. RealmacOS orca serve selected Nodeorcad, got realClaude/Codex replies, closed both chats and all56recordedprocesses with no9400listener. InheriteddirectClaudeCLI death reproduces disappearingpartialtext on signedbaseline; persistence rootcause was not established and is outside thisPR.

Limits: PATHparity unproven; nativeOpenCode sends404/directtimeout unpassed (selectedmodelterminalpreflight passed). Shortsetup/signin/versionhelpers still briefly show underOrca; Windows naming deferred. UNTESTED: native dialog visibility; older macOS; Intel; fork fallback; Linux/Windows serve; paired WebSocket-client chat; unsupported Electron; WSL; SSH; Windows naming. Compatibility keeps directlaunch for ineligible/fallback/remote/server routes without a minimum paired-server version. A LANdeniedhost is not automatically bypassed; no prompt-generatingLANdetector added.

The independent bulk evidence audit supports the eight access runs, two recovery replies, attribution and cleanup. Its safe archive omits the raw privacy stream and before/after config hashes, so those statements rely on the lead report and were not recounted by the auditor. Protected access on the replacement host after SIGKILL was not repeated; those recovery sends prove real replies only.

For Brennan’s review, the actual captured results:

Baseline Claude:

Baseline Claude

Baseline Codex:

Baseline Codex

Upgraded hosted Claude:

Upgraded hosted Claude

Upgraded hosted Codex:

Upgraded hosted Codex

Restart 1 Claude:

Restart 1 Claude

Restart 1 Codex:

Restart 1 Codex

Restart 2 Claude:

Restart 2 Claude

Restart 2 Codex:

Restart 2 Codex

Host-loss recovery Claude:

Host-loss recovery Claude

Host-loss recovery Codex:

Host-loss recovery Codex

Final repair verification: both continuing reviewers accepted the valid native Node24.22.1 RED against the old registry and the actual CI Node24.22.3 GREEN. All15 hosted transport tests passed in node-runtime (3214ms), including native E2BIG/home-lock release and real held-child termination after an observer exception; registry and ordinary process contracts passed too, with zero unhandled errors. CI checkout includes051267 and the four owning files are byte-identical. The original P1 and fixture race are fixed, all threads resolved. Local GREEN was never admitted and was stopped after its exact CI counterpart passed; no local PASS is claimed. Full-head CI completed88checks (73success/15skip). Fedora WSL froze during initial setup; after the recorded cancellation/time-cap annotation, the repository’s single automatic retry passed in9m55s. No manual rerun or source change. The failure-only repair uses the tests row; signed14d run-row evidence carries with qa_head.

@brennanb2025
brennanb2025 changed the base branch from brennanb2025/orca-agents-process to main November 13, 2026 22:16
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The changes add capability-gated provider spawning through the daemon and advance the daemon protocol to version 58. Provider-child abstractions and supervisor paths support hosted and direct launches, readiness checks, output handling, and exit-state observation. Claude, Codex, Pi, OpenCode, and source-control integrations adopt these lifecycle paths. Restart notices and macOS provider-host documentation are also updated.

Merge Risk: Moderate · previous review 16c81

Supported macOS chats now launch under the independent agent host. At this head the changed integration test fails type checking, which blocks the desktop CI build. One test also expects an error that its setup cannot produce. The author has also marked the change not ready while the folder-access fallback repair and its signed tests are still pending. Fix the test issues and complete that work before merging.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description follows the repository template closely: it has ELI5, What Changed, Why, Testing, Risk, and a risk level. It explains the mechanism, the fallback behavior, and the limits of the change… 1) Add a linked issue, using 'Fixes #' for an existing issue, because the template requires one. 2) Add before/after visual proof for the macOS chat-attribution and restart-consequence text changes, or write 'N/A' with a reason. 3) Compl…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: supported local macOS chats and background agents now run under the Orca Agents host, which matches the raw summary's core change (independent-host launching for suppo…
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: Title check

Explanation

The title names the main change: supported local macOS chats and background agents now run under the Orca Agents host, which matches the raw summary's core change (independent-host launching for supported native chat providers, with the helper named com.stablyai.orca and the host named Orca Agents in the description). It is concise, specific, and not misleading.

Full details: Description check

Explanation

The description follows the repository template closely: it has ELI5, What Changed, Why, Testing, Risk, and a risk level. It explains the mechanism, the fallback behavior, and the limits of the change. Testing lists the platforms actually exercised (signed macOS build on M4Air, orca serve), the skipped real-Mac permission rows with a follow-up ticket, and the reasons. Sections are still incomplete: the Linked Issue section has no 'Fixes #' reference, the Visual Proof section has no before/after media or 'N/A' with reason, the Review and Agent skill upstream boundary sections are unchecked or blank, and the checklist items are not ticked. The PR objectives also flag the HOLD / NOT READY status, including the unrepaired folder-access fallback and untested signed fresh-grant and revoked-folder tests. The description does not state that hold, so its Risk and Testing sections read as more settled than the objectives allow.

Resolution

  1. Add a linked issue, using 'Fixes #<n>' for an existing issue, because the template requires one. 2) Add before/after visual proof for the macOS chat-attribution and restart-consequence text changes, or write 'N/A' with a reason. 3) Complete the Review and Agent skill upstream boundary sections, and tick or explain the checklist items. 4) State the current readiness status. The objectives say the folder-access fallback repair and the signed fresh-grant and revoked-folder tests are still pending, so either finish them or record them as open blockers in Testing and Risk. 5) Fill in the AI Disclosure section if any AI tooling was used, since the author is not a stablyai team member.
  • Autofix · 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

@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: 9

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4f5a33d-61f2-4069-ac31-77afe887d9f6
Commits

Reviewing files that changed from the base of the PR and between 3168bad and 9e22856.

Files selected for processing: 95

  • config/main-sync-fs-baseline.txt
  • config/scripts/desktop-distribution/runtime-verification/verify-packaged-daemon-entry.cjs
  • config/scripts/macos/terminal-host-bundle/macos-terminal-host-bundle.cjs
  • docs/agents-md-refs/macos-daemon-tcc-attribution.md
  • src/main/claude/child-process/claude-agent-sdk-exit-proof.ts
  • src/main/claude/child-process/claude-agent-sdk-process-spawn.ts
  • src/main/claude/child-process/claude-child-exit-proof-ladder.ts
  • src/main/claude/child-process/claude-child-root-termination.ts
  • src/main/claude/claude-stream-json-connection.ts
  • src/main/claude/sdk-transport/claude-stream-json-connection.test.ts
  • src/main/codex/app-server/codex-app-server-client.ts
  • src/main/codex/app-server/codex-app-server-connection.ts
  • src/main/codex/app-server/codex-app-server-session.ts
  • src/main/codex/history/index/codex-state-db-backfill-recovery-process.ts
  • src/main/codex/history/index/codex-state-db-backfill-recovery.ts
  • src/main/codex/trust/hooks/codex-hook-trust-derivation.ts
  • src/main/daemon/daemon-entry.ts
  • src/main/daemon/daemon-process-name.ts
  • src/main/daemon/executable-host/macos/macos-daemon-bundle-retirement.ts
  • src/main/daemon/executable-host/macos/macos-daemon-bundle.ts
  • src/main/daemon/executable-host/macos/macos-daemon-launchd.ts
  • src/main/daemon/executable-host/macos/testing/macos-daemon-bundle-retirement.test.ts
  • src/main/daemon/executable-host/macos/testing/macos-daemon-bundle.test.ts
  • src/main/daemon/executable-host/macos/testing/macos-daemon-launchd.test.ts
  • src/main/daemon/protocol/daemon-hello-protocol.ts
  • src/main/daemon/protocol/daemon-protocol-version.ts
  • src/main/daemon/protocol/daemon-provider-process-protocol.ts
  • src/main/daemon/protocol/daemon-rpc-contract.ts
  • src/main/daemon/providers/adapter/daemon-pty-preserved-host-loss.ts
  • src/main/daemon/providers/lifecycle/daemon-provider-state.ts
  • src/main/daemon/server/daemon-client-connections.ts
  • src/main/daemon/server/daemon-main.ts
  • src/main/daemon/server/daemon-provider-processes.test.ts
  • src/main/daemon/server/daemon-provider-processes.ts
  • src/main/daemon/server/daemon-provider-requests.ts
  • src/main/daemon/server/daemon-request-router.ts
  • src/main/daemon/server/daemon-server-lifecycle.ts
  • src/main/daemon/server/daemon-server-options.ts
  • src/main/daemon/server/daemon-server.ts
  • src/main/daemon/testing/daemon-process-name.integration.test.ts
  • src/main/daemon/transport/client/daemon-client-hello-handshake.ts
  • src/main/daemon/transport/client/daemon-client-ndjson-readers.ts
  • src/main/daemon/transport/client/daemon-client.ts
  • src/main/daemon/transport/client/daemon-provider-observers.ts
  • src/main/daemon/transport/client/testing/daemon-provider-control.test.ts
  • src/main/daemon/transport/stream/daemon-stream-backlog-probe.ts
  • src/main/jsonl-rpc/agent-connection.ts
  • src/main/native-chat/agent-model-catalog/agent-model-catalog-probe-runner.ts
  • src/main/opencode/model-launch/opencode-launch-model-context.ts
  • src/main/pi/rpc/rpc-session-adapter.ts
  • src/main/pi/rpc/rpc-session-startup.test.ts
  • src/main/pi/rpc/rpc-session.ts
  • src/main/pi/rpc/rpc-startup-open.ts
  • src/main/provider-process/hosted-provider-child.integration.test.ts
  • src/main/provider-process/hosted-provider-child.ts
  • src/main/provider-process/hosted-provider-exit-observer.test.ts
  • src/main/provider-process/hosted-provider-exit-observer.ts
  • src/main/provider-process/hosted-provider-launch.ts
  • src/main/provider-process/hosted-provider-ownership.test.ts
  • src/main/provider-process/managed-provider-process.ts
  • src/main/provider-process/provider-child-handle.ts
  • src/main/provider-process/provider-child.ts
  • src/main/provider-process/provider-group-orphan-guard.test.ts
  • src/main/provider-process/provider-group-orphan-guard.ts
  • src/main/provider-process/provider-output-handoff.ts
  • src/main/provider-process/provider-owner-channels.ts
  • src/main/provider-process/provider-process-close.ts
  • src/main/provider-process/provider-process-spawn.ts
  • src/main/provider-process/provider-process-supervisor-script.ts
  • src/main/provider-process/provider-process-supervisor.ts
  • src/main/provider-process/provider-process-teardown.ts
  • src/main/provider-process/provider-supervisor-output-gate.test-support.ts
  • src/main/provider-process/supervised-child-process-stop.ts
  • src/main/startup/pty-startup/main-process-pty-startup.ts
  • src/main/text-generation/execution/source-control-agent-termination.ts
  • src/main/text-generation/execution/source-control-local-process.ts
  • src/main/text-generation/execution/source-control-supervised-agent-spawn.ts
  • src/main/text-generation/models/commit-message-model-discovery.ts
  • src/main/text-generation/policies/source-control-policy-probe.ts
  • src/main/text-generation/source-control-text-generation-types.ts
  • src/renderer/src/components/shared/MacFolderAccessFixDialog.tsx
  • src/renderer/src/components/shared/useDaemonActions.tsx
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ru.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/local-build-compatibility-contract.json
  • src/shared/local-build-compatibility-contract.ts

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

Comment thread src/main/jsonl-rpc/agent-connection.ts Resolved

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab38672e-ea56-46da-b70f-02f34d61f01c
Commits

Reviewing files that changed from the base of the PR and between 9e22856 and 14d7349.

Files selected for processing: 26

  • docs/agents-md-refs/macos-daemon-tcc-attribution.md
  • src/main/claude/claude-stream-json-connection.ts
  • src/main/claude/sdk-transport/claude-stream-json-connection.test.ts
  • src/main/claude/structured/claude-structured-session-acquisition-processless.test.ts
  • src/main/claude/structured/claude-structured-session-acquisition.ts
  • src/main/daemon/daemon-entry.ts
  • src/main/daemon/protocol/daemon-protocol-version.ts
  • src/main/daemon/protocol/daemon-provider-process-protocol.ts
  • src/main/daemon/providers/adapter/daemon-pty-preserved-host-loss.ts
  • src/main/daemon/providers/adapter/testing/daemon-pty-adapter-protocol-compatibility.test.ts
  • src/main/daemon/server/daemon-provider-processes.test.ts
  • src/main/daemon/server/daemon-provider-processes.ts
  • src/main/daemon/server/daemon-provider-requests.ts
  • src/main/daemon/server/daemon-request-router.ts
  • src/main/daemon/server/daemon-server-lifecycle.ts
  • src/main/daemon/server/daemon-server.ts
  • src/main/pi/rpc/rpc-session-startup.test.ts
  • src/main/pi/rpc/rpc-startup-open.ts
  • src/main/provider-process/hosted-provider-child.integration.test.ts
  • src/main/provider-process/hosted-provider-child.ts
  • src/main/provider-process/hosted-provider-exit-observer.ts
  • src/main/provider-process/hosted-provider-launch.ts
  • src/main/provider-process/hosted-provider-ownership.test.ts
  • src/main/provider-process/provider-child-handle.ts
  • src/shared/local-build-compatibility-contract.json
  • src/shared/local-build-compatibility-contract.ts

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

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3b71585b-2135-48e1-9d54-b3bbddf79d61
Commits

Reviewing files that changed from the base of the PR and between 051267b and 16c81a3.

Files selected for processing: 10

  • docs/agents-md-refs/macos-daemon-tcc-attribution.md
  • src/main/daemon/protocol/daemon-provider-process-protocol.ts
  • src/main/daemon/server/daemon-provider-requests.ts
  • src/main/daemon/server/daemon-request-router.ts
  • src/main/provider-process/hosted-provider-child.integration.test.ts
  • src/main/provider-process/hosted-provider-child.ts
  • src/main/provider-process/hosted-provider-launch.ts
  • src/main/provider-process/hosted-provider-ownership.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/pt.json
Files skipped from review as they are similar to previous changes: 2

  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/pt.json

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

…nts-chat-process

# Conflicts:
#	src/main/claude/claude-stream-json-connection.ts
#	src/main/claude/structured/claude-structured-session-acquisition-processless.test.ts
#	src/main/codex/history/index/codex-state-db-backfill-recovery-process.ts
#	src/main/pi/rpc/rpc-session-startup.test.ts
#	src/main/pi/rpc/rpc-session.ts
#	src/main/startup/pty-startup/main-process-pty-startup.ts
#	src/main/text-generation/policies/source-control-policy-probe.ts
#	src/packages/process-host/src/run-process.ts
…ners

The host now only starts orca-provider-exec and connects every owner pipe back to
the app, which owns the chat exactly as on a direct launch. This replaces the
hosted per-chat supervisor and keeps the native owner memory savings.
…rowth

A host still starting no longer holds a chat past its bootstrap deadline, the host's
code signature is read once per host process, and the native owners the host starts
for the app do not count as its terminal work. The hosted launch test runs under Node,
whose destroy closes only the host's own socket copy.
…nd keep launch-folder errors

The native owner clears O_NONBLOCK that a host's sockets carry, so its gate read and the
CLI's stdio behave as on a direct launch. A reconnect to another host before dispatch
launches here instead of on an unprobed host, and a host spawn error keeps its code and
path so a deleted folder is still reported as missing.
…ge read

The growth sample now stops at hosted owners instead of walking their subtrees again,
so it never does more work than before. A host's code-signature read is reused only
for 10 s, so a bundle removed while the host runs is noticed on a later launch.
…nts-chat-process-1116

# Conflicts:
#	src/main/daemon/protocol/daemon-protocol-version.ts
#	src/shared/remote-runtime/orcad-distribution/local-build-compatibility-contract.json
#	src/shared/remote-runtime/orcad-distribution/local-build-compatibility-contract.ts
The native owner runs its CLI only after this app opens its gate, which
attaching does. A host spawn error, a lost reply or pipes that never arrive
therefore leave no CLI running and no input sent, so the chat now launches
here instead of failing. Once attached, a failure still ends the launch.

Tests cover a host that can't read or can't start in the chat's folder, a
host that never answers the folder probe, a lost spawn reply, and the
folder-access notice verdicts.
A hosted start could spend 10 s on the spawn reply and 10 s on its pipes,
past the owner's 15 s bootstrap deadline, so a late failure ended the
chat instead of launching it here. The hosted attempt now has one 8 s
budget from the start of the launch.

A folder denial whose app-side recheck finished after a newer readable
verdict restored a cleared notice; the newest verdict for the same helper
and folder class now wins.
…nts-chat-process-1116

# Conflicts:
#	config/scripts/test-runtime/sqlite-admission/vitest-node-runtime-files.mjs
The hosted attempt's budget is now the bootstrap deadline minus the
ownership proof window, so a hosted owner or a direct fallback still has
time to prove ownership. A timer bounds the spawn request too, so a
stalled event loop can't let the bootstrap deadline fire first.

Only a newer readable verdict from the same helper supersedes a pending
folder denial, so a later denial in another folder no longer hides a real
notice, and the record holds one entry per folder class.
…notice

Keying the re-allow marker by folder class alone forgot an old helper's
re-allow once a new helper read that class, so the old helper's late
denial overwrote the new helper's notice. Marks are per helper and class
again, capped to the most recent pairs.
… marks

Capped marks could evict a re-allow while its denial was still being
read, reviving the stale denial. A readable verdict now flags the same
helper's pending denials for that folder class, and only denials still
being read are kept.
@brennanb2025
brennanb2025 marked this pull request as draft November 18, 2026 03:45
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: head 0cd1a11 (merge base 5a28037)

Verdict: no perf blocker. This is a fresh, independent full perf-scan of the diff 5a28037b3f8...0cd1a1192ed. I read every changed production file and their callers. Author claims were not used.

All the new work runs once per provider launch and costs a fixed amount per launch. None of it is repeated per chunk, status update or growth sample, and none of it grows with the number of worktrees, terminals, chats or history. The one per-chunk change is a single extra stream hop with O(1) cost per chunk, and the one per-sample change makes the growth sample do less work. I found no polls or intervals that never settle, and no per-entity state left behind after teardown.

What triggers new work, and how much

Work Trigger Population Bound / cost per trigger Thread
connectedHost: getClient (waits for PTY provider ready, capped at 1 s), ensureConnectedWithin(1 s), ping RPC (1 s timeout) each supervised provider launch on macOS desktop (spawnProviderProcess with a boot id; installProviderProcessHost only runs when darwin && !serve) launches are started by users or admission-gated probes (native chats, model-catalog and ACP probes, source-control generation, Codex rename). No caller runs on a timer or once per worktree. 1 RPC on the existing terminal control socket, so no new connection Electron main (async)
hostCodeIdentity: one codesign --display +pid child at most once every 10 s per host identity. Concurrent launches share the in-flight read. A failed read is not cached. one host 1 child process. I timed it at 20–60 ms on this overloaded Mac (3 runs against the live Orca Agents pid and Finder) child process, off main
probeProviderCwd RPC; in the helper, enumerateDirectoryOnce (one opendir plus one read, shared per path while in flight) per launch one folder 1 RPC with a 1.5 s cap; in the helper, 1 opendir with a 1 s wait cap app main (async) / helper loop
Verdict to notice logic (reportDaemonPtyCwdVerdict) per launch whose verdict is ok or denied per verdict ok: one loop over the in-flight denials for that helper and folder class (normally 0 or 1), one O(1) mismatch clear, and, in TCC folders only, one telemetry event, which costs a sync readFileSync of the small pid file plus one codesign. denied: the existing app-side opendir path. pendingDenials only holds denial reads still in flight, and settle() removes each one in a finally. main (async; the pid-file read is sync but tiny)
ProviderOwnerListener: mkdtemp, chmod, listen, chmod, then rm -r per hosted launch 1 server per launch, closed (release()) as soon as all 7 pipes arrive, or on any failure 4 async fs ops plus 1 recursive rm. Accepts at most 7 connections; any extra is destroyed immediately. main
spawnProvider in the helper: validLaunch, 7 connects each with a 5 s timer (cleared), 1 spawnProcess, then all 7 helper sockets destroyed in finally per hosted launch 7 sockets per launch O(env size) validation. The fork moves from Electron main to the helper; it is not new work. helper event loop
Header read in accept per chunk, but only until the header's newline. After that, off('data', read) runs. 7 sockets per launch at most 128 header bytes, so in practice 1 chunk. One indexOf(10) and one bounded Buffer.concat. main
DeferredProviderOwner / DeferredPipe per chunk of owner output, for every supervised launch on macOS desktop, including ones that fall back to a direct launch 7 pipes per chat 1 extra PassThrough hop per chunk. Buffers are not copied and backpressure carries through pipe(). main
Unix sockets replace pipes for hosted owners per chunk hosted chats macOS net.local.stream.recvspace = 8192 bytes, versus 16–64 KB for a pipe, so bulk output arrives in up to about 2–8× more data events. The NDJSON framer (main-process-ndjson-framer.ts) is segment-based and linear in bytes, so the only extra cost is the fixed per-event overhead. main
Growth monitor skip set per growth sample (cadence unchanged) number of process rows one O(1) Set.has per visited pid. Hosted subtrees are no longer walked, so each sample does less work. helper
hostedProviderOwners add on spawn, delete on exit live hosted owners bounded by live chats helper
Startup: installProviderProcessHost once at startup 1 stores a route; adds no listener, timer or import cost beyond modules already on the PTY startup graph main
Protocol 57 → 59 once per upgrade 1 the existing legacy-daemon mechanism: the old host keeps its terminals until they drain —

Fleet pricing (100+ agents, several hundred terminals):

  • Launches do not scale with the fleet; they are user actions or admission-gated probes.
  • A burst of 100 simultaneous launches costs about 100 ping+probe+spawn RPC triples, 700 short-lived helper sockets (helper fds return to baseline once spawns finish) and 100 temp dirs. It shares one codesign read.
  • Per chunk, the extra hop costs a few µs. At 100 agents × 10 chunks/s that is about 1,000 hops/s, a few ms/s on main. This is a rough estimate from per-hop cost, not a measurement, and is far below the 50 ms/s P0 line.
  • Happy-path added chat-start latency: 3 serial RPCs to the terminal host, plus one 20–60 ms codesign at most once per 10 s, plus 7 local connects. This is async and does not block main.

Listener and subscription census (perf-surface-detect hits)

Listener Owner / lifetime Rate at idle Rate under load
provider-owner-channels.ts:75 socket.on('error', destroy) each of the 7 app-side sockets, for the chat's lifetime 0 only on transport error
provider-owner-channels.ts:76 once('close') (pending delete) each socket, fires once 0 1 per socket close
provider-owner-channels.ts:111 socket.on('data', read) each socket until the header is read, then removed (:89) 0 about 1 call per socket per launch (7 per launch); 0 after handoff
deferred-provider-owner.ts:33 endpoint.on('error', ignore) plus once end/close/finish and stream.once('close') each of the 7 endpoints, for the chat's lifetime 0 lifecycle events only (1 each)
daemon-provider-spawn.ts:59 socket.on('error', noop) each helper socket, from connect until finally destroys it (lasts as long as the spawn call) 0 7 per launch, short-lived
daemon-provider-spawn.ts:93 child.on('error', noop) plus once('exit') each hosted owner in the helper, removed when the child exits 0 1 per owner exit
hosted-provider-launch.ts:157 child.once('error') direct fallback when the pid is undefined 0 1 per failed spawn
provider-leader-outcome.ts:66 and direct-provider-child.ts:136 once('spawn') each launch while the pid is pending 0 1 per launch

No listener publishes, bumps a version or fans out to renderer subscribers. The PR adds no publication or IPC.

Regression classes the diff touches

Class Disposition
Fixed-cadence poll that never settles Matched and disproved. The only timers are per-launch deadlines (withTimeout, withProviderStartDeadline ×2, connectPipe ×7), all cleared in finally or on success. No setInterval. The 10 s codesign reuse is a timestamp compare, not a timer.
Subprocess per item or event Matched and disproved. codesign runs at most once per 10 s per host, and concurrent reads share one. There is one owner fork per launch, which was already there and has moved to the helper.
Sync fs on Electron main Matched and disproved. The listener uses only async fs. The verdict path's readFileSync of the pid file is pre-existing, runs at most once per launch in TCC folders, and reads about 100 bytes.
Hot-path rescans Matched and disproved. The header scan is capped at 128 bytes, the data listener is removed after the header, and the downstream framer is linear.
Per-entity state outlives the entity Matched and disproved. hostedProviderOwners deletes on exit. pendingDenials drains in finally. The listener's pending and pipes are cleared on success and on close. lastHostImage holds a single entry. The temp dir is removed on both paths.
Unbounded fan-out Matched and disproved. The helper's Promise.allSettled covers exactly 7 connects, and accept caps connections at 7. Launch concurrency is set by the existing callers' admission and is unchanged.
Eager startup imports Matched. main-process-pty-startup.ts now imports provider-process-spawn and daemon-adoption-telemetry-event. Both already load through the PTY and provider graph, and no SDK or adapter is added.

The six scan questions

  1. Is unused work paid for before the skip gate? Reviewed. The ping gates the codesign read and the probe. An old host, a host without provider support, or a degraded adapter returns before any RPC or child process. Telemetry runs only for TCC folder classes.
  2. Does ownership multiply or recreate work? Reviewed. The PR reuses the one terminal control client and opens no new connection. It adds one listener per launch, not per chat or row. The pipe count per chat stays at 7.
  3. Which thread and storage layer pays? Reviewed. On main: async fs, RPCs, and one extra stream hop per chunk. The fork moves to the helper's loop, where it is one spawn per launch for terminals that share the loop. There is no SQLite.
  4. What grows, and does the next attempt advance? Reviewed. Nothing grows with history or fleet size. A failed codesign read is not cached, so a later launch retries it.
  5. What does the execution host change? Reviewed. The route is gated to macOS desktop. Windows, Linux, serve mode and SSH keep direct spawn (installProviderProcessHost is never called). macOS Unix socket buffers produce smaller chunks, priced above.
  6. Does obsolete work stop and release its budget? Reviewed. Cancel or failure closes the listener, destroys the pipes and removes the dir. An owner started by an unanswered request exits at its gate once the app closes its pipes, and the helper then deletes its pid on exit.

Not blocking, recorded with numbers

  • Degraded-host latency (failure mode only, constant per launch).
    • When the terminal host is connected but not responding, each launch waits up to 1 s (getClient) + 1 s (ensureConnectedWithin) + 1 s (ping) before launching directly.
    • If the ping passes but later steps are slow, the worst case is about 3 s + 3 s (codesign timeout) + 1.5 s (probe) = about 7.5 s before the direct fallback.
    • No negative cache: each launch during a host hang pays the 1 s ping again. It does not scale with the fleet, and a hung host has already broken every terminal.
  • Budget arithmetic (correctness, not perf).
    • HOSTED_START_BUDGET_MS = 15 000 − 9 000 − 1 000 = 5 000 ms. It is checked only just before spawnProvider (hosted-provider-launch.ts:198).
    • The pre-spawn steps (connect, codesign, probe) are not bounded by it, so in the 7.5 s worst case the direct fallback starts with about 7.5 s of the 15 s bootstrap deadline left. That is less than the 9 s worst-case proof window.
    • A typical proof finishes far faster, so this only matters when several stages are near their timeouts at once. Worth a look by the correctness reviewers.

Evidence and limits

  • Source-proven: every count above, from target-ref code.
  • Measured: the codesign wall time (20–60 ms on this Mac) and sysctl net.local.stream.{send,recv}space = 8192.
  • Targeted test: hosted-provider-launch.integration.test.ts through tc-gate. Result: 1 file, 5/5 tests pass on this head (direct delivery, denial fallback, no-answer probe fallback, host start failure fallback, lost-reply single launch).
  • Not run: no app launch, build or benchmark, because this Mac is overloaded. So there is no measured CPU, frame time or chat-start latency, and the per-hop estimate is unmeasured.
  • Not examined: the native provider-exec.c change (a one-time fcntl loop over 7 fds at owner start) was reviewed only as a constant per-launch cost.

Native-chat folder verdicts now reach the shared verdict telemetry, so its
spawner-path check and pid-file read are now asynchronous instead of
blocking the main process. The extracted backlog code only builds the
sampler, so the server keeps calling the existing probe directly. Lowered
the blocking-helper baseline rows that shrank.

Connecting to the host and checking its signature and the folder now share
the hosted start budget, so a slow host still leaves a direct launch time
to prove ownership.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: head 6b7e0c5 (fresh pass)

Verdict: no perf blocker. I found no P0 or P1 at the reference fleet. All new work happens once per chat launch, has a fixed bound, and stops or is released on success, failure and cancel. Nothing runs on a timer, nothing grows with worktrees, terminals or history, and no sync fs was added on Electron main.

This is an independent scan of the whole PR (5a28037b3f8..6b7e0c5), not only the commits since the last scan. Since 0cd1a11, five files changed:

  • hosted-provider-launch.ts: the connect, signature and folder checks now share the start budget.
  • daemon-adoption-telemetry-event.ts and daemon-endpoint-incarnation.ts: async pid-file read and access() replace readFileSync/existsSync.
  • daemon-server.ts and daemon-stream-backlog-probe.ts: a pure refactor of the backlog sampler.

Work added per chat launch (macOS desktop only)

Trigger: a supervised native provider spawn: a chat start, a background agent start, an opencode model probe, source-control text generation or Codex backfill recovery. The short-lived Codex hook probes opt out (allowHost: false). Population: one per launch. Launch concurrency comes from the existing callers and is unchanged.

Work Thread Bound
getClient + ensureConnectedWithin + ping (hosted-provider-launch.ts:122-139) main, async RPC on the existing control client ≤ 1 s each, 3 s at most. Opens no new connection.
codesign --display +<host pid> (hosted-provider-launch.ts:62-74) child process at most 1 per 10 s per host identity. Concurrent launches share the in-flight read. 3 s timeout. Measured at 20-60 ms on this Mac by the earlier pass.
probeProviderCwd (daemon-provider-requests.ts:27-34) daemon, async opendir 1.5 s app-side and 1 s host-side waits. The opendir is deduped per path (directory-enumeration-probe.ts:26-35), the same pattern each daemon terminal spawn already uses (terminal-host-session-process.ts:47).
The whole pre-spawn phase above main Changed in 6b7e0c5: now raced against HOSTED_START_BUDGET_MS = 15 000 − 9 000 − 1 000 = 5 000 ms (:175-185). The worst case is no longer about 7.5 s before direct fallback. It is 5 s.
ProviderOwnerListener (provider-owner-channels.ts) main 1 mkdtemp + 2 chmod + 1 Unix server + ≤ 7 accepted sockets (:70 caps it) + 1 rm. The server closes as soon as all 7 pipes arrive, or on close().
spawnProvider on the helper (daemon-provider-spawn.ts) helper (daemon) loop 7 connects (5 s timeout each, allSettled), 1 spawn (the fork the app did before). The helper destroys its socket copies in finally. hostedProviderOwners adds on spawn and deletes on exit.
Folder-verdict telemetry (daemon-adoption-telemetry-event.ts:148-204) main, async Readable: only for TCC folder classes. 1 async pid-file read, 1 access() and 1 codesign (shared only while in flight). That matches what each daemon terminal spawn already does at base. Denied: 1 app-side opendir, deduped per path. pendingDenials drains in finally.

Price at the reference fleet (100+ agents): a burst of 100 launches costs about 300 small RPCs on one existing socket, 1 codesign for the gate (10 s reuse), up to 100 telemetry codesign children only when every chat is in a Documents/Desktop-style folder, 100 temp dirs and 700 transient sockets on each side. All of it is async or off main, and it costs the same at 10× fleet per launch. It is one-time per launch, not a repeated trigger, so it is not a finding.

Abandoned work after the new deadline (Q6, new in 6b7e0c5)

When the 5 s race wins, the inner connectedHost and inspectHostedIdentity task keeps running until its own timeouts. That is at most about 2.5 s more (inner worst case 3 + 3 + 1.5 = 7.5 s, minus 5 s), with at most 1 ping, 1 shared codesign and 1 per-path-deduped probe. A late ok/denied can still call reportCwd. That is one true telemetry event or notice and starts no process for the chat. Nothing is retained after the tail settles, so this is bounded and not a finding.

Listener census

Listener Per Idle rate Under load
ProviderOwnerListener server connection launch, lives ≤ start budget 0 ≤ 7 accepts, then closed
accepted socket data (header reader) pipe 0 removed after the ≤ 128-byte header (:89), so 0 per later chunk
accepted socket error / close pipe, for the chat's lifetime 0 fire once at teardown
DeferredPipe.attach: error, end, close, stream close, finish, plus pipe() 7 pipes per chat (also on the direct fallback while the route is installed) 0 one extra PassThrough hop per chunk (passes the buffer by reference, no copy)
observeProviderLeaderOutcome: spawn + close once chat 0 the one that doesn't fire stays until the owner is collected (constant 1)
helper connectPipe error/connect, child error/exit launch 0 sockets destroyed in finally; child listeners go with the child
startup installProviderProcessHost (main-process-pty-startup.ts:208-221) app, once no timer, no listener; only stores the route n/a

Streaming cost: macOS Unix sockets read in chunks of about 8 KiB or less (net.local.stream.recvspace = 8192) instead of up to 64 KiB from a pipe. The chunk count is bounded by bytes / 8 KiB, and the bytes are the same. At 100 agents streaming 20 KB/s each, that is about 250 chunks/s × one extra stream hop. Estimated at a few ms/s on main (unmeasured), well under the 50 ms/s P0 line. The per-chunk work is constant, with no rescans: the header scan is capped and then removed.

Regression classes the diff touches

Class Disposition
Fixed-cadence poll Disproved. No setInterval and no self-rescheduling timer. withProviderStartDeadline (×3), withTimeout and connectPipe timers are all cleared in finally or on settle. The 10 s codesign reuse is a timestamp compare.
Subprocess per item/event Disproved. Per launch, not per item: gate codesign ≤ 1/10 s and shared in flight. Telemetry codesign ≤ 1 per TCC-folder launch, matching what each daemon terminal spawn already does at base. The owner fork moves to the helper (still 1).
Sync fs on Electron main Disproved, and improved in 6b7e0c5. readDaemonPidRecordAsync and access() replace readFileSync and existsSync on the verdict path. The main-blocking ratchet drops daemon-adoption-telemetry-event.ts (count 5 → removed). The listener uses only async fs. providerOwnershipBootId sync mkdir/lstat is cached per directory (once per process).
Hot-path rescans Disproved. Header ≤ 128 bytes, then the data listener is removed. countDescendantsByRoot skip is an O(1) Set.has per visited row on the existing monitor cadence.
Per-entity state outlives entity Disproved. hostedProviderOwners deletes on exit. pendingDenials drains in finally. pending/pipes are cleared on success and on close. lastHostImage is a single slot. The temp dir is removed on both paths.
Unbounded fan-out Disproved. 7 connects per launch, the accept cap is 7, and probes are deduped per path.
Eager startup imports Matched. main-process-pty-startup.ts adds value imports of provider-process-spawn and daemon-adoption-telemetry-event. Both already load through the PTY/provider graph, and no SDK or adapter is added.
Re-reading unchanged input Disproved. The pid file (about 100 bytes) is read once per verdict event, not polled.

The six questions

  1. Unused work before the skip gate: reviewed. providerSpawn and ping gate the codesign and the probe. Old, degraded or non-provider hosts return before any child process. Readable telemetry runs only for TCC folder classes.
  2. Ownership multiplies work: reviewed. It reuses the one terminal control client. One listener per launch. Pipes per chat stay at 7.
  3. Thread/storage: reviewed. Main sees async fs, RPCs and one stream hop per chunk. The fork runs on the helper loop. No SQLite.
  4. Growth / next attempt advances: reviewed. Nothing grows with fleet or history. A failed codesign is not cached, so the next launch retries it.
  5. Execution host: reviewed. The route is installed only when darwin && !isServeMode. Windows, Linux, serve and SSH keep direct spawn. Socket chunk size is priced above.
  6. Obsolete work stops: reviewed. Cancel or failure closes the listener, destroys the pipes and removes the dir. The tail after the deadline is bounded, as described above. An owner started by an unanswered request exits at its gate once the app closes its pipes.

Not blocking, recorded with numbers

  • Degraded host (failure only, constant per launch): each launch while the host hangs waits up to 3 s (connect + ping), or up to 5 s in total if later steps stall, then launches directly. There is no negative cache, so a burst of N launches during a hang each pay that latency. Cost does not grow with the fleet, and no resources are retained.

Evidence and limits

  • Source-proven: every count and bound above, from target-ref code at 6b7e0c5.
  • Test: hosted-provider-launch.integration.test.ts through tc-gate on this head: 1 file, 5/5 tests pass.
  • Not run (this Mac is overloaded): no build, app launch or benchmark. So there is no measured chat-start latency, main-thread CPU or per-chunk hop cost. The streaming figure above is an estimate.
  • Native code: provider-exec.c was reviewed as a one-time fcntl loop over 7 fds at owner start.

A host check still running when the direct fallback took over could report
a late denial and bring back a notice a newer readable verdict had
cleared. Checks past the budget now count as abandoned and report nothing.

The integration test now ends the CLI's input only after it starts, since
its owner allows only a short grace once input closes.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan: head 28d7fa6 (fresh reviewer, pass 6)

Verdict: clean. No perf blocker. All new work runs once per chat launch, with fixed limits. Nothing runs at idle, and no cost grows with worktrees, terminals, chats or history. The new commit 28d7fa6 makes the code after the start budget do slightly less work than 6b7e0c5 did.

Diff range: 5a28037b3f8..28d7fa613a0 (merge base with main to head). Commits since the last graded head (6b7e0c5):

  • ce02ca0: removes one row from config/main-sync-fs-baseline.txt. No runtime change.
  • 28d7fa6: in hosted-provider-launch.ts:174-182, the folder check's cancel test changes from owner.canceled to owner.canceled || remainingMs() === 0.

I traced every changed production file again on this head. I did not rely on the earlier scans.

What 28d7fa6 changes for performance

abandoned() costs one performance.now() call. inspectHostedIdentity calls it at most twice per launch (:92 and :100). It is a closure over the launch's own deadline and lives only as long as that launch.

Effect after the 5 s start budget (HOSTED_START_BUDGET_MS = 15 000 − 9 000 − 1 000):

  • Before: a check that was still running after the direct fallback started could still send the probeProviderCwd RPC, which runs an opendir on the helper. It could also call reportCwd, which does a pid-file read, access(), a codesign child, or an app-side opendir.
  • Now: once the budget is spent, the check stops at :92, before the probe RPC, or at :100, before reportCwd.
  • What can still run late: the work already in flight, which is at most 1 ping (≤ 1 s), 1 shared codesign (≤ 3 s timeout) and 1 probe already sent (≤ 1.5 s). Nothing new starts, and nothing is kept once these settle.

Every piece of new work: trigger, population, bound

Trigger for all rows below: one supervised provider launch on macOS, with the route installed (darwin && !isServeMode). This covers native chat CLIs, Codex app-server sessions and the agent model-catalog probes. It excludes callers that pass allowHost: false (Codex hook-trust listing and grant). Population: launches per second, not worktrees, terminals or chats alive at once.

Work Thread / process Per launch Bound
connectedHost (hosted-provider-launch.ts:122-139) main, async getClient (≤ 1 s), ensureConnectedWithin (≤ 1 s), 1 ping RPC (≤ 1 s) on the existing control socket Inside the 5 s race. Any failure launches directly.
Host signature check hostCodeIdentity (:62-74) main, plus 1 codesign child 1 codesign --display +pid (3 s timeout), reused for 10 s per host identity, shared while in flight ≤ 1 child per 10 s while the host is healthy. A failed read clears the cache, so the next launch tries again.
Folder probe (daemon-provider-requests.ts:26-34) helper loop 1 opendir + 1 read, shared per path while in flight (directory-enumeration-probe.ts:26-35), 1 s wait One per launch.
ProviderOwnerListener (provider-owner-channels.ts) main, async fs 1 mkdtemp, 2 chmod, 1 Unix server, ≤ 7 accepted sockets (cap at :70), 1 rm The server closes once all 7 pipes arrive (:105-108) or on close(). The temp dir is removed on both paths.
spawnProvider on the helper (daemon-provider-spawn.ts:67-115) helper loop 7 connects (5 s timeout each, allSettled), 1 spawnProcess. This replaces the fork the app used to do. The helper's socket copies are destroyed in finally. hostedProviderOwners adds the pid on spawn and deletes it on exit (:106-107).
DeferredProviderOwner (deferred-provider-owner.ts) main 7 DeferredPipes, each 2 PassThroughs (plus Duplex.from for fd 3) Lives as long as the chat. This replaces the 7 direct pipes and runs on both the hosted and direct paths.
Folder verdict (daemon-adoption-telemetry-event.ts:148-204) main, async Readable, TCC folder classes only: 1 async pid-file read (~100 bytes), 1 access(), 1 codesign (shared while in flight, not cached). Denied: 1 app-side opendir, shared per path. pendingDenials holds only checks still in flight and is cleared in finally. Nothing stays after they settle.
Native owner fcntl loop (provider-exec.c:656-662) owner process 7 × F_GETFL/F_SETFL at startup Fixed.
Growth-monitor skip (daemon-process-growth-monitor.ts:95-99, process-growth-breaker.ts:139) helper 1 Set.has per row it visits, on the monitor's existing schedule. The set is passed by reference, so nothing is allocated. Fixed. Skipping a subtree means fewer rows are visited.
Startup wiring (main-process-pty-startup.ts:208-221) main, once Stores 2 closures. No timer, listener, I/O or await at startup. Runs once per app start.

Cost at the reference fleet. Assume a burst of 100 chat launches (100+ agents restored or started at once):

  • about 300 small RPCs on one existing socket
  • 1 gate codesign (reused for 10 s)
  • up to 100 telemetry codesign children, but only if every chat is in a Documents/Desktop-style folder; launches that overlap share one
  • 100 temp dirs and 700 short-lived sockets on each side

All of it is async or off main. The per-launch cost is the same at 10× the fleet. It is one-time work per launch, which already forks the native owner and a CLI. It does not repeat on a store write, PTY chunk, status update or timer, so it is not a finding.

Recorded with numbers, not blocking. In TCC folders, each hosted launch runs one telemetry codesign (daemon-adoption-telemetry-event.ts:73 through inspectMacProcessCodeIdentity). The gate's result for the same pid was read up to 10 s earlier and is not reused here. That is at most 1 extra child per launch, async, the same as each daemon terminal spawn already does at base. Folding it into the gate's 10 s cache would save it. That is optional, because the cost is fixed per launch.

Listener census

perf-surface-detect --pr 41917 flags 4 subscribe lines and 1 startup-migration file. All of them are below, along with the other listeners the diff adds.

Listener Per Rate at idle Rate under load
provider-owner-channels.ts:75 accepted socket error → destroy pipe, for the chat's life 0 at most once, at teardown
provider-owner-channels.ts:76 accepted socket close → pending.delete pipe 0 once
provider-owner-channels.ts:111 header reader data pipe, only until the header arrives 0 Reads ≤ 128 bytes, then is removed (:89). So 0 calls per later output chunk. The 128-byte cap stops a peer that never sends a newline.
provider-owner-channels.ts:38-40 server connection, once('error') launch, live ≤ start budget 0 ≤ 7 accepts, then the server closes
deferred-provider-owner.ts:33 endpoint error (ignore) 7 per chat 0 0 in normal operation
deferred-provider-owner.ts once('end'), once('close'), stream once('close'), once('finish'), pipe() 7 per chat 0 Each fires once at teardown. pipe() adds one PassThrough hop per output chunk, passing the buffer by reference with no copy.
provider-leader-outcome.ts:66-69 once('spawn') + once('close') chat 0 One fires; the other stays until the owner is collected (1 per chat)
direct-provider-child.ts:136 once(raw, 'spawn') chat bootstrap 0 Settles on spawn or error
daemon-provider-spawn.ts:49-59 connect error/connect, then a no-op error 7 per launch on the helper 0 Sockets are destroyed in finally, which removes their listeners
daemon-provider-spawn.ts:93 child error (no-op), :100 once('error'), :107 once('exit') launch on the helper 0 Each fires once. They go away with the child.
hosted-provider-launch.ts:157 child.once('error') (direct path with no pid) failed spawn 0 once

There is no new setInterval and no timer that reschedules itself. The timers in withProviderStartDeadline (up to 3 per launch), the timers inside withTimeout, and the timer in connectPipe are all cleared in finally or when they settle.

Streaming hop. On macOS, Unix sockets deliver chunks of about 8 KiB or less (recvspace = 8192), where a pipe can deliver up to 64 KiB. The number of chunks is bytes ÷ 8 KiB, and the bytes are the same as before. At 100 agents streaming 20 KB/s each, that is about 250 chunks/s, each with one extra stream hop and no scan or copy. I estimate a few ms/s on main, but did not measure it. That is far below the 50 ms/s P0 line, and the work per chunk is fixed.

Regression classes the diff touches

Class Disposition
Fixed-cadence poll Disproved. No interval and no self-rescheduling timer. The 10 s codesign reuse is a timestamp comparison.
Subprocess per item/event Disproved. Children are per launch, not per item. Gate codesign ≤ 1 per 10 s, shared while in flight. Telemetry codesign ≤ 1 per TCC-folder launch, the same as base terminal spawns. The owner fork moves to the helper, so there is still 1.
Sync fs on Electron main Disproved. The verdict path uses readDaemonPidRecordAsync and access(). ce02ca0 removes the emptied baseline row. The listener uses only async fs.
Hot-path rescans Disproved. The header scan stops at 128 bytes and its listener is then removed. The growth-monitor skip is an O(1) Set.has per visited row.
Per-entity state outlives entity Disproved. hostedProviderOwners deletes on exit. pendingDenials is cleared in finally. pending and pipes are cleared on success and on close. lastHostImage is a single slot. The temp dir is removed on both paths.
Unbounded fan-out or queues Disproved. Each launch makes 7 connects and accepts at most 7. Probes are shared per path.
Eager startup imports Matched, disproved. main-process-pty-startup.ts adds value imports of provider-process-spawn and daemon-adoption-telemetry-event. Both already load through the PTY/provider graph, and no SDK or adapter is added. hosted-provider-launch imports only modules on the same graph.
Update published when nothing changed No matching code. The protocol version bump to 59 is a wire constant, not a notify.
Launch work that scales with history Disproved. Startup only stores closures. The protocol bump keeps v57/v58 daemons attachable, so terminals survive an upgrade (the existing bump pattern). Nothing loops over records.

The six questions

  1. Unused work paid for before the skip gate: reviewed. The order is providerSpawn, then ping, then codesign, then probe. Old, degraded or non-provider hosts return before any child process starts. Readable telemetry runs only for TCC folder classes. With 28d7fa6, once the budget is spent no new probe or verdict starts.
  2. Ownership multiplies work: reviewed. Launches reuse the one terminal control client. Each launch gets one listener. Each chat still has 7 pipes.
  3. Thread and storage: reviewed. Main sees async fs, RPCs and one stream hop per chunk. The fork runs on the helper's loop. No SQLite.
  4. Growth, and does the next attempt advance: reviewed. Nothing grows with the fleet, history or uptime. A failed codesign is not cached, so the next launch reads it again. An abandoned check now ends without reporting.
  5. Execution host: reviewed. The route is installed only when darwin && !isServeMode. Windows, Linux, serve mode and SSH keep direct spawn. Socket chunk size is priced above. The fcntl loop runs only in the native owner.
  6. Obsolete work stops: reviewed. Cancel or failure closes the listener, destroys the pipes and removes the temp dir (:234-245). The work after the budget is now limited to calls already in flight (see above). An owner started by an unanswered request exits at its gate once the app closes its pipes.

Not blocking (failure case only, fixed per launch)

While the host is hung, each launch waits up to 3 s for connect and ping, or up to 5 s in total, then launches directly. There is no negative cache, so N launches during a hang each pay that wait. The wait does not grow with the fleet, and nothing is kept.

Evidence and limits

  • Source-proven: every count and bound above, from code at 28d7fa613a0.
  • Test: src/main/provider-process/hosted-provider-launch.integration.test.ts through tc-gate on this head: 1 file, 5/5 tests pass. It covers the hosted and fallback launch paths. It does not time anything.
  • Not run (this Mac is overloaded): no build, app launch or benchmark. So there is no measured chat-start latency, main-thread CPU or per-chunk hop cost. The streaming figure is an estimate.
  • Paths examined: the provider-process launch seam (all callers of spawnProviderProcess and spawnManagedProviderProcess, including allowHost: false callers), the daemon provider request and spawn handlers, the folder-verdict telemetry, the growth monitor, the startup wiring, the protocol version and provider-exec.c. Hosts: macOS hosted, macOS direct fallback, and non-darwin/serve (route not installed).

@brennanb2025

brennanb2025 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status: ready (head 28d7fa613a)

Problem: on macOS, Claude and Codex chats were started by the Orca app, so macOS charged their memory and privacy access to Orca rather than the Orca Agents helper that terminal agents already use.

User-facing change: on supported macOS builds, chats and background agent tasks start under Orca Agents. Orca still owns each chat: Stop, output, history, exit and cleanup behave as before, and restarting the helper no longer ends running chats. If the helper can't read the chat's folder, is slow or fails before Orca takes over the chat, the chat starts directly as before. A real folder denial shows the existing folder-access notice.

Fixed during review (this round):

  • A hosted start that failed before Orca attached the chat now starts it directly instead of failing. The CLI can't run before Orca opens its gate, so nothing runs twice.
  • The whole hosted attempt (connect, signature, folder check, start) fits a 5 s budget inside the 15 s startup deadline, leaving time for main's ownership check after a fallback.
  • The folder notice can no longer be brought back by a late, abandoned or replaced-helper denial. Its telemetry reads files asynchronously instead of blocking the main process.
  • One merge of main to resolve a test-list conflict; main's new ownership proof works with hosted owners.

Verified:

  • Signed build QA on 81026e0 (M4Air): 7/7 pass, covering hosted topology, Stop, tab close, helper restart with chats surviving, graceful quit, GUI crash cleanup with history intact, and hosted commit-message generation. This Mac: hosted chats, a new-helper Codex Documents read with a reply, protected-folder probes and no notice. CLI start is faster (Claude 72 ms vs 177, Codex 124 ms vs 179).
  • 150 chats on the M4Air vs main: memory p50 3451.4 vs 3437.6 MiB, peak 3515.8 vs 3580.6 MiB; switch p50 104.9 vs 104.2 ms; typing p95 29.6 vs 30.3 ms; history 1305/1305; clean quit. Different harness versions, so not a strict pair.
  • Later commits change only the pre-attach fallback, its budget and folder-verdict ordering. Integration tests with the real native owner and host spawn cover them: denied, unanswered and failed hosted starts launch directly and reply once, the stranded owner exits, and stale denials can't restore the notice. Stress-run 3x in parallel.
  • Fresh Claude + Codex reviewers passed every repair; the final pair is clean on 28d7fa613a. Perf-scan of 28d7fa613a: clean (comment above).
  • check:changed on Omarchy for this head: 38 of 39 checks pass. The one failure is the blocking-helper ratchet, on three federation files this PR doesn't touch; main fixed them after this branch's merge base (0fa0ad5, 96a897c), so CI's merge with main passes them.

QA screenshots (signed build v1.4.262-adhoc.20261117181458, head 81026e0, this Mac; each agent ran its own access script):

Hosted Claude chat in a normal folder: Documents read, reply

Hosted Claude chat in a normal folder: Documents read, reply

Hosted Codex chat after a new helper: Documents read, reply

Hosted Codex chat after a new helper: Documents read, reply

Hosted Claude chat in a protected folder: folder read, reply, no notice

Hosted Claude chat in a protected folder: folder read, reply, no notice

Hosted Codex chat in a protected folder: folder read, reply, no notice

Hosted Codex chat in a protected folder: folder read, reply, no notice

Skipped / deferred:

  • Real-Mac Documents off and re-allow rows: skipped with Brennan's approval, since they would change the operator's own Orca permissions. Covered by the tests above. Follow-up STA-15877 runs them on a disposable macOS user or VM.
  • A helper that hangs costs each new chat up to 5 s before it starts directly; nothing remembers the hang between launches.
  • One telemetry codesign per launch in Documents-style folders isn't reused from the gate check, as on main for terminals.

@brennanb2025
brennanb2025 marked this pull request as ready for review November 18, 2026 05:41
@brennanb2025
brennanb2025 merged commit a7b5c0a into main Nov 18, 2026
103 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