Repository navigation
feat(corch-14): built-in account quota source - #550
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 943923ea2a
ℹ️ 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".
| } catch (err: any) { | ||
| return { ok: false, reason: `network_error: ${err?.name ?? 'error'}` } | ||
| } | ||
| if (!res.ok) return { ok: false, reason: `http_${res.status}` } |
There was a problem hiding this comment.
Preserve valid quota headers on rate-limited responses
When the probe receives HTTP 429 with valid unified utilization headers, this return discards the reading before parseUnifiedHeaders runs. Rate limiting is precisely when the hub needs the exhausted-account reading: pollAndSendSlotQuota sends no report on failure, so evaluateAccounts can continue treating the previous below-ceiling snapshot as eligible until its 10-minute TTL expires, allowing new work to target an exhausted account. Anthropic documents 429 as a rate-limit response. Accept valid quota headers from 429 responses while continuing to reject responses without usable windows; an injected 429 with 100% utilization currently reproduces the dropped report.
Useful? React with 👍 / 👎.
…t their own usage) The orchestrator no longer depends on a separate usage app. A slot supervisor (REMO_ACCOUNT_SLOT + its account token) polls its own account by reading the unified rate-limit headers of a minimal /v1/messages call and sends a slot_quota_report frame. The hub stores it in corch_quota_accounts through the existing store function, only for the connection's own registered slot. - supervisor: usage/slot-quota-poll.ts, wired into HubClient on auth_ok - hub: slot_quota_report schema, corch/slot-quota.ts, supervisor handler - POST /api/quota/snapshot unchanged and now optional (runbook item 1) - eligibility rules unchanged Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…terval ceiling; 429 readings Live probe (2026-11-17) returned 200 with the 7d headers and no 5h headers, so requiring both would have left such an account with no reading. A null 5h is sent instead (unknown, never 0; the hub caps it at one run). Also from the phase verifier: clamp the interval below the hub staleness TTL, accept a 429 that carries the windows, cancel the unread body, fix the CLAUDE.md docs map. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
8fcd52b to
c7d6877
Compare
|
Zero Exposure did not auto-merge this PR. Blocking reason: auto-merge blocked: not eligible -- diff classifier: hub/src/corch/slot-quota.ts: potential flag/safety change: identifier-shape heuristic matched "enabled" added with a truthy value and no removed counterpart to pair against; semantic effect unverified; requires review: enabled: true,; diff classifier: hub/test/corch-slot-quota.test.ts: potential flag/safety change: identifier-shape heuristic matched "enabled" added with a truthy value and no removed counterpart to pair against; semantic effect unverified; requires review: source: 'live', enabled: true, blocked: false,; diff classifier: supervisor/src/usage/slot-quota-poll.ts: cron/cadence literal or identifier changed (an outbound-send-rate change): /** The hub treats a reading as stale 10 min after it was received, so the cadence must stay well inside that. */; diff classifier: supervisor/test/slot-quota-poll.test.ts: potential flag/safety change: identifier-shape heuristic matched "ignored" added with a truthy value and no removed counterpart to pair against; semantic effect unverified; requires review: return new Response('{"ignored":true}', { status: 200, headers: FULL }) Reviewed commit: |
CORCH-14: built-in account quota source
The orchestrator now reads per-account Claude usage itself. No separate usage app, release or
quota:publishkey is needed for the cutover.What changed
supervisor/src/usage/slot-quota-poll.ts, wired inhub-client.ts): a slot supervisor (REMO_ACCOUNT_SLOTset and holding its account token) polls onauth_okand everyREMO_SLOT_QUOTA_INTERVAL_MS(default 300000, floor 60000). It sends a minimalmax_tokens: 1/v1/messagescall and readsanthropic-ratelimit-unified-{5h,7d}-{utilization,reset}. The long-lived slot token gets 403 from/api/oauth/usage(nouser:profilescope), so the headers are the only source. The token is only the Authorization header: never logged, returned or framed; the body is never read. Desktop supervisors never run it./ws/agentframeslot_quota_report(percentages 0..100, ISO resets,fetched_at).hub/src/corch/slot-quota.ts, handler inws/agent.ts): accepted only when the reporting connection registered that exactaccount_slot; a reading dated more than 120s ahead is dropped. Upsertscorch_quota_accounts(account_id = slot,source = 'live') through the existingquotaStore.upsertSnapshot, then the same queue push and dispatch evaluation as the HTTP ingest. Stored with the CORCH flag OFF too.POST/GET /api/quota/snapshot, scopes andquota-eligibility.tsare unchanged. No schema change.docs/corch.md(new section),docs/corch-linux-slots.md,docs/corch-enable-runbook.md(item 1 is now OPTIONAL),CLAUDE.md.Tests (run locally, all pass)
supervisor/test/slot-quota-poll.test.ts(header parsing boundaries, gating, token never in results)supervisor/test/corch-slot.test.ts(slot sends oneslot_quota_reporton connect, non-slot sends none, no frame carries a secret)hub/test/corch-slot-quota.test.ts(schema, own-slot only, future-dated, eligibility with unchanged rules)hub/test/corch-no-token-guard.test.ts,corch-quota-eligibility.test.ts,corch-quota-ingest.test.ts,supervisor/test/corch-slot-image.test.tsstill passtsc --noEmit: no new errors in hub or supervisor versus mainNot proven here
🤖 Generated with Claude Code