Repository navigation
fix(auth): await durable OAuth refresh transitions - #145196
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: needs maintainer review before merge. Reviewed September 11, 2026, 10:26 PM ET / September 12, 2026, 02:26 UTC (Revision 4). ClawSweeper reviewWhat this changesOAuth refresh now waits for durable storage operations and checks current credentials before publishing refreshed session state. Merge readiness✅ Ready for maintainer review This remains a useful repair absent from current main. The earlier publication-ownership finding is addressed, and no blocking defect was found in the introduced changes. Priority: P2 Review scores
Verification
How this fits togetherAuthStorage supplies provider credentials to agent sessions from OpenClaw’s SQLite auth store. The refresh protocol coordinates token rotation, persists its outcome, and updates the session’s credential view. flowchart TD
A[Session requests credentials] --> B[Read current credential]
B --> C{Refresh needed?}
C -->|Yes| D[Persist refresh claim]
D --> E[Provider refresh]
E --> F[Persist success or failure]
F --> G[Recheck current ownership]
C -->|No| G
G --> H[Publish current session credentials]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +52, Tests +514. Total +566 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one durable refresh owner, await its transitions, and publish only a freshly validated credential view while preserving the existing storage and SDK contracts. Do we have a high-confidence way to reproduce the issue? Yes, at the source and storage-boundary level: delayed backend completion exposes the unawaited protocol, and the added suites exercise publication races. No current-main runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? Yes. The patch extends the existing refresh owner, retains synchronous transaction callbacks, and adds a current-state publication check without changing credential encoding or the public backend API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aca7954e00b1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
b89ef17 to
9c0956d
Compare
9c0956d to
0c5208f
Compare
|
Merged via squash.
|
* fix(auth): await durable OAuth refresh transitions * refactor(auth): preserve refresh failures through promise settlement * fix(auth): validate current ownership before refresh publication
What Problem This Solves
Asynchronous auth storage needs the refresh protocol to await durable claims and settlements. Runtime publication must also retain the current credential owner and the latest unrelated-provider state when an awaited operation finishes.
Why This Change Was Made
Await backend reads, claims, success writes, failure fencing, and observer snapshots while retaining synchronous transaction callbacks. Before publishing an AuthStorage refresh snapshot, the existing synchronous backend rereads authoritative state, verifies the provider entry, and publishes the fresh complete map. Failed initial publication runs the existing terminal cleanup before returning.
Observation reads retain their existing absolute deadline. Native Promise settlement preserves the exact original fulfillment or rejection before that deadline, including primitive rejection reasons, without a lint suppression. Observer timeout still stops waiting without abandoning an already-owned durable settlement; this does not extend the provider timeout to initial database admission.
User Impact
Credential publication follows durable persistence and current ownership. Completed logout and account replacement remain reflected in runtime state, unrelated-provider updates survive publication, and failed publication leaves the refresh claim settled. SQLite schema, credential encoding, namespace, provider timeout scope, and public SDK contracts are unchanged.
The AuthStorage compatibility backend and its final authoritative publication read remain synchronous. This repairs the awaited protocol handoff; it does not move all auth SQLite execution into workers.
Evidence
The final candidate has 56 passing cases across the async fence, generation fence, AuthStorage refresh, and AuthStorage publication suites. These use isolated synthetic state and native SQLite through the production AuthStorage entry points, with synthetic provider credentials and callbacks. They cover normal refresh, observer completion, current facade/persisted state, unrelated-provider preservation, failed publication cleanup, and rejection identity. Source hashes were captured before and after the run and remained identical. The full changed-code gate also passed on the refreshed main composition with identical before/after source hashes, including core/test types, lint, all Knip scans, storage guards, and zero runtime import cycles.
The original suppression repair separately passed 44 behavior cases plus all four cases in the actual CI suppression owner, with its allowlist unchanged. The existing native SQLite ordering/reopen proof remains applicable to that prerequisite. The final production repair and tests are reviewed together in the index and working source; a fresh isolated Codex review through P2 reports no actionable findings.
No real credentials, external provider calls, Gateway restarts, or schema migrations were used. This is native storage/lifecycle boundary proof, not a claim of an external provider round trip or complete auth worker migration. Exact-head hosted CI and native preparation remain required for landing.
Validated head:
0c5208f694e6de7786b49a1cf1caf9906d311fa2, rebased patch-identically onto47ce03dbc6994435af783fecf13d5586e7b307f4, which includes the shared UI repairs from #145415. All four authored file hashes and the three-commit range-diff are unchanged. All 56 affected cases and the full changed-code gate pass on this composition; exact-head hosted CI remains required for landing.