Skip to content

fix: defer Codex ticket gate to authoritative scheduler account - #188

Merged
HTExplicit merged 1 commit into
mainfrom
fix/scheduler-ticket-authoritative-gate
Sep 19, 2026
Merged

HTExplicit merged 1 commit into
mainfrom
fix/scheduler-ticket-authoritative-gate

Conversation

@HTExplicit

Copy link
Copy Markdown
Owner

Production request 5d66478e-14ec-4335-894c-000e893ef31c failed selection with pool=4, runtime_blocked=4 even though accounts 16376, 16378, and 16379 had valid 292 tickets. The load-aware and advanced scheduler candidate loops evaluated the credential-bound Codex ticket gate against the partial scheduler snapshot. That projection intentionally drops codex_turn_ticket:* and the OAuth identity credentials (chatgpt_account_id, chatgpt_user_id, organization_id, email), so fail_closed=true treated valid tickets as missing and excluded every ticket-capable account before the authoritative account was hydrated.

Split the runtime-block check into an authoritative gate and a projection-safe candidate gate. The candidate gate keeps persisted cooldowns, model limits, runtime breaker, Cindy state, and every other projection-safe veto, but defers Codex ticket validation to the existing resolveFreshSchedulableOpenAIAccount / recheckSelectedOpenAIAccountFromDB path. Both the legacy load-aware and advanced scheduler candidate loops use the candidate gate; every final selection still rechecks the full account with the authoritative gate, preserving exact-292 validation, owner binding, and fail_closed.

Startup ticket seeding now refreshes the authoritative scheduler snapshot for every still-valid stored ticket, so a restart cannot leave a durable ticket invisible to the full-account cache. Scheduler metadata still does not receive ticket material; no API, DTO, database migration, frontend, proxy, or production setting changes are included.

Validation: new unit tests cover candidate-versus-authoritative behavior for missing, expired, wrong-principal, and wrong-length tickets, plus successful selection through both legacy load-aware and advanced scheduler paths while fail-closed remains effective for ticketless accounts. The repository integration test verifies startup seeding refreshes the full scheduler snapshot. TestOpenAI* unit tests, go vet, and integration-test compilation pass locally; the normal Linux PR checks will execute the PostgreSQL integration suite.

@HTExplicit
HTExplicit merged commit c53441f into main Sep 19, 2026
16 checks passed
@HTExplicit
HTExplicit deleted the fix/scheduler-ticket-authoritative-gate branch September 19, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant