Repository navigation
fix(imessage): avoid unnecessary startup work in Doctor - #132435
Conversation
Keep configuration repair and legacy-state detection dependency-light by sharing existing cache contracts and using the narrow account-resolution SDK. Preserve storage keys, limits, TTLs and migration behavior. Independent iMessage follow-up to the CLI startup preparation repair in #131503.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready implementation and proof checkpoint for head 19e77d0aca15ee9b6cfee3d7751ca0b9e071806a. The repair stays with the iMessage plugin: one pure state-contract owner replaces imports through live reply/catchup/echo caches, the existing Doctor plan adapter loads the detector only when resolving plans, and account lookup uses the existing narrow SDK facade. The old definitions and duplicate reply TTL are removed; config, state shapes, keys, limits, ordering, archive behavior and public APIs remain unchanged. A new core cache or consumer guard would preserve the wrong import boundary rather than fix it. Source proof: unchanged baseline 386 tests; three intended eager-import failures before production edits; 389 owner tests and 45 Doctor siblings pass after extraction. Full changed-file checks and fresh isolated Codex review are clean at the requested P0 scope. Production +169/-143 (net +26), tests/support +132/-19; remaining production growth is shared import/type declarations and the lazy handoff, not new storage functionality. CI run 33238419076 is successful on this exact head: 41 successful jobs, 18 intentionally skipped, including a successful required CI gate. No remote Testbox run was needed beyond hosted CI; the installed-package proof ran locally on macOS with Node 24.20.0. Local commands executed: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/imessage/doctor-contract-api.test.ts extensions/imessage/src/state-migrations.test.ts extensions/imessage/src/accounts.test.ts extensions/imessage/src/monitor-reply-cache.test.ts extensions/imessage/src/monitor.behavior.test.ts extensions/imessage/src/monitor/cache-lifecycle.test.tsOPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/plugins/doctor-contract-registry.state-migrations.test.ts src/plugins/doctor-contract-registry.load-paths.test.ts src/commands/doctor-config-preflight.plugin-persistence.test.tsnode scripts/check-changed.mjs -- extensions/imessage/doctor-contract-api.test.ts extensions/imessage/doctor-contract-api.ts extensions/imessage/src/accounts.ts extensions/imessage/src/monitor-reply-cache.ts extensions/imessage/src/monitor/catchup-bridge.test-support.ts extensions/imessage/src/monitor/catchup.test-support.ts extensions/imessage/src/monitor/catchup.ts extensions/imessage/src/monitor/echo-cache.ts extensions/imessage/src/monitor/monitor-provider.echo-cache.test-support.ts extensions/imessage/src/monitor/persisted-echo-cache.ts extensions/imessage/src/state-contract.ts extensions/imessage/src/state-migrations.test.ts extensions/imessage/src/state-migrations.tspnpm buildnode scripts/package-openclaw-for-docker.mjs --skip-build --allow-unreleased-changelog --output-dir .artifacts/startup-split-B/host-package-19e77d0aca15 --output-name openclaw-startup-B.tgz --pack-json .artifacts/startup-split-B/host-package-19e77d0aca15/pack.jsonnode --import ./scripts/tsx.mjs scripts/check-plugin-npm-runtime-builds.mts --package extensions/imessageOPENCLAW_PLUGIN_NPM_PACK_OUTPUT_DIR="$B_PACK_DIR" bash scripts/plugin-npm-publish.sh --pack extensions/imessageThe fresh host tarball was installed into an isolated prefix using normal node "$B_INSTALLED_CLI" plugins install "npm-pack:$B_PLUGIN_TGZ" --force --accept-capabilitiesnode "$B_INSTALLED_CLI" plugins inspect imessage --jsonThe actual installed built Doctor module then ran natively against synthetic legacy fixtures and the real installed host migration executor. All 104 assertions passed: absent-state/config operations created no state, four canonical rows preserved keys and remaining TTLs, counter/cursor values never regressed, eight archives retained their exact bytes, and repeated detection/migration returned null/empty without changing rows. Installed bytes matched 10,073 host dist files and all 2,135 plugin files. The parent independently verified artifact hashes, the retained SQLite rows/integrity, archives and frozen source. Host SHA-256: The PR body now contains this completed evidence. All canonical commands passed; one local proof-receipt naming collision required a fresh-state rerun, which also passed. This is built/installed Doctor proof, not full Doctor CLI orchestration, official-catalog trust, live Messages send/receive, dynamic dependency tracing, or a startup benchmark. No operator Gateway, Messages, imsg, native permissions, Chrome, or credentials were touched. No UI behavior changed, so screenshots are not applicable. The latest ClawSweeper comment is still a review-start placeholder with no published rank-up moves; any actionable result arriving before merge will be checked. |
|
Merged via squash.
|
…enclaw#132435) Keep configuration repair and legacy-state detection dependency-light by sharing existing cache contracts and using the narrow account-resolution SDK. Preserve storage keys, limits, TTLs and migration behavior. Independent iMessage follow-up to the CLI startup preparation repair in openclaw#131503.
Related: the generic CLI startup preparation repair. This is the independent iMessage import-boundary follow-up; Browser CLI and native relay changes are not included.
What Problem This Solves
Fixes unnecessary startup work for operators running configuration repair or Doctor with the iMessage plugin installed. Those control-plane checks could load the live channel and message-routing dependency graph even when no channel execution was requested.
Why This Change Was Made
Keep the existing state definitions in one lightweight, plugin-owned module shared by migration planning and the live caches. Load the migration detector only when the existing Doctor adapter resolves plans, and use the existing narrow account-resolution SDK export instead of the message-routing barrel.
This removes the eager detector/runtime/routing edges and the duplicate reply-cache TTL without introducing another cache, SDK surface, compatibility wrapper, or migration path. The existing adapter still owns detection and migration execution. Storage namespaces, capacities, TTLs, hash keys, serialized values, retry ordering, replacement rules, source archival and idempotence are unchanged. There are no schema, configuration, dependency, permission or protocol changes.
The eager Doctor import is traceable to the legacy-state migration unification, authored and merged by @steipete on August 9, 2026. This preserves that canonical adapter rather than reverting its ownership model. The narrow account-resolution export is already present in the host's 2026.8.1 beta SDK.
User Impact
Configuration repair and state detection avoid unrelated channel initialization work. Existing iMessage reply mappings, catchup cursors and sent-message echo state keep the same behavior. This is an import-boundary repair, not a five-second startup guarantee or a change to sending, receiving, native permissions, or account selection.
Evidence
AI-assisted; implementation and independent Codex review were inspected against the real owner and SDK contracts.
pnpm buildpassed on19e77d0aca15ee9b6cfee3d7751ca0b9e071806a: all 15 phases completed, with no ineffective dynamic imports.plugins install npm-pack:... --force --accept-capabilitiesandplugins inspect imessage --jsonall passed in isolated state. Installed bytes matched 10,073 host dist files and all 2,135 plugin files.19e77d0aca15ee9b6cfee3d7751ca0b9e071806a: 41 successful jobs, 18 intentionally skipped, and the requiredopenclaw/ci-gatesuccessful. No CI rerun was needed.Artifact identities: host tarball SHA-256
0a89d644bb3f0de1e209521b1923c4e63910f320d3e51475051075283b840b2c; iMessage tarball SHA-2568987c28522122c138f71efee473eddbb047b65a1d555e82341a2fcb22be1ce13. Installed Doctor entry SHA-2561dfe5ad94caebf87e936b801202aebd3482c640f947a61ed919216df52dba477. Build ID:2026.8.1-19e77d0aca15-2026-08-29T06-10-11.492Z.All canonical build/package/install commands passed. A local proof-output filename collision overwrote the first detailed functional receipt, so the same successful proof was rerun once with distinct receipt names and entirely fresh synthetic state; the retained run passed all 104 assertions. No product changes, deadline extensions or skipped checks were used. The source tree and staged Git entries remained unchanged throughout artifact proof.
Owner tests:
Sibling tests:
Production LOC: +169/-143 (net +26). Tests/support: +132/-19 (net +113). Most of the 125-line state-contract module is relocated code. The remaining production growth is the shared imports/types and lazy detector handoff; the extraction already removes the old definitions and duplicate TTL. No unrelated deletion is included to manufacture a net-neutral count.
Proof boundaries: all state is synthetic. No operator Gateway, Messages,
imsg, native registrations, credentials, or Chrome state is touched. iMessage hasbundledDist: false, so the root/Browser artifact is not counted as external iMessage package proof. The existing unreadable-source test proves failed plan reading, not full failed-executor source retention.