Skip to content

feat(quota): support Google Antigravity weekly quota and Ollama Cloud quota (carry of #3447) - #3587

Merged
lidge-jun merged 4 commits into
devfrom
codex/260905-antigravity-ollama-quota
Sep 5, 2026
Merged

feat(quota): support Google Antigravity weekly quota and Ollama Cloud quota (carry of #3447)#3587
lidge-jun merged 4 commits into
devfrom
codex/260905-antigravity-ollama-quota

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Google Antigravity quota now includes the weekly window (from retrieveUserQuotaSummary) alongside the 5-hour window, and Ollama Cloud quota is parsed and shown. Carries #3447 (author @hualiny, head 745b70e1e, cherry-picked; git merge-tree clean — GitHub's CONFLICTING flag was rename-detection noise from the tests/<domain>/ move).

Two maintainer additions on top of the carry:

  • src/providers/quota.ts fetchAntigravityQuota: the new summary request carried the account bearer to an operator-configured baseUrl with default redirect following. It now goes through providerOutboundPost against the pinned ANTIGRAVITY_ACCOUNT_QUOTA_BASE with a providerRedirectError check — the exact shape fetchAntigravityUsageQuota already uses. Only the model-list fallback still honors baseUrl (unchanged from dev). Documented in reference/configuration/providers.md.
  • The multi-provider quota test now injects the pinned-transport seam (it would otherwise make a real request to Google now that the probe is off globalThis.fetch).

CodeRabbit's "duplicate const seen" finding on #3447 is a false positive (two separate test() scopes). Supersedes #3447.

Stack (wp4 quota stack; merge bottom-up):

# Layer Branch Base
2 #2783 quota reset detection codex/260905-quota-reset-detection this
1 #3447 Antigravity weekly + Ollama Cloud quota ← you are here codex/260905-antigravity-ollama-quota dev

(#2973 / codex/260905-quota-window-activation is independent and targets dev directly.) Unit: devlog/_plan/260905_open_work_closeout/ (040, 041, 042).

Verification

  • bun run typecheck — exit 0.
  • bun test tests/providers/provider-quota.test.ts — RED with the bearer fix reverted: 117 pass / 4 fail (does not send the account bearer to a configured baseUrl, refuses a redirected summary response, and the two summary-mapping tests once they stopped stubbing globalThis.fetch); GREEN 121 pass / 0 fail. With provider-account-quota + layout guard: 156 pass / 0 fail (unsandboxed).
  • bun test tests/ci-workflows/repo-hygiene.test.ts — 14 pass / 0 fail (no duplicate basename recreated at tests/ root).
  • Exact-head hosted CI is the merge gate (no repository-wide local suite by maintainer instruction).

Checklist

  • Targets dev
  • Focused regression test RED before / GREEN after
  • Docs updated
  • Original author credited via Co-authored-by trailer in the branch commits

Co-authored-by: hualiny 82697947+hualiny@users.noreply.github.com

hualiny and others added 4 commits September 5, 2026 11:43
Carries #3447 by @hualiny (Antigravity weekly windows via
retrieveUserQuotaSummary, plus Ollama Cloud quota from /api/usage),
rebased rename-aware onto tests/providers/.

The provider-level probe added there sent the stored account bearer to an
operator-configured baseUrl with default redirect following, while
fetchAntigravityUsageQuota in the same file already pins the identical
request. Route it through providerOutboundPost against
ANTIGRAVITY_ACCOUNT_QUOTA_BASE with the providerRedirectError check so a
configured baseUrl stays a routing choice for model requests, not a second
destination for Google's accounting. The fetchAvailableModels fallback is
unchanged from dev.

Co-authored-by: hualiny <82697947+hualiny@users.noreply.github.com>
…ogle's host

Co-authored-by: hualiny <82697947+hualiny@users.noreply.github.com>
…vider quota test

After the summary probe moved off globalThis.fetch, this test made a real request to Google (sandbox DNS failure masked it as a fallthrough). Inject the seam with a 404 so the fetchAvailableModels fallback is what the test exercises, as before.

Co-authored-by: hualiny <82697947+hualiny@users.noreply.github.com>
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 5, 2026 02:48
@lidge-jun lidge-jun added the enhancement New feature or request label Sep 5, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T02:52:04.254803Z 4a721e4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: dac212dd-c6f3-40d3-a2d5-3e6e2d4823ad

📥 Commits

Reviewing files that changed from the base of the PR and between 3c920af and 4a721e4.

📒 Files selected for processing (4)
  • docs-site/src/content/docs/reference/configuration/providers.md
  • src/providers/quota.ts
  • tests/providers/provider-account-quota.test.ts
  • tests/providers/provider-quota.test.ts

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

Comment @coderabbitai help to get the list of available commands.

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

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

| `googleMode?` | `"ai-studio" \| "vertex" \| "cloud-code-assist"` | Google transport/auth mode. Default `ai-studio`. |
| `directGeminiWireRenames?` | `boolean` | Google only. Applies only to direct AI Studio requests. Omitted or `true` keeps the `-tiered` wire rename for Gemini Flash ids (`gemini-3.7-flash` -> `gemini-3.7-flash-tiered`); `false` sends the requested bare ids to the wire unchanged. Vertex preserves the requested model ID, and Cloud Code Assist routing is unchanged. Set `false` when the configured upstream still serves the bare ids. |
| `project?` | `string` | Vertex or Antigravity Cloud Code Assist project id. |
| — | — | Antigravity account quota probes (`retrieveUserQuota` and `retrieveUserQuotaSummary`) always go to Google's own Cloud Code host through the pinned outbound transport, regardless of a configured `baseUrl`; the account bearer is never sent to an operator-configured endpoint and a redirect aborts the probe. Only the model-list fallback still honors `baseUrl`. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Correct the claim that the bearer never reaches baseUrl

When retrieveUserQuotaSummary returns a non-success response other than 401/403, throws, or contains no recognized windows, fetchAntigravityQuota falls through to the model-list request at src/providers/quota.ts:2577-2584; that request uses the operator-configured baseUrl, includes the Google bearer, and follows redirects by default. The new statement that the bearer is never sent to such an endpoint is therefore false precisely during summary fallback and may encourage an unsafe custom configuration; either pin the fallback as well or explicitly document that credential exposure exception.

AGENTS.md reference: docs-site/AGENTS.md:L7-L10

Useful? React with 👍 / 👎.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 63 / 80

이 PR은 @hualiny 의 #3447을 dev 위로 캐리한 것입니다. 지금 GitHub 상태는 MERGEABLE이고, 베이스는 dev, 헤드 브랜치는 codex/260905-antigravity-ollama-quota입니다. 하는 일을 쉽게 말하면 두 가지입니다. 첫째, Google Antigravity 쿼터가 예전처럼 5시간 창만 보지 않고 retrieveUserQuotaSummary로 주간(weekly) 창까지 읽어 Gem / Gem (Weekly) / Cla / Cla (Weekly) 네 칸으로 보여 줍니다. 둘째, Ollama Cloud(https://ollama.com) 계정의 /api/usage를 읽어 레거시 5시간·주간, 또는 새로 옮긴 월간 크레딧 계획을 쿼터 리포트로 올립니다. 원작자 크레딧은 Co-authored-by로 남아 있고, 메인테이너가 캐리하면서 보안 핀을 한 겹 더 얹었습니다.

보안 핀이 왜 중요하냐면, 요약 프로브는 계정 bearer를 들고 Google로 갑니다. 예전 캐리 초안은 그 요청을 운영자가 넣은 baseUrl로도 보낼 수 있었고, 리다이렉트도 따라갈 수 있었습니다. 이번 브랜치는 fetchAntigravityUsageQuotafetchAntigravityQuota 둘 다 providerOutboundPostANTIGRAVITY_ACCOUNT_QUOTA_BASE(daily-cloudcode-pa.googleapis.com)에만 붙이고, providerRedirectError로 리다이렉트를 끊습니다. 모델 목록 폴백만 예전처럼 설정된 baseUrl을 씁니다. docs-site/.../providers.md에도 “계정 쿼터 프로브는 고정 호스트, 모델 목록만 baseUrl”이라고 한 줄 적어 두었습니다. Ollama Cloud 쪽도 키가 비정규 baseUrl로 나가지 않게 isCanonicalOllamaCloudUrl로 막고, redirect: "error"를 켭니다.

테스트는 꽤 단단합니다. tests/providers/provider-quota.test.ts에 요약 매핑·중첩 remaining·bearer가 루프백 baseUrl로 안 감·리다이렉트 거절·Ollama 레거시/월간/혼합/404/401/비정규 URL이 들어갔고, provider-account-quota.test.ts는 계정별 요약 프로브와 404 시 fetchAvailableModels 폴백을 잠급니다. 본문 검증 메모대로 요약 시임을 빼면 빨개지고, 넣으면 초록으로 돌아오는 RED/GREEN도 적혀 있습니다. 지금 dev HEAD 3c920af5f 기준으로 Windows 스위트는 이미 들어갔고, package는 2.43.0 방향입니다. 이 PR 자체는 MERGEABLE이라 당장 충돌로 막히지는 않습니다.

다만 같은 src/providers/quota.ts를 provider-usage 스택도 만집니다. #3582는 attribution/정책 층이고, #3584는 per-account OAuth·API-key usage로 quota.ts를 크게 고칩니다(+211/−97)며 maybeFetchProviderQuota / Antigravity 경로 / provider-account-quota.test.ts와도 겹칩니다. 파일 경로는 이 PR과 동일합니다. 둘 다 열리면 나중에 한쪽이 리베이스·충돌 정리 비용을 집니다. 기능 자체는 서로 다른 목표(주간·Ollama 프로브 vs 계정별 usage 노출)라 닫을 대상은 아니지만, 머지 순서는 메인테이너가 정해야 합니다. 원본 #3447은 아직 OPEN입니다. 이 PR이 랜딩하면 원본은 superseded로 닫는 게 맞습니다(유지보수 규칙: leftover를 열어 두면 open PR 수가 부풀어 기여자를 헷갈리게 함).

라인 / 경로로 보면 아래를 보면 됩니다.

경로 src/providers/quota.ts fetchAntigravityQuota / fetchAntigravityUsageQuota - 요약 프로브 본문이 거의 두 번 복제되어 있다. 동작은 맞고 핀도 같지만, 나중에 헤더·타임아웃·에러 처리를 고칠 때 한쪽만 고치기 쉽다
경로 src/providers/quota.ts parseAntigravityQuotaSummary - 그룹 이름을 gemini / claude·3p·gpt 문자열로 나눈다. 라벨이 바뀌면 창이 Other로 떨어지거나 섞일 수 있다. 지금 테스트 fixture와는 맞는다
경로 src/providers/quota.ts fetchAntigravityQuota 폴백 fetchAvailableModels - 요약은 핀인데 폴백은 여전히 설정된 baseUrl + bearer다. PR·문서가 “의도된 잔여”라고 적어 두었으니 회귀가 아니라 계약 확인이다
경로 src/providers/quota.ts fetchOllamaCloudQuota - Antigravity와 달리 providerOutboundPost가 아니라 fetch + canonical URL + redirect: "error"다. Cloud 고정 호스트라 실사용은 안전해 보이지만, 핀 패턴을 맞출지 여부는 취향이다
경로 src/providers/quota.ts / #3584 - 같은 파일·같은 maybeFetchProviderQuota 이웃을 고친다. 이 PR을 먼저 넣으면 #3584 리베이스, 반대로 하면 이 PR 리베이스다
경로 tests/providers/provider-quota.test.ts - 요약 시임 setAntigravityAccountQuotaTransportForTests를 멀티 프로바이더 테스트에도 넣었다. 없으면 실네트워크로 나가니 유지 필수다
경로 #3447 - 아직 OPEN. 이 캐리가 랜딩한 뒤 Landed via #3587 at <commit> + landed-via-maintainer로 닫을 대상이다

메인테이너의 판단이 필요한 지점

너의 추천
merge 후보로 두되, provider-usage 스택(#3582#3584)과의 quota.ts 충돌을 피하려고 이 enhancement를 먼저 올리거나, 반대로 #3584가 먼저면 이 브랜치를 그 위에 리베이스한 뒤 exact-head CI만 보고 머지하세요. 머지 직후 열린 #3447은 Landed via #3587 at <commit> 코멘트 + landed-via-maintainer 라벨로 completed/superseded 클로즈하세요. types/config 대형 스플릿에 무효화되는 형태는 아니고, 닫고 리베이스할 “잘못된” PR이 아니라 캐리·보안 핀이 들어간 정상 enhancement입니다.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer admin merge (ruleset bypass recorded per MAINTAINERS.md): carry of #3447, head 4a721e4; typecheck 0, focused 156/0 locally; per maintainer instruction the final dev-tip CI run is the acceptance gate for this batch. wp4 of the 260905 open-work closeout.

@lidge-jun
lidge-jun merged commit dcdad53 into dev Sep 5, 2026
28 of 29 checks passed
@lidge-jun
lidge-jun deleted the codex/260905-antigravity-ollama-quota branch September 5, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants