-
Notifications
You must be signed in to change notification settings - Fork 789
feat(antigravity): live quota, geoblock, CCA wire, and host failover #1916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
yansigit
wants to merge
14
commits into
lidge-jun:dev
Choose a base branch
from
yansigit:feat/antigravity-hardening
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eb78b8e
chore: start Antigravity hardening ledger
yansigit 17f9836
feat(antigravity): probe live retrieveUserQuota with catalog fallback
yansigit f1c8ebe
feat(antigravity): classify Cloud Code Assist geoblocks
yansigit d074729
feat(antigravity): process-local account cooldown map
yansigit f41d2cd
chore(antigravity): record Wave 1 landing progress
yansigit d312b23
fix(antigravity): honor supplied quota-exhausted reset duration
yansigit 7d3b970
fix(antigravity): bound live quota RPC response bodies
yansigit 735202d
feat(antigravity): Claude CCA header, preamble, prefill and tool-pair…
yansigit add234c
feat(antigravity): always-SSE unary, host failover, and account coold…
yansigit a717388
docs(antigravity): record Task 5 validation
yansigit 23b53d8
fix(antigravity): honor empty-stream and UNAVAILABLE host failover
yansigit 9f52f1e
fix(antigravity): do not fail over completed SSE; normalize peer-host…
yansigit 60541f9
fix(antigravity): cap CCA probe, avoid duplicate image POST, honor in…
yansigit 2d32d02
fix(antigravity): close CCA failover, quota, and project-id holes
yansigit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # Antigravity Hardening Whole-Branch Review | ||
|
|
||
| Base: `git merge-base origin/dev HEAD` | ||
| Head: `9757b66f9c8d76b94a21da0218d1c2b4bca31450` | ||
| Branch: `feat/antigravity-hardening` | ||
|
|
||
| ## Strengths | ||
|
|
||
| - The branch ports the planned quota, geoblock, process-local cooldown, Claude | ||
| CCA wire, always-SSE, and daily/production failover behavior in focused | ||
| modules rather than adding another provider path. | ||
| - CCA unary requests now share the streaming parser, and the focused | ||
| Antigravity/Google tests cover the normal unary, host-failover, tool-pair, | ||
| geoblock, quota, and cooldown paths. | ||
| - The implementation preserves PKCE, does not add `src/lab` imports to the | ||
| protected core files, and keeps request bodies, tokens, and account data out | ||
| of diagnostics. `bun run privacy:scan` passed. | ||
| - `git diff --check` passed, and the focused Antigravity run passed: 160 tests, | ||
| 0 failures across 8 files. Typechecking also passed in the task validation | ||
| runs. | ||
|
|
||
| ## Issues | ||
|
|
||
| ### Critical | ||
|
|
||
| None found. | ||
|
|
||
| ### Important | ||
|
|
||
| 1. **The CCA probe byte cap can be exceeded by one upstream read** | ||
| - File: `src/adapters/google-http.ts:90-107, 170-207` | ||
| - Issue: `CcaProbeBuffer.append()` grows its backing array to `required` | ||
| even when `required` is greater than `CCA_STREAM_PROBE_MAX_BYTES`. The | ||
| read loop only checks the limit before the next read, so a single large | ||
| `ReadableStream` chunk can allocate and retain more than the advertised | ||
| 100 MiB cap; line 207 then returns that oversized buffer to the parser. | ||
| - Impact: The new protection against oversized CCA streams is not a hard | ||
| memory bound. A large upstream chunk can impose an avoidable process-wide | ||
| memory spike before the parser's later frame checks run. | ||
| - Fix: Make the probe stop buffering at the cap and pass the current chunk | ||
| through without copying it into the probe, or otherwise use a bounded | ||
| prefix plus a stream that preserves the unread bytes. Add a regression | ||
| test where one read crosses the cap. | ||
|
|
||
| 2. **Standalone Antigravity image failover can duplicate a paid POST** | ||
| - File: `src/server/images.ts:230-249` | ||
| - Issue: A failed `fetch()` to the first host is followed by a second | ||
| `POST /v1internal:generateContent` to the peer. A transport failure is | ||
| ambiguous: the first host may have accepted and processed the generation | ||
| before the response was lost. | ||
| - Impact: The request can generate twice or incur duplicate provider-side | ||
| work/charges. This also contradicts the repository invariant in | ||
| `structure/04_transports-and-sidecars.md:153-159`, which says each paid | ||
| standalone Images POST receives one upstream attempt. | ||
| - Fix: Do not retry image-generation POSTs after an unknown transport | ||
| outcome unless the upstream provides a verified idempotency key. If host | ||
| candidates are retained for images, restrict fallback to a response that | ||
| is known to precede request acceptance and document that exception in the | ||
| structure note. | ||
|
|
||
| 3. **Inline SSE quota/rate-limit errors bypass cooldown and account rotation** | ||
| - Files: `src/adapters/google-http.ts:66-76`, | ||
| `src/adapters/google.ts:619-632`, `src/server/responses/core.ts:3890-3932` | ||
| - Issue: The always-SSE path can receive an HTTP-200 stream whose first data | ||
| frame is `{ error: { code: 429, status: "RESOURCE_EXHAUSTED", ... } }`. | ||
| The probe treats this as terminal and the Google parser emits an error, | ||
| but cooldown recording is only performed for HTTP 429/403 responses and | ||
| the account carousel only enters on `upstreamResponse.status === 429`. | ||
| - Impact: An account that is quota-exhausted or rate-limited in an inline | ||
| SSE error is immediately selected again, defeating the new process-local | ||
| cooldown and failover behavior. | ||
| - Fix: Preserve the classified inline error status/reason through the | ||
| adapter response path, record the same cooldown for inline 429/geo | ||
| errors, and feed inline pre-stream 429 errors into the existing bounded | ||
| account carousel. Keep geoblock non-rotating as required by the plan. | ||
| Add an HTTP-200 SSE error regression test. | ||
|
|
||
| ### Minor | ||
|
|
||
| No remaining Minor finding beyond the documentation-table triage item below. | ||
|
|
||
| ## Documentation-table triage | ||
|
|
||
| The leftover Task 1 docs-table Minor is **not still real**. The English | ||
| `guides/providers.md` table and the fr/ja/ko/ru/tr/zh-cn/zh-tw mirrors have | ||
| matching header/separator structure and the updated | ||
| `google-antigravity` rows contain the expected number of cells. No malformed | ||
| pipe-delimited row or locale contradiction was found. The known Astro build | ||
| extraction issue is therefore not evidence of a markdown defect. | ||
|
|
||
| ## Validation | ||
|
|
||
| - Focused Antigravity/Google validation: **160 passed, 0 failed**. | ||
| - `bun run typecheck`: passed in task validation. | ||
| - `bun run privacy:scan`: passed. | ||
| - `git diff --check`: passed. | ||
| - A full `bun run test` was also attempted, but the repository-wide run | ||
| returned nonzero because of unrelated environment/baseline failures, | ||
| including missing GUI React runtime packages, macOS `/bin/ps` permission | ||
| failures, and unrelated auth/Lab regression tests. No Antigravity-focused | ||
| failure appeared in that run. | ||
|
|
||
| ## Assessment | ||
|
|
||
| **Ready to merge? No — needs changes.** | ||
|
|
||
| The planned feature set is substantially present and the focused tests are | ||
| strong, but the probe cap is not actually hard, image failover can duplicate a | ||
| paid operation, and inline SSE quota errors bypass the cooldown carousel. | ||
| Resolve those Important findings and rerun the focused suite plus the | ||
| repository gates before merging. | ||
|
|
||
| ## Fix pass | ||
|
|
||
| - Finding 1 resolved: `CcaProbeBuffer` now refuses writes beyond the 100 MiB | ||
| cap, and the probe forwards an oversized read's unread bytes without copying | ||
| them into the probe buffer or failing over. | ||
| - Finding 2 resolved: standalone CCA image generation now performs exactly one | ||
| upstream POST. Ambiguous transport, 404, and 503 outcomes are surfaced rather | ||
| than replayed on the peer host; the one-attempt invariant is documented in | ||
| `structure/04_transports-and-sidecars.md`. | ||
| - Finding 3 resolved: inline CCA quota and geoblock SSE frames are converted to | ||
| cooldown-aware synthetic 429/403 responses. Quota enters the existing bounded | ||
| Antigravity account carousel; geoblock remains non-rotating. | ||
|
|
||
| Fix-pass validation: the requested Antigravity, quota, routing, wire, hardening, | ||
| and image tests passed (**175 passed, 0 failed**), and `bun run typecheck` | ||
| passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
|
|
||
| # SDD progress — Antigravity hardening | ||
|
|
||
| - Task 1/2/3: implemented (commits e558a771d3f4..986e5af9aa49, review pending) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ## Status | ||
|
|
||
| Implemented Task 4 CCA request fidelity. | ||
|
|
||
| ## Files changed | ||
|
|
||
| - `src/adapters/google-antigravity-tools.ts` | ||
| - `src/adapters/google.ts` | ||
| - `tests/google-antigravity-wire.test.ts` | ||
| - `tests/google-adapter.test.ts` | ||
| - `.superpowers/sdd/task-4-report.md` | ||
|
|
||
| ## Test | ||
|
|
||
| `bun test tests/google-antigravity-wire.test.ts tests/google-adapter.test.ts tests/google-empty-content.test.ts` — 88 passed, 0 failed. | ||
|
|
||
| `bun run typecheck` — passed. | ||
|
|
||
| ## Behavior | ||
|
|
||
| - Claude CCA sends the interleaved-thinking beta header. | ||
| - CCA requests include the system-instruction replacement preamble. | ||
| - Claude trailing model prefills are stripped while lone model turns remain. | ||
| - Orphan tool results and assistant calls without later results are removed before allocator prepass; valid parallel pairs remain intact. | ||
|
|
||
| ## Concerns | ||
|
|
||
| - The full repository test suite was not rerun; validation used the requested focused adapter tests and strict typecheck. | ||
| - Task 5 transport behavior remains intentionally untouched. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Task 5 report — Transport | ||
|
|
||
| ## Status | ||
|
|
||
| Implemented always-SSE Cloud Code Assist requests, daily/production host | ||
| failover, quota/image host candidate reuse, and Antigravity account cooldown | ||
| wire-up. The existing AI Studio and Vertex unary paths remain on | ||
| `generateContent`. | ||
|
|
||
| ## Validation | ||
|
|
||
| - `bun test tests/google-antigravity-wire.test.ts tests/google-hardening.test.ts tests/antigravity-routing.test.ts tests/antigravity-quota.test.ts` | ||
| - 104 passed, 0 failed | ||
| - `bun run typecheck` | ||
| - passed | ||
| - `git diff --check` | ||
| - passed | ||
|
|
||
| ## Coverage | ||
|
|
||
| - Unary CCA parsing buffers the SSE event contract. | ||
| - Empty CCA streams and first-host transport/404/unavailable failures try the | ||
| single maintained peer; authentication, geoblock, invalid request, and | ||
| exhausted quota do not host-fail over. | ||
| - 429 responses classify rate limits versus exhausted quota and record | ||
| account-keyed process-local cooldowns. | ||
| - Geoblock records cooldown without starting an account carousel. | ||
| - Provider documentation tables remain structurally valid after the quota and | ||
| transport notes were folded into the Antigravity rows. | ||
|
|
||
| ## Concerns | ||
|
|
||
| CCA response inspection clones and reads up to 256 KiB before returning a | ||
| successful response so an empty stream can fail over deterministically. This | ||
| preserves the response body for the adapter, but can delay the first client | ||
| event until the bounded inspection completes. | ||
|
|
||
| ## Commit | ||
|
|
||
| `3b48b9802` — `feat(antigravity): always-SSE unary, host failover, and account cooldowns` | ||
|
|
||
| ## Review fixes | ||
|
|
||
| - P1 streaming: replaced clone-to-EOF inspection with a bounded first-meaningful-event probe. CCA responses return as soon as a candidate or terminal frame arrives, while the consumed bytes remain attached to the response body; empty streams still fail over at EOF. | ||
| - P1 oversized SSE: valid responses larger than the old 256 KiB inspection cap are no longer classified as empty or replayed. | ||
| - P2 inline `UNAVAILABLE`: a 200 SSE error frame with `UNAVAILABLE` (or code 503) now uses the single daily/production peer fallback. Terminal authentication, geoblock, invalid-request, and quota errors remain non-failover cases. | ||
|
|
||
| ## Review-fix validation | ||
|
|
||
| - `bun test tests/google-antigravity-wire.test.ts tests/google-hardening.test.ts tests/antigravity-routing.test.ts tests/antigravity-quota.test.ts` | ||
| - 107 passed, 0 failed | ||
| - `bun run typecheck` | ||
| - passed | ||
| - `git diff --check` | ||
| - passed | ||
|
|
||
| ## Re-review fixes | ||
|
|
||
| - EOF-residual CCA terminal frames now stay on the original host; only empty | ||
| residuals and retryable `UNAVAILABLE` residuals invoke peer failover. | ||
| - Peer fallback now re-enters the shared Google retry, quota classification, | ||
| compatibility replay, and final error-normalization path with host failover | ||
| disabled for the peer leg. | ||
|
|
||
| ## Re-review validation | ||
|
|
||
| - `bun test tests/google-antigravity-wire.test.ts tests/google-hardening.test.ts tests/antigravity-routing.test.ts tests/antigravity-quota.test.ts` | ||
| - 109 passed, 0 failed | ||
| - `bun run typecheck` | ||
| - passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.