Skip to content

fix(state-migrations): isolate a throwing channel plan callback into a warning (#119200) - #119201

Merged
steipete merged 2 commits into
openclaw:mainfrom
ruel225:fix/state-migration-plan-isolation
Aug 31, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
ruel225:fix/state-migration-plan-isolation

Conversation

@ruel225

@ruel225 ruel225 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Refs #119200 — per-plan migration failure isolation, warning reporting, and continuation of unrelated plans.

What Problem This Solves

A failing channel migration callback skips later independent plans in its batch and discards the report of work that already completed. The issue's explicit expected behavior is to isolate each import plan, record a Failed migrating <label> warning, and continue unrelated plans. This PR targets that per-plan contract and the shared-source retirement safety required to preserve retry inputs while continuing.

The existing canonical Doctor flow already catches migration failures at the outer plugin boundary. PR #120716 — canonical Doctor migration routing — predates this patch; this patch is not credited with fixing the historical whole-Doctor/startup crash. The existing Gateway warning gate also remains fail-closed. The issue remains open pending whole-outcome operator proof; this PR uses a reference rather than an automatic closure trailer.

Continuing blindly is also unsafe: one legacy source can feed several imports. The iMessage migration derives a durable short-ID counter and an expiring reply cache from the same JSONL file. If the counter import fails, an empty-cache cleanup must not archive the file that the counter still needs for retry.

Why This Change Was Made

The executor owns both the per-plan failure boundary and the lifetime of each declared source. It preserves completed change reports, continues unrelated sources in their original order, visibly defers later plans sharing an incomplete source, and delays import-source cleanup until that source's last consumer finishes without a reported failure or incomplete import. Deferred callbacks re-enter their captured import state directory; unique-source cleanup retains its original position relative to unrelated work.

Duplicate baseline maps, key sets, and per-entry cleanup-failure tracking are consolidated into the source-lifecycle flow. No configuration option, dependency, public API, protocol, SQLite schema, or runtime-entry TTL/cap policy is changed. Source identity is the declared sourcePath within one executor invocation; this is not filesystem-alias detection, a cross-invocation transaction, or rollback of already completed imports or explicit moves. Successful empty reads remain valid: core does not reinterpret a plugin's empty result as an I/O failure.

User Impact

Doctor keeps completed work visible and allows unrelated migrations to finish without losing a failed shared-source import's retry input. Gateway startup continues to refuse readiness when migration warnings remain. Operators still resolve the reported plugin failure and run openclaw doctor --fix before retrying startup.

Thanks @ruel225 for the report and initial repair. This maintainer update preserves the original contributor commit ancestry and replaces its narrow callback test with ordered failure, shared-source lifetime, and retry coverage.

Evidence

Inspectable retained output and recorded state assertions: exact-head Doctor failure, retry, and no-op proof. Both current ClawSweeper rank-up requests are addressed by that output and the completed exact-head CI; no source change or new replay is claimed.

  • Before the initial repair, a real public SDK-adapter/executor/SQLite probe completed the earlier move, rejected at the callback, and skipped the later move. The initial ordered regression failed for both synchronous throws and asynchronous rejections. The implicated source was verified against frozen main ee036be7796396868bfa4851210e66c17bb2a25c.
  • A first, unpublished per-plan-isolation candidate failed the real SDK probe with the actual iMessage two-consumer shape: it archived the source after the counter callback failed, left the canonical counter at 1 instead of importing 9000, and completed the unrelated move. The probe exited 1 on the source-preservation assertion. The shared-source refinement prevents that candidate regression; this is synthetic producer-shape evidence, not an observed iMessage incident or an execution of iMessage itself.
  • An independent rerun of that unchanged SDK probe against committed head 3bd51c896322b0ee87d03e9ad85ccca6443eb927 exited 0: the source remained unarchived, the canonical counter stayed at 1 after the failed callback, the unrelated move completed, and the failed counter plus dependent-plan deferral were both reported. The receipt binds the exact full-base diff and unchanged source/module descriptors before and after execution.
  • The revised owner passes nine regression cases: ordered throw/rejection isolation; shared-source predicate, reader, and capacity failures; cleanup requested before a later failure; a valid empty counter; scoped cleanup success/failure; repaired retries and no-op convergence.
  • Existing Doctor migrations: 97/97 pass, including source cleanup, public removeSource, namespace/plugin capacity, creation-time preservation, cap eviction, retry, and plugin-index warning behavior.
  • Existing public SDK migrations: 4/4 pass, including real SQLite retention and mocked adapter delegation. The separate SDK probe, not the delegation mock, supplies real adapter execution evidence.
  • An independent caller-boundary batch passed all three selected cases in src/commands/doctor-config-preflight.state-migration.test.ts: warnings still refuse Gateway readiness despite a current checkpoint, a rejecting fresh-config guard releases the startup lease, and a deferred service exit releases the lease before propagation. Its actual stderr included the refusal and openclaw doctor --fix recovery hint. These are focused tests, not a live Gateway run.
  • Commands: node scripts/run-vitest.mjs src/infra/state-migrations.plugin-state.test.ts, node scripts/run-vitest.mjs src/commands/doctor-state-migrations.test.ts, and node scripts/run-vitest.mjs src/plugin-sdk/runtime-doctor-migrations.test.ts; each ran separately with at most two workers and the supported task-private filesystem-cache path. Total: 110 passing tests on one unchanged source revision.
  • Fresh Codex autoreview of the complete ancestry-preserved candidate against original PR base 80e4dd3d3ae4bb5e18e7718f466241ea4bc6f8f5: scoped-clean through P2, no actionable findings. Full owner, all four real plan producers, relevant caller/SDK/store contracts, and regression/sibling test sources were included as evidence; source hashes were unchanged after review.
  • A separate read-only Codex source review of committed head 3bd51c896322b0ee87d03e9ad85ccca6443eb927, tree 99b79a6ed9344cb45193397ebc5037c5bc7f50fb, and the full original-base diff also passed with no actionable P0–P2 findings. Its receipt verifies unchanged source, read-only sandboxing, and no project-code execution. This is independent source review, not runtime, package, CI, or landing approval.
  • A later private pnpm install --frozen-lockfile --ignore-scripts passed using task-local Corepack and the exact repository-pinned pnpm 12.0.0 hash. It covered all 174 workspace projects, skipped resolution, and cloned 1,349 packages from the local store. The worktree now owns its dependency directory and @openclaw/ai resolves to its own workspace package. Tracked manifests, lockfile, source, shared dependency metadata, and hooks-path value were unchanged. This install receipt does not claim lifecycle or clean-machine validation.
  • Canonical pnpm build then passed in 268.65 seconds, including AI/package/unified declarations, public SDK exports, CLI bootstrap checks, plugin artifacts, and the Control UI build. No INEFFECTIVE_DYNAMIC_IMPORT diagnostic was emitted. dist/build-info.json names candidate commit 3bd51c896322b0ee87d03e9ad85ccca6443eb927; its identity and tracked source stayed unchanged through the subsequent Doctor runs.
  • Real dist-backed CLI proof ran node openclaw.mjs doctor --fix --non-interactive in isolated HOME/state directories: initialization; a throwing shared-source counter callback; retry after changing only that synthetic callback to return true; and a no-op replay. All four CLI invocations exited 0. The failing invocation visibly reported the callback error and dependent cleanup deferral, preserved the source/counter value 1, and reported both unrelated moves. Retry imported counter 9000 and archived the source. Replay preserved the fixture/archive/move bytes, emitted no fixture import/archive report, and did not invoke the predicate. Fresh callback-boundary traces and artifact hashes bind the actual public SDK adapter and executor to this candidate's dist, not the previously borrowed checkout.
  • node scripts/check-changed.mjs --base 80e4dd3d3ae4bb5e18e7718f466241ea4bc6f8f5 --head 3bd51c896322b0ee87d03e9ad85ccca6443eb927 --timed -- docs/gateway/doctor.md src/infra/state-migrations.plugin-state.test.ts src/infra/state-migrations.plugin-state.ts passed all 29 selected gates in 426.728 seconds. This includes core/core-test typechecking, changed-file formatting and lint, three Knip scans, zero runtime import cycles, and the selected architecture/dependency/schema-version guards. Final checks confirmed a clean checkout and unchanged source, built-artifact hashes, private dependency descriptors, and workspace AI ownership.
  • Independent final artifact readback was accepted for the exact commit/tree and full-index patch. It checked the actual build/static endings, all four CLI logs and retained drivers, callback-only repair, no-op identities, public SDK chain, six traced runtime chunks, and unchanged source/artifact hashes. A unique copy of the complete terminal SQLite/WAL/SHM family had one fixture counter row at 9000, zero cache rows, and quick_check=ok; the original family was unchanged. Historical phase query receipts were inspected, not relabeled as pre/failure whole-DB snapshots or a fresh replay. The no-op claim is predicate non-entry and no repeated fixture migration, not global executor-module absence.

Production LOC against the original PR base: +226/−224 (net +2, mostly reindentation). Tests: +294/−0; the old broad test file returns to its original-base bytes. Docs: +2/−0. The remaining production growth implements shared-source retirement after duplicate tracking and catch paths were absorbed.

Exact-head CI run 33388860633, attempt 1, completed successfully; the remaining steps are the normal native landing gates. The real Doctor proof is scoped to these migrations, not a healthy whole installation or live Gateway: no Gateway was started, so the isolated-port health check reported ECONNREFUSED. Normal node-onboarding, command-owner, backup, desktop, synthetic plaintext-token, browser legacy-auth, STT, and missing memory/provider-key advisories remained visible. Doctor also reported another existing state root, while active config writes and service-skip diagnostics stayed bound to the isolated fixture. These advisories were not suppressed or turned into a claim that the broader issue is closed. The test receipts above used borrowed frozen-main modules with matching test-tool versions; the later private install is recorded separately and does not retroactively change those test environments or establish lifecycle proof. Two earlier local Vitest attempts stalled before reporting cases; an owned process was observed waiting in a filesystem rename. Those attempts are not passing evidence, their root cause is unproven, and no timeout or assertion was weakened. A supported task-private cache allowed the unchanged candidate to run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 9:03 AM ET / 13:03 UTC.

ClawSweeper review

What this changes

The PR makes Doctor turn a failed legacy plugin-state migration plan into a warning, continue unrelated plans, and retain a shared legacy source until every consumer succeeds.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still has the uncaught callback path, while this PR adds the owner-level failure boundary and shared-source protection. No blocking correctness findings; the new exact-head Doctor CLI transcript is sufficient real behavior proof.

Priority: P2
Reviewed head: 3bd51c896322b0ee87d03e9ad85ccca6443eb927

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) This is a focused owner-boundary repair with direct exact-head CLI evidence and substantive shared-source regression coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The retained exact-head Doctor CLI transcript exercises the public SDK adapter and changed executor with a throwing shared-source callback, visibly reports the warning and deferral, preserves the source and canonical counter, and completes unrelated moves.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The retained exact-head Doctor CLI transcript exercises the public SDK adapter and changed executor with a throwing shared-source callback, visibly reports the warning and deferral, preserves the source and canonical counter, and completes unrelated moves.
Evidence reviewed 7 items Current-main defect: Current main awaits a plugin replacement callback inside the import loop without a per-plan catch, so a thrown or rejected callback escapes the executor rather than becoming a warning.
Introduced repair: The PR wraps each plan in a failure boundary, records incomplete sources, defers dependent consumers, and runs pending cleanup only after the final consumer succeeds.
Caller and sibling shape: The public plugin Doctor adapter resolves plans and delegates them to this executor; iMessage supplies two imports from the same reply-cache source, making source-lifetime tracking the correct owner boundary.
Findings None None.
Security None None.

How this fits together

Doctor collects state-migration plans from plugins before normal startup. The executor returns migration changes and warnings to Doctor and Gateway startup, where unresolved warnings prevent readiness.

flowchart LR
  A[Plugin migration plans] --> B[Doctor migration executor]
  B --> C[Import or file operation]
  C --> D[Shared source tracking]
  C --> E[Changes and warnings]
  D --> E
  E --> F[Doctor and startup gate]
Loading

Before merge

  • Resolve merge risk (P1) - Merging intentionally changes failed shared-source migrations to retain the legacy source and keep readiness blocked by a warning until Doctor succeeds; the isolated exact-head CLI proof covers this contract, but not an existing-user upgrade fixture.
  • Complete next step (P2) - The open PR already owns the narrow repair, and no actionable finding calls for an automated follow-up.
Agent review details

Security

None.

PR surface

Source +2, Tests +294, Docs +2. Total +298 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 226 224 +2
Tests 1 294 0 +294
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 522 224 +298

Review metrics

Metric Value Why it matters
Production and regression-test delta production +2 net (+226/−224), tests +294, docs +2 The small production increase implements source-lifetime tracking, with cases for callback failures, shared sources, cleanup scope, retry, and convergence.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/infra/state-migrations.plugin-state.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the recoverable migration contract (recommended)
    Land the documented warning-and-retry behavior that preserves a shared legacy source instead of retiring it after an incomplete consumer.

Technical review

Best possible solution:

Retain the per-plan failure boundary and source-lifetime ownership in the migration executor so incomplete imports remain recoverable while independent migration work completes.

Do we have a high-confidence way to reproduce the issue?

Yes: current main’s callback await is outside its local read/entry catches, and the precise throwing/rejecting plan is covered by the proposed regression cases.

Is this the best way to solve the issue?

Yes: handling failure in the executor that owns ordering and source cleanup avoids a downstream catch that could lose completed reports or retire a shared retry input.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3ee32fb9c10d.

Labels

Label justifications:

  • P2: This repairs a bounded Doctor migration failure with a documented recovery path.
  • merge-risk: 🚨 compatibility: Migration cleanup timing and warning-driven readiness affect existing installations that still have legacy plugin state.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The retained exact-head Doctor CLI transcript exercises the public SDK adapter and changed executor with a throwing shared-source callback, visibly reports the warning and deferral, preserves the source and canonical counter, and completes unrelated moves.
  • proof: sufficient: Contributor real behavior proof is sufficient. The retained exact-head Doctor CLI transcript exercises the public SDK adapter and changed executor with a throwing shared-source callback, visibly reports the warning and deferral, preserves the source and canonical counter, and completes unrelated moves.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-10T04:53:31.098Z sha 95cf0a4e7bf7a897a7331897e9b8631c80ae2b63 :: needs maintainer review before merge. :: none
  • reviewed August 14, 2026, 12:54 PM ET / 16:54 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed August 15, 2026, 5:52 PM ET / 21:52 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T18:46:31.091Z sha 95cf0a4e7bf7a897a7331897e9b8631c80ae2b63 :: needs changes before merge. :: none
  • reviewed 2026-08-26T01:22:22.267Z sha 95cf0a4e7bf7a897a7331897e9b8631c80ae2b63 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T02:04:59.598Z sha 95cf0a4e7bf7a897a7331897e9b8631c80ae2b63 :: needs changes before merge. :: none
  • reviewed 2026-08-30T00:45:26.252Z sha df4ea5e :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T11:59:07.395Z sha 3bd51c8 :: needs real behavior proof before merge. :: none

@ruel225
ruel225 force-pushed the fix/state-migration-plan-isolation branch from fc0c5ad to f1ceafa Compare August 4, 2026 12:52
@ruel225

ruel225 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Added a real after-fix runtime transcript: tsx driving the real runLegacyMigrationPlans with a throwing shouldReplaceExistingEntry + a follow-up move plan. The throwing callback is isolated into a warning and the move plan still executes. PR body Evidence updated.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@ruel225
ruel225 force-pushed the fix/state-migration-plan-isolation branch from f1ceafa to 95cf0a4 Compare August 5, 2026 06:21
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 6, 2026
@ruel225

ruel225 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Re-ran the proof on the exact head 95cf0a4e7bf. The transcript now shows the correct head SHA and confirms the throwing callback is isolated + the move plan still executes. PR body Evidence updated.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 6, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 14, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 26, 2026
…a warning

runLegacyMigrationPlans ran the plugin-state-import plan without a
try/catch, so a throwing shouldReplaceExistingEntry (a channel plugin
contract callback) escaped through runLegacyStateMigrationSteps and
config-guard, crashing doctor/gateway startup and skipping every
unrelated migration plan. Wrap the import plan in the same per-plan
isolation sibling migratePluginDoctorStatePlans already uses: record a
warning and continue so the remaining plans still run.

Re-applied on top of the plugin-state import rewrite, which grew
rename/remove source cleanup and archive-on-cover handling around the
same withPluginStateImportEnv call.

Co-Authored-By: Claude <[email protected]>
@ruel225
ruel225 force-pushed the fix/state-migration-plan-isolation branch from 95cf0a4 to df4ea5e Compare August 30, 2026 00:38
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
Keep each migration plan's failure boundary in the executor so earlier
change reports survive and unrelated sources can continue in order.
Defer plans sharing an incomplete source and retire import sources only
after their last consumer succeeds, preserving the import state scope.
This protects durable counters and expiring caches derived from one file.

Absorb source-lifecycle tracking by consolidating duplicate key sets,
baseline maps, and per-entry cleanup-failure state. Preserve warning-based
startup refusal without configuration, API, schema, or retention changes.

Replace the narrow callback test with ordered throw/rejection, shared
source read/capacity failures, cleanup ordering/scope, retry, and no-op
regressions. Existing Doctor and SDK migration coverage remains green.

Related: openclaw#119200

Co-authored-by: ruel225 <[email protected]>
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 31, 2026
@steipete

Copy link
Copy Markdown
Contributor

Inspectable exact-head Doctor proof

This supplies the retained output requested in the current ClawSweeper review, without another replay or source change. All four CLI invocations used candidate 3bd51c896322b0ee87d03e9ad85ccca6443eb927 after a successful canonical pnpm build. The repair remains Refs #119200: per-plan reporting/continuation and shared-source retirement safety, not a claim that this patch fixed the historical whole-Doctor/Gateway crash. The pre-existing outer plugin catch and fail-closed Gateway warning gate remain intact.

