Skip to content

fix(antigravity): rotate to a sibling account when one pooled account is refused or failing - #8750

Closed
andrew05060414 wants to merge 2 commits into
lidge-jun:devfrom
andrew05060414:fix/antigravity-403-rotate
Closed

andrew05060414 wants to merge 2 commits into
lidge-jun:devfrom
andrew05060414:fix/antigravity-403-rotate

Conversation

@andrew05060414

@andrew05060414 andrew05060414 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Problem. In a pool of Antigravity accounts, one account that Google keeps refusing (HTTP 403 PERMISSION_DENIED) or that keeps answering 502/503/504 kept receiving requests, and each request ended in that error even though other accounts in the pool were healthy. Only the narrow VALIDATION_REQUIRED 403 shape moved on to another account; a 503 was retried only against the same account.

What changes after this PR.

  • A plain access-denied 403 now cools the refused credential for 60 seconds (the existing auth cooldown, no stored verdict) and replays the request on the next live sibling, repeating while siblings remain up to the existing failover limit. The "verify your account" 403 keeps its own durable quarantine path and is not pre-empted. The web-search sidecar accepts the same refusal for its one rotation.
  • A 502/503/504 that survived the same-account retry ladder before any output now replays once on a live sibling; the failed account is cooled for 15 seconds (process-local). One hop per request keeps a pool-wide outage to two ladders.

Impact. Users with several Antigravity accounts stop seeing the pool pinned to one bad account. Nothing is written to disk by either path, so an account that is only occasionally refused is never blacklisted. Usage rows stay one attempt: an account rotation is recorded as a recovery kind inside the attempt (oauth-account-403, transient-5xx), not as a second attempt.

Verification

  • bun run typecheck, bun run structure:check: pass.
  • Focused tests that ran locally and pass: tests/adapters/google/google-vertex-http.test.ts (new unit test for the marker), tests/adapters/google/antigravity-refusal.test.ts, tests/ci-workflows/file-size-ratchet.test.ts.
  • New integration cases are in tests/server/server-google-antigravity-oauth-401-replay.test.ts (403 rotates and cools without a stored verdict; keeps walking the pool; every-account 403 ends after one send per account; lone account keeps the refusal; 502/503/504 replay once on a sibling; every-account 503 stops after one hop; cooldown lapses after 15 s). These could not be run on the author's Windows machine: icacls spawning fails inside the test harness there (EICACLS) and the git-config guard trips on git 2.56, which also fails untouched tests in the same file (for example "same-account refresh succeeds without pool rotation"). Please rely on CI for this file; I did not run it green locally.
  • The existing test "unclassified 403 retains the refusal without a sibling send" encoded the old contract and is rewritten to the new one.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (structure/transports/responses-failover.md).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

…is refused

A pooled google-antigravity account whose credential was rejected answered every
request with 403 PERMISSION_DENIED, and the pool kept sending to it: only the
VALIDATION_REQUIRED shape rotated. A plain access-denied 403 now cools the refused
credential generation (auth cooldown, no needs-reauth mark) and replays on the next
live sibling, bounded by the failover limit. The verify-account shape keeps its
quarantine path, and the web-search sidecar accepts the same refusal for its one
rotation.
…r the same-account retries

The transient ladder retried a failing Antigravity account only against itself, so one
account stuck on 503/504 kept answering every request that landed on it. After the ladder
gives up before any output, the request now replays once on a live sibling and the failed
account is cooled for 15 seconds (process-local, no stored verdict). One hop per request
keeps a pool-wide outage to two ladders.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/oauth/generic-account-failover.ts.

@github-actions github-actions Bot added intake: hygiene-blocked Deterministic PR hygiene checks failed bug Something isn't working labels Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: unsponsored_surface.

What to do

  • Fix unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/oauth/generic-account-failover.ts.
  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.
@andrew05060414 Tick the boxes once required local validation has passed with commands, results, and any full-suite exception documented, your branch is on the latest dev commit, and every correct Codex and CodeRabbit finding is resolved.

lidge-jun added a commit that referenced this pull request Nov 16, 2026
…ed Vertex ADC (carries #8740, #8750) (#8778)

* fix(antigravity): scope round-robin and session affinity per quota family

Round-robin peeked a model-filtered ring but committed on the unfiltered
account list, so the realign path reseeded the ring and the next request got
the same account. Both sides now read the same model- and exhaustion-filtered
list, and the ring key carries the quota family (genericPoolKey(provider,
family)), so a Gemini request no longer moves the Claude ring.

Conversation affinity keeps one binding per family with the family-less key
as a read fallback. Accounts with known zero headroom for the requested family
are dropped unless every listing account is spent, including on the
model-listing reroute. A manual selection seeds the provider ring and both
family rings.

Source: #8740 (fef2c75, b9dd5db), originally #8664.

Co-authored-by: Andrew (agent) <[email protected]>

* fix(antigravity): rotate to a sibling account when one account's 403 is refused

A pooled google-antigravity account whose credential Google refused answered
every request with 403 PERMISSION_DENIED, and the pool kept sending to it: only
the VALIDATION_REQUIRED shape rotated. A plain access-denied 403 now cools the
refused credential generation for 60 seconds (the existing auth cooldown, no
needs-reauth mark) and replays on the next live sibling, repeating while
siblings remain up to the failover limit. A 403 whose PERMISSION_DENIED body is
worded as invalid credentials normalizes to "authentication failed" and is
treated the same way.

The verify-account shape keeps its durable quarantine path on both the main
dispatch and the web-search sidecar. The sidecar accepts the same plain refusal
for its one rotation, so the web-search validation cases that used to assert
"never rotates" for unrelated, spoofed and malformed 403 bodies now assert one
sibling rotation with nothing persisted; verify-account wording and oversized
bodies still never rotate.

Source: #8750 (7441a44).

Co-authored-by: Andrew (agent) <[email protected]>

* fix(antigravity): replay a 502/503/504 once on a sibling and share one cooldown write

The transient ladder retried a failing Antigravity account only against itself,
so one account stuck on 503/504 kept answering every request that landed on it.
After the ladder gives up before any output, the request now replays once on a
live sibling and the failed account is cooled for 15 seconds (process-local, no
stored verdict). One hop per request keeps a pool-wide outage to two ladders.

The 403 refusal and the 5xx fault now take one rotation path: both pick the
sibling through nextAntigravitySibling and dispatch through rotateAntigravityAuth,
which checks the failover limit before any cooldown is written. Both cooldowns
go through coolAntigravityAccount, fenced on the sent credential generation and
never shortening a cooldown already running for the account and family, so a
15-second fault window cannot cut short a 60-second refusal.

docs-site (English and Spanish, which carried the old wording) now describes the
403 walk and the 5xx hop.

Source: #8750 (bdf1139).

Co-authored-by: Andrew (agent) <[email protected]>

* feat(vertex): show gcloud ADC credentials as verified once a token is minted

A Google Vertex provider signed in with Application Default Credentials kept
showing "Credentials unverified" because nothing recorded a successful token
exchange. src/lib/gcp-adc.ts now records the source and generation of the last
successful exchange per credential scope; the proof lapses when the ADC source
the next request would use changes, and a failed exchange clears only its own
record, never a newer exchange's. safeConfigDTO exposes one boolean,
vertexCredentialVerified, for ambient and marker rows (no credential material).

The static-catalog branch of POST /api/providers/test mints one Vertex ADC token
(new src/server/management/static-catalog-probe.ts); every other static catalog,
including Antigravity and API-key Vertex, still answers static_catalog before
any credential resolution. The dashboard treats a verified row as ready, keeps
its "Host credentials" auth label, and drops a retained probe result when the
verification state changes. Docs say the test proves the credential, not
Vertex permissions.

Source: #8740 (947ed8a, ef78868, 801e772, and the probe-key line of
9e0a92b), originally #8720.

Co-authored-by: Andrew (agent) <[email protected]>

* fix(antigravity): rotate only on Google's structured PERMISSION_DENIED 403

classifyGoogle writes the bare "Antigravity access denied" prefix for every 403,
including an empty body, a proxy or WAF HTML page and an envelope without the
status enum. hasAntigravityAccessDeniedMarker accepted that prefix, so any 403
walked the pool and wrote a 60 second family cooldown on every account.

The marker now requires the "(PERMISSION_DENIED)" suffix classifyGoogle keeps
only when it parsed the enum, or the authentication-failed prefix, and still
requires classifyAntigravityRefusal(403, text) to be "other". Text carrying the
validation marker never qualifies. Unrelated, spoofed and malformed web-search
403 bodies and the oversized or spoofed-prefix main-path variants keep their
refusal again; a structured PERMISSION_DENIED earns the one sibling rotation, and
an empty, HTML or enum-less 403 is not rotated and cools nothing. Docs and the
responses-failover note say what triggers the walk.

Co-authored-by: Andrew (agent) <[email protected]>

* fix(vertex): require an access_token before verifying ADC and skip reference rows in the probe

resolveAccessToken recorded "verified" for any 200 token response; a body
without a non-empty access_token now fails the exchange before the token cache
and the verified record are written.

The static-catalog connection test resolved keychain: and ${ENV} reference rows
through selectVertexDiscoveryCredential before answering static_catalog. It now
classifies the configured text with vertexConfiguredCredentialKind, the rule the
dashboard DTO already used, and answers for api-key and reference rows without
reading the credential store. The Spanish adapters page no longer claims the
static-catalog test verifies nothing, and the structure note describes the probe.

Co-authored-by: Andrew (agent) <[email protected]>

* refactor(pool): drop the unused prefix sweep in clearPoolRotationState

No production caller clears a generic provider key, and the one codex caller
already clears its scoped keys explicitly, so the prefix sweep never ran for the
Antigravity family rings and only widened what clearing the codex key removes.
reconcilePoolRotationState alone treats generic:<provider>:<family> keys as part
of their provider; the structure note says so, and now records that Antigravity
session affinity writes two entries per session.

Co-authored-by: Andrew (agent) <[email protected]>

---------

Co-authored-by: Andrew (agent) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant