Skip to content

feat(oauth): reset-first strategy for generic OAuth pools (carry #5408) - #7167

Merged
lidge-jun merged 3 commits into
devfrom
carry/5408-reset-first
Oct 15, 2026
Merged

lidge-jun merged 3 commits into
devfrom
carry/5408-reset-first

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Carries the generic reset-first rotation out of #5408 by @agentHits (source head 2db983800a02785250cc3ebed86f399bc772303e), as the first of three stacked slices the earlier review asked for:

  1. this PR: reset-first for generic OAuth pools (backend, API, CLI)
  2. account pool card for generic OAuth providers, stacked on this one
  3. redesigned OAuth accounts workspace, stacked on (2)

Generic OAuth pools (Google Antigravity, xAI, Kiro, Cursor and the rest) can now store reset-first and, with pool.kernel on, run it. Both the first attempt (while the proactive preference is on) and a 429 rotation prefer the non-exhausted account whose quota resets soonest. That is the requested model family's weekly window when one is reported, otherwise the 5-hour window, with more headroom breaking ties. Exhausted accounts go last. Without quota evidence, or when a passive provider has evidence for only part of the ring, ordering stays on headroom. With pool.kernel off, a stored reset-first is inert, like round-robin and fill-first.

Before: PUT /api/pool/settings {"provider":"google-antigravity","strategy":"reset-first"} returned 400. After: it returns 200 and round-trips. The Anthropic kind still refuses it with strategy must be one of: quota, round-robin, fill-first, because the Anthropic runtime does not implement it. On dev that kind went through the generic parser, so this PR also gives the Anthropic kind its own parser.

Changes from the source PR:

  • Model roster check. The first-attempt pick now uses the same eligible set as round-robin and fill-first (eligibleFailoverAccounts + preferKiroModelSupport). In feat(gui): unified provider workspace with pool controls and reset-first rotation #5408 it skipped that check, so a Gemini 4 Argon request could be steered to an Antigravity account whose roster does not list Argon. A new test covers this. It fails against the feat(gui): unified provider workspace with pool controls and reset-first rotation #5408 code (27 pass / 1 fail) and passes here.
  • CLI. ocx account pool <generic> --strategy reset-first is accepted, matching what ocx account strategy already got from the server. The capability summary, generated skill surface, recipes and CLI reference are updated.
  • Docs. providers.<name>.oauthAccountFailover.strategy in the configuration reference, plus the ownership note in structure/transports/inventory.md.

Co-authored-by: agentHits 140916359+agentHits@users.noreply.github.com

Independent review round 1 fixed a further Kiro defect: reset-first omitted the account map used to validate Kiro's credential-bound quota evidence. Both proactive selection and refusal rotation now pass the map, so missing reset times retain headroom ordering and exhausted accounts stay last. The regression failed before the fix (27 pass / 1 fail) and passes after it.

Verification

Fresh review runs on macOS arm64 / Bun 1.4.3, with temporary OPENCODEX_HOME and CODEX_HOME:

  • bun scripts/test.ts --parallel=1 tests/providers/kiro/kiro-pool-rank.test.ts tests/oauth/oauth-account-quota-rank.test.ts tests/server/account-pool-management-api.test.ts tests/cli/cli-account-policy.test.ts: 185 pass / 0 fail.
  • bun run typecheck, bun run structure:check, bun scripts/file-size-ratchet.ts: pass on this layer.
  • Shared management-auth gate and origin checks reviewed; top-of-stack bun scripts/test.ts --parallel=1 tests/server/server-management-auth.test.ts: 47 pass / 0 fail.
  • Full GUI at the stack tip: 3355 pass / 0 fail. Broad root and clean-dev attribution are recorded on [WRONG BRANCH] feat(gui): redesigned OAuth accounts workspace (carry #5408) #7169. A full additional root suite is impractical with concurrent triage worktrees; focused routing/API coverage and the requested changed suite cover this review, with cross-platform coverage left to CI.
  • Cross-platform CI dispatched at c50aa7c: https://github.com/lidge-jun/opencodex/actions/runs/38718968361 (queued; not passing evidence).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Generic OAuth pools (Antigravity, xAI, Cursor, Kiro and the rest) can store
and run reset-first under pool.kernel: the first attempt and a 429 rotation
prefer the non-exhausted account whose weekly (else 5-hour) quota resets
soonest, with headroom breaking ties. A passive provider with partial
evidence keeps headroom order. The Anthropic kind still refuses it.

The first-attempt pick uses the same eligible set as round-robin, so an
Antigravity account whose model roster omits the requested model is not
chosen. ocx account pool --strategy now accepts reset-first for generic
pools as the server already does for ocx account strategy.

Carried from #5408 (source head 2db9838).

Co-authored-by: agentHits <140916359+agentHits@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 51a76eed-39c2-4bf0-879a-e5a615a0ac4e
📥 Commits

Reviewing files that changed from the base of the PR and between b538531 and 15911b6.

📒 Files selected for processing: 16
  • docs-site/src/content/docs/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/reference/configuration/providers.md
  • skills/ocx/references/01_surface_accounts.md
  • skills/ocx/references/03_recipes.md
  • src/cli/account-policy.ts
  • src/cli/capabilities-accounts.ts
  • src/oauth/account-quota-rank.ts
  • src/oauth/generic-account-failover.ts
  • src/oauth/pool-settings-capability.ts
  • src/server/management/oauth-account-routes.ts
  • src/types/provider.ts
  • structure/transports/inventory.md
  • tests/cli/cli-account-policy.test.ts
  • tests/oauth/oauth-account-quota-rank.test.ts
  • tests/providers/kiro/kiro-pool-rank.test.ts
  • tests/server/account-pool-management-api.test.ts
+--------------------------------------------------+
| I want to be a VS Code extension when I grow up. |
+--------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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

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

@lidge-jun
lidge-jun marked this pull request as ready for review October 15, 2026 10:20
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 15, 2026 10:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-10-15T10:23:57.893544Z c50aa7c Draft marked ready
ℹ️ 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.

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

ℹ️ 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 on lines +158 to +163
let rawReset = weekly?.resetAt ?? quota.weeklyResetAt;
if (rawReset === undefined && provider !== "google-antigravity" && provider !== "anthropic") {
// Providers without a weekly cadence: prefer an explicitly 5h-labeled window before
// falling back to first-window order.
const fiveHour = windows.find(w => /5h|five/i.test(w.label)) ?? windows[0];
rawReset = fiveHour?.resetAt ?? quota.fiveHourResetAt;

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 Include monthly rollover evidence in reset-first ranking

When reset-first is enabled for Kiro—or for monthly-only xAI/Cursor quota responses—the strategy silently degenerates to headroom ordering: those quota readers store the known rollover in monthlyResetAt (and Kiro also exposes it through kiroAccountEvidence), but this selector only considers weekly, five-hour, and custom-window timestamps. Consequently every healthy Kiro candidate receives an infinite reset rank in both proactive selection and 429 rotation, so the advertised strategy never prefers the account that actually resets first. Include valid monthly/account-bound reset evidence among the candidate deadlines.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 15, 2026
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration into dev (MAINTAINERS.md dev maintainer-integration policy; batch integration authorized by @lidge-jun on 2026-10-15).

  • Head: 15911b6c2421777fae5c65d8235e3be11a9b9f99 (tree c9e1ba543f5fbaf833b7e9d06881ed4b91e69365) = this branch merged with origin/dev b538531bd9.
  • Exact-head evidence: GitHub-hosted Actions for this account have not been assigning runners since 2026-10-15 13:30 UTC, so by owner decision the evidence is a full bun run test (Bun 1.4.3 test runner, root and GUI dependencies installed, GUI built) of this exact tree on a maintainer host (Linux x86_64): exit 1, 7 min, 30 failing test(s), each also failing in the same host's baseline run of dev 60bf4c7 (environment-only): Codex shim install readiness > a refused install exits unsuccessfully and preserves its re, Codex shim install readiness > keeps install advisory when the Codex config cannot be read, Codex shim install readiness > the install command surfaces readiness warnings without lea, GUI pairing client > sends one bodyless origin-bound capability and redacts rejected bodie, Node launcher PATH fallback activation > broken bundle reaches validated PATH Bun, Node launcher PATH fallback activation > inspection bundle reaches validated PATH Bun, Node launcher PATH fallback activation > missing bundle reaches validated PATH Bun, a secondary ensure parent preserves shared Grok, Codex and Claude agent bytes, ….
  • Local gates on the same tree: bun run typecheck, file-size ratchet, test-layout and structure:check.
  • Hosted CI checks for this head may still be queued; they are not claimed as evidence.

@lidge-jun
lidge-jun merged commit afd0bcf into dev Oct 15, 2026
4 checks passed
@lidge-jun
lidge-jun deleted the carry/5408-reset-first branch October 15, 2026 17:36
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.

1 participant