Skip to content

fix(auth): await durable OAuth refresh transitions - #145196

Merged
steipete merged 3 commits into
mainfrom
codex/async-auth-profile-storage
Sep 12, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/async-auth-profile-storage

Conversation

@steipete

@steipete steipete commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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 onto 47ce03dbc6994435af783fecf13d5586e7b307f4, 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.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 10:26 PM ET / September 12, 2026, 02:26 UTC (Revision 4).

ClawSweeper review

What this changes

OAuth 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
Reviewed head: 0c5208f694e6de7786b49a1cf1caf9906d311fa2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful durability and ownership coverage and no remaining actionable finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied maintainer classification exempts ordinary contributor proof. Inspected native-SQLite AuthStorage coverage addresses the changed publication boundary, including logout and replacement; the body reports passing runs, without claiming external provider execution. No unresolved introduced authority case requires additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer classification exempts ordinary contributor proof. Inspected native-SQLite AuthStorage coverage addresses the changed publication boundary, including logout and replacement; the body reports passing runs, without claiming external provider execution. No unresolved introduced authority case requires additional proof.
Evidence reviewed 7 items Introduced scope: The verified merge-base-to-head delta contains the refresh protocol, its AuthStorage adapter, and two regression suites. Base-only UI and provider changes are excluded from this review. The introduced diff passes the whitespace check.
Publication ownership repair: The adapter synchronously rereads authoritative storage, compares the selected provider entry, and publishes the fresh complete map. The protocol routes initial publication failure through terminal claim cleanup.
Authority and lifecycle regression coverage: The publication suite exercises AuthStorage.getApiKey with native SQLite and injected same-facade or peer logout, account replacement, unrelated-provider updates, observer settlement, and publication-read failure. Assertions cover returned credentials, runtime state, persisted state, and whether provider refresh started.
Findings None None.
Security None None.

How this fits together

AuthStorage 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +52, Tests +514. Total +566 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 84 32 +52
Tests 2 514 0 +514
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 598 32 +566

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +52 lines; tests +514 lines Production growth implements awaited transitions and authoritative publication; most added code exercises durability and ownership races.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This is a bounded OAuth storage-ordering repair without evidence of a widespread urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied maintainer classification exempts ordinary contributor proof. Inspected native-SQLite AuthStorage coverage addresses the changed publication boundary, including logout and replacement; the body reports passing runs, without claiming external provider execution. No unresolved introduced authority case requires additional proof.

Evidence

What I checked:

  • Introduced scope: The verified merge-base-to-head delta contains the refresh protocol, its AuthStorage adapter, and two regression suites. Base-only UI and provider changes are excluded from this review. The introduced diff passes the whitespace check. (0c5208f694e6)
  • Publication ownership repair: The adapter synchronously rereads authoritative storage, compares the selected provider entry, and publishes the fresh complete map. The protocol routes initial publication failure through terminal claim cleanup. (src/agents/sessions/auth-storage-oauth-refresh.ts:61, 0c5208f694e6)
  • Authority and lifecycle regression coverage: The publication suite exercises AuthStorage.getApiKey with native SQLite and injected same-facade or peer logout, account replacement, unrelated-provider updates, observer settlement, and publication-read failure. Assertions cover returned credentials, runtime state, persisted state, and whether provider refresh started. (src/agents/sessions/auth-storage.publication.test.ts:84, 0c5208f694e6)
  • Durability and deadline coverage: The async suite delays claim and settlement completion around real SQLite transactions, checks reopened durable state, and covers stalled reads, expired snapshots, and original rejection identity. The captured PR body reports 56 passing affected cases and a passing changed-code gate; this read-only review did not execute them. (src/agents/auth-profiles/oauth-refresh-fence.async.test.ts:25, 0c5208f694e6)
  • Still necessary on main and latest release: Both production files have identical pre-repair blobs on fetched main and v2026.9.4. Main still uses synchronous refresh backend results and forwards publication directly, so neither inspected revision contains this repair. (src/agents/auth-profiles/oauth-refresh-fence.ts:22, aca7954e00b1)
  • Feature-history routing: Main history connects the refresh protocol and adapter to the shared OAuth generation-fence work. GitHub commit metadata identifies vincentkoc and records the protocol file as added; raw commit inspection records parent 4e01e2f. (src/agents/auth-profiles/oauth-refresh-fence.ts:18, b824b72ce284)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-11T19:24:44.701Z sha b89ef17 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-11T19:34:58.577Z sha b89ef17 :: needs real behavior proof before merge. :: [P1] Revalidate ownership before publishing an awaited settlement
  • reviewed 2026-09-11T23:33:36.179Z sha 9c0956d :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 11, 2026 19:30
@steipete
steipete requested a review from a team as a code owner September 11, 2026 19:30
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 11, 2026
@steipete
steipete force-pushed the codex/async-auth-profile-storage branch from b89ef17 to 9c0956d Compare September 11, 2026 23:27
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@steipete
steipete force-pushed the codex/async-auth-profile-storage branch from 9c0956d to 0c5208f Compare September 12, 2026 02:20
@steipete
steipete merged commit 04aac5b into main Sep 12, 2026
179 checks passed
@steipete
steipete deleted the codex/async-auth-profile-storage branch September 12, 2026 02:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
* fix(auth): await durable OAuth refresh transitions

* refactor(auth): preserve refresh failures through promise settlement

* fix(auth): validate current ownership before refresh publication
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant