Skip to content

fix(doctor): preserve migration authority and stop refused repairs - #139683

Merged
fuller-stack-dev merged 10 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-migration-authority-r152
Sep 6, 2026
Merged

fuller-stack-dev merged 10 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-migration-authority-r152

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Related: #124396

Continues #136529 by Jason (Json), @fuller-stack-dev, as the approved credited replacement. The original public branch and its history remain intact. This PR carries the reviewed Doctor changes onto current canonical code without rewriting that branch.

Additional instructions

Keep Allow edits from maintainers enabled.

What Problem This Solves

Fixes an issue where users running Doctor through update or repair callers could leave required legacy state unmigrated, or continue later repairs after a required migration refused. The public CLI also imported and removed exec approvals before reporting malformed TUI state.

Copied-state migration inspection had a separate authority problem: discovery could reach external configured stores or change SQLite sidecars and existing process locks while describing the operation as read-only.

Why This Change Was Made

Use the migration owner for ordered detection, execution and recorded outcomes. Preserve the same action, owner endpoints and requiredness through live preparation and receipts, including deferred post-session plugin work. A required refusal closes later work and reaches the real Doctor caller instead of ending as a successful repair.

Copied inspection uses explicit snapshot roots and artifact-preserving SQLite readers. It does not load plugin code, create live profile state or reuse copied-plan authority for ordinary live Doctor execution. The diagnostic update migration-plan command cannot bind a candidate artifact, so it reports candidate-artifact-digest-required rather than granting execution authority.

Plugin declarations provide metadata-only planning. Live plugin selection retains disabled-owner and external-shadow boundaries. Existing state-schema, auth, worktree and session owners perform their own repairs; no new SQLite schema version, update transaction, activation, rollback or worker-cleanup owner is introduced.

The current-base integration preserves retired-model context, plugin SDK diagnostics, browser skipped status and unrelated baseline reductions. The optional-skill update-preference fix already landed separately in #138730 and is not duplicated here.

Production: +4,859/-757 lines, net +4,102. Tests and test support: +7,557/-925, including the test-runtime prerequisite. Docs: +36/-3. Assertion baseline: +1/-3. The production growth implements closed plan/receipt descriptions and copied-state authority for the existing migration graph; it is not a new storage framework. Tests moved between split files are included in the raw test totals.

User Impact

Doctor-owned migrations stay selected when invoked through the automatic helper. Required failures stop subsequent repairs and return failure to the operator. Partially invalid configuration still permits the existing config-independent recovery path. Ordinary automatic migrations and explicit live Doctor repair retain their distinct authority.

Copied planning preserves protected configuration, state, DB/WAL/SHM inputs and existing Linux auth locks. It records unresolved or deferred work honestly instead of guessing endpoints or loading plugins. This diagnostic plan is not candidate containment or permission to execute it.

Evidence

The original red observations and earlier failed private-package result remain at the original PR and the packaged CLI failure receipt. No historical failure has been regraded.

Packaged Linux and independent observations

Evidence summary · Exact artifact manifest · Raw terminal video

The published records bind real source base 561d6556d3c5081eb64f8f184a5b8fe92917c060, authored tree 8d9beb66dd4c3a5b8f48de8662deff83302ff53c and package SHA256 f7bd2b2926e3c51cc61a7848a41fa0a5d8aa7a6c384e1913b6f6cf9053133465. Native build metadata names the real base; the authored tree is recorded separately. These are not claims of execution on a later integrated head.

  • Packaged CLI run: fresh AWS/Linux account, Node 24.19.0. Five actual CLI calls covered three copied plans, successful live repair and malformed-TUI refusal. The independent passive validator passed packaged clauses 1–5 and 7, including complete home inventories, installed identities, allowed scratch/generated-link changes, and the original WAL handle remaining open across both samples and the command.
  • Auth run: captured clause 6 passed. The same-process read lock and selected DB/WAL/SHM records survived inspection; the original connection remained usable and the after-close control was empty.
  • Source/API run: captured S1–S5 passed for caller mode, ordered receipts/refusal closure, post-session settlement and worker startup. Its historical header and post-run current-order qualification remain explicit in the independent note.

The manifest includes all three independent evidence notes and the original prospective contracts. Its SHA256 is 0b68e7742121edfbcb903ca356a428feb4734fcec4682213c3651a54dbc827e4. The video hashes to 04f36876180220237d3d6c1d1772df63c543e3a52974f074538eef810fa1d43a; seven frames were inspected. Right-edge clipping is retained; complete CLI text is authoritative. Links expire September 13, 2026.

The recorded live fixture permits ordinary config repair and selected-package generated skill links. It does not prove strict update config preservation, command-free recovery, continuous custody, hidden descriptor parity, expiry soak or a complete atomic update. The pre-run producer seal binds the package; the diff measurement is post-run, not reproducible-build proof. All three leases have recorded release and native settlement; remote erasure is not inferred.

Current integration

The reviewed task delta is integrated on canonical 23fda78a3436de81c399a6b4de28bd147fef94a9, authored tree a070c64c9c5920ceb47ea0908a2b8bc227228084. The intervening owners and dependency/tool inputs were assessed once. All 102 non-baseline authored blobs and modes match the completed prior candidate; the baseline also retains upstream reductions. Unchanged proof is retained with that qualification.

All 18 selected retirement, refusal, plugin, session-reclamation and browser files ran: 312 passed. Three additional cron/config-write ordering cases passed. The four retained real plugin-import/caller controls preserved the live writer and matching bound receipt, with disabled-owner and partially invalid configuration controls. These local controls are source-aware, not another source-blind or packaged run.

One scoped max-P2 integration review found no actionable findings at bd8d6146. Prior whole-candidate reviews and resolved dispositions remain retained. The only subsequent correction reduces config flow from 704 to 700 counted lines by naming returned migration facts locally and inlining a single-use boolean alias. The original lint failure remains recorded. Targeted lint, core/core-test types and two write/no-write controls passed. Repeated real bound/disabled callers preserve property presence, all 44 ordered receipt values, the one selected writer call and disabled-owner non-execution. This mechanical correction does not change the reviewed contract. All eleven previously unreached native phases then passed, completing the selected plan with the prior 29 passed phases and corrected-file lint. This is qualified phase reuse, not a relabeled uninterrupted run.

The final canonical range adds login-shell process isolation and uses the existing session-list projection in Gateway lookup. Their four affected test files passed: 45 tests, with one Linux-only session-ID test explicitly skipped on macOS. The native assertion ratchet and final diff/ancestry checks passed. All 193 policy/dependency inputs match the completed setup. The packaging helper extraction is byte-equivalent logic; its new caller is Docker-image pruning, not the retained self-contained tarball path. No final-head hosted CI or landed state is claimed by the artifact proof above.

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
fuller-stack-dev requested a review from a team as a code owner September 6, 2026 03:34
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalouser Channel integration: zalouser extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: device-pair extensions: acpx extensions: memory-wiki extensions: codex plugin: workboard extensions: crabbox channel: reef Channel integration: reef extensions: active-memory extensions: canvas size: XL labels Sep 6, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Snapshot publication cleanup correction

Published 98dd65039879, tree 301a361e483a7eed84b30377a9effb031653b41b, with a valid GitHub signature. Its sole parent is verified server merge 2277f59d, preserving prior head 6314d2ba and canonical 2239858f. Only the reviewed snapshot publisher and its regression tests changed above that merge. Original #136529 attribution, public history and failed evidence remain preserved.

The snapshot failure catch could infer cleanup ownership from a later pathname observation and remove another writer's replacement. The existing fs-safe publisher already retains the original opened-object identity. This correction removes SQLite's second failed-publication cleanup path. Successful publication still records its receipt before strict directory-sync validation and retains guarded cleanup for its own target. Production changes are +27/-42, net -15; tests are +99/-16.

One tradeoff is explicit: bytes linked from a substituted staging pathname are not proven to belong to this publication. They may remain after refusal. The operation still fails and never accepts those bytes as a verified snapshot or retries an overwrite. Tests retain the refusal and assert preservation.

Unmodified captured collision/unknown-zero cases refused publication but deleted the literal replacement and ended in ENOENT. A separate staging-transition control reproduced the same loss in the first draft. All corrected captured cases preserve the replacement. The existing independent reader assessed the additive packet 4c1b64066ec811ce9f6c774cf0fccf2a0dc956f4202debab4ee0333a1e542c24 without source or runtime access. These are passive Darwin/Node24.20 observations, not proof of the historical Windows trigger or real inode reuse. The corrected owner no longer requests the projected numeric stat; consumed-projection coverage is not claimed. The transition preserves bytes and dev/inode/size while ctime/link count change, not full-stat immutability.

The same 24 publication controls pass, including owned hardlink/exclusive-copy durability cleanup. Corrected max-P2 review is scoped-clean. The 21 affected or previously unreached native stages passed, with eight unchanged predecessor stages retained separately. This is not a fabricated uninterrupted gate pass. The integrated runner also passed two selected CI-plan checks and the same 24 publication controls. No build or broader behavior matrix was repeated.

The latest review's intentional stop-on-required-refusal behavior remains within the accepted migration contract, with partial-invalid-config, advisory-warning and legacy-plugin controls preserved. No schema version, stored representation or dependency policy changed. User merge authorization is already recorded; this does not claim a secops review or organization membership. The existing Linux package/auth/API and later caller-lock evidence keep their original source identities and limitations; the PR's public evidence links remain unchanged.

Exact-head CI run 34017907280, including native Windows and security/audit, is still required. Old-head green CI is not substituted. Native preparation and verified merge remain pending.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Follow-up to the 07:05 review of 98dd65039879b5da3930c70c0dd8401500661da9: the pinned filesystem dependency was inspected directly during the repair and rechecked before landing.

For installed @openclaw/fs-safe 0.8.1:

  • dist/publish-file-failure.js:2–6 retains original BigInt device/inode for cleanup separately from the numeric public diagnostic identity.
  • dist/publish-file.js:279–287 records the opened source's exact identity at hardlink publication. Lines 162–176 and 351–358 use that retained identity for failure cleanup, not a newly adopted pathname identity.
  • dist/file-identity.js:25–33 refuses cleanup when Windows device/inode identity is unknown zero, and otherwise compares exact stat values.

SHA256, respectively: bc29fea51f17e9522faf8a09894c8e74efec555c6f93893a12d5181e5e3476c3, 5f9f4510f1bde2672a60a9ae1bc9ce1d472f4c2c0a35b3d5b46680e4ed63d716, 01dc2a6b3a2b2cb6c69140bf1b485c846fea0e0a39f0919f89dfc766ce7ed3a9.

The SQLite correction removes the compensating cleanup owner rather than using the numeric error receipt as deletion authority. An unowned target can remain after a refused publication; it is not accepted, overwritten or retried. The retained replacement/staging-substitution controls and corrected scoped review cover that choice. No native Windows cause or real inode-reuse claim is added.

Exact-head CI 34017907280 and Workflow Sanity completed successfully, including Windows and all three fixed-256-MiB session-memory scenarios. The production audit completed with no matching high-or-higher npm-bulk advisories; its stated coverage limit remains. Native preparation passed without changing the public head. Required-refusal behavior, legacy/advisory compatibility and the previously recorded user-directed scope acceptance remain unchanged. No security-team review is being represented by that acceptance.

Earlier evidence keeps its original source/platform qualifications. Custom per-feature Lab reenactments are no longer a remaining gate under the user's revised journey scope; unrun clauses are superseded, not passed. This comment is a dependency/review disposition, not a merge claim.

@fuller-stack-dev
fuller-stack-dev merged commit 6277d6d into openclaw:main Sep 6, 2026
211 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

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
steipete added a commit that referenced this pull request Oct 19, 2026
…177761)

## What Problem This Solves

Removes redundant snapshot recertification and a second command-line parser while keeping the existing config-capture and Commander owners.

## User Impact

No public flags, config fields, stored data, or features change. Backup archives continue using hash-checked staged config bytes; read-only migration planning retains before/after identity comparisons, file-open checks, and hard-link confinement. Concurrent edits between separate observations are best effort.

## Why This Change Was Made

The migration snapshot worker retained every observed entry and synchronously walked the entire tree again after hashing. The planner already compares independent captures around planning, and the worker still verifies files while reading them. Archive config staging also replayed the resolver and reread every original after writing validated bytes into private staging. That cannot change the staged payload. The update-recovery caller uses a different copy path, so its resolver revalidation remains.

Plugin-install pre-action handling now consumes Commander's parsed arguments/options directly instead of reparsing raw argv as a fallback. Commander processes arguments before pre-action hooks. All source ownership and invalid-config recovery policy checks remain.

### Best-effort tradeoffs accepted

- Editing an already-hashed entry while later entries are being hashed is no longer caught by a final synchronous census. The introducing [#139683](#139683) supplies no human-filed incident for that census; its real safe-open, external-hardlink, and caller-lock protections remain. A later observation detects ordinary changes; pathological interleavings during this read-only planning operation are accepted.
- Changing live config after its validated bytes have entered archive staging no longer rejects the archive through a second resolver/file-read pass. The include-completeness repair from [#143693](#143693) remains: each staged file must match the captured graph's initial hash and identity. No human report establishes a need to certify the originals again after staging. The archive contains the already captured bytes; root-alias publication checks stay.
- No extra fallback is retained for a pre-action hook running before Commander has parsed its arguments: the installed Commander dispatch order rules that out. Public arguments/options and plugin recovery decisions are unchanged.

This is a residue-waiver cleanup, not a LARGE PR: **106 net production lines removed**, plus 80 test lines removed. Only the synthetic late-mutation table tied exclusively to the removed final census is deleted; ordinary safety and recovery coverage is retained.

## Evidence

Focused proof: 113 distinct tests across seven files pass, covering real Commander recovery policy, archive/restore with include graphs, read-only snapshot identities, caller SQLite locks, external hard links and lint-suppression policy. The first run exposed one test invoking pre-action before parsing; it now uses its existing real-Commander parse helper with every recovery input/assertion unchanged, and all24 pre-action tests pass on replay. No production fallback was restored.

Four-root production typecheck, eight-file lint/format and runtime import cycles pass (zero cycles). Check-changed classification was inspected in dry-run mode; broad local gates were deliberately not run. Shared-host wall time: three infra files519.47s (67% transform), final pre-action file141.34s (70% transform). Existing process/filesystem safety cases remain; no timeout, retry, skip or baseline was weakened. This is correctness proof, not a wall-time speedup claim.

Type-inclusive cycles also pass (zero), and independent final eight-file review is scoped-clean through P2. Exact-head PR CI is the broad gate. All local commands used isolated HOME/state/config/XDG paths; no live state, external channel, schema, dependency, permission, retention or durability change.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…penclaw#177761)

## What Problem This Solves

Removes redundant snapshot recertification and a second command-line parser while keeping the existing config-capture and Commander owners.

## User Impact

No public flags, config fields, stored data, or features change. Backup archives continue using hash-checked staged config bytes; read-only migration planning retains before/after identity comparisons, file-open checks, and hard-link confinement. Concurrent edits between separate observations are best effort.

## Why This Change Was Made

The migration snapshot worker retained every observed entry and synchronously walked the entire tree again after hashing. The planner already compares independent captures around planning, and the worker still verifies files while reading them. Archive config staging also replayed the resolver and reread every original after writing validated bytes into private staging. That cannot change the staged payload. The update-recovery caller uses a different copy path, so its resolver revalidation remains.

Plugin-install pre-action handling now consumes Commander's parsed arguments/options directly instead of reparsing raw argv as a fallback. Commander processes arguments before pre-action hooks. All source ownership and invalid-config recovery policy checks remain.

### Best-effort tradeoffs accepted

- Editing an already-hashed entry while later entries are being hashed is no longer caught by a final synchronous census. The introducing [openclaw#139683](openclaw#139683) supplies no human-filed incident for that census; its real safe-open, external-hardlink, and caller-lock protections remain. A later observation detects ordinary changes; pathological interleavings during this read-only planning operation are accepted.
- Changing live config after its validated bytes have entered archive staging no longer rejects the archive through a second resolver/file-read pass. The include-completeness repair from [openclaw#143693](openclaw#143693) remains: each staged file must match the captured graph's initial hash and identity. No human report establishes a need to certify the originals again after staging. The archive contains the already captured bytes; root-alias publication checks stay.
- No extra fallback is retained for a pre-action hook running before Commander has parsed its arguments: the installed Commander dispatch order rules that out. Public arguments/options and plugin recovery decisions are unchanged.

This is a residue-waiver cleanup, not a LARGE PR: **106 net production lines removed**, plus 80 test lines removed. Only the synthetic late-mutation table tied exclusively to the removed final census is deleted; ordinary safety and recovery coverage is retained.

## Evidence

Focused proof: 113 distinct tests across seven files pass, covering real Commander recovery policy, archive/restore with include graphs, read-only snapshot identities, caller SQLite locks, external hard links and lint-suppression policy. The first run exposed one test invoking pre-action before parsing; it now uses its existing real-Commander parse helper with every recovery input/assertion unchanged, and all24 pre-action tests pass on replay. No production fallback was restored.

Four-root production typecheck, eight-file lint/format and runtime import cycles pass (zero cycles). Check-changed classification was inspected in dry-run mode; broad local gates were deliberately not run. Shared-host wall time: three infra files519.47s (67% transform), final pre-action file141.34s (70% transform). Existing process/filesystem safety cases remain; no timeout, retry, skip or baseline was weakened. This is correctness proof, not a wall-time speedup claim.

Type-inclusive cycles also pass (zero), and independent final eight-file review is scoped-clean through P2. Exact-head PR CI is the broad gate. All local commands used isolated HOME/state/config/XDG paths; no live state, external channel, schema, dependency, permission, retention or durability change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: reef Channel integration: reef channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: acpx extensions: active-memory extensions: canvas extensions: codex extensions: crabbox extensions: device-pair extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki 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. plugin: workboard proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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