Skip to content

fix(imessage): avoid unnecessary startup work in Doctor - #132435

Merged
steipete merged 1 commit into
mainfrom
steipete/imessage-doctor-imports-a0c9da
Aug 29, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/imessage-doctor-imports-a0c9da

Conversation

@steipete

@steipete steipete commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Baseline: 386 owner tests passed. The three new import-denial cases then failed on the old eager detector, live runtime and routing edges, before production changes.
  • After extraction: the same three cases passed; the complete owner selection passed 389 tests across six files. This includes the real migration adapter writing canonical keyed-store rows, archiving synthetic legacy files, and repeated detection/migration.
  • Doctor registry/load-path and post-startup-repair persistence siblings: 45 tests passed across three files.
  • The full changed-file gate passed extension and test types, lint, formatting, five Doctor declaration/import-closure cases, dead-export checks, dependency/SDK guards and import-cycle checks. No timeouts, assertions or gates were weakened.
  • Fresh isolated pre-commit review: scoped-clean at P0, with no findings.
  • Fresh full pnpm build passed on 19e77d0aca15ee9b6cfee3d7751ca0b9e071806a: all 15 phases completed, with no ineffective dynamic imports.
  • Canonical host packaging, normal lifecycle-enabled npm installation, external iMessage runtime build and local package, then real installed plugins install npm-pack:... --force --accept-capabilities and plugins inspect imessage --json all passed in isolated state. Installed bytes matched 10,073 host dist files and all 2,135 plugin files.
  • Native Node execution of the actual installed built Doctor artifact passed 104 assertions: config normalization, non-creating absent-state checks, four canonical SQLite rows, remaining TTLs, counter sequence 42→42→73, cursor rowid sequence 42→42→99, eight byte-verified archives, and three repeated null-detection/empty-migration runs. The driver used the real installed host executor and read-only SQLite inspection, not workspace aliases or a mocked executor.
  • Exact-head CI passed on 19e77d0aca15ee9b6cfee3d7751ca0b9e071806a: 41 successful jobs, 18 intentionally skipped, and the required openclaw/ci-gate successful. No CI rerun was needed.

Artifact identities: host tarball SHA-256 0a89d644bb3f0de1e209521b1923c4e63910f320d3e51475051075283b840b2c; iMessage tarball SHA-256 8987c28522122c138f71efee473eddbb047b65a1d555e82341a2fcb22be1ce13. Installed Doctor entry SHA-256 1dfe5ad94caebf87e936b801202aebd3482c640f947a61ed919216df52dba477. 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:

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.ts

Sibling tests:

OPENCLAW_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.ts

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 has bundledDist: 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.

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.
@steipete steipete self-assigned this Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage size: M maintainer Maintainer-authored PR labels Aug 29, 2026
@steipete
steipete marked this pull request as ready for review August 29, 2026 06:25
@steipete

Copy link
Copy Markdown
Contributor Author

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.ts
OPENCLAW_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.ts
node 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.ts
pnpm build
node 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.json
node --import ./scripts/tsx.mjs scripts/check-plugin-npm-runtime-builds.mts --package extensions/imessage
OPENCLAW_PLUGIN_NPM_PACK_OUTPUT_DIR="$B_PACK_DIR" bash scripts/plugin-npm-publish.sh --pack extensions/imessage

The fresh host tarball was installed into an isolated prefix using normal npm install --global --prefix with lifecycle scripts enabled. B_PACK_DIR was a fresh task-owned output directory; the commands below used that exact plugin tarball and the freshly installed CLI, with isolated HOME/state/config/TMPDIR and empty npmrc files:

node "$B_INSTALLED_CLI" plugins install "npm-pack:$B_PLUGIN_TGZ" --force --accept-capabilities
node "$B_INSTALLED_CLI" plugins inspect imessage --json

The 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: 0a89d644bb3f0de1e209521b1923c4e63910f320d3e51475051075283b840b2c.
iMessage SHA-256: 8987c28522122c138f71efee473eddbb047b65a1d555e82341a2fcb22be1ce13.
Doctor entry SHA-256: 1dfe5ad94caebf87e936b801202aebd3482c640f947a61ed919216df52dba477.

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.

@steipete
steipete merged commit 7cdda72 into main Aug 29, 2026
182 checks passed
@steipete
steipete deleted the steipete/imessage-doctor-imports-a0c9da branch August 29, 2026 06:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant