Skip to content

refactor(auth): await stored credential preparation - #169111

Merged
steipete merged 54 commits into
mainfrom
dbasync/sdkasync-auth
Oct 11, 2026
Merged

steipete merged 54 commits into
mainfrom
dbasync/sdkasync-auth

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Credential preparation and provider capability selection still force Gateway callers through synchronous SQLite-backed auth helpers, even though their owner already supports worker reads.

User Impact

Bundled model, media, speech, realtime voice, TTS, setup, and credential preparation now await the auth owner. Existing Plugin SDK synchronous contracts remain available, deprecated, and emit migration warnings; plugin authors can adopt the documented async replacements without a flag day. Final credential, execution, disclosure, and deletion authority checks remain at their real effects.

Why This Change Was Made

Use the existing worker-backed auth reader and atomic writer, propagate asynchronous preparation through bundled callers, and keep one auth policy owner. The canonical loader retains its exact canonical-versus-overlay behavior. Atomic profile upserts preserve neighboring profiles instead of writing back a caller-read snapshot. Provider selection preserves explicit/profile/environment precedence and existing synchronous external provider hooks.

Discord voice prepares the provider once per room while keeping each speaker bridge creation synchronous so the first PCM chunk is retained. Talk revalidates requester authority immediately before opening its transcription relay after asynchronous provider preparation. Comfy and OpenAI retain their provider-specific synchronous readiness hooks for external compatibility callers while bundled callers await their async peers. Async compatibility peers are documented in docs/plugins/sdk-migration/how-to-migrate.md; retained synchronous SDK APIs are explicitly deprecated rather than silently changing their return types.

Native run preparation now receives the committed writer-claim row instead of its pre-queue snapshot. Scoped OAuth refresh validates the shared credential once, then each waiter validates its own requested account after awaiting it. Prompt snapshot generation awaits the async builder while retaining a deterministic clock; no intentional prompt-byte change.

Removed ordinary checks and accepted edges:

  • Native web-search selection no longer reloads credentials already prepared by its owner. A later credential change is handled by the final request/credential boundary.
  • xAI fallback no longer rereads and refilters the same auth store during preparation. A concurrent change may affect the next preparation; the final credential check remains.
  • Profile upsert no longer performs caller-side read-modify-write. The existing writer owns the atomic profile mutation, retaining unrelated profiles.
  • Runtime auth reads no longer reject a captured selection merely because a concurrent refresh changed selection metadata. The next read uses write-receipt invalidation; real credential, removal, and worker-lifetime guards remain. The obsolete selection wait/retry plumbing and tests were removed.
  • Web-search candidate selection consumes an explicitly supplied or published auth snapshot instead of selecting once, loading it again, and selecting again. A later update is observed by the next owner preparation.
  • Media model assembly no longer repeats readiness checks after admitting each provider. A provider may become unavailable after preparation; generation resolves current credentials and reports that outcome at execution.

Explicit remaining owner follow-ups: config-health async caller-chain migration using the existing read/patch owner; async initialization of the placement factory using its existing listAsync; live verbose callbacks and published settings; and a physical-target auth batch/rollback operation. These are owner migrations, not schema blockers. Incognito belongs to its actor lane, while the following session/config PR migrates the TTS machine-preference resolver. Released synchronous compatibility APIs and genuine effect-authority checks remain distinct exceptions. No schema, retention, permission, or durability policy change is included.

Evidence

Current source is 8286e5eeae59170f5a8fcc091e8d8db34275c5ce, with main 2c543afc5ec2f8aea8ad9753f9a06d941967fdca as its integrated base. The landed skills commit eed70eeb06935dc16f0a008dad5e8d8ceeb212bf remains an ancestor. This PR excludes that landed implementation. Size: 490 files, +6,522/−4,596 lines; most caller edits propagate await and update matching mocks.

The integrated SDK budgets are 3,688 public exports, 2,149 callables, and 176 deprecated exports. Main contributes one preview-response helper on top of the previously verified 3,687/2,148/176 auth surface. Relative to the integrated main base, this lane still adds 15 async replacement pairs and 15 deprecations. All 15 added public callables have documented deprecated synchronous counterparts. Surface and runtime API checks pass on the integrated, production-equivalent 67776b9 source. Its SDK API diff passed in 337 seconds: 225 affected exports (202 reachable changes, 15 additions, 8 direct signature changes), with no public entrypoint added or removed. Report digest: f0ffac152bb416d9a8af752de7c0699eec822c3420c23fdefce50c3251651640.

Global lexical T1 remains 215 files / 612 calls → 215 files / 612 calls (forwarding-normalized 610→610). The auth kernels retain 6 expressions, 4 in sqlite-json and 2 in sqlite, for compatibility and final-authority implementations. This is not a zero-T1 claim. The worker and dialect ratchets pass, with no added dialect constructs; the canonical inventory is regenerated in this final head (629 files / 2,412 calls, including one inherited worker call; T1 remains 215 files / 612 calls). Madge passed in 19 seconds. Nine unused internal exports were removed in the final cleanup, including obsolete Talk/TTS test surfaces; no public SDK surface was removed. Final cleanup and conflict-owner validation are pending.

The required main integration preserves the incoming async user-profile link list and runtime-auth changes together with this lane’s awaited store initialization and types. The SDK budget conflict retains both main’s new preview helper and the 15 auth replacement pairs. Three conflict-owner tests are queued with the proof owner.

Two independent Codex review rounds completed and accepted findings were fixed; no third review was requested. The Talk requester guard and synchronous Comfy/OpenAI readiness contracts were restored with regressions. loadAuthProfileStoreForRuntimeAsync preserves explicit environment scope. The parallel media preparation tuple retains its three distinct result types.

Behavior proof: 22 Gateway files / 464 tests passed. The broader 113-file replay passed 81 files, then stopped on two Codex-health broker-routing assertions, leaving 31 files unexecuted (1,012.8 seconds). After correcting fixture isolation, Comfy configuration, and broker routing, the 35-file follow-up passed 472 tests across 8 shards in 670.17 seconds, covering all 31 unreached files and the repaired fixtures. The later OAuth regression correction requires exactly one error, one null result, and one upstream refresh call instead of assuming which concurrent caller becomes the owner. Its production behavior is unchanged; final narrowed replay results remain pending here.

On exact test-corrected head a227dd3, CI run 38159889637 passed production types, all five core test-type stripes, extension/root test types, both core lint jobs, all three extension lint jobs, and source contracts. The integrated local check:changed passed production types and 26 core test graphs before the inherited UI-components error; exact-head CI provides the completed type coverage. The earlier 12 UI diagnostics were independently identical on main b5a9b9b (run 38156022678); a later configObject UI fixture mismatch is byte-identical in its test, options type, and reader on base 65414ea and auth. The one config.patch request timeout in run 38159889637 is recorded for focused qualification, not relabeled as a passing test.

The published-driver update cell passed from 2026.10.1 to candidate a227dd3: package preparation 400 seconds, update 733 seconds, /readyz HTTP 200, running version verified, durable and incognito state preserved, and the test service stopped. Later changes only narrow internal exports, update tests, and regenerate the inventory.

Final Knip/export-collision cleanup proof, the named timeout qualification, three conflict-owner tests, and three alternating shared-harness baseline/candidate pairs are pending. The measurement report will include warmed all-thread statements and requests, MAIN statements, workload totals, and auth-operation deltas before merge.

Expose async skill-command preparation through the existing SDK entries and migrate bundled Discord, Mattermost, Slack, and Telegram callers. Retain deprecated synchronous SDK methods through the next Plugin SDK major with bounded warnings.
Route bundled credential discovery, capability selection, profile writes,
OAuth preparation, and setup reads through the existing auth worker owner.
Preserve canonical versus runtime-overlay selection and current credential
checks at effects. Profile upserts preserve neighboring committed profiles.

Add async SDK peers and migrate bundled callers together. Retain deprecated
synchronous APIs and required legacy provider hooks for external consumers.
Prepare Discord voice provider facts once per room so per-speaker bridge
creation still precedes first-audio capture.

Remove duplicated native-search auth checks, xAI fallback store rereads,
and auth-owner currency checks already covered by prepared read ownership.
Document the accepted snapshot lifetimes and retained native owner gaps.

Release-note context: plugin authors should await the documented async auth,
provider-selection, and TTS APIs; synchronous contracts remain compatible
through the next Plugin SDK major. No schema or retention changes.

Validation so far: two Codex review rounds with compatibility and fixture
findings addressed; formatting and diff checks. Remote behavior/static proof
and alternating SQL measurements follow on this committed head.
@clawsweeper

clawsweeper Bot commented Oct 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.

steipete added a commit that referenced this pull request Oct 12, 2026
## What Problem This Solves

The cross-agent OAuth coordination test waits serially for three independent persisted-owner lookups while its provider refresh is blocked.

## User Impact

There is no production behavior change. The focused candidate now passes all eleven OAuth coordination cases, including the ownership case that previously timed out. This does not establish the cause of the entire historical timeout or a measured speedup.

## Why This Change Was Made

Start the copied, independent, and portable credential-owner lookups together with order-preserving `Promise.all`, registering each with the existing `AsyncWorkScope` so cleanup still joins sibling work on failure. Preserve every ownership assertion, the blocked-provider gate, and the 10-second deadline. No sleeps, retries, diagnostic hooks, production changes, or new synchronization are introduced.

The serial assertions were added by `00be4531663b` (#169111). That establishes their source provenance, not their contribution to the full timeout. Scope: one test file, +12/−9 lines.

## Evidence

Publication head `980d26386b3c30901d39bc820794df5dba582f7b` is one focused commit on `e3ec1f2eeaf6b3a24b7e17362383b3c3c6b366b3`, preserving the original reviewed preimage and postimage without diagnostic ancestry. One isolated Codex P0–P2 review found no actionable issues. Formatting, basic lint, diff checks, and normal commit hooks passed.

[Candidate CI](https://github.com/openclaw/openclaw/actions/runs/38314932510) completed successfully: **18 successful jobs, 29 skipped**, including baseline ratchets, source contracts, boundaries, selected lint, core test types, and `openclaw/ci-gate`. The focused Bun target passed **11/11** in **54.99 seconds Vitest duration / 56.95 seconds wrapper wall time**. The formerly timed ownership case took **3.611 seconds**. CI executed merge ref `c917981263d7048d5772cf1c393110da3dc06f34`, combining this head with main `e3735bccb4c5164c5ef0016248a2c09e07249840`; no local execution is claimed.

Scoped static reuse: V28 run `38311910220` executed Madge with zero cycles; this patch changes no imports or exports. V28's executed Knip scan reported only three unused Team scale exports, removed by `36e78f215f1f058af15919da8a60c06797a759e8`, already in this branch's base. Manifests, lockfile, static runners, and all-export configuration match; the production Knip configuration differs only in a comment. No exported-symbol usage is removed. This is scoped source qualification, not a fresh whole-tree Knip pass; omitted checks are not counted as passes.

The earlier V27 diagnostic composition still timed out at 13.393 seconds and had a different test blob. Its overlapping lookups completed, but later work reached cleanup. That failure is not passing evidence, and the clean candidate result does not prove a historical timing cause. No production SQL, T1, security, schema, SDK, update, or service lifecycle behavior changes; no update cell is required.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…claw#169779)

Preserve captured absence in async auth reads instead of treating normal
first database creation as replacement. Never open or adopt the new file
through the earlier read; subsequent preparations observe it. Existing-file
replacement, owner revocation, maintenance, and cleanup checks remain.

The async secrets loader in openclaw#169111 exposed the older guard. The unchanged
Gateway overlap test fails before this repair and passes afterward. A focused
reader regression fails with the same error on the original code.

Validation: six tests pass at maxWorkers=1, 141.32s command wall (reader
9.96s Vitest, new case 8ms; Gateway 114.12s). Core/agents test types,
normal and boundary lint, formatting, and independent P2 review pass.
No schema, stored bytes, permissions, migration, or update changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…170311)

## What Problem This Solves

The cross-agent OAuth coordination test waits serially for three independent persisted-owner lookups while its provider refresh is blocked.

## User Impact

There is no production behavior change. The focused candidate now passes all eleven OAuth coordination cases, including the ownership case that previously timed out. This does not establish the cause of the entire historical timeout or a measured speedup.

## Why This Change Was Made

Start the copied, independent, and portable credential-owner lookups together with order-preserving `Promise.all`, registering each with the existing `AsyncWorkScope` so cleanup still joins sibling work on failure. Preserve every ownership assertion, the blocked-provider gate, and the 10-second deadline. No sleeps, retries, diagnostic hooks, production changes, or new synchronization are introduced.

The serial assertions were added by `4aefa0f5aeb0` (openclaw#169111). That establishes their source provenance, not their contribution to the full timeout. Scope: one test file, +12/−9 lines.

## Evidence

Publication head `980d26386b3c30901d39bc820794df5dba582f7b` is one focused commit on `37ce022f37b400bb2dc836bf03797d8c7b329dfc`, preserving the original reviewed preimage and postimage without diagnostic ancestry. One isolated Codex P0–P2 review found no actionable issues. Formatting, basic lint, diff checks, and normal commit hooks passed.

[Candidate CI](https://github.com/openclaw/openclaw/actions/runs/38314932510) completed successfully: **18 successful jobs, 29 skipped**, including baseline ratchets, source contracts, boundaries, selected lint, core test types, and `openclaw/ci-gate`. The focused Bun target passed **11/11** in **54.99 seconds Vitest duration / 56.95 seconds wrapper wall time**. The formerly timed ownership case took **3.611 seconds**. CI executed merge ref `c917981263d7048d5772cf1c393110da3dc06f34`, combining this head with main `1d13b36288e5768886fa2badab13cc6830ef7a70`; no local execution is claimed.

Scoped static reuse: V28 run `38311910220` executed Madge with zero cycles; this patch changes no imports or exports. V28's executed Knip scan reported only three unused Team scale exports, removed by `2531250f65253f9d6466ee7f2d50c80184b41e42`, already in this branch's base. Manifests, lockfile, static runners, and all-export configuration match; the production Knip configuration differs only in a comment. No exported-symbol usage is removed. This is scoped source qualification, not a fresh whole-tree Knip pass; omitted checks are not counted as passes.

The earlier V27 diagnostic composition still timed out at 13.393 seconds and had a different test blob. Its overlapping lookups completed, but later work reached cleanup. That failure is not passing evidence, and the clean candidate result does not prove a historical timing cause. No production SQL, T1, security, schema, SDK, update, or service lifecycle behavior changes; no update cell is required.
holgergruenhagen added a commit to holgergruenhagen/openclaw that referenced this pull request Oct 15, 2026
Conflict in extensions/openai/image-generation-provider.ts resolved to
main's readOpenAIImageGenerationResponse path (openclaw#169111, openclaw#169714, openclaw#170278);
the route diagnostics are re-attached in the following commit.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
Both are fork-only (absent upstream), green at base dab29d6 and red at
7a537c6 (found by the scribe's Gate 2.7 run). Bisected across the lane's
first-parent commits in a spare checkout.

side-question.continuation.test.ts: first red at step 60 (4e3aee6,
upstream 2b9aa2e). openclaw#169111 made the Codex auth bridge await stored
credential preparation, which opens the shared-state store; that admission
requires the main-thread host broker, so it rejects in the threads pool
("Shared-state admission requires the host broker"). Upstream's sibling
side-question.test.ts already runs in the extension-database-workers
project; the fork split never joined it. The suite is routed there next to
its sibling. Same file, same assertions.

codex-dynamic-tool-origin.integration.test.ts: not a commit regression. The
bisect's first red (3115072) went green on a rerun and the last green
(9a3022b) went red under the same load. The run has the harness's 5 s
execution budget, and the first production tool build in a fresh worker
spends 2.6-3.0 s of it before turn/start (measured: factory 2,640 ms cold,
11 ms warm; first app-server request at 3.7 s), leaving ~0.6 s for the
simulated restart and four tool calls. The test now builds the production
tools once before the run starts, so module load stays outside the budget
(turn/start at ~0.9 s). Budget, assertions and the production tool
boundary are unchanged.

Proof at 7a537c6 + this change: both files, two runs, 2/2 files and 2/2
tests green each run, both in extension-database-workers.

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: active-memory extensions: alibaba extensions: anthropic extensions: byteplus extensions: clawrouter Extension: clawrouter extensions: cloudflare-ai-gateway extensions: codex extensions: comfy extensions: copilot extensions: deepinfra extensions: deepseek extensions: fal extensions: github-copilot extensions: google extensions: kie extensions: microsoft-foundry extensions: minimax extensions: novita extensions: openai extensions: openrouter extensions: runway extensions: together extensions: venice extensions: vydra extensions: xai extensions: xiaomi extensions: zai gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: facetime FaceTime plugin plugin: pixverse rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant