Repository navigation
refactor(runtime): prepare config, auth, and session facts asynchronously - #169714
Merged
Merged
Conversation
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/agents/auth-profiles/upsert-with-lock.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # docs/reference/database-schemas/worker-access.md # scripts/database-worker-inventory.mjs # src/state/openclaw-state-db-read-admission.test.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/config/sessions/session-accessor.sqlite-projection.ts # src/config/sessions/session-lifecycle-projection.worker.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/agents/subagents/registry/subagent-registry-read-snapshot.ts # src/cron/isolated-agent/run-subagent-registry.runtime.ts # src/cron/run-continuation-cleanup.ts # src/cron/session-reaper.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # extensions/qa-lab/src/providers/shared/auth-store.ts
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
# Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
steipete
added a commit
that referenced
this pull request
Oct 13, 2026
* fix(doctor): prepare runtime config before plugin health checks Publish the prepared Doctor config through the existing runtime snapshot owner before health contributions register plugins. Preserve an existing process snapshot and keep strict runtime readers intact. Fixes the regression from #169714 exposed by standalone Doctor after updates. Add real plugin-registration regression coverage and document the standalone update flow. * docs(doctor): retain post-update guidance after runtime fix The equivalent runtime preparation fix and regression landed in #170445. Remove this branch’s overlapping implementation and test so the PR only adds its standalone Doctor documentation clarification. Keep the original update proof in the PR body. Co-authored-by: Peter Steinberger <[email protected]>
This was referenced Oct 13, 2026
Open
This was referenced Oct 13, 2026
This was referenced Oct 16, 2026
This was referenced Oct 17, 2026
This was referenced Oct 24, 2026
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Several bundled runtime paths still reached synchronous SQLite through otherwise asynchronous owner APIs. This moves ACP metadata, model-catalog discovery, credential preparation, native binding checks, Reef trust reads, and managed-plugin install-ledger preparation onto existing workers or committed owner facts. It removes repeated ACP and Claw provenance reads while preserving current authority at credential, command, consent, disclosure, and other real effects.
This is the third misc-owner slice; #169631 and #169633 are already landed. The final comparison isolates this slice against integrated main
64400ffa0503af72fc7cd089fedc8aa427342802. The source and result pins, source-call inventory, shared read families, and CI evidence are recorded below.Owner changes
readAcpSessionMetaForEntryAsyncuses the existing batched metadata worker. Session patch preparation reads only when a runtime-sensitive field needs metadata, then shares that result across validation.sessions_sendreuses its prepared target metadata and reads again only when it actually creates a different target. Agent preflight, runtime-session creation, export, status, Discord binding lifecycle, and Telegram reconciliation await the same reader. Lifecycle matching happens in the worker; bound metadata requires matching entry identity, while unbound metadata retains its existing read contract.ModelRegistry.createAsync,refreshAsync, andunregisterProviderAsyncread persisted plugin catalogs through the existing catalog worker. Prepared catalogs usefromCapturedSources; session forks retain their immediate in-memory behavior. Runtime discovery and session reload await the async path, and refresh clears normalized lookup results. The internal synchronousdiscoverModelspath is deleted; every bundled caller and its fixtures now usediscoverModelsAsyncor already captured sources. Legacy disk-backed SDK methods remain deprecated and supported.runAuthProfileStoreUpdate. Rollback changes only entries still owned by that attempt, preserves intervening neighboring writes, and is awaited before recovery continues.AuthStoragegains worker-backed creation, reads, writes, and reload; login and OAuth settlement await publication. CLI credential fingerprints, auth display paths, model-auth labels, setup inference, and QA fixtures use awaited preparation. Explicit QA state roots remain isolated. The OpenAI image provider drops its duplicate synchronous readiness callback.readAsync. Legacy external binding adapters retain their synchronous callback with a migration warning.listCurrent. Deprecated hooks remain for released hosts without async hooks; an async failure does not fall back to the native path.readPersistedInstalledPluginIndexInstallRecordsreader is deleted, and every internal caller, including update/Doctor and lifecycle fixtures, now awaitsreadPersistedInstalledPluginIndexInstallRecordsAsync. This removes that reader, not all native recovery or inspection contracts in the shared owner.getRuntimeConfigconsumes the prepared snapshot and no longer falls through to a cold synchronous load. Long-lived bundled startup paths await the existing config preparation owner; 64 ordinary CLI reads await the same captured async reader and preserve their validation options. The only retained direct cold reads are the offline CLI custody getter, Doctor session target discovery, and migration context, all one-shot process boundaries. The SDK's released getter retains its cold-load contract behind an explicit deprecation;readRuntimeConfigis the prepared-only replacement.Removed checks and accepted edges
No new fencing protocol, foreign-commit probe, schema, retention rule, or durability mode is introduced. Size-limiting SQL JSON projections are unchanged.
SDK migration
Await these replacements before dependent work. Deprecated APIs remain available until removal in a later stable release after deprecation ships.
agent-sessionsModelRegistry.createawait ModelRegistry.createAsync;fromCapturedSourceswhen catalogs are already preparedagent-sessionsModelRegistry.refreshawait refreshAsync()agent-sessionsModelRegistry.unregisterProviderawait unregisterProviderAsync(name)agent-sessionsAuthStorage.create,AuthStorage.forAgentawait AuthStorage.forAgentAsync(agentDir, config)agent-sessionsAuthStorage.reload,set,remove,logoutreloadAsync,setAsync,removeAsync,logoutAsyncagent-runtimeloadAuthProfileStoreForSecretsRuntimeloadAuthProfileStoreForRuntimeAsyncwithreadOnly: trueandallowKeychainPrompt: false; internal secret callers useloadAuthProfileStoreForSecretsRuntimeAsyncagent-runtimesaveAuthProfileStoreawait updateAuthProfileStoreWithLock(...)fromprovider-auth; mutate only the intended current rowsresolveAuthStorePathForDisplayresolveAuthStorePathForDisplayAsync; the released SDK getter remains deprecated, and the internal replacement is not newly exported fromagent-runtimeresolveAuthStatePathForDisplayresolveAuthStatePathForDisplayAsyncacp-runtimereadAcpSessionEntryreadAcpSessionEntryAsyncsession-catalogupsertSessionUpstreamLink,deleteSessionUpstreamLinkupsertSessionUpstreamLinkAsync,deleteSessionUpstreamLinkAsyncNativeSessionBindingStateStoreV2.assertLeaseCurrentcustom SQL callbackwithCurrentbacked byapi.runtime.state.openKeyedStoreV2; canonical leases derive current facts from receiptsresolveAllowFrom,describeAccount,resolveDmPolicyresolveAllowFromAsync,describeAccountAsync,resolveDmPolicyAsyncruntime-config-snapshot,memory-core-host-runtime-coregetRuntimeConfigreadRuntimeConfigfromruntime-config-snapshotfor prepared reads;await captureRuntimeConfigAsyncReader()()at a cold boundaryThe only new public callable exports are
runtime-config-snapshot.readRuntimeConfigandcaptureRuntimeConfigAsyncReader. Internal auth-display and secret-runtime helpers are not newly re-exported. The task-authorized deprecate-and-replace migration requires exact authored allowances of +2 public exports / +2 callable / +4 deprecated, with per-entry deprecation allowances forruntime-config-snapshotandagent-runtime. The authored source limits increase only for these replacements; generated shipped-surface inventory is unchanged. The four public deprecations areruntime-config-snapshot.getRuntimeConfigandagent-runtime.loadAuthProfileStoreForSecretsRuntime,saveAuthProfileStore, andresolveAuthStorePathForDisplay; thememory-core-host-runtime-coregetter is local-only.The actual SDK surface cap passed on
f53c0078in Workflow Sanity 38273557824, job 114893468444: 154 public entrypoints, 3,712 exports, 2,167 callable, and 190 deprecated, with no unauthorized v2026.10.2 removals. This executed the generated surface cap rather than relying on a skipped automatic job. The earlier SDK API diff passed with the two authored exports, separately from the cap; final static evidence follows below. Later changes are fixture repairs and main integration.Async-created
AuthStorageinstances reject synchronous mutation/reload methods with the replacement name. Existing synchronous instances preserve immediate completion.get,list, andhasconsume the prepared local view; credential resolution refreshes and checks the owning source before use. Captured model registries keep immediate in-memory extension registration/removal.T1 and retained native boundaries
Exact-source scans compare base
64400ffa0503af72fc7cd089fedc8aa427342802with production source38be4769d117583a84514951b24dfe3d8d6e3724. Subsequent authored repairs change tests, test support, shrink-only mock baselines and generated inventory. Main integration is identified separately from these exact-source measurements.Both measured-source scans contain 626 files and 2,386 primitive call expressions. The single T1→worker classification change is
src/acp/runtime/session-meta-keys.ts(3→2 T1, 1→2 worker), from migrating its ordinary caller path. The kernel source bytes are unchanged. The committed base inventory was stale (496 T1, 1221 worker, 2384 calls); correcting that document is not claimed as a saving.The final canonical generator on the integrated
3df58d7fproduction tree reports 624 files / 2,384 call expressions: 481 T1, 2 compatibility, 412 T2, 261 T3, and 1,228 worker calls. Its document refresh is +46/−46. Those current-main/classifier counts are separate from the exact measured M494/C493 comparison and are not attributed wholesale to this PR. Subsequent authored repairs change test fixtures and delete one unused test-only downgrade helper; they do not change these measured production paths.This slice does not reach zero T1 in the original lane; the inventory still includes the retained native and SDK paths below.
The initial observation of nonportable, unfenced OAuth credentials remains synchronous before the first yield. A queued batch compares its original observation with the credential held at commit; observing only after an await can mistake a rotated credential for its starting state and restore a consumed generation. API keys, static tokens, portable OAuth copies, and fence records skip this observation. Current local/inherited credentials come from the worker transaction, so the post-lock native reread is removed. Queued-refresh regressions cover this boundary.
Native credential removal, credential-attribution/disclosure checks, and deletion commit guards remain. Codex retains synchronous reads for actual tool/command/disclosure and native ownership boundaries or legacy adapters; prepared reads do not authorize a later effect. This slice does not port or claim a saving for incognito-native paths; that cutover belongs to the dedicated removal lane.
The caller audit found no additional ordinary bundled durable MAIN path in health config, proxy capture, skill selection, pairing, managed workspaces, ambient session-state events, trajectory, or progress cards. Config policy readers disable health observation; remaining synchronous skill callers do not supply library selections. Bundled proxy, workspace, prompt, compaction, and harness callers use async APIs. Retained kernels serve deprecated adapters, CLI/maintenance, incognito, or native atomic reset. Board writes with cross-physical, nonphysical, or explicitly native source authority still execute through the native transaction path; target-only worker admission cannot validate the source, and a source-owner publication contract is the remaining cutover prerequisite. Same-physical source predicates use the worker.
Live SQL measurement
The unchanged shared harness ran against isolated state. One additional pair was required because the earlier
0644d3a7→2d1972fepair was ambiguous: warm SQL means were 411.8 → 406.8 and requests 101.2 → 98.3, but actor hydration rose by 5, row-fact SELECTs by 3, and watermark SELECTs by 1 over ten turns. Those increases were retained in the analysis rather than waived as noise. Both runs completed all 13 turns, child execution, cron, compaction, and shutdown, with warm MAIN at zero. The additional pair uses the integrated production source and the same instrumentation.64400ffad6b8512eBoth runs passed all 13 turns, child execution, cron, compaction, RPCs and shutdown. This is a worker/API cutover, not a demonstrated deterministic warmed-turn speedup: paired-turn median deltas were only −5.5 statements and −1 request, and work moved between startup and later phases.
The cutover's warmed owner operations are unchanged: ACP metadata is 20 requests / 10 statements, auth-profile rows 30 / 30, and plugin-state entries 30 / 30 on both sides. The scheduled plugin-catalog snapshot write ran once on the baseline warm sequence and in a different phase on the candidate. Generic source/cache/vector publication accounts for most raw warm reduction; some of that work moved into the first turn.
Cold-workload tradeoff: five extra exact-entry SELECTs and two extra actor hydrations remain attributed to the candidate. Exact-entry requests rise by five in cron; actor append hydrations rise 21 → 23 within the same 41 commands, delivery hydrations 1 → 2 within the same 26 commands, offset by one fewer actor-read hydration. The trace does not prove why these caches missed. None of these families increases on warmed turns, warm MAIN remains zero, and whole workload statements/requests both fall; this is disclosed under the T1 move exception, not claimed as a paid deterministic query reduction.
The host was loaded; no latency or throughput claim is made. Native SQL and request-census events reconcile across every thread. Per-turn ranges are workload-turn ranges, not confidence intervals across independent trials.
Both runs retained the same five failed
BEGIN IMMEDIATEexecutions during shutdown: two MAIN lease idle-close, two worker lease-close and one worker audit-pruning attempt. They reported database locked, are excluded from successful statement counts, and both shutdowns exited zero. SQL/request-census conservation reconciled 11,605/11,605 base events and 11,535/11,535 candidate events. Two boot requests on each side have unknown transport targets but no missing SQL events.Evidence
Core runtime config reads now require a prepared snapshot. Fixtures that formerly relied on a mocked facade or implicit disk load publish their existing config at the setup/invocation boundary and clear it after cleanup. Security, provider, writer, and source-identity assertions remain. Partial mocks retain the actual owner exports. The completed hidden cron alias is explicitly absent after cleanup, while both pre-run provenance/sandbox checks and the stable-row post-run checks remain.
Doctor prepares the already-read config through the async owner without another config read. Native close reports the original close failure and leaves retry in charge of cleanup; it does not wait forever for a worker that failed to stop. No schema or stored-format migration is required. Current main's type fixes, cancellation callback waits, moved deletion-safety tests, usage coalescing, visible-child writer isolation, and model-catalog warnings are retained. The only latest merge conflict was the model-list import block: it keeps async config preparation and main's shared catalog-warning reader.
Basic local oxfmt, oxlint and whitespace checks passed on the changed files. Final session-mutation fixtures wait for their own transcript reconciliation before native inspection; the catalog-authority regression uses an entry signal instead of a one-second poll, retaining all security assertions. Knip identified one unreferenced historical downgrade fixture, which is deleted without changing migration code. Completed Codex implementation/repair reviews found no remaining actionable P0/P1 findings; mechanical integration and fixture follow-ups were independently inspected. No broad local suite/typecheck is claimed under relaxed testing v6. Focused diagnosis of the identityless SQLite peer regression passed: one selected test, 18 skipped, 179.53 seconds including a 115.5-second cold worker build. The fixture now observes the peer selecting the pending fence before releasing the refresh owner; every credential, refresh-count and subsequent-read assertion remains.
The final update cell passed in Package Acceptance run 38272933543, job 114898947762. Its artifact reports: published 2026.10.2 → candidate 2026.10.2 at
f53c0078c99043ed86015483f5e41c6f77614b08, finished,readyz=200, running version verified. Candidate package SHA-256:5e2587f14005651409f4c11b1887c74a075abe26bbd0079c7ceb27bcf914c512. Later authored changes repair test fixtures/delete unused test support and fix CI report allocation/routing; the update-related production inputs are unchanged.On prior head
dbd59df934ec467a710001313004f86337ce5099, CI 38276954075 passed production and root test types, all five core test-type shards, all five core lint shards and root lint, source contracts, and Knip/dependencies job 114905017597. The orphaned test helper was the sole prior Knip failure and is removed.Before final main integration, head
a34535bcpassed Madge/architecture with zero cycles, database T1/dialect/worker ratchets, source contracts, and plugin/runtime API guardrails, with all 251 contract tests passing. Unchanged SDK surface/runtime-API inputs retain these supporting receipts; final integrated static evidence is recorded below. PostgreSQL conformance correctly skips: none of the changed paths match its engine/workboard ownership filters.The SDK qualification also repairs the report allocation: only its dispatch row moves to the existing 32-class, with the existing planner assertion and runner documentation updated. Two hosted serial attempts (a345, dbd59df) exceeded the unchanged 20-minute job deadline after baseline rendering consumed about 11.4–11.7 minutes. Separate runner diagnostics show the 8-class exposes two CPUs/about 8 GiB and the 32-class eight CPUs/about 32 GiB; only the latter clears the existing eight-CPU/24-GiB parallel floor. No renderer guard, heap limit, global backend or deadline changes. Ordinary CI row counts are unchanged. Main-shaped qualification dispatches retain the SDK report alongside their existing push-shaped coverage; PR-shaped qualification stays unchanged. The first qualification was safely rejected before SDK execution because GitHub's merge ref still named the previous head. The second exposed the planner's incompatible main-tier input and omitted comparison row. The main-tier validation guard remains intact; qualifications use the supported full tier. Neither failed preflight is passing evidence. Focused diagnosis of the routing correction passed all three planner cases in 69.09 seconds; an independent source review found no actionable issue.
The integrated SDK API comparison passed for base
bcd41d1aae8d60336fbf5466f22eb665ee353e4f→ merge9568291752cb2ebb56cb0ce1973cf1794616c1f9(second parentd1c2b2ebc8b7ed82ba3666b40df72d07a9f592f6). The full job took 6m48s, with concurrent renders of 331.0s and 335.3s; acknowledgment26528526. It reports two added exports, two changed signatures, and 34 changed reachable declarations. Later edits are fixture-only and preserve all renderer inputs.Final head
719bf1ad1ef7fdf9cc23cd92917558f74fd4fec7passes the corrected UI/core-types-3 lane, root lint, and source contracts. The only change from6980154ff3c1is the explicit action label in the UI fixture. All other static inputs retain the completed 698 verification: production/root types, the other four core type stripes, all five core lint stripes, guards, boundaries, plugin/runtime contracts, Madge/architecture, Knip/dependencies, T1/dialect/worker ratchets, and security. Final ratchets report T1 481 → 481, compatibility 2 → 2, and dialect groups 0 → 0, 5 → 5, and 2 → 2. Madge reports zero cycles. The superseded UI type failure is recorded rather than described as inherited. These final test-only changes preserve the completed SDK, update, and SQL measurement inputs above.The preceding qualification at
349e7cf5467fpassed all selected static and security checks, including the SDK API comparison in 6m49s. Both SDK renders overlapped (347.4s / 349.0s). Ratchets reported T1 481→481 and compatibility 2→2; Madge reported zero cycles. That result is supporting evidence; the later integrated SDK result above includes main's catalog-declaration changes.Broad runtime CI is not claimed all-green. The final broad dispatches also contain runtime failures that were not investigated after the static-check freeze; they are neither passing proof nor labeled inherited. The earlier attributed observations below retain their original evidence. Fixture-only head
6980154ff3c1b2db9be06b54d2204de168dfdc1eadds explicit config preparation in 37 more session fixtures and the confirmed Gateway/status fixtures. Snapshot cleanup follows owner drainage, including reverse-order teardown registration. Local basic lint passes all 45 changed tests. Final fixture repairs address the confirmed catalog-entry polling and rewind transcript-reconciliation ordering failures, plus missing runtime-config preparation in session, Gateway, worktree, heartbeat, and cleanup fixtures. Each publishes its authored config before the dependent operation; assertions, security inputs, and timeouts stay intact. Incoming main's composer-banner test spread an action/no-action union and made the paired action label optional. The refreshed fixture now states its existingUnarchivelabel and action explicitly, preserving the rendered values. The first kind-only repair did not resolve this and failed CI; the follow-up removes the union spread. No UI behavior changes. Optional runtime jobs do not replace the static gates; unresolved observations remain explicitly listed below under relaxed landing v4. The prior head retains these unresolved observations, with no claim that they are inherited or that a replay proves repair:applied-restart-required; the underlying reload error is absent. The latest scheduled-main exact case passed, so this is not labeled inherited. Earlier candidate outcomes vary; attribution remains open.Final optional runtime failures (metadata snapshot; uninvestigated)
These are not passing proof and have no inherited classification. Later job completions are outside this snapshot.
Separately, the untouched placement-reclaim failure has the same main stack, and focused main
f2c48ebdreproduces the unchanged UI i18n fallback-baseline drift. Those named inherited exceptions are recorded in the campaign red-main inbox. Unresolved runtime follow-ups are also assigned there without converting uncertainty into an inherited claim. All required static, security, SDK and update evidence remains separate from these optional runtime observations.Size
Relative to merge-base main
8eae8c826dd9: 1,233 files, +8,809/−2,980. Heuristic buckets: production 192 files +1,747/−937; tests 1,027 files +6,843/−1,898; docs/config/tooling 14 files +219/−145. Test buckets include named test support, fixtures, and test utility modules. Most changed files prepare existing test configs explicitly; no assertion or timeout is weakened. Final integration retains main's catalog warnings and cancellation cleanup.