Repository navigation
fix(daemon): detect severed macOS TCC attribution behind terminal automation denials (STA-3491) - #12848
Conversation
…restart remedy (STA-3491) macOS pins the detached PTY daemon's TCC responsible process to the app binary that forked it. Once that binary is deleted (packaged updates replace the bundle), Accessibility/Automation grants on Orca silently stop covering every daemon-hosted terminal: osascript/System Events fails with -25211 no matter what the user grants. - record spawnerExecPath in the daemon pid file at fork - adoption checks it: severed + 0 live sessions -> replace the daemon (reason severed_tcc_attribution); live sessions are preserved - Settings (Developer Permissions + Manage Sessions) show a visible banner pointing at Manage Sessions -> Restart while severed
📝 WalkthroughWalkthroughThe daemon now records its spawner executable path and evaluates macOS TCC attribution as 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bf6bd709-9cda-438e-9bc8-78e4e2889e33
📒 Files selected for processing (16)
src/main/daemon/daemon-health.tssrc/main/daemon/daemon-init.test.tssrc/main/daemon/daemon-init.tssrc/main/daemon/daemon-spawner.tssrc/main/daemon/daemon-tcc-attribution.test.tssrc/main/ipc/pty-management.test.tssrc/main/ipc/pty-management.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/DeveloperPermissionsPane.tsxsrc/renderer/src/components/settings/ManageSessionsSection.tsxsrc/renderer/src/components/settings/TerminalTccAttributionNotice.test.tsxsrc/renderer/src/components/settings/TerminalTccAttributionNotice.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/web-preload-api.tssrc/shared/daemon-lifecycle-telemetry.ts
Electron QA evidenceValidated this branch in an isolated development profile via CDP. Repro: spawned one daemon-backed terminal ( The warning rendered in macOS Permissions and its action navigated to Terminal → Manage Sessions. Confirming Restart daemon closed the retained session, replaced the daemon, and produced |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/settings/TerminalTccAttributionNotice.tsx (1)
19-25: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winApply only the latest attribution result.
refresh()runs on mount, window focus, and everyrefreshRevisionchange. These calls can overlap. An olderseveredresponse can overwrite a newerintactresponse and keep the warning visible after the daemon restart. Track a request sequence or cancel stale probes. Add an out-of-order response test.Suggested fix
-import { useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect, useRef, useState } from 'react' export function useMacTccAttributionSevered(refreshRevision = 0): boolean { const [severed, setSevered] = useState(false) + const refreshSequence = useRef(0) const refresh = useCallback(async (): Promise<void> => { + const sequence = ++refreshSequence.current try { const { health } = await window.api.pty.management.macTccAttribution() + if (sequence !== refreshSequence.current) return setSevered(health === 'severed') } catch { + if (sequence !== refreshSequence.current) return setSevered(false) } }, [])Also applies to: 28-36
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 07c20def-0c43-470e-b45e-69d15d57dd74
📒 Files selected for processing (6)
src/main/daemon/daemon-health.test.tssrc/main/daemon/daemon-health.tssrc/main/daemon/daemon-tcc-attribution.test.tssrc/renderer/src/components/settings/ManageSessionsSection.tsxsrc/renderer/src/components/settings/TerminalTccAttributionNotice.test.tsxsrc/renderer/src/components/settings/TerminalTccAttributionNotice.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/daemon/daemon-tcc-attribution.test.ts
Review completionReview verdict: clean after fixes. Pushed Validation: 127 focused tests, typecheck, changed-file lint, max-lines ratchet, and diff checks passed locally; fresh required CI is green, including both Node 24/26 shard 3 jobs, static analysis, package checks, and the macOS native-owner smoke test. |
…-osascript-automation # Conflicts: # src/main/daemon/daemon-health.ts # src/main/daemon/daemon-init.test.ts # src/main/daemon/daemon-init.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/daemon/daemon-server.ts (1)
323-326: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftKeep the endpoint owned until RPC shutdown finishes.
finishRpcShutdowncallsfinishOrdinaryShutdown, which removes the canonical endpoint beforedisposeDaemonResources()awaitshost.dispose().cleanupDaemonForProtocoltreats endpoint disappearance as proof that the old daemon is safe to replace insrc/main/daemon/daemon-init.ts, Lines 1295-1302. If native disposal stalls, replacement can start while the old daemon still runs or still owns PTY children.The signal path has a five-second shutdown bound in
src/main/daemon/daemon-entry.ts, Lines 169-197. This RPC path has no equivalent bound. Keep the endpoint claimed until disposal completes, or make replacement wait for the daemon process to exit. Add a bounded fallback for a wedgedhost.dispose().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 177fc610-adbc-4b39-baee-071176a728c9
📒 Files selected for processing (14)
src/main/daemon/client.test.tssrc/main/daemon/client.tssrc/main/daemon/daemon-entry.test.tssrc/main/daemon/daemon-entry.tssrc/main/daemon/daemon-health.test.tssrc/main/daemon/daemon-health.tssrc/main/daemon/daemon-hello-protocol.tssrc/main/daemon/daemon-init.test.tssrc/main/daemon/daemon-init.tssrc/main/daemon/daemon-main.tssrc/main/daemon/daemon-server.tssrc/main/daemon/daemon-spawner.tssrc/renderer/src/i18n/locales/en.jsonsrc/shared/remote-runtime-shared-control-state.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/renderer/src/i18n/locales/en.json
- src/main/daemon/daemon-spawner.ts
- src/main/daemon/daemon-health.test.ts
- src/main/daemon/daemon-init.test.ts
- src/main/daemon/daemon-health.ts
…omation denials (STA-3491) (stablyai#12848) * fix(daemon): detect severed macOS TCC attribution and surface daemon-restart remedy (STA-3491) macOS pins the detached PTY daemon's TCC responsible process to the app binary that forked it. Once that binary is deleted (packaged updates replace the bundle), Accessibility/Automation grants on Orca silently stop covering every daemon-hosted terminal: osascript/System Events fails with -25211 no matter what the user grants. - record spawnerExecPath in the daemon pid file at fork - adoption checks it: severed + 0 live sessions -> replace the daemon (reason severed_tcc_attribution); live sessions are preserved - Settings (Developer Permissions + Manage Sessions) show a visible banner pointing at Manage Sessions -> Restart while severed * fix(daemon): harden TCC attribution recovery


Summary
Fixes the macOS half of STA-3491 that Orca can own:
osascript/System Events automation run inside Orca's embedded terminal fails with-25211("osascript is not allowed assistive access") even after the user grants Orca Accessibility + Automation in System Settings.Root cause. macOS pins a process's TCC "responsible process" to the binary that forked it, by file reference. Orca's terminal PTYs are hosted by the detached daemon (
daemon-entry.js, reparented to launchd), which deliberately outlives the app. When the app instance that originally forked the daemon is gone and its binary has been deleted — which happens on every packaged update, since the updater replaces the bundle —tccdcan no longer resolve the grant subject for any terminal child of that daemon. Accessibility checks are then silently denied with no prompt and no grantable entry in System Settings, exactly matching the report ("permanently denied regardless of the grants on Orca.app", process tree rooted in a nestedOrca Helper.app).Change (macOS-gated, minimal):
spawnerExecPath(the forking app'sprocess.execPath) in the daemon pid file at fork time.getMacDaemonTccAttributionHealth()indaemon-health:severedwhen the verified pid record's spawner binary no longer exists (legacy pid files fall back to a packaged app-version mismatch heuristic),unknownfails open.severed_tcc_attribution). With live sessions it is preserved — replacing would kill the user's running terminals.pty:management:macTccAttributionIPC that computes the verdict on demand from the pid record.Explicit limitation (deliberate). This does not auto-fix a severed daemon that always has live sessions. The alternative — routing fresh terminals to the in-app local provider while the old daemon drains — would re-trigger after every app update and silently strip daemon persistence from all new panes for as long as superseded daemons take to drain (often very long). That trade was judged worse; the banner makes the state and the one-click remedy visible instead, and the daemon self-heals at the first 0-session adoption.
Reproduction steps from the issue, and the second symptom reported there (focus reverting to Orca between commands), are discussed under Notes.
Screenshots
No visual change in the default state. The new banner renders only in the severed state (macOS + daemon whose spawning binary was deleted), which cannot be triggered on the development machine without destroying its live daemon's spawner binary; the banner uses the existing amber alert pattern (
quick-open-install-rg-guidance) and the existing Developer Permissions pane layout.Testing
pnpm lint— full pipeline not run as one command; ran each gate individually:oxlint(only pre-existing failure:mobile/src/session/use-mobile-native-chat-controller.tsmax-lines, present on clean tree),audit:code-quality:native,audit:code-quality:type-aware,check:reliability-gates,check:max-lines-ratchet,verify:localization-catalog,verify:localization-extraction,audit-localization-coverage --check— all pass.pnpm typecheck—tsconfig.node(--composite false),tsconfig.tc.web,tsconfig.tc.cliall clean.pnpm test— full suite not run; focused run:daemon-init(69),daemon-tcc-attribution(7, new),pty-management(16),TerminalTccAttributionNotice(4, new),DeveloperPermissionsPane,daemon-bundle-staleness,macos-tcc-login-shell— all pass.pty-subprocess.test.tshas 2 failures that reproduce identically on the clean tree (local-environment reds, untouched by this PR).pnpm build— not run (no build-config changes).daemon-tcc-attribution.test.ts(new, real-process harness likedaemon-bundle-staleness.test.ts): severed/intact by spawner-path existence, legacy version-mismatch heuristic, fail-open on missing pid record and off-macOS.daemon-init.test.ts: severed + 0 sessions → replace withsevered_tcc_attributionbilled once; severed + live sessions → preserve, no kill, no replacement event; pid-file shape now pinsspawnerExecPath.pty-management.test.ts: new IPC returns the daemon verdict and fails open tounknown.TerminalTccAttributionNotice.test.tsx(new): renders only while severed, navigates to Manage Sessions, hides its button on the Manage Sessions surface, fails closed when the probe is unavailable.Reproduction / evidence
The reporter's exact environment (macOS 26.2 + their TCC state) is not reproducible here; per policy this PR states that limitation explicitly and builds the evidence chain instead:
osascript -e 'tell application "System Events" to get UI elements of process "Dock"'inside an Orca embedded terminal and readinglog show --predicate 'subsystem == "com.apple.TCC"'yields:AUTHREQ_ATTRIBUTION: … responsible={TCCDProcess: identifier=com.stablyai.orca, …, responsible_path=/Users/…/.Trash/STA-3380-…/Orca-1.4.169-hourly.disabled-bundle/Contents/MacOS/Orca, binary_path=/usr/bin/osascript}i.e. the responsible process for a terminal
osascriptis resolved by recorded file reference to the (long-dead) app binary that forked the daemon — here it still resolves only because that binary happens to survive in the Trash. The daemon's process tree (Orca Helper … daemon-entry.js, ppid 1 →login -flpq→ shell) confirms the daemon hosts every terminal child.-25211, unfixable from System Settings. This matches the issue: automation prompts (which can prompt/persist per-identity) partially worked, the assistive-access check never did.daemon-tcc-attribution.test.tsreproduces the detection contract against real processes;daemon-init.test.tspins the adoption behavior.AI Review Report
Reviewed the daemon adoption flow for regressions: the new check runs only in the final "safe to reuse" branch (after resolver-health, launch-identity, and stale-bundle checks), so no existing replacement path changes; live-session daemons are always preserved, and
unknownfails open to today's behavior (legacy pid files, probe errors, non-macOS). Verified the telemetry reason flows through the existingidentifiedReplacementgate and is billed exactly once. Checked the IPC handler fails open and that web/serve clients get a stub (unknown) so the banner never renders there — remote wire compatibility unaffected (new optional preload method, no protocol change; the pid record is a local file, not wire state).Cross-platform: detection and replacement are
darwin-gated insidegetMacDaemonTccAttributionHealth; Linux/Windows returnunknownand keep current behavior; no shortcuts, labels, paths, or shell behavior change on any platform;spawnerExecPathrecording is harmless on win32 (including the relocated daemon host, which only overrides the daemon's own exec, not the recorded spawner). SSH/folder workspaces unaffected: the check concerns only the local daemon.Security Audit
process.execPath) with the existing0o600/wxflags; it is only everexistsSync-checked afterreadVerifiedDaemonPidproves the record belongs to the live daemon — no path is executed, spawned, or interpolated.unknown.Notes
app.focus({steal:true})sites: notification click, second-instance launch, dashboard pop-out) — none fire between terminal commands, so Orca does not steal focus itself. The observed behavior is consistent with macOS 26's cooperative-activation returning focus to the responsible app when the short-livedosascriptprocess that brokeredactivateexits — the same responsible-process linkage as the TCC bug, and not addressable from Orca's code. If field reports persist after attribution is healed, that should be a separate issue.login -flpqTCC wrapper (Fix macOS TCC attribution for terminal children via login(1) #7003/fix(pty): restore macOS TCC attribution persistence #12562) is not the culprit and is untouched: the live trace above shows responsibility rolling up throughloginto the app correctly.