Repository navigation
perf(doctor): keep bundled doctor contract closures dependency-light - #120698
Conversation
Doctor contract enumeration cold-loads each plugin's doctor-contract-api closure via jiti, so a static value import of openclaw/plugin-sdk/runtime-doctor pulled the state-db/kysely graph (~4.3s per closure) into listPluginDoctorLegacyConfigRules / listPluginDoctorStateMigrationEntries. - migrate all light doctor-contract closures (66 files) to the dependency-light openclaw/plugin-sdk/runtime-doctor-migrations subpath - voice-call: load detect/repairOpenClawStateDatabaseSchema* lazily inside the migration bodies; keep only a type-only static runtime-doctor import - matrix: split pure credential record shapes/normalizers into credentials-state.ts so the doctor closure no longer imports the sync plugin-state store through credentials-read - guard: doctor-contract-closure-guard.test.ts now forbids static value imports of runtime-doctor in closures alongside agent-runtime
Knip production scan flags the export as consumer-less; the type is only referenced by the exported union and revocation guard signature.
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 5:45 PM ET / 21:45 UTC. ClawSweeper reviewWhat this changesThe PR routes lightweight plugin doctor-contract code through a focused SDK entrypoint, defers Voice Call database helpers until migrations run, and extracts Matrix credential normalization from state-store access to reduce doctor enumeration cost. Merge readinessKeep open. This is a coherent maintainer-owned follow-up to the merged doctor-loading refactor; the inspected loader, SDK seam, Matrix split, and Voice Call lazy boundary show no actionable defect, but final exact-head validation remains a maintainer decision. Priority: P2 Review scores
Verification
How this fits togetherThe doctor registry reads bundled plugin manifests and loads each declared contract closure before running diagnostics or migrations. Those closures supply migration definitions that doctor then uses to inspect and repair plugin configuration and state. flowchart LR
A[Plugin manifests] --> B[Doctor contract registry]
B --> C[Contract closure loading]
C --> D[Migration definitions]
D --> E[Doctor diagnostics and repairs]
Decision needed
Why: The patch has no concrete correctness finding, but the required sibling Codex source is unavailable in this review environment and the performance evidence was reported rather than independently replayed. Before merge
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +13. Total +34 across 74 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current main, retain the focused guard and built enumeration timing evidence on the resulting head, and land the existing owner-boundary refactor if those checks remain green. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a performance and dependency-boundary refactor, not a reported user failure; the registry load path and dependency edges are source-verified. Is this the best way to solve the issue? Yes, subject to exact-head proof: using the existing focused SDK seam and moving only pure Matrix state out of the store-backed module is the narrowest maintainable solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 909509a5db8d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Pre-merge verification (head
|
|
Merged via squash.
|
Punchcard-Session: amber-workshop-workshop-36 * origin/main: (28 commits) perf(doctor): keep bundled doctor contract closures dependency-light (#120698) fix(elevenlabs): preserve repeated committed speech segments (#120792) fix(ai): fence Responses replay metadata (#120777) fix(ai): invalidate stale compaction replay (#120786) fix(telegram): clean up every failed webhook startup phase (#120788) fix(codex): preserve configured MCP tools in scheduled turns (#120366) fix(ui): show dev checkout commit lag in Updates (#120769) fix(agents): repair XML-polluted tool names (#113814) fix(discord): remove only the bot own reactions (#120785) fix(macos): complete ChatGPT subscription setup (#120782) fix(plugins): surface safe administrator install warnings (#120783) fix(release): keep upgrade survivor sessions fresh (#120778) fix(providers): preserve realtime tool-result delivery ownership (#120776) fix(plugins): retain incognito scope for embedded session ownership (#120215) fix(elevenlabs): surface realtime provider error events (#120772) fix(agents): preserve exact steering delivery ownership (#120770) fix(telegram): prevent session-count routing slowdown (#120774) fix(agents): preserve authoritative background process outcomes (#120754) test(process): make Linux adapter wiring portable (#120741) fix(diagnostics-prometheus): send Content-Length on metrics HEAD responses (#120212) ...
* perf(doctor): slim remaining heavy doctor contract closures Follow-up to #120698: several doctor closures still cold-loaded multi-second kysely-bearing graphs through other broad barrels (session-store-runtime, realtime-voice, channel-outbound, logging-core, memory-host-core/-events, sqlite-runtime, persistent-dedupe, and plugin-local barrels). - lazy-import heavy helpers inside async migration bodies (codex, msteams, zalouser, workboard, matrix inbound-dedupe, memory-core migrations) - bypass plugin-local barrels to defining modules (reef protocol, memory-core short-term-promotion) - move to lighter existing subpaths (slack -> channel-streaming, matrix logger -> security-runtime, memory-wiki -> agent-scope-runtime, which now also exports resolveSessionAgentId) - add narrow openclaw/plugin-sdk/realtime-voice-activation for discord's sync wake-name doctor rules - split src/infra/kysely-sync-cache-state.ts so sqlite-transaction clears Kysely caches without value-loading kysely; split the memory-host-sdk kysely bridge off the schema/transaction bridge - guard: forbid the heavy barrels in doctor closures with per-kind scoping Cold enumeration per plugin: discord 52.6s->0.3s, msteams 30.9s->0.5s, codex 29.6s->2.6s, zalouser 28.8s->2.3s, matrix 27.2s->3.2s, slack 17.5s->1.5s, reef 9.9s->0.7s, memory-core 6.4s->3.6s, workboard 3.4s->0.25s; all kysely-free except llm-task (named follow-up). * fix(plugins): route slack streaming compat through a focused streaming-config subpath The channel-streaming compat barrel is deprecated for extension production code (deprecated-api-usage guard + SDK package contract). Add the narrow non-deprecated openclaw/plugin-sdk/channel-streaming-config subpath for the pure streaming config readers, and drop the now consumer-less short-term-promotion barrel re-exports knip flagged. * test(plugins): register memory-host-sdk kysely bridge in package boundary inventory * fix(plugins): classify realtime-voice-activation as private-local ClawSweeper P2: the subpath exports only a default target, which is the private-local shape; register it in plugin-sdk-private-local-only-subpaths, the package-boundary d.ts alias maps, and correct the public surface budgets (realtime-voice-activation no longer counts as public). * fix(release): exclude realtime-voice-activation declarations from the published package Private-local subpaths ship without d.ts; register the files negation the release pack-path check requires.
…penclaw#120698) * perf(doctor): keep bundled doctor contract closures dependency-light Doctor contract enumeration cold-loads each plugin's doctor-contract-api closure via jiti, so a static value import of openclaw/plugin-sdk/runtime-doctor pulled the state-db/kysely graph (~4.3s per closure) into listPluginDoctorLegacyConfigRules / listPluginDoctorStateMigrationEntries. - migrate all light doctor-contract closures (66 files) to the dependency-light openclaw/plugin-sdk/runtime-doctor-migrations subpath - voice-call: load detect/repairOpenClawStateDatabaseSchema* lazily inside the migration bodies; keep only a type-only static runtime-doctor import - matrix: split pure credential record shapes/normalizers into credentials-state.ts so the doctor closure no longer imports the sync plugin-state store through credentials-read - guard: doctor-contract-closure-guard.test.ts now forbids static value imports of runtime-doctor in closures alongside agent-runtime * fix(matrix): keep credential revocation record type module-local Knip production scan flags the export as consumer-less; the type is only referenced by the exported union and revocation guard signature.
…#120811) * perf(doctor): slim remaining heavy doctor contract closures Follow-up to openclaw#120698: several doctor closures still cold-loaded multi-second kysely-bearing graphs through other broad barrels (session-store-runtime, realtime-voice, channel-outbound, logging-core, memory-host-core/-events, sqlite-runtime, persistent-dedupe, and plugin-local barrels). - lazy-import heavy helpers inside async migration bodies (codex, msteams, zalouser, workboard, matrix inbound-dedupe, memory-core migrations) - bypass plugin-local barrels to defining modules (reef protocol, memory-core short-term-promotion) - move to lighter existing subpaths (slack -> channel-streaming, matrix logger -> security-runtime, memory-wiki -> agent-scope-runtime, which now also exports resolveSessionAgentId) - add narrow openclaw/plugin-sdk/realtime-voice-activation for discord's sync wake-name doctor rules - split src/infra/kysely-sync-cache-state.ts so sqlite-transaction clears Kysely caches without value-loading kysely; split the memory-host-sdk kysely bridge off the schema/transaction bridge - guard: forbid the heavy barrels in doctor closures with per-kind scoping Cold enumeration per plugin: discord 52.6s->0.3s, msteams 30.9s->0.5s, codex 29.6s->2.6s, zalouser 28.8s->2.3s, matrix 27.2s->3.2s, slack 17.5s->1.5s, reef 9.9s->0.7s, memory-core 6.4s->3.6s, workboard 3.4s->0.25s; all kysely-free except llm-task (named follow-up). * fix(plugins): route slack streaming compat through a focused streaming-config subpath The channel-streaming compat barrel is deprecated for extension production code (deprecated-api-usage guard + SDK package contract). Add the narrow non-deprecated openclaw/plugin-sdk/channel-streaming-config subpath for the pure streaming config readers, and drop the now consumer-less short-term-promotion barrel re-exports knip flagged. * test(plugins): register memory-host-sdk kysely bridge in package boundary inventory * fix(plugins): classify realtime-voice-activation as private-local ClawSweeper P2: the subpath exports only a default target, which is the private-local shape; register it in plugin-sdk-private-local-only-subpaths, the package-boundary d.ts alias maps, and correct the public surface budgets (realtime-voice-activation no longer counts as public). * fix(release): exclude realtime-voice-activation declarations from the published package Private-local subpaths ship without d.ts; register the files negation the release pack-path check requires.
…ility transitively Follow-up to #120698/#120811/#120882: the closure guard's enumerated barrel bans cannot catch new heavy edges, and two closures still statically reached kysely on main. - guard: add a transitive kysely-reachability test that walks static value imports from every doctor-contract and legacy-setup closure through plugin, plugin-sdk, and relative core graphs, failing with the full import chain; type-only and lazy dynamic imports stay allowed - llm-task/model refs: manifest-model-id-normalization reads snapshots through a registration-slot runtime bridge (snapshot modules register at eval; require fallback covers cold processes) and current-plugin-metadata-state moves its process-scoped facts onto a globalThis singleton so dual module instances share published state - telegram: split thread-bindings-store.ts (pure record shapes + legacy-file readers) out of the acp-runtime-heavy manager, delete the consumer-less testing export, move the pure bot-user-id token parse to token-fingerprint.ts, and lazy-import token.js in the async update-offset detector llm-task enumeration drops to ~0.8s/157 modules cold; every closure is now statically kysely-free and stays that way by construction.
…uard it transitively (#120876) * perf(plugins): close the last kysely closure chains and guard reachability transitively Follow-up to #120698/#120811/#120882: the closure guard's enumerated barrel bans cannot catch new heavy edges, and two closures still statically reached kysely on main. - guard: add a transitive kysely-reachability test that walks static value imports from every doctor-contract and legacy-setup closure through plugin, plugin-sdk, and relative core graphs, failing with the full import chain; type-only and lazy dynamic imports stay allowed - llm-task/model refs: manifest-model-id-normalization reads snapshots through a registration-slot runtime bridge (snapshot modules register at eval; require fallback covers cold processes) and current-plugin-metadata-state moves its process-scoped facts onto a globalThis singleton so dual module instances share published state - telegram: split thread-bindings-store.ts (pure record shapes + legacy-file readers) out of the acp-runtime-heavy manager, delete the consumer-less testing export, move the pure bot-user-id token parse to token-fingerprint.ts, and lazy-import token.js in the async update-offset detector llm-task enumeration drops to ~0.8s/157 modules cold; every closure is now statically kysely-free and stays that way by construction. * fix(telegram): repoint the native-command menu state at the token-fingerprint parser
…uard it transitively (openclaw#120876) * perf(plugins): close the last kysely closure chains and guard reachability transitively Follow-up to openclaw#120698/openclaw#120811/openclaw#120882: the closure guard's enumerated barrel bans cannot catch new heavy edges, and two closures still statically reached kysely on main. - guard: add a transitive kysely-reachability test that walks static value imports from every doctor-contract and legacy-setup closure through plugin, plugin-sdk, and relative core graphs, failing with the full import chain; type-only and lazy dynamic imports stay allowed - llm-task/model refs: manifest-model-id-normalization reads snapshots through a registration-slot runtime bridge (snapshot modules register at eval; require fallback covers cold processes) and current-plugin-metadata-state moves its process-scoped facts onto a globalThis singleton so dual module instances share published state - telegram: split thread-bindings-store.ts (pure record shapes + legacy-file readers) out of the acp-runtime-heavy manager, delete the consumer-less testing export, move the pure bot-user-id token parse to token-fingerprint.ts, and lazy-import token.js in the async update-offset detector llm-task enumeration drops to ~0.8s/157 modules cold; every closure is now statically kysely-free and stays that way by construction. * fix(telegram): repoint the native-command menu state at the token-fingerprint parser
What Problem This Solves
Doctor contract enumeration (
src/plugins/doctor-contract-registry.ts) cold-loads each declaring plugin'sdoctor-contract-apiclosure via jiti. After #120678 introduced the dependency-lightopenclaw/plugin-sdk/runtime-doctor-migrationssubpath, ~40 bundled plugin doctor closures still statically value-imported the heavyopenclaw/plugin-sdk/runtime-doctorbarrel, which pulls the state-db/kysely graph (~500 modules). Measured through the same jiti loader path enumeration uses, cold-loadingruntime-doctorcosts ~4.3s versus ~72ms forruntime-doctor-migrations— paid per plugin duringlistPluginDoctorLegacyConfigRules/listPluginDoctorStateMigrationEntries.Why This Change Was Made
openclaw/plugin-sdk/runtime-doctor-migrations.extensions/voice-call/doctor-contract-api.tsgenuinely needsdetectOpenClawStateDatabaseSchemaMigrations/repairOpenClawStateDatabaseSchema: those now load viaawait importinside the async migration bodies, keeping only a type-only staticruntime-doctorimport, so enumeration never touches the state-db graph while real doctor runs pay the cost exactly when repairing.createPluginStateSyncKeyedStorethroughsrc/matrix/credentials-read.ts. The pure credential record shapes/normalizers moved to a newcredentials-state.ts;credentials-read.tskeeps the store-backed functions (openMatrixCredentialsStore,loadMatrixCredentials,clearMatrixCredentials,credentialsMatchConfig) and all callers were repointed in the same change — no compat re-exports.src/plugins/doctor-contract-closure-guard.test.tsnow carries a specifier→reason map and forbids static value imports ofopenclaw/plugin-sdk/runtime-doctorin doctor closures alongside the existingagent-runtimerule (type-only and lazy dynamic imports stay allowed).Intentionally unchanged heavy value users outside enumeration closures:
extensions/matrix/auth-presence.ts,extensions/matrix/src/doctor.ts,extensions/matrix/src/matrix/credentials-read.ts,extensions/qa-lab/src/suite-runtime-flow.ts.Known follow-up (out of scope here, tracked separately): several closures remain multi-second heavy through other barrels — codex/msteams/zalouser via
openclaw/plugin-sdk/session-store-runtime(→ session-accessor → kysely) and matrix viaopenclaw/plugin-sdk/logging-core(→ diagnostic → config → kysely); discord/slack/llm-task/reef/memory-* chains still need tracing.User Impact
openclaw doctorand any flow enumerating plugin doctor contracts loads far fewer modules per plugin; light closures now enumerate in ~100–300ms cold instead of multi-second state-db graph loads. No behavior change to migrations themselves.Evidence
node scripts/run-vitest.mjs src/plugins/doctor-contract-closure-guard.test.ts— 2 tests pass; before extending it, the new rule caught the matrixcredentials-readedge, which drove the split.pnpm tsgo:core,pnpm tsgo:extensions,pnpm check:test-typesclean;oxfmt --checkandscripts/run-oxlint.mjsclean on all 74 changed files.runtime-doctorcold load 4333ms vsruntime-doctor-migrations72ms; per-plugin fresh-process enumeration of light plugins (anthropic, qqbot, telegram, clickclack, copilot, …) now ~100–300ms withrequire.cachefree of kysely.