Command for initialization and each phase below: node openclaw.mjs doctor --fix --non-interactive, using an isolated HOME, state directory, config, and port. Initialization completed before seeding a synthetic canonical counter of 1, a legacy short ID of 9000, and two unrelated move inputs. The configured plugin imports definePluginDoctorMigrationFromPlans from the public openclaw/plugin-sdk/runtime-doctor-migrations entrypoint.

Only known filesystem roots are redacted below as <fixture>, <checkout>, and <other-state-root>. The captured output and state values are otherwise retained. These are application CLI captures, not an agent conversation.

1. Throwing callback: source retained, unrelated plans complete

Recorded state assertions (selected fields from the live phase-query receipt):

{
  "phase": "failed",
  "earlierMoved": true,
  "laterMoved": true,
  "sourceRetained": true,
  "sourceArchived": false,
  "canonicalCounter": 1,
  "callbackWarningVisible": true
}

Recorded child exit:

{"label": "failed", "exit": 0, "signal": null}
Captured Doctor stdout/stderr
┌  OpenClaw doctor
[state-migrations] Auto-migrated legacy state:
- Moved Earlier fixture artifact → <fixture>/state/earlier-artifact.txt.moved
- Moved Later fixture artifact → <fixture>/state/later-artifact.txt.moved
│
◇  Doctor changes ──────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                               │
│  - Moved Earlier fixture artifact →                                                                           │
│    <fixture>/state/earlier-artifact.txt.moved  │
│  - Moved Later fixture artifact →                                                                             │
│    <fixture>/state/later-artifact.txt.moved    │
│                                                                                                               │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Doctor warnings ───────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                         │
│  - Failed migrating Synthetic reply counter                                                             │
│    (<fixture>/state/reply-cache.jsonl):  │
│    Error: synthetic callback failure                                                                    │
│  - Deferred Synthetic expired reply cache: another migration of                                         │
│    <fixture>/state/reply-cache.jsonl     │
│    did not complete.                                                                                    │
│                                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[warning] core/doctor/node-hosting-preconditions plugins.entries.device-pair.enabled - The device-pair plugin is not enabled; node onboarding join codes and openclaw connect are unavailable.
  fix: Set plugins.entries.device-pair.enabled: true, ensure device-pair is not denied or excluded by plugins.allow, then restart the Gateway.
[warning] core/doctor/node-hosting-preconditions gateway.bind - Gateway is only bound to loopback. Set gateway.bind=lan, enable tailscale serve, or configure plugins.entries.device-pair.config.publicUrl.
  fix: If an edge proxy fronts node onboarding, allow /j/* and /__openclaw__/worker without edge identity auth, and preserve WebSocket upgrade on /__openclaw__/worker. Both routes enforce their own credentials.
│
◇  Command owner ─────────────────────────────────────────────────────────╮
│                                                                         │
│  No command owner is configured.                                        │
│  A command owner is the human operator account allowed to run           │
│  owner-only commands and approve dangerous actions, including           │
│  /diagnostics, /export-session, /export-trajectory, /config, and exec   │
│  approvals.                                                             │
│  DM pairing only lets someone talk to the bot; it does not make that    │
│  sender the owner for privileged commands.                              │
│  Fix: set commands.ownerAllowFrom to your channel user id, for example  │
│  openclaw config set commands.ownerAllowFrom '["telegram:123456789"]'   │
│  Restart the gateway after changing this if it is already running.      │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Legacy state detected ──────────────────────────────────────────────────────────────────────────────╮
│                                                                                                      │
│  - Synthetic reply counter:                                                                          │
│    <fixture>/state/reply-cache.jsonl  │
│  - Synthetic expired reply cache:                                                                    │
│    <fixture>/state/reply-cache.jsonl  │
│                                                                                                      │
├──────────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Doctor warnings ─────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                       │
│  Failed migrating Synthetic reply counter                                                             │
│  (<fixture>/state/reply-cache.jsonl):  │
│  Error: synthetic callback failure                                                                    │
│  Deferred Synthetic expired reply cache: another migration of                                         │
│  <fixture>/state/reply-cache.jsonl     │
│  did not complete.                                                                                    │
│                                                                                                       │
├───────────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Plugin registry ───────────────────────────────────────────╮
│                                                             │
│  Plugin registry refreshed: 3/152 enabled plugins indexed.  │
│                                                             │
├─────────────────────────────────────────────────────────────╯
│
◇  State integrity ─────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                   │
│  - OAuth dir not present                                                                          │
│    (<fixture>/state/credentials).  │
│    Skipping create because no WhatsApp/pairing channel config is                                  │
│    active.                                                                                        │
│  - Multiple state directories detected. This can split session history.                           │
│    - <other-state-root>                                                                    │
│    Active state dir:                                                                              │
│    <fixture>/state                 │
│                                                                                                   │
├───────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Backups ─────────────────────────────────────────────────────────────╮
│                                                                       │
│  No successful backup is recorded.                                    │
│  Create one now with openclaw backup create.                          │
│  Schedule versioned backups with openclaw backup enable --repository  │
│  <dir>.                                                               │
│                                                                       │
├───────────────────────────────────────────────────────────────────────╯
│
◇  Gateway ──────────────────────────────────────────────────────────╮
│                                                                    │
│  service management skipped: non-default state dir or config path  │
│                                                                    │
├────────────────────────────────────────────────────────────────────╯
│
◇  Host desktop ──────────────────────────────────────────────────────────╮
│                                                                         │
│  disabled; enable the Desktop lab with desktop.host.enabled=true, then  │
│  restart the gateway                                                    │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Security ─────────────────────────────────────────────────────────────╮
│                                                                        │
│  - WARNING: openclaw.json contains plaintext secret-bearing config     │
│    fields.                                                             │
│    Paths: gateway.auth.token                                           │
│    Agents or workspace tools that can read config files may see these  │
│    API keys/tokens.                                                    │
│    Migrate them to SecretRefs with openclaw secrets configure or       │
│    openclaw secrets apply, then verify with openclaw secrets audit     │
│    --check.                                                            │
│  - Run: openclaw security audit --deep                                 │
│                                                                        │
├────────────────────────────────────────────────────────────────────────╯
│
◇  GitHub projects ────────────────────────────────────────────────────────╮
│                                                                          │
│  Prefer gateway.controlUi.github.token for Gateway-owned GitHub project  │
│  access, or set GH_TOKEN/GITHUB_TOKEN in the shared Gateway process      │
│  environment. Without either, search is public-only.                     │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Browser relay authentication ──────────────────────────────────────────╮
│                                                                         │
│  - Legacy Browser Relay Authentication is enabled                       │
│    (browser.extensionRelay.allowLegacyAuth=true).                       │
│  - Update paired Chrome extensions and external CDP clients to Browser  │
│    Relay Authentication v2, then set                                    │
│    browser.extensionRelay.allowLegacyAuth=false.                        │
│  - V2 clients never downgrade to legacy authentication.                 │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Browser ─────────────────────────────────────────────────────────╮
│                                                                   │
│  - System browser profile cookie import is enabled                │
│    (browser.allowSystemProfileImport).                            │
│  - Importable Chrome-family profile cookie databases found: 0.    │
│  - Doctor does not access the macOS Keychain; importing asks for  │
│    consent separately.                                            │
│                                                                   │
├───────────────────────────────────────────────────────────────────╯
│
◇  Doctor information ─────────────────────────────────────────────────────╮
│                                                                          │
│  - Local STT commands were found but none are ready for auto-selection:  │
│    whisper-cli: model file not found.                                    │
│    path: tools.media.models                                              │
│    fix: Install the matching local model/runtime, or configure an        │
│    audio-capable tools.media.models CLI entry.                           │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Memory search ──────────────────────────────────────────────────────────╮
│                                                                          │
│  Remember across conversations is effectively enabled for agent "main",  │
│  but the Active Memory plugin is disabled. Enable the plugin or set      │
│  memory.search.rememberAcrossConversations to false.                     │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Memory search ───────────────────────────────────────────────────────╮
│                                                                       │
│  Memory search provider is set to "openai" but no API key was found.  │
│  Semantic recall will not work without a valid API key.               │
│                                                                       │
│                                                                       │
│  Fix (pick one):                                                      │
│  - Set OPENAI_API_KEY in your environment                             │
│  - Configure credentials: openclaw configure --section model          │
│  - To disable: openclaw config set memory.search.enabled false        │
│                                                                       │
│  Verify: openclaw memory status --deep                                │
│                                                                       │
├───────────────────────────────────────────────────────────────────────╯
│
◇  Workspace ────────────────────────────────────────────────────────────────────────────╮
│                                                                                        │
│  Memory system not found in workspace.                                                 │
│  Paste this into your agent:                                                           │
│                                                                                        │
│  Install the memory system by applying:                                                │
│  https://github.com/openclaw/openclaw/commit/9ffea23f31ca1df5183b25668f8f814bee0fb34e  │
│  https://github.com/openclaw/openclaw/commit/7d1fee70e76f2f634f1b41fca927ee663914183a  │
│                                                                                        │
├────────────────────────────────────────────────────────────────────────────────────────╯
│
└  Doctor complete.


[state-migrations] Legacy state migration warnings:
- Failed migrating Synthetic reply counter (<fixture>/state/reply-cache.jsonl): Error: synthetic callback failure
- Deferred Synthetic expired reply cache: another migration of <fixture>/state/reply-cache.jsonl did not complete.
Health check failed: GatewayTransportError: Gateway not reachable at ws://127.0.0.1:52979 (ECONNREFUSED).
Start it with `openclaw gateway run` or check `openclaw gateway status`.
Gateway target: ws://127.0.0.1:52979
Source: local loopback
Config: <fixture>/state/openclaw.json
Bind: loopback

2. Callback corrected: counter imported, source archived

The only fixture-code correction was throw new Error("synthetic callback failure"); → return true;. All plan ordering, source, import, and cleanup logic stayed unchanged. No production source changed.

Recorded state assertions (selected fields from the live phase-query receipt):

{
  "phase": "repaired",
  "earlierMoved": true,
  "laterMoved": true,
  "sourceRetained": false,
  "sourceArchived": true,
  "canonicalCounter": 9000,
  "callbackWarningVisible": false
}

Recorded child exit:

{"label": "repaired", "exit": 0, "signal": null}
Captured Doctor stdout/stderr
┌  OpenClaw doctor
[state-migrations] Auto-migrated legacy state:
- Migrated 1 Synthetic reply counter entry → plugin state
- Archived Synthetic expired reply cache legacy source → <fixture>/state/reply-cache.jsonl.migrated
│
◇  Doctor changes ──────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                               │
│  - Migrated 1 Synthetic reply counter entry → plugin state                                                    │
│  - Archived Synthetic expired reply cache legacy source →                                                     │
│    <fixture>/state/reply-cache.jsonl.migrated  │
│                                                                                                               │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[warning] core/doctor/node-hosting-preconditions plugins.entries.device-pair.enabled - The device-pair plugin is not enabled; node onboarding join codes and openclaw connect are unavailable.
  fix: Set plugins.entries.device-pair.enabled: true, ensure device-pair is not denied or excluded by plugins.allow, then restart the Gateway.
[warning] core/doctor/node-hosting-preconditions gateway.bind - Gateway is only bound to loopback. Set gateway.bind=lan, enable tailscale serve, or configure plugins.entries.device-pair.config.publicUrl.
  fix: If an edge proxy fronts node onboarding, allow /j/* and /__openclaw__/worker without edge identity auth, and preserve WebSocket upgrade on /__openclaw__/worker. Both routes enforce their own credentials.
│
◇  Command owner ─────────────────────────────────────────────────────────╮
│                                                                         │
│  No command owner is configured.                                        │
│  A command owner is the human operator account allowed to run           │
│  owner-only commands and approve dangerous actions, including           │
│  /diagnostics, /export-session, /export-trajectory, /config, and exec   │
│  approvals.                                                             │
│  DM pairing only lets someone talk to the bot; it does not make that    │
│  sender the owner for privileged commands.                              │
│  Fix: set commands.ownerAllowFrom to your channel user id, for example  │
│  openclaw config set commands.ownerAllowFrom '["telegram:123456789"]'   │
│  Restart the gateway after changing this if it is already running.      │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Plugin registry ───────────────────────────────────────────╮
│                                                             │
│  Plugin registry refreshed: 3/152 enabled plugins indexed.  │
│                                                             │
├─────────────────────────────────────────────────────────────╯
│
◇  State integrity ─────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                   │
│  - OAuth dir not present                                                                          │
│    (<fixture>/state/credentials).  │
│    Skipping create because no WhatsApp/pairing channel config is                                  │
│    active.                                                                                        │
│  - Multiple state directories detected. This can split session history.                           │
│    - <other-state-root>                                                                    │
│    Active state dir:                                                                              │
│    <fixture>/state                 │
│                                                                                                   │
├───────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Backups ─────────────────────────────────────────────────────────────╮
│                                                                       │
│  No successful backup is recorded.                                    │
│  Create one now with openclaw backup create.                          │
│  Schedule versioned backups with openclaw backup enable --repository  │
│  <dir>.                                                               │
│                                                                       │
├───────────────────────────────────────────────────────────────────────╯
│
◇  Gateway ──────────────────────────────────────────────────────────╮
│                                                                    │
│  service management skipped: non-default state dir or config path  │
│                                                                    │
├────────────────────────────────────────────────────────────────────╯
│
◇  Host desktop ──────────────────────────────────────────────────────────╮
│                                                                         │
│  disabled; enable the Desktop lab with desktop.host.enabled=true, then  │
│  restart the gateway                                                    │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Security ─────────────────────────────────────────────────────────────╮
│                                                                        │
│  - WARNING: openclaw.json contains plaintext secret-bearing config     │
│    fields.                                                             │
│    Paths: gateway.auth.token                                           │
│    Agents or workspace tools that can read config files may see these  │
│    API keys/tokens.                                                    │
│    Migrate them to SecretRefs with openclaw secrets configure or       │
│    openclaw secrets apply, then verify with openclaw secrets audit     │
│    --check.                                                            │
│  - Run: openclaw security audit --deep                                 │
│                                                                        │
├────────────────────────────────────────────────────────────────────────╯
│
◇  GitHub projects ────────────────────────────────────────────────────────╮
│                                                                          │
│  Prefer gateway.controlUi.github.token for Gateway-owned GitHub project  │
│  access, or set GH_TOKEN/GITHUB_TOKEN in the shared Gateway process      │
│  environment. Without either, search is public-only.                     │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Browser relay authentication ──────────────────────────────────────────╮
│                                                                         │
│  - Legacy Browser Relay Authentication is enabled                       │
│    (browser.extensionRelay.allowLegacyAuth=true).                       │
│  - Update paired Chrome extensions and external CDP clients to Browser  │
│    Relay Authentication v2, then set                                    │
│    browser.extensionRelay.allowLegacyAuth=false.                        │
│  - V2 clients never downgrade to legacy authentication.                 │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Browser ─────────────────────────────────────────────────────────╮
│                                                                   │
│  - System browser profile cookie import is enabled                │
│    (browser.allowSystemProfileImport).                            │
│  - Importable Chrome-family profile cookie databases found: 0.    │
│  - Doctor does not access the macOS Keychain; importing asks for  │
│    consent separately.                                            │
│                                                                   │
├───────────────────────────────────────────────────────────────────╯
│
◇  Doctor information ─────────────────────────────────────────────────────╮
│                                                                          │
│  - Local STT commands were found but none are ready for auto-selection:  │
│    whisper-cli: model file not found.                                    │
│    path: tools.media.models                                              │
│    fix: Install the matching local model/runtime, or configure an        │
│    audio-capable tools.media.models CLI entry.                           │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Memory search ──────────────────────────────────────────────────────────╮
│                                                                          │
│  Remember across conversations is effectively enabled for agent "main",  │
│  but the Active Memory plugin is disabled. Enable the plugin or set      │
│  memory.search.rememberAcrossConversations to false.                     │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Memory search ───────────────────────────────────────────────────────╮
│                                                                       │
│  Memory search provider is set to "openai" but no API key was found.  │
│  Semantic recall will not work without a valid API key.               │
│                                                                       │
│                                                                       │
│  Fix (pick one):                                                      │
│  - Set OPENAI_API_KEY in your environment                             │
│  - Configure credentials: openclaw configure --section model          │
│  - To disable: openclaw config set memory.search.enabled false        │
│                                                                       │
│  Verify: openclaw memory status --deep                                │
│                                                                       │
├───────────────────────────────────────────────────────────────────────╯
│
◇  Workspace ────────────────────────────────────────────────────────────────────────────╮
│                                                                                        │
│  Memory system not found in workspace.                                                 │
│  Paste this into your agent:                                                           │
│                                                                                        │
│  Install the memory system by applying:                                                │
│  https://github.com/openclaw/openclaw/commit/9ffea23f31ca1df5183b25668f8f814bee0fb34e  │
│  https://github.com/openclaw/openclaw/commit/7d1fee70e76f2f634f1b41fca927ee663914183a  │
│                                                                                        │
├────────────────────────────────────────────────────────────────────────────────────────╯
│
└  Doctor complete.


Health check failed: GatewayTransportError: Gateway not reachable at ws://127.0.0.1:52979 (ECONNREFUSED).
Start it with `openclaw gateway run` or check `openclaw gateway status`.
Gateway target: ws://127.0.0.1:52979
Source: local loopback
Config: <fixture>/state/openclaw.json
Bind: loopback

3. Unchanged replay: no repeated fixture migration

The fixture code, archived source, and both moved-file byte hashes were unchanged across replay. Prior diagnostic trace outputs were cleared outside product state; a fresh adapter trace appeared, but the marker written inside the replacement predicate did not. executorTracePresent: false means that fixture predicate was not entered—not that the global executor module never loaded.

Recorded state assertions (selected fields from the live phase-query receipt):

{
  "phase": "noop",
  "earlierMoved": true,
  "laterMoved": true,
  "sourceRetained": false,
  "sourceArchived": true,
  "canonicalCounter": 9000,
  "callbackWarningVisible": false,
  "executorTracePresent": false
}

Recorded child exit:

{"label": "noop", "exit": 0, "signal": null}
Captured Doctor stdout/stderr
┌  OpenClaw doctor
[warning] core/doctor/node-hosting-preconditions plugins.entries.device-pair.enabled - The device-pair plugin is not enabled; node onboarding join codes and openclaw connect are unavailable.
  fix: Set plugins.entries.device-pair.enabled: true, ensure device-pair is not denied or excluded by plugins.allow, then restart the Gateway.
[warning] core/doctor/node-hosting-preconditions gateway.bind - Gateway is only bound to loopback. Set gateway.bind=lan, enable tailscale serve, or configure plugins.entries.device-pair.config.publicUrl.
  fix: If an edge proxy fronts node onboarding, allow /j/* and /__openclaw__/worker without edge identity auth, and preserve WebSocket upgrade on /__openclaw__/worker. Both routes enforce their own credentials.
│
◇  Command owner ─────────────────────────────────────────────────────────╮
│                                                                         │
│  No command owner is configured.                                        │
│  A command owner is the human operator account allowed to run           │
│  owner-only commands and approve dangerous actions, including           │
│  /diagnostics, /export-session, /export-trajectory, /config, and exec   │
│  approvals.                                                             │
│  DM pairing only lets someone talk to the bot; it does not make that    │
│  sender the owner for privileged commands.                              │
│  Fix: set commands.ownerAllowFrom to your channel user id, for example  │
│  openclaw config set commands.ownerAllowFrom '["telegram:123456789"]'   │
│  Restart the gateway after changing this if it is already running.      │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Plugin registry ───────────────────────────────────────────╮
│                                                             │
│  Plugin registry refreshed: 3/152 enabled plugins indexed.  │
│                                                             │
├─────────────────────────────────────────────────────────────╯
│
◇  State integrity ─────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                   │
│  - OAuth dir not present                                                                          │
│    (<fixture>/state/credentials).  │
│    Skipping create because no WhatsApp/pairing channel config is                                  │
│    active.                                                                                        │
│  - Multiple state directories detected. This can split session history.                           │
│    - <other-state-root>                                                                    │
│    Active state dir:                                                                              │
│    <fixture>/state                 │
│                                                                                                   │
├───────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Backups ─────────────────────────────────────────────────────────────╮
│                                                                       │
│  No successful backup is recorded.                                    │
│  Create one now with openclaw backup create.                          │
│  Schedule versioned backups with openclaw backup enable --repository  │
│  <dir>.                                                               │
│                                                                       │
├───────────────────────────────────────────────────────────────────────╯
│
◇  Gateway ──────────────────────────────────────────────────────────╮
│                                                                    │
│  service management skipped: non-default state dir or config path  │
│                                                                    │
├────────────────────────────────────────────────────────────────────╯
│
◇  Host desktop ──────────────────────────────────────────────────────────╮
│                                                                         │
│  disabled; enable the Desktop lab with desktop.host.enabled=true, then  │
│  restart the gateway                                                    │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Security ─────────────────────────────────────────────────────────────╮
│                                                                        │
│  - WARNING: openclaw.json contains plaintext secret-bearing config     │
│    fields.                                                             │
│    Paths: gateway.auth.token                                           │
│    Agents or workspace tools that can read config files may see these  │
│    API keys/tokens.                                                    │
│    Migrate them to SecretRefs with openclaw secrets configure or       │
│    openclaw secrets apply, then verify with openclaw secrets audit     │
│    --check.                                                            │
│  - Run: openclaw security audit --deep                                 │
│                                                                        │
├────────────────────────────────────────────────────────────────────────╯
│
◇  GitHub projects ────────────────────────────────────────────────────────╮
│                                                                          │
│  Prefer gateway.controlUi.github.token for Gateway-owned GitHub project  │
│  access, or set GH_TOKEN/GITHUB_TOKEN in the shared Gateway process      │
│  environment. Without either, search is public-only.                     │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Browser relay authentication ──────────────────────────────────────────╮
│                                                                         │
│  - Legacy Browser Relay Authentication is enabled                       │
│    (browser.extensionRelay.allowLegacyAuth=true).                       │
│  - Update paired Chrome extensions and external CDP clients to Browser  │
│    Relay Authentication v2, then set                                    │
│    browser.extensionRelay.allowLegacyAuth=false.                        │
│  - V2 clients never downgrade to legacy authentication.                 │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────╯
│
◇  Browser ─────────────────────────────────────────────────────────╮
│                                                                   │
│  - System browser profile cookie import is enabled                │
│    (browser.allowSystemProfileImport).                            │
│  - Importable Chrome-family profile cookie databases found: 0.    │
│  - Doctor does not access the macOS Keychain; importing asks for  │
│    consent separately.                                            │
│                                                                   │
├───────────────────────────────────────────────────────────────────╯
│
◇  Doctor information ─────────────────────────────────────────────────────╮
│                                                                          │
│  - Local STT commands were found but none are ready for auto-selection:  │
│    whisper-cli: model file not found.                                    │
│    path: tools.media.models                                              │
│    fix: Install the matching local model/runtime, or configure an        │
│    audio-capable tools.media.models CLI entry.                           │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Memory search ──────────────────────────────────────────────────────────╮
│                                                                          │
│  Remember across conversations is effectively enabled for agent "main",  │
│  but the Active Memory plugin is disabled. Enable the plugin or set      │
│  memory.search.rememberAcrossConversations to false.                     │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Memory search ───────────────────────────────────────────────────────╮
│                                                                       │
│  Memory search provider is set to "openai" but no API key was found.  │
│  Semantic recall will not work without a valid API key.               │
│                                                                       │
│                                                                       │
│  Fix (pick one):                                                      │
│  - Set OPENAI_API_KEY in your environment                             │
│  - Configure credentials: openclaw configure --section model          │
│  - To disable: openclaw config set memory.search.enabled false        │
│                                                                       │
│  Verify: openclaw memory status --deep                                │
│                                                                       │
├───────────────────────────────────────────────────────────────────────╯
│
◇  Workspace ────────────────────────────────────────────────────────────────────────────╮
│                                                                                        │
│  Memory system not found in workspace.                                                 │
│  Paste this into your agent:                                                           │
│                                                                                        │
│  Install the memory system by applying:                                                │
│  https://github.com/openclaw/openclaw/commit/9ffea23f31ca1df5183b25668f8f814bee0fb34e  │
│  https://github.com/openclaw/openclaw/commit/7d1fee70e76f2f634f1b41fca927ee663914183a  │
│                                                                                        │
├────────────────────────────────────────────────────────────────────────────────────────╯
│
└  Doctor complete.


Health check failed: GatewayTransportError: Gateway not reachable at ws://127.0.0.1:52979 (ECONNREFUSED).
Start it with `openclaw gateway run` or check `openclaw gateway status`.
Gateway target: ws://127.0.0.1:52979
Source: local loopback
Config: <fixture>/state/openclaw.json
Bind: loopback

Unchanged readiness/lease boundary

No Gateway was started for this Doctor proof. The three independently executed existing cases in src/commands/doctor-config-preflight.state-migration.test.ts cover warning-gated readiness and both lease-release exits; they are test proof, not a live Gateway run. Their captured refusal output was:

[test] starting test/vitest/vitest.commands.config.ts
stderr | src/commands/doctor-config-preflight.state-migration.test.ts > runDoctorConfigPreflight state migration > blocks gateway readiness when state migration warnings outlive the startup checkpoint
OpenClaw startup migrations did not complete cleanly; refusing to report the gateway ready.
- Left legacy config health state in place.
Run "openclaw doctor --fix" against the same state/config, then restart the gateway.

[test] passed 1 Vitest shard in 7.64s

The corresponding stdout reports Tests 3 passed | 27 skipped (30).

Identity and terminal checks

The actual callback stacks resolve the public SDK adapter and executor into this candidate’s built artifacts. The public SDK entrypoint and traced owner hashes were:

{
  "head": "3bd51c896322b0ee87d03e9ad85ccca6443eb927",
  "tree": "99b79a6ed9344cb45193397ebc5037c5bc7f50fb",
  "fullIndexBaseToHeadPatchSha256": "3554eaeb99f61d0935bd856607210c1c0e47c9461488f2801f6a9db50ac23b7c",
  "buildInfoSha256": "21b8d72644b1cd2ef20a687fe378ba5fc5d2e49fccd1e621256c1b6ae0394267",
  "publicSdkEntrypointSha256": "2e5030a034138c0d9308333075036750b5f623c9d4751f60ee17658040a41b23",
  "tracedArtifacts": {
    "dist/doctor-migration-plan-adapter-1T936Wiy.js": "22aef97cfe35f2c144faecee9bd258cba6df33d56667877d74c83bf1105dd374",
    "dist/state-migrations.plugin-doctor-B9C71dRe.js": "135a92fbe781d4c2c771c17aef9dcb0b9460e893c2307432eac9d9677640ca8b",
    "dist/state-migrations.plugin-state-CWdwyEt3.js": "5fd2c49d94d90c791fb22f7badd1760a883e56f434213fbfae5b1b873c64e8c7"
  }
}

The final independent readback checked the retained drivers/logs, exact callback-only correction, source/artifact identities, and a unique copy of the complete terminal SQLite/WAL/SHM family: one fixture counter row at 9000, zero cache rows, and quick_check=ok. Historical phase receipts above are live queries from their phase, not pre/failure whole-database snapshots or a newly executed replay.

Exact-head CI run 33388860633, attempt 1 completed successfully. The required openclaw/ci-gate succeeded on this head. Local proof also includes 110 focused tests, the separate three readiness/lease cases, the unchanged SDK probe, full canonical build, and all 29 selected static gates.

Scope and advisories: manual Doctor returned 0 while visibly reporting the migration failure. That is not a healthy-Gateway claim. The expected isolated-port ECONNREFUSED and normal node-onboarding, owner, backup, desktop, synthetic plaintext-token, browser, STT, and missing memory/provider-key advisories remain visible in the captures; none were suppressed to obtain the result. No operator Gateway was started, stopped, or restarted. Runtime-entry TTL/cap policy and SQLite schema were not changed. The two net production lines implement safe shared-source retirement after duplicate tracking was consolidated.

Both current rank-up requests are addressed by this retained inspectable output and the completed exact-head CI; no additional source repair or replay is being claimed. Thanks @ruel225 for the report and original repair.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
@steipete
steipete merged commit f81afb2 into openclaw:main Aug 31, 2026
274 of 276 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…a warning (openclaw#119200) (openclaw#119201)

* fix(state-migrations): isolate a throwing channel plan callback into a warning

runLegacyMigrationPlans ran the plugin-state-import plan without a
try/catch, so a throwing shouldReplaceExistingEntry (a channel plugin
contract callback) escaped through runLegacyStateMigrationSteps and
config-guard, crashing doctor/gateway startup and skipping every
unrelated migration plan. Wrap the import plan in the same per-plan
isolation sibling migratePluginDoctorStatePlans already uses: record a
warning and continue so the remaining plans still run.

Re-applied on top of the plugin-state import rewrite, which grew
rename/remove source cleanup and archive-on-cover handling around the
same withPluginStateImportEnv call.

Co-Authored-By: Claude <[email protected]>

* fix(doctor): preserve shared migration sources on failure

Keep each migration plan's failure boundary in the executor so earlier
change reports survive and unrelated sources can continue in order.
Defer plans sharing an incomplete source and retire import sources only
after their last consumer succeeds, preserving the import state scope.
This protects durable counters and expiring caches derived from one file.

Absorb source-lifecycle tracking by consolidating duplicate key sets,
baseline maps, and per-entry cleanup-failure state. Preserve warning-based
startup refusal without configuration, API, schema, or retention changes.

Replace the narrow callback test with ordered throw/rejection, shared
source read/capacity failures, cleanup ordering/scope, retry, and no-op
regressions. Existing Doctor and SDK migration coverage remains green.

Related: openclaw#119200

Co-authored-by: ruel225 <[email protected]>

---------

Co-authored-by: ruel225 <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants