Skip to content

fix(update): stop skipping Doctor-owned migrations - #136529

Closed
fuller-stack-dev wants to merge 35 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-migration-plan-mode
Closed

fuller-stack-dev wants to merge 35 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-migration-plan-mode

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Related: #124396

What Problem This Solves

Fixes an issue where update and Doctor repair flows could detect Doctor-owned legacy state, then build an automatic-mode migration list that omitted it. Exec approvals and TUI last-session state could remain behind without a recorded reason.

Why This Change Was Made

The migration owner now derives one mode and carries it through detection, planning, and execution. Each selected step has a stable ID, exact source and target, requiredness, reversibility, and an outcome or refusal. Execution returns matching per-step receipts.

This also adds a hidden, read-only candidate command for the staged updater work:

openclaw update migration-plan \
  --snapshot-home <copied-home> \
  --snapshot-config <copied-config> \
  --config-digest <digest> \
  --snapshot-state <copied-state> \
  --state-digest <digest> \
  --candidate-digest <digest> \
  --json

The running candidate supplies its own package root and version. The caller supplies the candidate and copied-state digests, and the plan integrity hash binds the complete result.

Planning cannot acquire write authority. It binds HOME, config, and state to the copied snapshot, disables config observation and shell fallback, uses core-only config validation, does not call migration runners, and defers plugin-owned planning with plugin-planning-deferred. Detection warnings produce a top-level refusal. Tests verify that planning neither creates nor registers SQLite databases and does not change copied bytes or create WAL/SHM files.

This PR does not implement activation, rollback, plugin compatibility, or the rest of the update transaction. It follows OCM's preparation/finalization separation only far enough to give the later updater stages a closed plan and execution receipts. There is no SQLite schema change.

User Impact

Doctor repair no longer drops Doctor-owned migrations when it is called through the automatic migration helper. A successful doctor --fix run also does not advise the operator to run doctor --fix again after the required migration completed.

The hidden candidate command can inspect an isolated copied snapshot while the incumbent Gateway remains live. Plugin migration planning stays with the separate candidate/plugin compatibility stage.

Evidence

  • Base red proof at 0ebdbe6155adc2413896989f61ca6fadc5fb4b12: Doctor detection found exec approvals and TUI state, but the automatic-mode step builder returned no changes, warning, or receipt and left both sources in place.
  • Published head: bc99f5123989125853de8b697f036f173e73c475, based on canonical 837ef59df9d9d9d86dd761102c21c1cf879ca7d5.
  • Copied-state, configured-target, SQLite read-only, and candidate CLI tests: 77 passed.
  • Migration owner tests, including exec approvals, automatic siblings, device identity, and meeting transcripts: 171 passed, 2 platform-specific tests skipped.
  • Adjacent Doctor and plugin restart-readiness tests: 157 passed.
  • Full build and pnpm check:changed: passed.
  • Source-blind CLI validation at behavior-identical head 6589799deb8c452569e09e02ed2ba1bd8abca467: 8 of 8 in-scope checks passed with two varied fixtures. Exact fields and digests changed with each fixture; the copied trees remained byte-identical; malformed config refused with exit 1. The later additive merge contains only Signal, WhatsApp, iMessage, CI, and locale changes.
  • P2 Autoreview found that the first refactor had accidentally made three existing eager migrations Doctor-only. The final diff restores device-auth, device-identity, and meeting-transcript work in both modes; the affected 176-test control passed before final integration, and the merged-head migration suite above passed afterward.

Production delta is +722/-132 lines; tests add 356 lines. The production growth is the closed plan/receipt contract, stable metadata for the existing migration owners, and its candidate CLI. The execution mode fix itself replaces the split mode checks with one mode value.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 2, 2026, 10:39 PM ET / September 3, 2026, 02:39 UTC.

ClawSweeper review

What this changes

The PR unifies Doctor migration mode through detection and execution, adds per-step migration receipts, and adds a hidden read-only update command that plans migrations for a copied state snapshot.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open for maintainer scope review: the mode-latch repair addresses the reported silent omission, but this Member-authored, maintainer-labeled PR also introduces a large candidate migration-planning protocol that needs an explicit product-boundary decision.

Priority: P2
Reviewed head: 1f20139d0e0052d40960fdbd7d0b1b0697f5100f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The central repair is source-backed and well-tested, but the substantial new updater protocol needs maintainer scope acceptance.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; the supplied focused migration tests are supplemental evidence, and no Telegram or browser behavior changed.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; the supplied focused migration tests are supplemental evidence, and no Telegram or browser behavior changed.
Evidence reviewed 6 items Baseline mode mismatch: The verified PR delta shows the baseline helper detected Doctor-owned state but built migration steps with a hard-coded automatic mode, excluding Doctor-only steps such as exec approvals and TUI last-session migration.
Unified owner boundary: The branch derives one mode latch from doctorOnlyStateMigrations and uses it for the migration flow; Doctor-only steps include TUI last-session and exec approvals.
Snapshot planning safeguards: The new planner captures copied config/state identity before work, rejects mismatched caller digests, and rechecks identity after planning; candidate artifact identity remains an explicit refusal until a staged-candidate owner exists.
Findings None None.
Security None None.

How this fits together

Doctor preflight prepares configuration and legacy state before startup or update recovery. This change feeds the selected migration mode into the migration owner, which then reports completed, skipped, warning, or refused state-repair steps.

flowchart LR
A[Config snapshot] --> B[Doctor preflight]
B --> C[Migration mode selection]
C --> D[Legacy-state detection]
D --> E[Migration steps and receipts]
E --> F[SQLite and state repair]
B --> G[Read-only candidate plan]
Loading

Decision needed

Question Recommendation
Should this PR deliver only the Doctor-mode repair, or also establish the new candidate migration-plan protocol before the broader update transaction is accepted? Narrow to the mode repair: Retain the unified Doctor mode and necessary receipt coverage, and move candidate planning to the transaction work.

Why: The mode repair is concrete, but the hidden command and plan schema add a durable operator-facing update boundary whose intended owner and completion path are not settled by this bug fix alone.

Before merge

  • Resolve merge risk (P1) - The branch has a net production increase of 1,874 lines around startup and Doctor migration ordering; a mistake in this enlarged owner can change upgrade recovery or leave legacy state un-migrated.
  • Resolve merge risk (P1) - The hidden migration-plan command establishes a new updater-facing protocol while candidate activation, rollback, and artifact binding remain owned by the broader transaction design.
  • Complete next step (P2) - Obtain a maintainer decision on whether to retain the candidate migration-plan protocol or narrow this PR to the Doctor mode repair.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +1875, Tests +1311. Total +3186 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 9 2133 258 +1875
Tests 6 1316 5 +1311
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 3449 263 +3186

Review metrics

Metric Value Why it matters
Production versus test delta production +2,132/-258; tests and test support +1,317/-5 The reported migration-mode defect is small, while the PR also adds a substantial planning and receipt protocol that warrants scope review.

Stored data model

Persistent data-model change detected: database schema: src/infra/state-migrations.types.ts, migration/backfill/repair: src/cli/update-cli.ts, migration/backfill/repair: src/cli/update-cli/update-command-migration-plan.ts, migration/backfill/repair: src/commands/doctor-config-preflight.ts, migration/backfill/repair: src/commands/doctor.e2e-harness.ts, migration/backfill/repair: src/infra/state-migrations.types.ts, and 1 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Narrow the migration change (recommended)
    Keep the fixed Doctor-mode latch and its regression coverage while deferring the standalone candidate-plan protocol to the transaction design.
  2. Accept the transaction foundation
    Explicitly approve the hidden plan schema and command as an updater contract before merging its compatibility-sensitive migration behavior.

Technical review

Best possible solution:

Keep the single mode latch and receipt boundary, then either narrow this PR to that repair or explicitly sponsor the candidate-plan protocol as part of the update transaction tracked by #124396.

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

Yes—source-reproducible: the verified baseline delta shows Doctor detection followed by automatic-only step construction, while the branch’s focused suite covers the affected exec-approval and TUI migration paths.

Is this the best way to solve the issue?

Unclear. Carrying one mode through the migration owner is the maintainable repair, but adding a standalone candidate planning protocol is a separate updater-direction choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 41419be40bbb.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; the supplied focused migration tests are supplemental evidence, and no Telegram or browser behavior changed.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a migration correctness path with bounded but meaningful upgrade and recovery impact.
  • merge-risk: 🚨 compatibility: The changed migration owner and new update-planning command can alter how existing state and upgrade recovery are handled.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; the supplied focused migration tests are supplemental evidence, and no Telegram or browser behavior changed.

Evidence

What I checked:

  • Baseline mode mismatch: The verified PR delta shows the baseline helper detected Doctor-owned state but built migration steps with a hard-coded automatic mode, excluding Doctor-only steps such as exec approvals and TUI last-session migration. (src/infra/state-migrations.doctor.ts:1329, 41419be40bbb)
  • Unified owner boundary: The branch derives one mode latch from doctorOnlyStateMigrations and uses it for the migration flow; Doctor-only steps include TUI last-session and exec approvals. (src/infra/state-migrations.doctor.ts:2264, 1f20139d0e00)
  • Snapshot planning safeguards: The new planner captures copied config/state identity before work, rejects mismatched caller digests, and rechecks identity after planning; candidate artifact identity remains an explicit refusal until a staged-candidate owner exists. (src/infra/state-migrations.doctor.ts:1717, 1f20139d0e00)
  • Regression coverage: The added caller-mode suite checks that Doctor-owned exec-approval and TUI migrations are planned without writes or plugin loading, and that the candidate artifact remains refused rather than trusted from caller input. (src/infra/state-migrations.caller-mode.test.ts:141, 1f20139d0e00)
  • Area history: Recent migration-area history includes Peter Steinberger's merged migration-warning work and Omar Shahine's automatic agent-database migration work; the current branch's new migration protocol commits are by fuller-stack-dev. Exact line-introduction attribution could not be established because required historical blobs are unavailable in this partial checkout. (src/infra/state-migrations.doctor.ts:2264, 8c5442c01bb0)
  • Codex boundary check: Direct sibling Codex inspection found app-server turn lifecycle documentation, not an update-migration contract. The PR imports no Codex code or protocol, so Codex is not an authoritative dependency for this review. (codex-rs/app-server/README.md:1766, 5adb68a49933ae446bf11935662c83dba55a0804)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain a maintainer decision on retaining versus deferring the candidate migration-plan protocol.
  • If the protocol remains, provide a current-head before/after Doctor fixture showing the operator-visible repair and its per-step receipts.

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 (1 earlier review cycle)
  • reviewed 2026-09-02T18:52:16.378Z sha bc99f51 :: found issues before merge. :: [P2] Verify snapshot digests before minting a migration plan

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Packaged CLI proof found a blocking failure in the unpublished repair candidate. This is not a green result for the public PR head.

AWS/Linux run run_821eb055bfd3 installed the package built from d9e32fb05f1eec3656b010de5fde3306f8670012, with package SHA-256 29fd0e7a430ff49671b3ac5e76517af586bd99033723076a5db731f6d6f8ab5a. The installed build identity matched. Runtime was Node 24.19.0 and npm 11.17.0.

The prewritten negative used malformed legacy TUI state plus pending legacy exec approvals. The actual installed command was openclaw doctor --fix --non-interactive --no-workspace-suggestions. It imported approvals, removed their legacy file, then reported the TUI parse failure and finished with Doctor complete, exit 0. The contract required the later approvals migration to remain untouched after the required refusal.

Caller inspection found that runDoctorConfigPreflight invokes the approvals writer before the ordered autoMigrateLegacyState graph. The graph's refusal also does not become a failed ordinary Doctor outcome. The existing Doctor owner is repairing that boundary while preserving the earlier partially-invalid-config recovery contract. Direct graph tests did not exercise this CLI caller and cannot certify it.

The retained npm debug log confirms the packaged preinstall/postinstall hooks completed with code 0. The allow-scripts warnings were preserved; no permission override or install replay was used.

Raw observations SHA-256: 081c1835d5bdb9126372ef654bc98e9684458054920da282c1a1710c20cfe340. This is failure evidence, not a passing source-blind CLI verdict, video, or combined upgrade journey. The corrected candidate still needs matching packaged proof, review and exact published-head landing gates. No merge is requested from this result.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Requesting @openclaw/openclaw-secops involvement for the pending Doctor planning changes in src/agents/auth-profiles/path-resolve.ts and src/agents/auth-profiles/shared-store-bootstrap.ts, as required by CODEOWNERS and the repository's restricted-owner policy.

The pending changes add artifact-preserving inspection of shared auth state and an inspection-only ownership read that does not populate the process-stable runtime cache. The intended boundary is that planning must not initialize or repair the source database, alter its artifacts, or change runtime ownership through a planning read. No schema or protocol version change is proposed.

The current public head 1f20139d0e0052d40960fdbd7d0b1b0697f5100f does not yet contain these pending auth-owner changes. This is a request for owner involvement, not final-head approval or a land-ready claim. The final published head and its proof will be identified before landing. Signed publication and corrected packaged-runtime validation are still outstanding.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Following up on the existing owner request, @openclaw/openclaw-secops: we need an owner to direct or author the copied-auth inspection change, or actively review the proposed bytes below.

The required behavior is that Doctor copied-state planning reads auth ownership and legacy cleanup facts without changing the source DB/WAL/SHM or populating the process-stable runtime ownership cache. Ordinary live auth behavior must stay intact. No schema, protocol, credential representation, or new persistence owner is proposed.

The deferred proposal is exactly two files, +54/-21, from cc7261dfacce69bcce934afc1bbe8d66e2cccd2c to retained private checkpoint 6407f14f20c670e7bc77026d2d7cebae6309297b, tree 1b719ebd8ea6cba8153f43f6e79709c54822c658. Diff SHA-256: 10cf64adb64a143aff973797901bc44ce683c4ac2fe703638fbe193b470553c0. The full scoped diff is included so review does not depend on access to a private commit.

Public head 1f20139d0e0052d40960fdbd7d0b1b0697f5100f and replacement tree b0d33270a86fc26d5edf8a42d91c376b4f167523 deliberately exclude these deferred edits. Neither is the proposed auth review target. This retained proposal still needs current-reader integration and its exact proof; it is not a request to approve stale runtime behavior or bypass Linux lock safety.

Could an authorized owner take one of these concrete actions: direct the implementation at these helpers, author an equivalent repair, or review this scoped proposal and identify the required corrections? A reviewer assignment or pending team request alone will not be recorded as involvement. Final published-head review, CI and behavior gates remain required.

Deferred two-helper proposal
diff --git a/src/agents/auth-profiles/path-resolve.ts b/src/agents/auth-profiles/path-resolve.ts
index 3e05342f05a..a3c93c227bc 100644
--- a/src/agents/auth-profiles/path-resolve.ts
+++ b/src/agents/auth-profiles/path-resolve.ts
@@ -78,6 +78,20 @@ export function resolveSharedAuthStoreOwnership(
   return ownership;
 }
 
+/** Inspect copied migration state without populating the process-stable runtime owner cache. */
+export function inspectSharedAuthStoreOwnership(
+  env: NodeJS.ProcessEnv = process.env,
+): SharedAuthStoreOwnership {
+  const databasePath = path.resolve(resolveOpenClawStateSqlitePath(env));
+  return parseSharedAuthStoreOwnership(
+    readConfigMachineState<unknown>(
+      SHARED_AUTH_STORE_STATE_KEY,
+      { env, path: databasePath },
+      { artifactPreservingReadOnly: true },
+    ),
+  );
+}
+
 /** Update the process-stable cache after this process commits the ownership row. */
 export function noteCommittedSharedAuthStoreOwnership(
   ownership: SharedAuthStoreOwnership,
diff --git a/src/agents/auth-profiles/shared-store-bootstrap.ts b/src/agents/auth-profiles/shared-store-bootstrap.ts
index f621940803e..6f54f9aa2a1 100644
--- a/src/agents/auth-profiles/shared-store-bootstrap.ts
+++ b/src/agents/auth-profiles/shared-store-bootstrap.ts
@@ -4,9 +4,13 @@ import type { DatabaseSync } from "node:sqlite";
 import { hasErrnoCode } from "../../infra/errno.js";
 import { executeSqliteQueryTakeFirstSync, getNodeSqliteKysely } from "../../infra/kysely-sync.js";
 import { openNodeSqliteDatabase } from "../../infra/node-sqlite.js";
+import { prepareSqliteReadOnlyLocationSyncInProcess } from "../../infra/sqlite-readonly-location.js";
 import { writeConfigMachineState } from "../../state/config-machine-state.js";
 import type { DB as OpenClawAgentKyselyDatabase } from "../../state/openclaw-agent-db.generated.js";
-import { withExistingOpenClawStateDatabaseReadOnly } from "../../state/openclaw-state-db-readonly.js";
+import {
+  withExistingOpenClawStateDatabaseArtifactPreservingReadOnly,
+  withExistingOpenClawStateDatabaseReadOnly,
+} from "../../state/openclaw-state-db-readonly.js";
 import { tableExists } from "../../state/openclaw-state-db-schema-helpers.js";
 import type { DB as OpenClawStateKyselyDatabase } from "../../state/openclaw-state-db.generated.js";
 import { resolveUserPath } from "../../utils.js";
@@ -105,14 +109,21 @@ export function readSharedAuthLegacyRowsFromDatabase(database: DatabaseSync): Sh
   return { store, state };
 }
 
-export function inspectSharedAuthLegacyRowsReadOnly(sourcePath: string): SharedAuthLegacyRows {
+export function inspectSharedAuthLegacyRowsReadOnly(
+  sourcePath: string,
+  behavior: { artifactPreservingReadOnly?: boolean } = {},
+): SharedAuthLegacyRows {
   if (inspectSharedAuthLegacySourceFile(sourcePath).status === "missing") {
     return { store: null, state: null };
   }
+  const prepared = behavior.artifactPreservingReadOnly
+    ? prepareSqliteReadOnlyLocationSyncInProcess(sourcePath)
+    : undefined;
   let database: DatabaseSync;
   try {
-    database = openNodeSqliteDatabase(sourcePath, { readOnly: true });
+    database = openNodeSqliteDatabase(prepared?.location ?? sourcePath, { readOnly: true });
   } catch (error) {
+    prepared?.cleanup();
     throw new SharedAuthStoreSourceInspectionError(sourcePath, "open", error);
   }
   try {
@@ -121,28 +132,36 @@ export function inspectSharedAuthLegacyRowsReadOnly(sourcePath: string): SharedA
     throw new SharedAuthStoreSourceInspectionError(sourcePath, "read", error);
   } finally {
     database.close();
+    prepared?.cleanup();
   }
 }
 
-export function hasPendingSharedAuthCleanup(env: NodeJS.ProcessEnv, sourcePath: string): boolean {
+export function hasPendingSharedAuthCleanup(
+  env: NodeJS.ProcessEnv,
+  sourcePath: string,
+  behavior: { artifactPreservingReadOnly?: boolean } = {},
+): boolean {
+  const read = ({ db: database }: { db: DatabaseSync }) => {
+    if (behavior.artifactPreservingReadOnly && !tableExists(database, "migration_sources")) {
+      return false;
+    }
+    const db = getNodeSqliteKysely<SharedAuthMigrationDatabase>(database);
+    const row = executeSqliteQueryTakeFirstSync(
+      database,
+      db
+        .selectFrom("migration_sources")
+        .select("source_key")
+        .where("migration_kind", "=", SHARED_AUTH_STORE_MIGRATION_KIND)
+        .where("source_path", "=", sourcePath)
+        .where("removed_source", "=", 0)
+        .limit(1),
+    );
+    return Boolean(row);
+  };
   return (
-    withExistingOpenClawStateDatabaseReadOnly(
-      ({ db: database }) => {
-        const db = getNodeSqliteKysely<SharedAuthMigrationDatabase>(database);
-        const row = executeSqliteQueryTakeFirstSync(
-          database,
-          db
-            .selectFrom("migration_sources")
-            .select("source_key")
-            .where("migration_kind", "=", SHARED_AUTH_STORE_MIGRATION_KIND)
-            .where("source_path", "=", sourcePath)
-            .where("removed_source", "=", 0)
-            .limit(1),
-        );
-        return Boolean(row);
-      },
-      { env },
-    ) ?? false
+    (behavior.artifactPreservingReadOnly
+      ? withExistingOpenClawStateDatabaseArtifactPreservingReadOnly(read, { env })
+      : withExistingOpenClawStateDatabaseReadOnly(read, { env })) ?? false
   );
 }

fuller-stack-dev added a commit to fuller-stack-dev/openclaw that referenced this pull request Sep 6, 2026
Keep live caller authority separate from artifact-preserving copied-state
planning. Carry planned endpoints and requiredness through ordered receipts,
close required refusals, and settle deferred plugin work after its writer.

Continue the migration work from openclaw#136529 by Jason (Json),
@fuller-stack-dev, without replacing the original public branch or history.
fuller-stack-dev added a commit that referenced this pull request Sep 6, 2026
…139683)

* fix(doctor): bind migration authority and ordered receipts

Keep live caller authority separate from artifact-preserving copied-state
planning. Carry planned endpoints and requiredness through ordered receipts,
close required refusals, and settle deferred plugin work after its writer.

Continue the migration work from #136529 by Jason (Json),
@fuller-stack-dev, without replacing the original public branch or history.

* fix(doctor): preserve caller locks during snapshot hashing

Isolate snapshot file descriptors from caller-held SQLite transactions. Keep framed worker input and ordered refusal semantics, classify deliberate foreign-store omissions at their owner, and retain exact CLI controls.

* fix(doctor): preserve uncached caller locks during planning

* test(doctor): bind final traversal refusal diagnostics

* fix(sqlite): preserve publisher cleanup ownership
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Superseded by the landed, credited continuation #139683, merged as 6277d6da1331b039c2603ae89caae5a9bd3c1df0 from verified head 98dd65039879b5da3930c70c0dd8401500661da9.

The landed replacement covers this PR's scoped contract:

  • One caller mode carries Doctor-owned migration selection through detection, planning and execution, while ordinary automatic migrations retain their controls.
  • Ordered steps retain identity, endpoints, requiredness and recorded outcomes. Required refusals stop later work, including through the real Doctor CLI; deferred post-session work settles after its writer.
  • Copied-state planning preserves protected configuration, state and SQLite artifacts without executing plugin migrations. The diagnostic plan explicitly refuses candidate execution authority with candidate-artifact-digest-required; it is not an activation or rollback implementation.

This is a corrected continuation, not a byte-identical merge of the original proposal. It includes the later CLI-refusal, caller-lock and publication-cleanup fixes. The relevant migration/planner, Doctor config/health, auth-reader and SQLite files in the squash commit match the verified final head. Exact-head CI and native preparation/merge passed. Native completion receipt.

Original author Jason (Json), @fuller-stack-dev, is credited in the replacement and landed commit. Closing this original PR as superseded, not merged. Its public head 1f20139d0e0052d40960fdbd7d0b1b0697f5100f, branch/history and historical evidence remain preserved. Earlier failed evidence is not regraded; this closure makes no full atomic-update journey claim.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…penclaw#139683)

* fix(doctor): bind migration authority and ordered receipts

Keep live caller authority separate from artifact-preserving copied-state
planning. Carry planned endpoints and requiredness through ordered receipts,
close required refusals, and settle deferred plugin work after its writer.

Continue the migration work from openclaw#136529 by Jason (Json),
@fuller-stack-dev, without replacing the original public branch or history.

* fix(doctor): preserve caller locks during snapshot hashing

Isolate snapshot file descriptors from caller-held SQLite transactions. Keep framed worker input and ordered refusal semantics, classify deliberate foreign-store omissions at their owner, and retain exact CLI controls.

* fix(doctor): preserve uncached caller locks during planning

* test(doctor): bind final traversal refusal diagnostics

* fix(sqlite): preserve publisher cleanup ownership
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations maintainer Maintainer-authored PR 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. size: XL 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.

1 participant