Skip to content

fix(server): read Antigravity macOS Keychain sign-in via /usr/bin/security - #41006

Open
pfurcode wants to merge 3 commits into
pingdotgg:mainfrom
pfurcode:fix/antigravity-macos-keychain-acl
Open

pfurcode wants to merge 3 commits into
pingdotgg:mainfrom
pfurcode:fix/antigravity-macos-keychain-acl

Conversation

@pfurcode

Copy link
Copy Markdown

Problem

On macOS, Antigravity instances signed in with Gemini Enterprise (oauth-business) repeatedly trigger the system login Keychain prompt (T3 Code (Nightly) wants to access key "gemini" in your keychain) roughly every hour — even after clicking Always Allow.

Why it happens:

  1. Antigravity CLI 1.5.x stores and refreshes its gemini / antigravity Keychain item through zalando/go-keyring, which shells out to /usr/bin/security (add-generic-password -U -s gemini -a antigravity -w go-keyring-base64:...). That places the item in macOS's apple-tool: XARA partition.
  2. makeAntigravityUsageProbe currently reads that item on macOS with @napi-rs/keyring, which calls Security.framework directly from the T3 Code process (teamid:ARK85ZXQ4Z), triggering ACL partition mismatch: client teamid:ARK85ZXQ4Z ACL ("apple-tool:").
  3. Clicking Always Allow adds teamid:ARK85ZXQ4Z to the item's partition list, but ~1 hour later when Google's OAuth access token expires, Antigravity CLI updates the item via /usr/bin/security (SecKeychainItemModifyContent), which rebuilds the integrity ACL (no previous integrity acl exists; making a new one) back to only ("apple-tool:") — wiping out T3 Code's approval and re-triggering the prompt on the next usage-limits poll.

Change

  • In apps/server/src/provider/antigravityUsageLimits.ts, add readMacOsCliCredential for platform === "darwin", which reads the item via /usr/bin/security find-generic-password -s gemini -a antigravity -w (with stdin: "ignore", stderr: "ignore", scoped cleanup, and a 5-second timeout), trims stdout, and decodes it with decodeGoKeyringSecret.
    • Exit code 44 (errSecItemNotFound) returns undefined (missing sign-in → unsupported).
    • Any other non-zero exit code or spawn/timeout failure wraps into AntigravityKeyringError (probeFailed).
    • Because /usr/bin/security runs in the same apple-tool: XARA partition that go-keyring writes with, macOS allows reads without prompting across hourly token refreshes and app updates (matching the pattern used for Claude Code's Keychain credentials in fix(server): Claude banked resets work when the server runs on macOS #34099).
  • In apps/server/src/provider/Drivers/AntigravityDriver.ts, provide the already-acquired ChildProcessSpawner.ChildProcessSpawner service to makeAntigravityUsageProbe.
  • In apps/server/src/provider/antigravityUsageLimits.test.ts, add unit tests covering macOS /usr/bin/security decoding (go-keyring-base64: + trailing newline), exit code 44 (unsupported), non-44 error codes (probeFailed), and ensuring oauth-personal never invokes /usr/bin/security.

Scope

Fixes #41000 (also relates to #39775, which was closed as a duplicate of #37587; #39485 bypassed the keyring only for oauth-personal, leaving oauth-business reading the shared macOS Keychain entry).

Verification

  1. Before (real macOS securityd logs on T3 Code Nightly 0.1.12-nightly.20261122.5085, macOS 27.2.1 arm64, Antigravity CLI 1.5.12):
    • Observed hourly security: SecKeychainItemModifyContent (no previous integrity acl exists; making a new one) at 16:49:20, 17:50:04, and 18:49:55, immediately followed by securityd: ACL partition mismatch: client teamid:ARK85ZXQ4Z ACL ("apple-tool:") on the next usage poll even after clicking Always Allow (adding XARA partition 'teamid:ARK85ZXQ4Z' to list).
  2. Unit tests, lint, formatting, and typecheck:
    • vp test run src/provider/antigravityUsageLimits.test.ts src/provider/Drivers/AntigravityDriver.test.ts → 29 passed | 1 skipped (Windows-only).
    • vp fmt --check on the 3 modified files → clean.
    • effect-tsgo vp lint --report-unused-disable-directives on the 3 modified files → 0 warnings, 0 errors.
    • effect-tsgo tsc -p tsconfig.json --noEmit → 0 errors in the 3 modified files.
  3. Live macOS Keychain check (using a temporary dummy item, without touching any real credential):
    • Created a temporary item via /usr/bin/security -i (add-generic-password -U ... go-keyring-base64:...), updated it a second time via add-generic-password -U to replicate an hourly OAuth refresh, read both back via /usr/bin/security find-generic-password ... -w, decoded both via decodeGoKeyringSecret, deleted it and confirmed exit code 44, and verified 0 Keychain prompts / ACL partition mismatch entries in securityd unified logs during the run.
    • Did not test Windows or Linux runtime hosts directly; Windows (readWindowsCliCredential) and Linux (@napi-rs/keyring) paths are unchanged.

Built with Gemini 4 Neon in T3 Code (Antigravity harness).

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

On macOS, the Antigravity usage probe reads Gemini Enterprise credentials through /usr/bin/security. Other platforms retain the existing reader, and an injected reader remains the override.

Changes: Antigravity macOS Keychain Lookup

Layer / File(s) Summary
Read credentials with the macOS security command
apps/server/src/provider/antigravityUsageLimits.ts
A scoped /usr/bin/security lookup reads the gemini service and antigravity account. Exit status 44 and empty output return undefined; other failures produce AntigravityKeyringError. The lookup has a five-second timeout.
Select the macOS reader and test the probe
apps/server/src/provider/antigravityUsageLimits.ts, apps/server/src/provider/Drivers/AntigravityDriver.ts, apps/server/src/provider/antigravityUsageLimits.test.ts
The probe uses the macOS reader by default on Darwin and retains the injected reader override. The driver provides ChildProcessSpawner. Tests cover a successful lookup, exit-status results, and a failure reported as probeFailed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 7f5f2

On macOS, the Antigravity usage probe now reads Gemini Enterprise credentials through the system security command, which avoids repeated Keychain prompts. The change is narrowly scoped and covered by tests, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Antigravity macOS Keychain sign-in is now read through /usr/bin/security. It uses the conventional commit format and matches the changeset, which adds the macOS re…
Description check Passed The description covers every template section: Problem, Change, Scope, and Verification. The Problem section gives the trigger, the root cause, and the reproduction environment. The Change section lis…
Linked Issues check Passed Issue #41000 requires T3 Code to read the Antigravity gemini/antigravity Keychain entry on macOS for oauth-business without repeated prompts. The issue suggests reading through /usr/bin/security find-…
Out of Scope Changes check Passed The reviewed whole-PR diff of antigravityUsageLimits.ts changes only the macOS credential path. It adds the effect/stream and effect/process imports, readMacOsCliCredential, the darwin branch in makeA…
Full details: Title check

Explanation

The title names the main change: the Antigravity macOS Keychain sign-in is now read through /usr/bin/security. It uses the conventional commit format and matches the changeset, which adds the macOS reader in antigravityUsageLimits.ts, passes ChildProcessSpawner in the driver, and adds tests. The title is 74 characters, within a reasonable length.

Full details: Description check

Explanation

The description covers every template section: Problem, Change, Scope, and Verification. The Problem section gives the trigger, the root cause, and the reproduction environment. The Change section lists the per-file edits and the exit-code handling. The Scope section links issue #41000 and related issues. The Verification section gives test counts, lint and typecheck results, and a live macOS check. It also states what was not tested (Windows and Linux). The author also names the model and harness, as the template asks. The description is long but complete.

Full details: Linked Issues check

Explanation

Issue #41000 requires T3 Code to read the Antigravity gemini/antigravity Keychain entry on macOS for oauth-business without repeated prompts. The issue suggests reading through /usr/bin/security find-generic-password -s gemini -a antigravity -w. The whole-PR diff of apps/server/src/provider/antigravityUsageLimits.ts (mergeBase to head) shows readMacOsCliCredential running that exact command with stdin and stderr ignored, a scoped 5-second timeout, trimmed stdout decoded by decodeGoKeyringSecret, exit code 44 returning undefined (unsupported), and other non-zero exits or failures wrapped in AntigravityKeyringError. makeAntigravityUsageProbe selects this reader when platform is darwin and no readKeyringSecret override is given. Linux and Windows keep their existing readers, which matches the issue scope. The unit tests are described in the PR and were not read directly. The AntigravityDriver.ts diff could not be read (changed blobs unavailable). The file at head shows ChildProcessSpawner already acquired in create(), so the driver wiring is plausible but its exact one-line change is unverified. The core requirement does not depend on that wiring because the probe reads the spawner from its own context.

Full details: Out of Scope Changes check

Explanation

The reviewed whole-PR diff of antigravityUsageLimits.ts changes only the macOS credential path. It adds the effect/stream and effect/process imports, readMacOsCliCredential, the darwin branch in makeAntigravityUsageProbe, and the spawner acquisition and provision. These directly support issue #41000. The Windows and Linux reader paths are unchanged in that diff. The AntigravityDriver.ts diff (+1 line, per the summary, to provide ChildProcessSpawner to the probe) and the test file diff (+89 lines per the summary, no removals) could not be read directly. Based on the summary, both support the same macOS reader and show no unrelated behavior. No unrelated change was demonstrated.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 88d24a2 and 7f5f298.

Files selected for processing: 2

  • apps/server/src/provider/antigravityUsageLimits.test.ts
  • apps/server/src/provider/antigravityUsageLimits.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 22, 2026
juliusmarminge and others added 2 commits November 22, 2026 19:14
Compare the security exit code directly and drop a test case that an
existing personal-account test already covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: The reproduction requires macOS desktop login Keychain access outside the device pool and Gemini Enterprise oauth-business sign-in with usage-limits polling. This Linux VM provides neither; Google account sign-in, the usage-limits panel, and Gemini Enterprise are explicitly unavailable. Consequently, repeated prompts on the base and prompt-free reads after token refresh on the head remain unverified. API-key mode and replay scenarios cannot reproduce these conditions.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 22, 2026
@CharlieSheather

Copy link
Copy Markdown

Reproduced on a real macOS desktop, in case it helps unblock verification. I also hit it with a different sign-in mode than the one in #41000.

Environment

  • T3 Code 0.1.12-nightly.20261123.5124, macOS 26.6.2 (25G83), arm64
  • Antigravity CLI 1.5.14, signed in with Google Cloud / Vertex (gcp), not oauth-business. CLI log: ChainedAuth: authenticated via keyring (effective: gcp)

So this affects any sign-in mode that stores the token in the gemini / antigravity keychain item, not just Gemini Enterprise. As far as I can tell, the change in this PR applies to every darwin read whatever the auth method, so it should cover this case too.

Keychain item ACL after clicking Always Allow and the CLI's next write. The partition list is back to apple-tool: only:

"acct"<blob>="antigravity"
"svce"<blob>="gemini"
entry 3:
    authorizations (1): partition_id
    description: apple-tool:

securityd log (log show --predicate 'subsystem == "com.apple.securityd"'). Always Allow is granted, then wiped 3 seconds later by security:

12:14:50.421 securityd  user approved 'always allow' for /Applications/T3 Code (Nightly).app(345)
12:14:50.421 securityd  adding XARA partition 'teamid:ARK85ZXQ4Z' to list
12:14:53.809 security   no previous integrity acl exists; making a new one
12:38:36.196 security   no previous integrity acl exists; making a new one
12:41:23.361 securityd  ACL partition mismatch: client teamid:ARK85ZXQ4Z ACL ( "apple-tool:" )
12:41:23.361 securityd  displaying keychain prompt for /Applications/T3 Code (Nightly).app(345)

After that it prompts on a steady 5-minute cadence, which matches the usage-limits poll:

16:15:02.275  ACL partition mismatch … displaying keychain prompt
16:20:02.290  ACL partition mismatch … displaying keychain prompt
16:25:02.343  ACL partition mismatch … displaying keychain prompt
16:30:02.351  ACL partition mismatch … displaying keychain prompt
16:35:02.369  ACL partition mismatch … displaying keychain prompt

Totals over the last ~3 days: 38 partition mismatches, 33 denied prompts, 30 ACL rewrites by security ("making a new one"). The first prompt on this machine was at 10:53 today, after this nightly installed at 02:45.

That's the before-the-fix half of the verification that the pipeline couldn't run.

@Brenton-Thriviti

Copy link
Copy Markdown

Reproduced on another real macOS desktop, plus a check of the read path this PR switches to.

Environment: T3 Code 0.1.12-nightly.20261123.5138, macOS 27.3 (26C5047e), arm64, Antigravity CLI 1.5.14, Gemini Enterprise (oauth-business).

Before (current nightly). Always Allow is wiped by each hourly token write:

12:32:38  gemini item mdat (CLI token write)
13:00:20  securityd  ACL partition mismatch: client teamid:ARK85ZXQ4Z ACL ( "apple-tool:" )
13:11:02  securityd  user approved 'always allow' for /Applications/T3 Code (Nightly).app(36078)
13:11:02  securityd  adding XARA partition 'teamid:ARK85ZXQ4Z' to list
13:32:38  gemini item mdat (CLI token write, exactly 1h later)
13:55:20  securityd  ACL partition mismatch: client teamid:ARK85ZXQ4Z ACL ( "apple-tool:" )

Item ACL after the 13:32 write: T3 Code is still in the application list, but partition_id is back to apple-tool: only.

After (read path from this PR). With the item in that reset state (partition_id: apple-tool:), I ran /usr/bin/security find-generic-password -s gemini -a antigravity -w as a descendant of the same T3 Code server process (PID 36078) that had just prompted. The process chain was T3 Code (Nightly) → agent → zsh → /usr/bin/security.

  • Exit code 0, so the secret was returned (discarded to /dev/null).
  • No keychain prompt.
  • Zero ACL partition mismatch or displaying keychain prompt lines from securityd during the read.

So a read through /usr/bin/security spawned from T3's process tree succeeds silently after a token refresh resets the partition list. A direct Security.framework read from the same process prompts. This PR depends on exactly that difference.

Not verified: I didn't build and run this PR's branch. I tested the mechanism it relies on, not its code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS repeatedly prompts for login keychain password for "gemini" on Antigravity Gemini Enterprise (oauth-business)

4 participants