Skip to content

Make Codex and Cursor credentials strictly read-only; delete the Keychain write path - #90

Merged
mstallone merged 48 commits into
codex-cursor-reads-in-processfrom
codex-cursor-read-only
Aug 4, 2026
Merged

mstallone merged 48 commits into
codex-cursor-reads-in-processfrom
codex-cursor-read-only

Conversation

@mstallone

@mstallone mstallone commented Aug 3, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #89, the tail of the credential stack. Completes the write-side ownership audit the post-stack reviews kept flagging — the last automatic prompt-capable paths (token-rotation writes through /usr/bin/security) are gone.

TL;DR: Codex and Cursor join Claude as strictly read-only credential consumers. With no writers left, the Keychain write protocol, the accessor's write methods, and the security add-generic-password subprocess (secrets in argv) are deleted outright — the only Keychain write API remaining in the app is RunwayOwnedKeychainStore.

What was happening

What this changes

  • Codex: never calls auth.openai.com/oauth/token, never writes auth.json or the keyring. The pre-fetch reload that adopts the codex CLI's own rotation stays (it is read-only and the reason meters keep working while the CLI is in use). A hard-expired token or a usage 401/403 shows "Codex login needs renewal. Run codex, then refresh Runway." — with source fallback preserved and local spend tiles unaffected. The refresh-era error cases (sessionExpired/tokenConflict/tokenRevoked/tokenExpired) collapse into one loginRenewalRequired.
  • Cursor: never calls the token endpoint, never writes the state database or keychain. Renewal notice: "Cursor login needs renewal. Open the Cursor app (or run agent login), then refresh Runway." — naming both remedies, since the keychain-source credential belongs to the agent CLI. SQLiteAccessing.execute (only used to write Cursor's DB) is deleted.
  • Write path deleted: KeychainAccessing collapses into KeychainReading everywhere; SecurityKeychainAccessor loses its write methods and the writePassword subprocess helper. The one remaining /usr/bin/security invocation in the app is the one-shot, existence-gated legacy device-id migration read.
  • Prompt bounds (from the review): a denied Codex prompt stops the per-home scan (never one dialog per home); a denied Cursor access-item prompt never chains into the refresh-item prompt; Cursor's unknown existence probe (nil = locked keychain) no longer collapses into "not logged in", matching Codex.
  • Docs: architecture.md's ownership section is now unconditional (resolving the contradiction the review flagged), privacy.md, codex.md, cursor.md rewritten to the read-only reality, with renewal troubleshooting entries.

Heads-up

  • Live Codex/Cursor meters now pause when the owning app hasn't run recently enough to hold a fresh token, showing the renewal notice — the same deliberate trade Claude made in Make Claude credentials strictly read-only (no refresh, no writeback) #84. While the CLI/app is in active use it rotates its own token and Runway picks it up on the next read (Codex explicitly re-reads the live store before each fetch).
  • Kimi and Grok still refresh their own providers' tokens, but through file stores only — no Keychain, no prompts, outside this incident class. Their ownership audit can follow the same recipe later.
  • Codex now degrades exactly like Claude — local spend tiles under a header warning — for both a lapsed login and a pending keyring approval. (An earlier revision listed this as future cosmetic follow-up; it is implemented.)

Tests

  • Read-only regressions mirroring Make Claude credentials strictly read-only (no refresh, no writeback) #84: an expired Codex/Cursor token performs zero token-endpoint calls and zero store writes and shows the renewal notice; a usage 401 does one call (no refresh-and-retry).
  • Prompt bounds: denied Codex prompt → exactly one interactive read across homes; denied Cursor access prompt → exactly one interactive read total.
  • Refresh-era tests (rotation persistence, refresh-endpoint parsing) removed with the machinery.
  • swift test: 1,706 tests, 0 failures.

Review follow-ups (later commits on this branch)

  • A rejected token now tries this account's other local credential once. Cursor's app and its agent CLI keep separate copies, and one can outlive the other. Previously only an expired selection fell back, so a revoked-but-unexpired token 401'd straight into the renewal notice while a live same-account token sat unread. The retry makes no OAuth call, writes nothing, and requires matching JWT subjects so it can never cross accounts.
  • An expired paid SQLite login can reach its protected keychain token. keychainCanWin suppressed prompts for every paid SQLite login, so even a manual refresh returned the dead credential with advice Runway could not act on.
  • Scoped the no-write claims honestly. privacy.md/architecture.md said Runway never writes another tool's credential files, but Grok and Kimi are refreshed and saved back to their CLIs' own files. The guarantee is now scoped to the Keychain (which the type system enforces), with Grok/Kimi and Antigravity's Google OAuth refresh named as the exceptions.

Later review follow-ups on this branch

  • A rejected token retries this account's other local credential once (no OAuth call, subject must match), and reports the alternative's own failure rather than a bogus renewal notice.
  • A protected alternative asks for approval instead of collapsing to "no alternative".
  • A live SQLite login beats an expired agent login; an expired paid login can still reach its protected keychain token.
  • The Cursor credential tests moved to CursorCredentialTests.swift to stay within the repository's ~500-line guideline.

…hain write path entirely

Completes the write-side ownership audit for the two remaining rotating
providers, closing the last automatic prompt-capable paths:

- Codex: no /oauth/token calls, no auth.json or keyring writes. The
  pre-fetch reload still adopts the codex CLI's own rotation; a lapsed
  token shows 'Codex login needs renewal'. OpenAI's reuse detection
  (refresh_token_reused, issue robinebers#516) is the same failure class the
  Claude read-only change closed.
- Cursor: no token refresh, no state-database or keychain writes; a
  lapsed token shows 'Cursor login needs renewal'.
- With no writers left, the KeychainAccessing refinement, the accessor
  write methods, the /usr/bin/security write helper (secrets in argv),
  and SQLiteAccessing.execute are deleted outright — every credential
  store now holds the read-only KeychainReading type, and the only
  Keychain write API in the app is RunwayOwnedKeychainStore.
- Prompt bounds (review findings): a denied Codex prompt stops the
  per-home scan; a denied Cursor access prompt never chains into the
  refresh-item prompt; Cursor's unknown existence probe no longer
  reads as logged-out.
- Docs rewritten to the now-unconditional ownership rule (the
  architecture/privacy contradiction the review flagged).

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

ℹ️ 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".

…nestly

Review findings:
- The keychain-source Cursor login belongs to the agent CLI, so
  'open the Cursor app' alone was wrong guidance — the notice now
  names both remedies.
- privacy.md and architecture.md over-claimed: Grok and Kimi still
  refresh their own file-based logins. The read-only guarantee is now
  scoped to the migrated providers, with Grok/Kimi named as the
  remaining (Keychain-free) follow-up.
…stigial refresh items

Review findings:
- A Codex renewal failure exited probe before the local log scans, so
  users with valid local sessions saw only an error card — contradicting
  the docs. Exhaustion with loginRenewalRequired now serves the local
  spend tiles under the renewal warning, exactly like Claude.
- With no refresh capability, Cursor's refresh-token entries (SQLite
  row and keychain item) had no consumer but still drove source
  selection and permission checks — a protected refresh item could
  block a readable access token, and a refresh-only SQLite row could
  outrank a usable keychain login. Only the access token is read now;
  the refresh-token service and key constants are gone.

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

ℹ️ 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/architecture.md Resolved
…dpoint claim

Review findings:
- The keychain branch returned a hard error on loginRenewalRequired,
  so keyring users missed the local-tiles degradation file users got.
  Both sources now degrade identically.
- Antigravity does call Google's OAuth token endpoint (safe: Google
  refresh tokens do not rotate; the result lands in Runway's own cache
  file, never Antigravity's Keychain item). architecture.md and
  privacy.md now say exactly that instead of over-claiming.

@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: 1deae2235a

ℹ️ 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".

Cloud-review finding: with a free SQLite login and an agent Keychain
login under the same JWT subject, source selection always chose SQLite.
Read-only removed the refresh-and-retry that used to rescue that case,
so an expired SQLite token now reported renewal while a working token
for the same account sat unread. Both subjects must be known and equal
for the fallback, so it can never cross accounts.

@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: 57ac97cfcc

ℹ️ 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/privacy.md Resolved
…en; scope the no-write claim

Cloud-review findings:
- keychainCanWin was false for every paid SQLite login, so when that
  token expired the same-account fallback could never see a protected
  keychain token — even a manual refresh read non-interactively and
  returned the dead credential with advice Runway could not act on. An
  expired SQLite login now allows the interactive read, and a protected
  item in that state reports the approval need. The subject check still
  guards against crossing accounts.
- privacy.md and architecture.md claimed Runway never writes another
  tool's credential files, while Grok and Kimi are refreshed and saved
  back to their CLIs' own files. Both now scope the guarantee to the
  Keychain (enforced by the type system) and name the file-side
  exception.

@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: 301b27e5dc

ℹ️ 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: the same-account fallback only ran when the selected
token's own exp had lapsed, so a revoked-but-unexpired SQLite token
(signed out elsewhere) 401'd straight into the renewal notice while the
agent CLI's live keychain copy for the same account sat unread. refresh()
now tries that alternative once — no OAuth endpoint, no writes, and the
subject must match so it can never cross accounts.

@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: 4c08590ea7

ℹ️ 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: any failure from the same-account alternative — a
transport error, a 5xx, a malformed body — was swallowed and reported as
the original renewal notice, telling the user to sign in again over a
connectivity blip. Only a second auth rejection means renewal now;
everything else surfaces its own error.

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

ℹ️ 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".

…approval is pending

Review findings:
- The free-membership rule preferred the agent keychain login even when
  its token had expired. Read-only means that trades live data for a
  renewal notice, so the live SQLite token now wins in that case; the
  agent login still wins whenever it can serve a request.
- A pending Codex keyring approval returned a hard error card, dropping
  the local spend tiles that the renewal path deliberately keeps. It
  degrades the same way now: tiles plus a header warning.

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

ℹ️ 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".

My credential regressions doubled CursorProviderTests (316 → 742),
pushing a compliant file well past the repository's ~500-line guideline.
Same treatment as the iCloud identity tests: credential selection,
read-mode, prompt-bound, and fallback suites move to
CursorCredentialTests.swift (284 + 489 lines). Same 1693 tests.

@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: 55bc5adacc

ℹ️ 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: sameAccountAlternative collapsed a protected keychain
item to 'no alternative', so a rejected-but-unexpired SQLite token
produced a renewal notice while the live credential sat behind an
unapproved ACL. It returns the permission state now, and the card says
to approve rather than to sign in again.

@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: 22166cf7e0

ℹ️ 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".

The retry's general catch returned the alternative's error to the card
without writing anything to the log, so a transport error or malformed
response left only the preceding "retrying" line and no explanation.
Once every provider moved in-process, nothing in the app called the
subprocess readers any more — but they were still there, still
prompt-capable, and a future caller could have reintroduced the exact
loop this stack exists to remove. A subprocess approval names the helper
binary rather than Runway, so it can never become a durable Always Allow.

The plain throwing reads stay as protocol requirements (mocks implement
them and the defaults forward through them), but the accessor now serves
them with prompt-free in-process reads. ProcessRunning is gone from the
accessor, and the app no longer references /usr/bin/security anywhere.
A usable paid SQLite login is returned unconditionally, so reading the
agent keychain item there bought nothing — and it is a synchronous
securityd round trip, so a wedged securityd could strand a refresh that
already had a good credential in hand. First-run detection takes the
same path with no enclosing deadline at all.

Also log the primary rejection before the fallback runs, not only in the
branches that fail, so the log always records why a fallback happened.
…em verdict

An indeterminate probe with no recorded category means the item was
never examined, so Cursor reports it unreadable rather than asking for
an approval that may already be granted — the same rule Copilot,
Codex, and Antigravity now follow.
@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.

The manual branch used ,
so a nil verdict — which is exactly what UI-gate contention leaves —
became a denial and asked the user to approve an item nothing examined.
The automatic branches already switched on all three states; this one now
matches. The denied-prompt fake records the verdict a real denial
produces, so it models the case it claims to.
@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.

The merge left promptFreeValue calling performNonInteractiveRead
directly, which no longer compiles now that a read is handed a ticket —
and going straight at Security skipped the single-flight, change-gating,
and breaker every other read gets. It uses the coordinated entry point.
@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 50c74d8 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
mstallone deleted the codex-cursor-read-only branch August 4, 2026 17:18
mstallone added a commit that referenced this pull request Oct 6, 2026
**TL;DR**

First batch from a production cleanup audit (the code-side follow-up to
the test-value audit): deletes declarations nothing calls and parameters
every caller passes the same way. No behavior changes.

**What was happening**

- Leftovers of the switch to read-only credentials (#90):
`CursorUsageError.usageAfterRefreshFailed` and
`CodexAuthError.invalidAuthPayload` were thrown by nothing,
`ProviderAuthRetry.fetch` kept a `retriedConnectionFailed` parameter no
caller passed, and both `CursorProvider` and `CodexProvider` copied the
access token into a `currentToken` alias "in case it rotated", which a
single request with no refresh cannot do.
- Parameters with one value: `SQLiteCLIAccessor.run(readOnly:)` (all
three callers pass `true`), `resolveDeviceID(allowLegacyInteraction:)`
(never passed), `fetchViewerEnterprises(after:)` (always `nil`),
`KimiAuthStore.credentialPath` defaults (the one caller passes both),
and `ModelPricingStore.loadCatalog(parse:)` (always the same codec).
- `ModelPricingStore.defaultSourceURLs` was a dictionary over a
three-case enum behind a `guard ... else { return false }` that could
not fail and logged nothing.
- `OpenCodeUsageScan` wrapped a single `LogUsageScan` field since #106
removed its second one.
- `CodexMemoryRow` carried four metadata fields that were selected and
decoded but never read, and the list query fetched `last_usage` for
nothing.
- Dead outright: `CodexUsagePricing.priorityMultiplier(for:rates:)`,
`MuseUsageClient.usageURL`, `HeaderView.toggle`'s toggle-back branch
(the header only mounts on the dashboard), the unreachable `"Refresh
failed"` fallback in `WidgetDataStore`, a redundant nil check in
`DevinProvider`, an unused `import Security`.
- Test-only: `UsageHistoryAggregator.merged(peerDocuments:)` and
`ProviderMetrics.init(provider:metrics:)` had no production caller.

**What this changes**

- Deletes the dead cases, functions, fields, aliases and parameters
above.
- `SourceID` gains a `url` property (a switch), replacing the dictionary
and its guard.
- `OpenCodeUsageScanner.scan` returns `LogUsageScan?` directly.
- `CodexMemoryDatabase.loadRow` selects only the three columns it
returns; the list query drops `last_usage`.
- The enterprise-slug GraphQL query drops the cursor variable and the
`pageInfo` selection it never read.
- `merged(peerDocuments:)` moves to `TestOnlyConveniences.swift`;
`ProviderAccountAssembly.assemble` becomes private.

**Heads-up**

- Deliberately left: the unreachable defaults at the end of the Claude,
Codex and Grok candidate loops (their invariant lives in another file,
and removing them would need a force-unwrap or would mislabel a future
empty list), `CodexTokens.refreshToken` (never read, but dropping it
changes synthesized equality on a credential type),
`PricingCatalog.retrievedAt` (round-trips into the cache file), and
`ProviderAccountRecord.removedTombstone` and the extra
`PiProviderMapping` entries (both documented as planned work).
- The enterprise-slug query still reads one page of 100, as before.

**Tests**

`swift test`: 1,967 tests, 0 failures locally on macOS 27.
mstallone added a commit that referenced this pull request Oct 6, 2026
**TL;DR**

Second batch from the production cleanup audit: rewrites comments and
one doc page that describe code that no longer exists or no longer works
that way. No code changes.

**What was happening**

- Claude and Codex comments still described the era before read-only
credentials (#84, #90) and guarded renewal (#99): "Runway never
refreshes a Claude token", "so Runway rotates on the same schedule", "a
successful usage fetch (which rotates tokens back to disk)". Two
functions in `CodexAuthStore` carried two doc comments fused together,
the first describing removed behavior.
- `DashboardView` comments said steady state keeps one live screen tree
and that the outgoing page unmounts when the push completes. Since #67
the page stays parked until the popover closes. Others referred to a
"scroll spacer" and an `outgoing` identifier that do not exist.
- `WidgetRowView` described a per-row timeline gate that #60 replaced
with the shared clock, 22 lines below a doc comment saying it is
deliberately not that.
- `MemoryEditorState.saveDirtyDocument` was documented as overwriting a
moved file; it keeps the conflict check.
- Comments named things that are gone or renamed: `EscapeToCloseReader`,
`discover`, `compactValue`, `formatTokens`, `enterpriseUnverified`, a
`Logger` in `LocalUsageServer`, the `MenuBarExtra` label, "Phase 1" of
account discovery, a pinned count on `ProviderRow`.
- `ProviderAuthRetry` was described as shared by every OAuth-style
provider; only Grok calls `fetch`.
- `docs/providers/openrouter.md` said `/credits` is required for a
usable snapshot. The provider renders whatever either endpoint returned
and reports an invalid key only when both return 401 or 403.

**What this changes**

- Rewrites each comment to match the code, after checking the claim
against the current source.
- Moves the keychain-before-file ordering doc in `ClaudeAuthStore` from
the `StoredCandidateLoad` struct to `orderedStoredCandidates`, the
function it describes. This is the only non-comment line movement in the
diff.
- Updates the OpenRouter page.

**Tests**

`swift build --build-tests` passes. The diff changes only comment lines,
apart from the struct move above.
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