Repository navigation
perf(doctor): delete the heavy doctor barrel and finish slimming enumeration - #120882
Conversation
Nothing may pull the state-db/kysely graph through a doctor barrel anymore. The barrel's remaining heavy exports move to two narrow private-local subpaths, each with a single purpose: - doctor-repair-runtime: install-path diagnosis, plugin config removal, and state-database schema detect/repair (matrix doctor, voice-call lazy import) - plugin-state-store-runtime: the sync keyed-store factory. It stays out of plugin-state-runtime because hot channel entrypoints import that at module load and opening a store pulls the state-database graph. Doctor closures also stop pulling ssrf-runtime (fetch-guard + gateway net) for two legacy private-network helpers that live in the lighter ssrf-policy subpath: mattermost, nextcloud-talk, tlon, matrix. The closure guard now forbids the two new heavy subpaths instead of the deleted barrel, so the invariant keeps being enforced where it still applies.
Doctor enumeration cold-loads each declaring plugin's contract closure, so one heavy import in a closure is paid by the whole sweep. Four barrels were still dragging unrelated graphs in for trivial helpers; each is repaired at the leaf rather than by caching downstream: - Legacy private-network config migration moves to a config leaf. It only reshapes records, but lived beside the SSRF runtime (DNS, proxy, logging), costing mattermost ~2.7s. ssrf-policy re-exports it, surface unchanged. - Streaming config readers move to a leaf. They read two config keys, but streaming.ts also formats tool aggregates, pulling tool-display/logging/ acp-core; that cost slack ~2.3s. - signal took the channel-secret barrel for isRecord; the canonical plugin record guard is string-coerce-runtime (root AGENTS.md). - llm-task took the provider-model barrel for parseModelRef, now a narrow model-ref-parse subpath. Full doctor enumeration of all 42 declaring plugins, built mode: legacy config rules 6668ms -> 1265ms, state migrations 184ms -> 127ms. No plugin remains an outlier; the slowest is now ~380ms against a ~200ms floor. Public export surfaces of every touched SDK subpath are byte-identical (verified by diffing built module exports before/after); the API baseline hashes move only because re-exported declarations emit differently. The closure guard gains rules for each repaired barrel so the invariant holds for future closures.
…ed package Same pack-path rule as c41da37: private-local subpaths ship without d.ts.
2cad3eb to
fa86c6d
Compare
|
Codex review: found issues before merge. Reviewed August 9, 2026, 12:42 AM ET / 04:42 UTC. ClawSweeper reviewWhat this changesThis PR replaces the broad doctor runtime SDK entrypoint with narrow internal subpaths and leaf helpers so doctor contract enumeration avoids loading heavyweight runtime graphs. Merge readinessKeep open: the new model-ref leaf still statically loads the manifest/state-database path, so the llm-task doctor closure retains the expensive dependency graph this PR is meant to remove. The patch also removes a current documented SDK import without updating its migration guide; the facade is main-only rather than shipped, so this is a pre-release contract decision rather than a released-user regression. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw doctor loads plugin migration contracts during CLI checks and startup migration scans. Those contracts read legacy configuration or state and produce repair rules and operator diagnostics. flowchart LR
A[Doctor CLI and startup scan] --> B[Plugin manifest discovery]
B --> C[Doctor contract enumeration]
C --> D[Focused SDK helper imports]
D --> E[Config and state migration rules]
E --> F[Operator diagnostics and repairs]
Decision needed
Why: Current docs and the workspace SDK facade describe an external plugin import, but release history shows the exact path is main-only; that compatibility direction requires maintainer intent. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +49, Tests -108, Config +25, Generated 0, Other +8. Total -26 across 41 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: Use a genuinely dependency-light model-reference parser for the llm-task migration and extend the closure proof to catch its transitive graph, then document the supported doctor-migration import before removing the old facade. Do we have a high-confidence way to reproduce the issue? Yes, from source: loading the new model-ref leaf reaches model-ref-shared, manifest normalization, plugin metadata, and the state-database reader before the llm-task doctor contract can enumerate. Is this the best way to solve the issue? No: re-exporting parseModelRef through a new leaf does not make it lightweight because its existing static dependency chain remains; a genuinely isolated parser plus a transitive closure check is the maintainable repair. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7f3cc6995bc6. 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
|
The landed guard fails on main: three closures import heavy barrels for one
symbol each. Two more surfaced once the guard learned about the provider-model
barrel. Each gets a narrow subpath at the leaf:
- telegram sent-message-cache + state-migrations took the session-store barrel
(session accessor + state-db) for resolveStorePath -> session-store-paths
- discord thread-bindings.state took the channel-outbound barrel (reply
pipeline + channel registry) for one identity write -> outbound-echo-runtime
- discord model-picker took the provider-model barrel for normalizeProviderId,
which model-ref-parse now exposes beside parseModelRef
The guard also stops walking artifacts of plugins whose manifest declares no
doctor surface. Such a declaration gates the artifact off every enumeration
path exactly as resolvePluginDoctorContracts does, so its closure cost is never
paid; anthropic ("doctorContract": {}) was being held to a cost it cannot
incur. Absent declarations still load eagerly and stay enforced.
Side effect worth naming: discord's built doctor contract now loads again.
On main both discord and telegram fail to require in packaged builds (an
ESM-only transitive dep) and silently lose their repairs; this restores
discord and takes enumerated legacy config rules from 87 to 99. Telegram's
built artifact still pulls execa through dist chunking - a build-level defect
with a different owner, filed as follow-up.
fa86c6d to
62bbdc7
Compare
…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
…eration (openclaw#120882) * refactor(plugin-sdk): delete the heavy runtime-doctor barrel Nothing may pull the state-db/kysely graph through a doctor barrel anymore. The barrel's remaining heavy exports move to two narrow private-local subpaths, each with a single purpose: - doctor-repair-runtime: install-path diagnosis, plugin config removal, and state-database schema detect/repair (matrix doctor, voice-call lazy import) - plugin-state-store-runtime: the sync keyed-store factory. It stays out of plugin-state-runtime because hot channel entrypoints import that at module load and opening a store pulls the state-database graph. Doctor closures also stop pulling ssrf-runtime (fetch-guard + gateway net) for two legacy private-network helpers that live in the lighter ssrf-policy subpath: mattermost, nextcloud-talk, tlon, matrix. The closure guard now forbids the two new heavy subpaths instead of the deleted barrel, so the invariant keeps being enforced where it still applies. * perf(doctor): keep heavy graphs out of every doctor closure Doctor enumeration cold-loads each declaring plugin's contract closure, so one heavy import in a closure is paid by the whole sweep. Four barrels were still dragging unrelated graphs in for trivial helpers; each is repaired at the leaf rather than by caching downstream: - Legacy private-network config migration moves to a config leaf. It only reshapes records, but lived beside the SSRF runtime (DNS, proxy, logging), costing mattermost ~2.7s. ssrf-policy re-exports it, surface unchanged. - Streaming config readers move to a leaf. They read two config keys, but streaming.ts also formats tool aggregates, pulling tool-display/logging/ acp-core; that cost slack ~2.3s. - signal took the channel-secret barrel for isRecord; the canonical plugin record guard is string-coerce-runtime (root AGENTS.md). - llm-task took the provider-model barrel for parseModelRef, now a narrow model-ref-parse subpath. Full doctor enumeration of all 42 declaring plugins, built mode: legacy config rules 6668ms -> 1265ms, state migrations 184ms -> 127ms. No plugin remains an outlier; the slowest is now ~380ms against a ~200ms floor. Public export surfaces of every touched SDK subpath are byte-identical (verified by diffing built module exports before/after); the API baseline hashes move only because re-exported declarations emit differently. The closure guard gains rules for each repaired barrel so the invariant holds for future closures. * fix(release): exclude new private-local declarations from the published package Same pack-path rule as c41da37: private-local subpaths ship without d.ts. * fix(doctor): repair the closure guard violations that break main The landed guard fails on main: three closures import heavy barrels for one symbol each. Two more surfaced once the guard learned about the provider-model barrel. Each gets a narrow subpath at the leaf: - telegram sent-message-cache + state-migrations took the session-store barrel (session accessor + state-db) for resolveStorePath -> session-store-paths - discord thread-bindings.state took the channel-outbound barrel (reply pipeline + channel registry) for one identity write -> outbound-echo-runtime - discord model-picker took the provider-model barrel for normalizeProviderId, which model-ref-parse now exposes beside parseModelRef The guard also stops walking artifacts of plugins whose manifest declares no doctor surface. Such a declaration gates the artifact off every enumeration path exactly as resolvePluginDoctorContracts does, so its closure cost is never paid; anthropic ("doctorContract": {}) was being held to a cost it cannot incur. Absent declarations still load eagerly and stay enforced. Side effect worth naming: discord's built doctor contract now loads again. On main both discord and telegram fail to require in packaged builds (an ESM-only transitive dep) and silently lose their repairs; this restores discord and takes enumerated legacy config rules from 87 to 99. Telegram's built artifact still pulls execa through dist chunking - a build-level defect with a different owner, filed as follow-up.
…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 enumeration cold-loads every declaring plugin's contract closure, so one
heavy import inside a closure is paid by the whole
openclaw doctorsweep and bythe startup migration scan. #120678 removed the worst offenders; this finishes the
job and deletes the barrel that made the problem possible.
It also repairs two things that are broken on
maintoday:main— three closures import aheavy barrel for one symbol each.
loses its repairs (an ESM-only transitive dependency reached through dist
chunking), so 12 of its legacy config rules never run.
Why This Change Was Made
plugin-sdk/runtime-doctoris deleted. Its heavy exports move to narrowprivate-local subpaths, each with one purpose, so no caller can pull the
state-database graph through a doctor barrel again:
doctor-repair-runtimeplugin-state-store-runtimemodel-ref-parseparseModelRef,normalizeProviderIdsession-store-pathsresolveStorePathoutbound-echo-runtimerecordOutboundMessageIdentityThe store factory deliberately does not go in
plugin-state-runtime: hotchannel entrypoints import that at module load, and opening a store pulls the
state-database graph.
Four more closures were pulling whole graphs for trivial helpers. Each is repaired
at the leaf rather than by caching downstream:
the SSRF runtime (DNS, proxy state, logging). Moved to a config leaf;
ssrf-policyre-exports it. Cost mattermost ~2.7s.
streaming.tsalso formatstool aggregates, pulling tool-display → logging → acp-core. Cost slack ~2.3s.
isRecord; the canonical pluginrecord guard is
string-coerce-runtime(rootAGENTS.md).parseModelRef.The guard gains a rule per repaired barrel, and stops walking artifacts of plugins
whose manifest declares no doctor surface — such a declaration gates the artifact off
every enumeration path exactly as
resolvePluginDoctorContractsdoes, so its closurecost cannot be incurred. Absent declarations still load eagerly and stay enforced.
User Impact
openclaw doctorand the startup migration scan get materially faster, and Discordoperators get back doctor repairs that silently did nothing in packaged builds. No
plugin API was removed: every touched SDK subpath keeps a byte-identical runtime
export surface.
Evidence
Full enumeration of all declaring plugins, built mode, same machine, three runs each:
mainOn a base without the pre-existing telegram build defect (measured before rebasing
onto current
main), the same sweep went 6668 ms → 1265 ms, and no pluginremained an outlier: worst ~380 ms against a ~200 ms floor, down from mattermost
2724 ms and slack 2289 ms.
Surface safety: built module exports were diffed before/after for all seven affected
SDK subpaths (
ssrf-policy,ssrf-runtime,channel-streaming-config,channel-outbound,channel-streaming,channel-message,infra-runtime) —identical in every case. The API baseline hashes move only because re-exported
declarations emit differently.
Checks: closure guard (green — it fails on
main), plugin contracts (44 files/1056tests), telegram/discord/matrix/slack/signal/mattermost/anthropic/llm-task suites,
plugin-sdk surface + export + API baseline gates, release pretag pack check (91
plugins), import cycles, tsgo core + extensions, full
pnpm build, and a cleanstructured pre-land review.
Two failures reproduce identically on clean
mainand are not touched here:npm-install-security-scan.release.test.ts(performs real installs) andbot-message-dispatch.draft-failures-progress.test.ts.Known Follow-up
Telegram's built doctor artifact still reaches
execathrough dist chunking andfails to require in packaged builds, losing its repairs. Its source closure is clean
(the guard passes); the artifact pulls telegram's runtime stores —
bot-info-cache,sticker-cache-store,update-offset-store,sent-message-cache,topic-name-cache— whose chunks carry runtime code. That is a build-level defectwith a different owner and is pre-existing on
main; it dominates the remaining4.8 s and is filed separately rather than bolted onto this change.