Repository navigation
fix(state-migrations): isolate a throwing channel plan callback into a warning (#119200) - #119201
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 9:03 AM ET / 13:03 UTC. ClawSweeper reviewWhat this changesThe 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 readinessKeep 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 Review scores
Verification
How this fits togetherDoctor 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +294, Docs +2. Total +298 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (17 earlier review cycles; latest 8 shown)
|
fc0c5ad to
f1ceafa
Compare
|
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 |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
f1ceafa to
95cf0a4
Compare
|
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 |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…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]>
95cf0a4 to
df4ea5e
Compare
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]>
Inspectable exact-head Doctor proofThis supplies the retained output requested in the current ClawSweeper review, without another replay or source change. All four CLI invocations used candidate Command for initialization and each phase below: Only known filesystem roots are redacted below as 1. Throwing callback: source retained, unrelated plans completeRecorded 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/stderr2. Callback corrected: counter imported, source archivedThe only fixture-code correction was 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/stderr3. Unchanged replay: no repeated fixture migrationThe 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. 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/stderrUnchanged readiness/lease boundaryNo Gateway was started for this Doctor proof. The three independently executed existing cases in The corresponding stdout reports Identity and terminal checksThe 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 Exact-head CI run 33388860633, attempt 1 completed successfully. The required Scope and advisories: manual Doctor returned 0 while visibly reporting the migration failure. That is not a healthy-Gateway claim. The expected isolated-port 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. |
|
Merged via squash.
|
…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]>
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
sourcePathwithin 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 --fixbefore 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.
ee036be7796396868bfa4851210e66c17bb2a25c.3bd51c896322b0ee87d03e9ad85ccca6443eb927exited 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.removeSource, namespace/plugin capacity, creation-time preservation, cap eviction, retry, and plugin-index warning behavior.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 andopenclaw doctor --fixrecovery hint. These are focused tests, not a live Gateway run.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, andnode 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.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.3bd51c896322b0ee87d03e9ad85ccca6443eb927, tree99b79a6ed9344cb45193397ebc5037c5bc7f50fb, 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.pnpm install --frozen-lockfile --ignore-scriptspassed 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/airesolves 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.pnpm buildthen passed in 268.65 seconds, including AI/package/unified declarations, public SDK exports, CLI bootstrap checks, plugin artifacts, and the Control UI build. NoINEFFECTIVE_DYNAMIC_IMPORTdiagnostic was emitted.dist/build-info.jsonnames candidate commit3bd51c896322b0ee87d03e9ad85ccca6443eb927; its identity and tracked source stayed unchanged through the subsequent Doctor runs.node openclaw.mjs doctor --fix --non-interactivein isolated HOME/state directories: initialization; a throwing shared-source counter callback; retry after changing only that synthetic callback toreturn 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'sdist, 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.tspassed 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.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.