Skip to content

Read Copilot and Antigravity credentials in-process, never through /usr/bin/security - #87

Merged
mstallone merged 42 commits into
credential-ownership-modelfrom
foreign-reads-in-process
Aug 4, 2026
Merged

mstallone merged 42 commits into
credential-ownership-modelfrom
foreign-reads-in-process

Conversation

@mstallone

@mstallone mstallone commented Aug 3, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #86 (credential-ownership-model) → #85 → #84. Closes the gap a post-stack review found: the exact /usr/bin/security find-generic-password pattern behind the 2026-08-03 prompt loop was still live for Copilot (and Antigravity), including at launch.

TL;DR: The read-only providers' Keychain reads (Copilot's gh:github.com, Antigravity's gemini/antigravity) now run in-process through the coordinator: automatic refreshes are prompt-free by construction, and only a manual refresh may raise the approval dialog — once, authorizing Runway itself.

What was happening

  • CopilotAuthStore and AntigravityAuthStore read their foreign Keychain items through the /usr/bin/security subprocess — the prompt-capable path whose dialogs authorize the helper binary instead of Runway, so approvals never stick to the app and the prompt can recur every cycle. Launch-time credential detection used the same path.
  • The PR Coordinate Keychain secret reads: change-gated, single-flight, circuit-broken #85 coordinator only covered in-process reads, so these subprocess reads bypassed the fingerprint gate, single-flight, and circuit breaker entirely.

What this changes

  • KeychainReading gains account-scoped readGenericPasswordWithoutUserInteraction(service:account:) and readGenericPasswordAllowingUserInteraction(service:account:); SecurityKeychainAccessor serves both through the existing coordinated in-process path (change-gated, single-flight, circuit-broken). Mock defaults route them through the plain account read, so existing test fakes are untouched.
  • Copilot: loadToken / loadBillingTokenCandidates take allowKeychainInteraction (default false). Automatic refresh and hasLocalCredentials use the prompt-free form; a manual refresh uses the interactive form. A denied interactive read is not retried through the broader service-only lookup — that would just repeat the same prompt.
  • Antigravity: loadKeychainToken gets the same mode split; an unauthorized item on the automatic path surfaces the existing friendly "couldn't read credentials" error locally instead of prompting.
  • Docs: prompt behavior notes in docs/providers/copilot.md and docs/providers/antigravity.md.

Heads-up

  • One-time migration friction: users whose previous "Always Allow" was granted to /usr/bin/security will see the Copilot/Antigravity Keychain source report unavailable until one manual refresh re-approves access for Runway itself. After that, reads are silent and survive forever (the grant now sticks to the app). File-based sources (editor config, hosts.yml) are unaffected and remain first in line.
  • Also in this push (amendments from the same review, committed to their own PRs): the fingerprint probe now runs inside the coordinator's single flight (Coordinate Keychain secret reads: change-gated, single-flight, circuit-broken #85 — a late arriver no longer touches the Keychain at all, not even the attributes query), and the iCloud device-id migration seeds from the saved UserDefaults copy so the legacy prompt-capable read runs only after a preferences reset, at most once (Enforce credential ownership at the type level; move Runway-owned secrets in-process #86).
  • After this PR, the only remaining /usr/bin/security reads (and writes) belong to Codex and Cursor — the disclosed read-write ownership audit that follows this stack.

Tests


Review follow-ups (later commits on this branch)

  • Copilot billing keeps the permission state. loadBillingTokenCandidates discarded keychainPermissionRequired, so an org-managed seat fell back to an editor token that usually lacks billing scopes and the card said "you need billing access" when an existing credential just needed approval.
  • Antigravity gained a permission-specific error. A protected item mapped to credentialStoreUnreadable, whose text says unlock Keychain / sign in again — neither fixes an unapproved ACL.
  • Corrected the CLI documentation twice. --force is not equivalent to ⌘R (it never prompts), and — the part I got wrong on the first pass — approving an item in the app does not authorize the command, because runway is a separately signed binary and macOS grants Keychain access per binary. Keychain-only providers reach the CLI through the app's shared snapshot instead.

Correction

An earlier revision of this description said Codex/Cursor writes were the only remaining /usr/bin/security use. That omitted the one-shot, existence-gated legacy iCloud device-id migration read, which remains after the whole stack. Also in later commits on this branch: Copilot billing keeps its permission state, Antigravity distinguishes a locked keychain from an unapproved ACL (they need opposite advice), and ProviderRefreshContext carries isForced separately from isManual so runway --force keeps bypassing negative caches without unlocking credential UI.

…sr/bin/security

The 2026-08-03 incident's prompt loop was fed by /usr/bin/security
subprocess reads, whose approval dialogs authorize the helper binary
instead of Runway and can repeat forever. Copilot (gh:github.com) and
Antigravity (gemini/antigravity) — the read-only providers — now use
the in-process, coordinator-backed reads:

- Automatic refreshes and launch detection use the prompt-free form:
  an unauthorized item reports unavailable locally instead of raising
  a dialog.
- Only a manual refresh may prompt, once, for Runway itself; a denial
  is not retried through a broader lookup.
- KeychainReading gains account-scoped non-interactive/interactive
  requirements; mock defaults route them through the plain account
  read so test fakes are unaffected.

The subprocess read path now remains only for Codex and Cursor, whose
read-write ownership audit is the planned follow-up.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8c8eda5df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ng prompt-free

Review findings on the in-process conversion:
- A gh token stored only in the Keychain and not yet approved for
  Runway read as .unavailable and collapsed into 'not logged in':
  launch detection missed the footprint (so seeding disabled the card)
  and enabled cards showed the wrong message. loadCredentials now
  reports keychainPermissionRequired when the item exists (attributes
  probe) but can't be read prompt-free, detection counts it, and the
  card tells the user to refresh manually and choose Always Allow.
- On a manual refresh of a keychain-only org-managed account, the
  billing candidate lookup performed a second interactive read of the
  same item — a second dialog when the user chose one-time Allow.
  Billing lookups are now always prompt-free; the coordinator's cache
  serves the just-approved value.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e64bebafdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…anual refresh approve the billing credential

Review findings:
- 'force' conflated cache-bypass with user presence: the CLI's one-shot
  reader, the Codex post-claim retry loop, and the profiler all force
  past caches with nobody attending, yet mapped to isManual and could
  raise interactive Keychain reads — from the CLI helper, whose Always
  Allow would authorize the wrong binary. WidgetDataStore now takes a
  separate 'interactive' flag set only by the GUI refresh actions;
  ProviderRefreshContext.isManual derives from it. This also fixes the
  pre-existing Claude/Sakana exposure to the same conflation.
- With an editor usage token and the gh billing token in a protected
  Keychain item, billing was permanently unapprovable (always
  prompt-free, permission state discarded). A manual refresh may now
  fall through to one interactive billing read after the prompt-free
  attempt; automatic refreshes stay silent.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 258100f87b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Review finding: eager array construction evaluated the service-only
read alongside the account-scoped one, so a successful scoped read
still read (and cached) an arbitrary gh:github.com secret and could
wait on a wedged broad query. The lookups are closures now, evaluated
in order only as needed.
…unt's token

Review finding: with several gh:github.com items, an .unavailable
account-scoped read fell through to the account-less lookup, which
could silently return a different account's authorized token and show
the wrong account's usage. A protected scoped item now reports
permission-required directly; the broad lookup runs only when the
scoped item provably does not exist (or no account is known).
…ocument CLI approval limits

Cloud-review findings:
- The service-level fallback still used == true, so a failed probe (a
  locked keychain, suppressed UI, or a stuck flight) collapsed a real
  login into 'not logged in' — disabling Copilot at first-run detection
  and showing a misleading sign-in error. Now != false, matching the
  account-scoped path and Codex/Cursor.
- docs/cli.md and docs/refreshing.md called --force the CLI equivalent
  of ⌘R, but it is deliberately non-interactive and can never approve
  Keychain access, so a user could repeat the documented recovery
  forever. Both now state that approval requires one refresh in the app.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cec8164a5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec260b90f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/cli.md Resolved
…orrect the CLI approval claim

Review findings:
- loadBillingTokenCandidates discarded keychainPermissionRequired, so an
  org-managed seat fell back to an editor token that usually lacks
  billing scopes and the card said 'you need billing access' when an
  existing credential just needed approval. It returns the flag now and
  the provider surfaces it instead of the managed badge.
- Antigravity mapped a protected item to credentialStoreUnreadable,
  whose text says unlock Keychain / sign in again — neither fixes an
  unapproved ACL. Added keychainPermissionRequired with the in-app
  refresh + Always Allow instruction, plus a troubleshooting entry.
- My previous cli.md fix replaced one wrong claim with another: the CLI
  is a separately signed binary, so macOS does not extend the app's
  Keychain approval to it. Both cli.md and refreshing.md now say that
  keychain-only providers reach the command through the app's shared
  snapshot instead.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26dfbdc055

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Review finding: collapsing isManual onto 'interactive' also removed the
forced-refresh signal from non-UI behavior. Antigravity keys its
15-minute no-process cooldown off that context, so 'runway antigravity
--force' stopped rescanning for a language server it had previously
missed — a regression I introduced. The context now carries both:
isForced (⌘R, --force, automated retries: bypass caches and negative
caches) and isManual (a user-attended app refresh: the only context
that may raise a Keychain prompt).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 274165983a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…rove when it's an ACL

Review finding (correctness, not polish): both failures arrived as
.unavailable and got the 'choose Always Allow' instruction, which does
nothing for a locked keychain. The prompt-free attributes probe already
tells them apart — a confirmed item means the ACL hasn't approved
Runway; an inconclusive probe means the keychain couldn't be read — so
each now gets the advice that actually resolves it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 092ec4b52b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mstallone mstallone closed this Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d60dc9953

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a20c21a70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Same gap in Antigravity and Copilot: the automatic branches consult the
read's recorded status, but the interactive catches hardcoded one
outcome. A user who cancelled the approval dialog was told to unlock
their keychain (Antigravity), and a locked keychain during a manual
refresh was reported as needing Always Allow (Copilot). Both now read
the same verdict the automatic branches use.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7228d56ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89e85227da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Categories are recorded by the read itself, without the sequence check
that guards the cache, so an older read finishing after a newer recovery
could leave one behind — and a later locally answered .unavailable would
then quote a verdict that no longer described the item.

The category now only answers while the item's stored outcome is still a
failure, which is the only state it was ever meant to describe.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 998f8fcbd1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

UI-gate contention deliberately records no failure category, and the
probe behind that same gate answers nil too — so "no verdict" meant
"ACL denial" in three places, telling the user to choose Always Allow
for an item that may already be authorized.

An indeterminate outcome now reports unreadable; only a recorded denial
or a confirmed-present item asks for approval, and only a confirmed
absence reports no credential. A manual refresh also retries the
unreadable case interactively, so unlocking the keychain recovers
immediately instead of waiting out the 15-minute breaker.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eadfb39fc5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8209f8fbdf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@mstallone
mstallone merged commit 9b0e043 into main Aug 4, 2026
2 checks passed
mstallone added a commit that referenced this pull request Aug 4, 2026
…t-broken (#85)

> Stacked on #84 (`claude-credentials-read-only`).

**TL;DR**: Every *in-process* read of another app's Keychain item now
goes through a small coordinator that only touches the secret when the
item actually changed, shares one read between concurrent callers, and
stops retrying an item after a denial until it changes or the user acts.
(Runway's own item stays outside it — its ACL names Runway, so it never
prompts or contends.)

## What was happening

- Every 5-minute refresh (plus the default-account observer) performed a
full ACL-checked secret read of Claude's Keychain item, even though the
item rarely changes.
- During the 2026-08-03 incident, securityd was wedged behind approval
dialogs; Runway's repeated reads stacked onto it, its own refreshes
blocked for 150 s, and there was no backoff — the next cycle piled on
again.
- Two Claude cards (default + extra account) could read concurrently
with no coalescing.

## What this changes

- New `KeychainReadCoordinator` (process-wide, injected into
`SecurityKeychainAccessor`):
- **Change-gated reads** — an attributes-only fingerprint probe
(prompt-free, no ACL evaluation, microseconds) runs first; the secret is
re-read only when the fingerprint moved (e.g. Claude Code rotated its
token). One real read per rotation instead of one per cycle.
- **Single-flight** — concurrent readers of the same service/account
share one underlying read. A background caller waits at most 2 s on
someone else's stuck read, then reports `.unavailable` instead of adding
another blocked call to a wedged securityd.
- **Circuit breaker** — after a denied/failed read (background or an
explicitly denied manual prompt), background reads of that item are
answered locally with no Keychain traffic until the item's fingerprint
changes or a manual-refresh read succeeds.
- Interactive (manual-refresh) reads always go through to securityd —
they are the one place a prompt is legitimate — and seed the cache /
clear the breaker on success.
- Docs: keychain paragraph in `docs/providers/claude.md`.

## Heads-up

- Cached secrets live in process memory only — the same lifetime as the
credential states providers already hold between refreshes.
- A `nil` fingerprint (item absent, or probe failed on a locked
keychain) is never cached: it cannot distinguish those two cases, so
such reads always go through.
- The subprocess (`/usr/bin/security`) read path used by other providers
is not coordinated here; it is in scope for the ownership follow-up (PR
3).

## Tests

- Unit tests for the coordinator: cache hit on unchanged fingerprint,
re-read on change, no caching without a fingerprint, breaker trip/reset,
interactive success clearing the breaker, interactive denial tripping
it, and a threaded single-flight/pile-up test.
- A live login-keychain integration test: `SecItemUpdate` on a real item
moves the fingerprint and the next read returns the fresh secret (skips
where the keychain is unavailable).
- `swift test`: 1,667 tests, 0 failures.

---

## Review follow-ups (later commits on this branch)

- **The global UI gate is bounded in both directions.**
`withUISuppressed` waited on an open approval dialog with no deadline,
so an abandoned prompt could strand every concurrent refresh — the
contention this gate exists to prevent. Past the deadline the body runs
with `isSuppressed: false`, which by contract yields a local unavailable
without touching Security.framework.
- **Recovery probes hit the exact item.** Claude's probe was keyed
`(service, nil)` while its read is keyed `(service, currentUser)`, so it
neither waited on that flight nor saw its breaker. Added
`genericPasswordForCurrentUserExists`.
- **Claude Desktop and Sakana Safe Storage reads joined the
coordinator** via a new `externalRead` entry point (they decode their
own payloads, so they don't speak `NonInteractiveKeychainRead`). Denials
throw from inside the flight so the breaker records them.
- **The breaker covers metadata probes**, and a caller that times out
behind a stuck flight serves a freshly recovered value rather than
reporting unavailable.

### Scope note

At this branch, subprocess (`/usr/bin/security`) readers still exist for
the providers converted later in the stack — the coordinator covers the
in-process path here, and #87/#89/#90 move the remaining providers onto
it. Runway's own item (`RunwayOwnedKeychainStore`) stays outside by
design: its ACL names Runway, so it never prompts or contends.

### Later review follow-ups on this branch

- The suppressed side of the UI gate is bounded, so an abandoned
approval dialog can't strand concurrent refreshes.
- Recovery probes use the exact `(service, currentUser)` item, and a
protected item ends the lookup instead of broadening to a service-wide
read that could select another account's login.
- Claude Desktop and Sakana Safe Storage reads run inside the
coordinator (`externalRead`) with an epoch guard; every failing Security
status trips the breaker.
mstallone added a commit that referenced this pull request Aug 4, 2026
> Stacked on #87 (`foreign-reads-in-process`), the tail of the
credential stack.

**TL;DR**: `swift test` no longer plays the system alert sound (Tink, or
whatever the Mac's alert sound is) — the share-card failure beep is now
injectable, and the test suite swaps it for a counter.

## What was happening

- `ShareCardRenderer`'s failure paths call `NSSound.beep()` so a failed
clipboard export is never silent.
`testCopyToPasteboardReturnsFalseForUnencodableImage` deliberately
exercises that path, so every automated test run played the system alert
sound (`/System/Library/Sounds/Tink.aiff` on this machine).

## What this changes

- The audible cue becomes `ShareCardRenderer.playAlertSound`, defaulting
to `NSSound.beep()` — production behavior unchanged.
- `ShareCardRendererTests` swaps it for a counter in `setUp` (restored
in `tearDown`), so the suite runs silently — and the failure test now
also asserts the cue fires exactly once, which the old direct call
couldn't verify.

## Tests

- `swift test`: 1,689 tests, 0 failures — and no beep.
mstallone added a commit that referenced this pull request Aug 4, 2026
…security (#89)

> Stacked on #88, the tail of the credential stack. Closes the "High"
finding from the latest post-stack review: Codex and Cursor could still
recreate the automatic password-prompt loop.

**TL;DR**: The last automatic prompt-capable `/usr/bin/security` reads —
Codex's keyring lookups (detection, refresh fallback, unattended
identity warming) and Cursor's two per-load reads — now run in-process
through the coordinator, prompt-free on every automatic path.

## What was happening

- `CodexAuthStore.loadKeychainAuth` and `CursorAuthStore`'s keychain
reads used the `/usr/bin/security` subprocess: prompt-capable, ACL'd to
the helper binary, uncoordinated, and running on launch detection, every
automatic refresh, and Codex's background identity-warm task.
- A protected item silently collapsed into "not logged in", so
keychain-only logins were undetectable and unapprovable.

## What this changes

- Codex `loadKeychainCredentials` / Cursor `loadCredentials` (tri-state
like Copilot's): automatic paths use the prompt-free in-process reads;
only a manual refresh may raise the approval prompt — once, authorizing
Runway itself.
- A protected item reports **permission-required**: it counts as a
credential footprint for seeding, and the card says "…login found in
Keychain. Refresh manually and choose Always Allow to connect it."
- Cross-login guard mirrors the Copilot fix: a protected exact item
(per-home Codex account item) never broadens to the service-only lookup,
which could silently select a different login. Other Codex homes are
still tried — each read targets its own exact account.
- The unattended identity-warm task keeps its collapse-to-nil behavior
(a protected home stays hidden with the existing log line) and is
prompt-free by construction.
- Docs: prompt behavior notes in `docs/providers/codex.md` /
`cursor.md`; `docs/architecture.md` now states every provider's
automatic Keychain reads are in-process and prompt-free.

## Also in this stack push (fixes from the same review, committed to
their PRs)

- **#85**: public existence/fingerprint probes now share the
coordinator's per-item flight — a probe of an item whose read is wedged
returns "unknown" within the bounded wait instead of stacking another
`SecItemCopyMatching` onto securityd.
- **#86**: the legacy device-id migration is gated on a prompt-free
existence probe, so a fresh install never spawns the `/usr/bin/security`
subprocess at all.

## Heads-up

- Same one-time migration friction as #87: an "Always Allow" previously
granted to `/usr/bin/security` doesn't carry over; the card shows the
permission-required message until one manual refresh re-approves for
Runway. The grant then sticks to the app permanently.
- After this PR the only `/usr/bin/security` invocations left are
Codex/Cursor **token-rotation writes** and the one-shot legacy device-id
migration (now existence-gated). The write side is the remaining
ownership audit — it decides whether Codex/Cursor become read-only like
Claude, which changes rotation behavior and deserves its own design
pass.

## Tests

- Codex + Cursor read-mode regression tests (shared
`ReadModeTrackingKeychain`): automatic loads perform only prompt-free
reads, manual loads only interactive ones, never the subprocess-style
path; protected items report permission-required and never broaden; a
coordinator test proves probes don't stack behind a wedged read; an
iCloud test proves fresh installs never spawn the legacy read.
- `swift test`: 1,698 tests, 0 failures.

---

## Review follow-ups (later commits on this branch)

- **Reset-credit claims can request approval.** `CodexResetClaimService`
loaded keyring credentials non-interactively and collapsed
permission-required to `nil`, so clicking **Use** reported a generic
"Couldn't reset usage" while the credential that could serve it sat
unread. Claiming is an explicit user action, so it may prompt exactly
like a manual refresh.
- **A denied Codex prompt stops the scan** on this branch too (it was
previously only fixed downstream), so this PR is correct standing alone:
an interactive denial returns `permissionRequired` immediately instead
of opening one dialog per remaining Codex home.
@mstallone
mstallone deleted the foreign-reads-in-process branch August 4, 2026 17:18
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