Skip to content

fix(terminal): re-verify cached macOS login-preflight rejections - #9973

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/bug-macos-access-other-apps-data-prompt-keeps-re
Jul 24, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/bug-macos-access-other-apps-data-prompt-keeps-re

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Protocol-26 PTY hosts could cache one macOS login(1) PAM rejection for the lifetime of a daemon that survives app quits and updates. That silently disabled the TCC attribution wrapper for every later terminal and agent spawned by the daemon; children then collapsed into com.stablyai.orca, and AppData grants could fail to persist (#9756, cause 2).

The original pipe probe also had a fidelity gap: a tty-sensitive PAM stack can reject over pipes while the production login(1) launch succeeds under a real PTY. Retrying only the pipe probe would not recover a deterministic mismatch.

ELI5: Before and after

Think of the Orca background terminal host as a doorman checking whether macOS will let it label each command correctly.

Before

A check could incorrectly say “no” because it ran through a pipe instead of a real terminal. The doorman remembered that answer for as long as the background process lived—even through Orca quits and updates. New terminal tools could then be labeled as Orca, so clicking Allow might not stick and the same “access other apps’ data” prompt could return.

After

If the pipe says “no,” Orca double-checks using a real terminal—the same shape used to launch commands. A false “no” is corrected immediately; a real “no” is tried again later instead of remembered forever. Updating also moves fresh terminals to a new fixed background host.

What users should notice

After updating and opening a fresh terminal, repeated prompts caused by this stale check should stop. Existing old terminals can remain on the legacy host, and prompts caused by changing CLI identities or macOS session-only permissions are separate and may still appear.

Fix

  • Confirm a conclusive pipe rejection with the existing expect-owned real-PTY oracle. A conclusive PTY acceptance enables the attribution wrapper immediately; an inconclusive confirmation preserves the safe direct-shell fallback.
  • Expire cached rejected verdicts after 30 minutes so later fresh spawns can recover from policy/session changes. Accepted spawn verdicts stay cached unless the login-session health watch observes newer authoritative state.
  • Route every conclusive cache writer through one path. Periodic health probes no longer omit the rejection timestamp or extend the original rejection age forever.
  • Require PTY confirmation before a negative health probe can disable a previously accepted login session or contribute to daemon retirement.
  • Keep stable never-accepted hosts off the new PTY health-probe path, avoiding a new subprocess every watch interval.
  • Bump the local daemon generation from protocol 26 to 27. Existing protocol-26 sessions remain routed to their legacy daemon; fresh terminals use protocol 27 and load the fix.

Scope

This fixes the stale/low-fidelity preflight failure mode identified as cause 2 in #9756. It does not claim to eliminate prompts caused by changing CLI code identities, macOS session-scoped grants for platform binaries, or local build/signing identity churn. The PR intentionally uses Refs #9756, not Fixes #9756.

Reliability contract

  • Invariant (terminal.macos-login-attribution): a fresh local or remote-macOS PTY uses the login(1) attribution wrapper whenever the production-shaped PTY oracle accepts it; rejected or inconclusive hosts still reach a usable direct shell. Updating cannot leave fresh sessions on a protocol-26 daemon with the permanent cache.
  • Failure source: [Bug]: macOS 'access other apps' data' prompt keeps reappearing — possible from user running 'pn build' locally #9756 cause 2, plus the merged login-session death watch writing and periodically refreshing the same cache.
  • Oracle: deterministic provider tests prove pipe-reject/PTY-accept recovery, rejection expiry, all-writer timestamping, no timestamp extension, in-flight dedupe, and bounded stable-negative probe counts. Protocol tests prove v27 routing while retaining v26 discovery for live sessions.
  • Gate: focused provider/daemon/protocol suites and PR verification are the gate. There is no dedicated config/reliability-gates.jsonc entry yet; that remains an accepted manifest gap for this narrow macOS host behavior.
  • Provider/platform coverage: local and daemon PTYs are covered at their shared host implementation; SSH/remote macOS evaluates on the PTY host using host-local system paths and account data. Linux, Windows, WSL, relay, and mobile behavior is runtime-gated and unchanged.
  • Diagnostics: existing macos-login-preflight daemon records and login-session-watch breadcrumbs retain outcome/reason without logging PAM output.

Performance

  • The common accepted path remains one pipe probe per PTY-host process lifetime; measured at 87 ms on the review Mac.
  • Only a conclusive negative adds one real-PTY confirmation; the exact production-shaped probe measured 110 ms. Each child is independently bounded to 500 ms and 1 KiB of output.
  • Concurrent spawns share the full pipe-plus-PTY in-flight operation. Deterministic tests hold both subprocess counts at one.
  • A cached rejection re-probes only on a fresh spawn after 30 minutes. No timer or polling was added.
  • Never-accepted hosts retain the existing pipe-only health cadence and do not gain periodic PTY subprocesses. Previously accepted sessions use PTY confirmation only on negative/ambiguous events from the existing bounded health watch.
  • No renderer, persistence, session-listing, or SSH provider fanout work was added.

Tests

  • 60 focused macOS preflight, PTY-oracle, login-session-watch, and daemon-protocol tests passed.
  • Broader provider/daemon/IPC run: 803 passed. Two longstanding deleted-cwd tests exceeded their 30-second timeout under unsupported Node 26; both passed in isolation with a 60-second timeout (75.96 seconds combined).
  • pnpm run typecheck:node passed.
  • Touched-file oxfmt and oxlint passed.
  • Reliability-manifest validation and max-lines ratchet passed.
  • Live probes on the review Mac: pipe 87 ms; real PTY 110 ms; both emitted the required marker.
  • Fresh PR CI: Ubuntu native smoke, Windows native smoke, and Windows terminal-restart E2E passed. verify and packaged crash-survival both stopped at the same repository-wide TypeScript errors in untouched worktree-common-git-directory.ts and skill-installation-topology.ts; contemporaneous PRs fail at the identical lines.

No UI changes; screenshots are not applicable.

AI Review Report

The deeper review found and fixed three material issues:

  1. Periodically retrying the same pipe probe could never recover a deterministic pipe/PTY PAM mismatch, so the user-visible problem could remain unchanged. Negative spawn decisions now use the production-shaped PTY oracle.
  2. Current main added a login-session health watcher that wrote rejected cache state without this PR's timestamp, recreating a permanent rejection after merge. All conclusive writers now share the cache transition.
  3. Simply timestamping health-watch rejections would let two-minute probes refresh the timestamp forever, while PTY-confirming every never-accepted watch would add subprocess churn. The first rejection age is preserved, and never-accepted hosts remain pipe-only.

The final review covered startup warmup, local and daemon spawn boundaries, daemon upgrade routing, cache races/epochs, health-watch retirement authority, SSH/remote host locality, cancellation, subprocess/output bounds, and stable-negative cadence.

Security audit

The PTY confirmation reuses fixed absolute macOS system binaries, passes the OS-resolved username through an environment variable without shell interpolation, caps lifetime and output, closes stdin, and never logs captured PAM output. No credentials, dependencies, IPC schemas, persisted settings, or user-controlled commands are added. An unavailable or inconclusive oracle fails safe to the established direct-shell path.

Refs #9756

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The daemon protocol version is increased to 27, with version 26 added to the previous-version compatibility list and corresponding tests updated. The macOS TCC login-shell provider now caches accepted PAM verdicts for the process lifetime while expiring rejected verdicts after a configured interval. PTY confirmation, concurrent probe deduplication, session health checks, and revalidation behavior are covered by tests.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: re-verifying cached macOS login-preflight rejections.
Description check ✅ Passed The description covers all required template sections and the core testing, review, security, and notes details.
✨ Finishing Touches
📝 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.

A conclusive PAM rejection was cached for the process lifetime, so one false
verdict (the probe runs over pipes, not a PTY) disabled the login(1) TCC
attribution wrapper for a daemon that survives app quits and updates for
weeks — reintroducing the every-invocation AppData prompts #7003 fixed.
Rejections now re-verify after 30 minutes; accepted verdicts still cache
for the process lifetime.

Refs #9756
Protocol 26 shipped the process-lifetime PAM rejection cache. Preserve its live sessions as a legacy generation, but route fresh terminals through protocol 27 so updating actually loads the expiring-cache fix.

Refs #9756
@brennanb2025
brennanb2025 force-pushed the brennanb2025/bug-macos-access-other-apps-data-prompt-keeps-re branch from 38c6405 to e38fae9 Compare July 22, 2026 21:34
…s-access-other-apps-data-prompt-keeps-re

Both sides bumped the daemon protocol to 27 (main: completion-process
inspection #9263; this PR: preflight-cache replacement). Resolve by
moving this PR's replacement bump to 28 so main-built v27 daemons,
which lack the preflight fix, are also retired; completion inspection
stays gated at >=27 and v27 joins PREVIOUS_DAEMON_PROTOCOL_VERSIONS.
@brennanb2025
brennanb2025 merged commit e420209 into main Jul 24, 2026
8 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…blyai#9973)

* fix(terminal): re-verify cached macOS login-preflight rejections

A conclusive PAM rejection was cached for the process lifetime, so one false
verdict (the probe runs over pipes, not a PTY) disabled the login(1) TCC
attribution wrapper for a daemon that survives app quits and updates for
weeks — reintroducing the every-invocation AppData prompts stablyai#7003 fixed.
Rejections now re-verify after 30 minutes; accepted verdicts still cache
for the process lifetime.

Refs stablyai#9756

* fix(daemon): replace hosts with stale login preflight cache

Protocol 26 shipped the process-lifetime PAM rejection cache. Preserve its live sessions as a legacy generation, but route fresh terminals through protocol 27 so updating actually loads the expiring-cache fix.

Refs stablyai#9756

* fix(terminal): validate rejected login probes under a PTY
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