Repository navigation
perf(doctor): slim remaining heavy doctor contract closures - #120811
Conversation
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).
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 10:39 PM ET / August 9, 2026, 02:39 UTC. ClawSweeper reviewWhat this changesThe PR makes Doctor enumerate plugin migration contracts without cold-loading heavy database, session, reply-pipeline, and runtime dependency graphs. Merge readinessNo concrete correctness regression remains after the two prior findings were addressed, but this maintainer-owned PR needs a deliberate decision on its new public Plugin SDK entrypoint and a reviewer with the required sibling Codex source available before a full merge verdict. Priority: P3 Review scores
Verification
How this fits togetherDoctor reads lightweight plugin contract modules to discover legacy configuration and state migrations before executing any repair. Those migration entries later load their heavier helpers only when detection or repair actually needs them. flowchart LR
A[Plugin manifests] --> B[Doctor contract registry]
B --> C[Light contract closures]
C --> D[Migration detection]
D --> E[Lazy runtime helpers]
E --> F[Doctor repair results]
Decision needed
Why: A public SDK export becomes a compatibility commitment for external plugins; source inspection shows it is narrow and generic, but repository policy reserves that contract direction for maintainer-visible judgment. Before merge
Agent review detailsSecurityNone. PR surfaceSource +83, Tests +64, Docs +2, Config +11, Generated +1, Other +7. Total +168 across 39 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the dependency-light migration boundary, retain the narrow public streaming-config seam only if maintainers intend to support it for external plugins, and complete the Codex-source contract check before merge. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR optimizes contract-module loading; source inspection confirms the lazy imports sit behind asynchronous detection and migration paths. Is this the best way to solve the issue? Unclear: the lazy-import and direct-module approach fits the Doctor control-plane boundary, but maintainers must choose whether the new public SDK seam is the intended long-term contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c9d2ad7c42db. 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
HistoryReview history (1 earlier review cycle)
|
…g-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.
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).
… published package Private-local subpaths ship without d.ts; register the files negation the release pack-path check requires.
|
Pre-merge verification (head
|
|
Merged via squash.
|
…#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
Follow-up to #120698. Doctor contract enumeration (
src/plugins/doctor-contract-registry.ts) cold-loads each plugin's doctor closure via jiti, and after theruntime-doctormigration several closures still pulled multi-second module graphs — most reaching kysely — through other broad barrels. Measured per-plugin fresh-process enumeration (listPluginDoctorLegacyConfigRules+listPluginDoctorStateMigrationEntries, jiti loader, source checkout): discord ~52.6s, msteams ~30.9s, codex ~29.6s, zalouser ~28.8s, matrix ~27.2s, slack ~17.5s, reef ~9.9s, memory-core ~6.4s, memory-wiki ~5.5s, workboard ~3.4s.Why This Change Was Made
Each closure was fixed at its owning boundary:
session-binding-sidecars(session-store-runtime), msteams (session-store-runtime), zalouser (session-store-runtime), workboard (ownsqlite-store), matrixinbound-dedupe-migration(persistent-dedupe,sqlite-runtime, localinbound-dedupe.js), memory-coredoctor-host-events/doctor-host-event-sources(memory-host-events),doctor-memory-sidecar(memory-core-host-engine-schema,sqlite-runtime),doctor-vector-index-provider(sqlite-runtime).doctor-durable-state/state/audit-statenow importprotocol/audit|encoding|canonical|envelope|identity|pipeline|receiptsdirectly instead ofprotocol/index.js(whoseguard-adaptersre-export pullsprovider-http→ plugin metadata → kysely); memory-core dreaming migrations importshort-term-promotion-{store,types,utils}instead of theshort-term-promotionbarrel.streaming-compat→channel-streaming(instead ofchannel-outbound's reply-pipeline graph); matrixsdk/logger→security-runtimeforredactSensitiveText(instead oflogging-core→ diagnostic → config graph); memory-wikiconfig→agent-scope-runtime(which now also exportsresolveSessionAgentId, previously only onmemory-host-core).openclaw/plugin-sdk/realtime-voice-activationre-exports the pure activation-name helpers fromsrc/talk/activation-name.tsfor discord's sync doctor rules; the broadrealtime-voicebarrel keeps composing from the same defining module.src/infra/kysely-sync-cache-state.tsholds the per-database Kysely cache state sosqlite-transactioncan clear caches without value-loading kysely (this removed kysely from everysqlite-transaction/sqlite-strictconsumer, includingplugin-state-runtime);packages/memory-host-sdk/src/host/openclaw-runtime-kysely.tssplits the Kysely re-exports off the schema/transaction bridge.doctor-contract-closure-guard.test.tsnow forbids static value imports ofsession-store-runtime,logging-core,realtime-voice,channel-outbound, andmemory-host-corein closures, with per-kind scoping (session-store-runtime/channel-outboundapply to doctor-contract closures only — telegramsent-message-cache/state-migrationsand discordthread-bindings.statelegacy-setup closures share sync runtime modules with those barrels and are a named follow-up).Known remaining follow-ups (named, out of scope): llm-task (~11.5s) —
parseModelRef→model-ref-sharedstatically requiresmanifest-model-id-normalization→ plugin metadata snapshot → kysely; fixing that is core model-ref policy surgery. The legacy-setup closure slimming above. Residual 2–3.5s cold enumerations (matrix, memory-wiki, codex, zalouser) are now plain plugin-module jiti compile cost with no kysely.User Impact
openclaw doctorand anything enumerating plugin doctor contracts no longer cold-loads the kysely/state-db/session/reply-pipeline graphs per plugin. After: discord 0.3s, msteams 0.5s, workboard 0.25s, reef 0.7s, slack 1.5s, zalouser 2.3s, codex 2.6s, matrix 3.2s, memory-core 3.6s (kysely-free), memory-wiki 3.6s. No behavior change to migrations; heavy helpers load exactly when a migration executes.Evidence
node scripts/run-vitest.mjs src/plugins/doctor-contract-closure-guard.test.tsgreen with the six-barrel rule map; it caught reef/memory-core/matrix second-hop edges during development.src/infrakysely-sync and sqlite-transaction suites.pnpm tsgo:core,pnpm tsgo:extensions,pnpm check:test-types,pnpm check:import-cycles(0 cycles),pnpm plugin-sdk:surface:check(budgets 151/4852/2924 with comments), API baseline regenerated,oxfmt/oxlint clean, fullpnpm buildexit 0 with no[INEFFECTIVE_DYNAMIC_IMPORT].pluginIds: [id]and checkingrequire.cachefornode_modules/kyselythrough the jiti loader path (tsx/ESM imports don't land inrequire.cache; the check matches the module path, not filenames).