Repository navigation
refactor: record inline API-key failures off the main thread - #153570
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. Reviewed September 20, 2026, 6:16 AM ET / 10:16 UTC (Revision 4). ClawSweeper reviewWhat this changesMoves inline API-key failure recording and auth snapshot refreshes into SQLite workers while retaining existing cooldown rules and synchronous SDK store APIs. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains This remains useful: current main still performs inline-key bookkeeping synchronously. No actionable introduced defect was found, and the updated compatibility evidence resolves the earlier storage concern. Priority: P2 Review scores
Verification
How this fits togetherThe model retry controller records authentication and billing failures in the selected agent’s auth store. Persisted cooldown state then feeds runtime snapshots used for subsequent model selection. flowchart TD
A[Model authentication or billing failure] --> B[Retry controller]
B --> C[Selected agent write admission]
C --> D[SQLite worker transaction]
D --> E[Persisted cooldown state]
E --> F[Runtime snapshot publication]
F --> G[Subsequent model selection]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +664, Tests +647, Docs +7, Other +2. Total +1320 across 23 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep failure recording under the existing agent database owner, sharing cooldown calculation and serialization while preserving committed outcomes through snapshot or cleanup failures. Do we have a high-confidence way to reproduce the issue? Not applicable as a user-facing bug reproduction: this is an internal scheduling refactor, and current-main source confirms the synchronous path it replaces. Is this the best way to solve the issue? Yes. Reusing the existing agent executor and shared state reducers preserves one persistence owner without adding configuration, a parallel public API, or a new data format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2889a999b1eb. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
…w#153570) * refactor: record inline API-key failures off the main thread * refactor: keep shared auth SQLite builder internal * fix: preserve inline auth worker settlement and validation
Related: #152286
What Problem This Solves
Inline API-key auth and billing failures still read, update, and republish auth state with native SQLite work on the calling thread during model retry handling.
User Impact
The retry controller records inline-key failures through the selected agent's existing SQLite worker, preserving cooldown behavior, scoped CLI auth state, and the synchronous public SDK APIs. This changes where bookkeeping runs; it does not claim faster retries. No configuration, schema, migration, or updater change is required.
Why This Change Was Made
The existing agent owner captures admission before waiting, rereads authoritative state inside its transaction, and publishes committed facts before the next admitted operation. Host snapshots use canonical worker reads and retain current resolved secrets and external profiles. Closing a queued owner rejects the write. Once a commit is acknowledged, publication, observer, or cleanup failures cannot make that write replayable, and a failing observer cannot leave sibling snapshots exposing an older cooldown.
Failure calculation, JSON-cell writes, and snapshot composition remain shared with the retained synchronous paths. The old inline timeout test's generic-updater mock is replaced by actual retry-controller state checks. Existing billing tests now use the required host-owned worker lane and await native cleanup before removing their state. A required preexisting prepared-runtime fixture uses its already-reviewed lifecycle factory with unchanged assertions.
Evidence
Data-model compatibility, addressing the review note: both SQLite schema files and their version declarations are byte-identical to the PR base.
AUTH_STORE_VERSIONremains 1, and the state serializer and persisted-store reader are unchanged. The adapter change extracts the same table/key/column DML into a shared helper; it introduces no schema or format migration. The real-controller round trips seed existing-format stores, write through the worker, and read them with the unchanged reader while checking credentials, order, last-good, and sibling state. Empty-store creation, legacy-main ownership, and a relocated shared base are covered too.A single identical-input scoped/empty-store test-harness comparison passed on both versions: baseline 130.50 seconds / 3,485,335,552 bytes maximum RSS; worker candidate 99.29 seconds / 3,160,997,888 bytes. These are whole-harness observations, not production latency or isolated-allocation measurements. These historical matched-input observations describe the initial worker conversion; later settlement and validation repairs were verified separately.