Repository navigation
feat(accounts): explicit health-gated resume, and login that clears an automatic pause - #8515
Conversation
… automatic pause Owner decision on #8398: resume stays explicit. `ocx account resume <provider> <id> --if-healthy` resumes a paused Codex pool or Anthropic OAuth account only after a fresh read of that account's own usage succeeds, refuses the two permanent reasons without a read, never refreshes a paused credential, and commits only if the probed credential and pause revision are unchanged. A refused resume is 409 resume_refused with a closed reason and exits 3. An explicit login or reauthentication now clears a pause that auto-pause recorded (one with pauseDetails) for the account whose credential it replaced; an operator pause stays. Closes #8398
…c pause Anthropic routing drops its quorum cache and session affinity, and generic failover its presence count, on a pause change. A login that cleared an automatic pause changed eligibility without that publication, so routing could keep treating the account as paused until its cache aged out. Refs #8398
…rity review) - Only an explicit reauthentication clears an automatic pause: saveAccountCredential takes clearAutomaticPause, which runLogin's reauth branch sets; Kiro's pre-login identity binding, which writes without the operator naming the account, now leaves the pause in place. - --if-healthy on an account that is not paused when checked answers 200 unchanged without a write, so a pause that lands meanwhile is never cleared without a health read. - A Codex resume also resumes linked accounts; a permanent reason on any of them refuses it. Refs #8398
…n to a cleared import (#8398 review) - The Codex health-gated resume rechecks the pause and its revision inside the pause-group callback, right before the write, so an operator re-pause during the claim wait is kept. - A local-cli Anthropic import that clears an automatic pause takes a selection parked on a paused row, as reauthentication already did. - Tests for a credential replaced mid-read, a stale resume guard, a Codex re-pause mid-read and a Codex needs_reauth verdict; the operator-pause relogin case now asserts the revision is kept. Refs #8398
|
✅ Deterministic PR hygiene checks passed. |
|
Maintainer judgment
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed567532f6
ℹ️ 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".
| runtimeConfig = getRuntimeConfig(config); | ||
| if (!isCodexAccountPaused(runtimeConfig, id) || runtimeConfig.codexAccountPauseState?.[id]?.revision !== healthPauseRevision) { | ||
| return jsonResponse({ error: "account was not resumed: account_changed", code: "resume_refused", reason: "account_changed", id }, 409); |
There was a problem hiding this comment.
Recheck the probed credential generation before resuming Codex
If the pool credential changes after the health probe succeeds but before the pause-group callback runs, this check still permits the resume because it verifies only the pause revision. withCodexAccountPauseGroup crosses an asynchronous native-main claim boundary, while concurrent account-list probes can refresh pool credentials without changing their pause revisions. The successful verdict discards freshCredentialGeneration, so the endpoint can return success and unpause a credential other than the one whose usage read succeeded. Carry the probed generation in the verdict and recheck isCodexAccountGenerationLive here immediately before clearing the pause, returning account_changed if it moved.
Useful? React with 👍 / 👎.
Summary
A paused account stayed paused until someone ran
ocx account resumeby hand, even after the provider-side cause was fixed (#8398). An unattended supervisor had no safe way to resume, and a re-login after renewing a subscription did not clear the pause. The owner chose explicit resume only, with no background auto-resume.ocx account resume <provider> <id> --if-healthyThe server resumes only after a fresh read of that account's own usage succeeds:
/api/oauth/usageread with the stored, unexpired token. It publishes no quota or routing evidence for the still-paused account.What it refuses or never does:
oauth_organization_disabledandaccount_permission_deniedare refused without a read.credential_expiredand a new login is the way back.health_check_unsupported; the CLI rejects the flag for API-key pools.Race protection:
unchangedwith no write.A refusal is 409
{ code: "resume_refused", reason }. The CLI prints<provider>: <id> not resumed: <reason>(or{ "ok": false, "resumed": false, "reason": ... }with--json) and exits 3, so a supervisor can tell "still unhealthy" from a failed command.An explicit login clears an automatic pause
An explicit login (
saveCredentialWithReceipt) or reauthentication of a paused account clears a pause that auto-pause recorded (one withpauseDetails), because that evidence described the credential the login replaced. It then publishes the pause change, so Anthropic routing drops its quorum cache and session affinity and generic failover its presence count. It also takes over a selection parked on a paused row. The Codex reauthentication branch does the same. A pause an operator set by hand stays.saveAccountCredentialclears only withclearAutomaticPause, which onlyrunLogin's reauthentication branch sets, so Kiro's pre-login identity binding leaves a pause alone.Review notes left as follow-ups (non-blocking, from the final review):
explicitRefresh, which can refresh a paused pool credential. That is the existing explicit-refresh behavior, used only on an operator command.Closes #8398
Verification
needs_reauth) cover guards that already existed.bun test tests/oauth tests/codex-integration/codex-auth-api.test.ts tests/codex-integration/codex-resume-if-healthy.test.ts tests/codex-integration/codex-linked-account-pause.test.ts tests/cli/cli-account-pool-verbs.test.ts tests/cli/cli-account-alias-target.test.ts tests/server/anthropic2-management.test.ts tests/providers/api-key-auto-pause-distribution.test.ts tests/responses/responses-account-auto-pause-wire-owner.test.ts: 1,665 pass, 1 skip, 0 fail (67 files) on the final head.bun run typecheck: no type errors in 2,399 files.bun run structure:check,bun run skill:surface:check,bun run privacy:scan: pass. Layout guards, the file-size ratchet (codex-auth-api.test.tsstays at its 6,549-line cap), the Lab core boundary andskill-ocx: 78 pass.bun run test:changedto completion. Two delegated lanes were running their own suites in parallel worktrees and the run did not finish in reasonable time, so the import-connected coverage above was run on the final head instead. Fullbun run testand macOS/Windows CI were also not run (the latter is a manualdevbatch only). The PR's Ubuntu CI covers the rest.Checklist