Skip to content

fix(doctor): release isolated state before cleanup - #147281

Merged
steipete merged 26 commits into
openclaw:mainfrom
giodl73-repo:user/giodl/doctor-lint-state-cleanup
Sep 24, 2026
Merged

steipete merged 26 commits into
openclaw:mainfrom
giodl73-repo:user/giodl/doctor-lint-state-cleanup

Conversation

@giodl73-repo

@giodl73-repo giodl73-repo commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Doctor lint cleanup failures when inspection leaves cached SQLite readers or a state writer open in its isolated snapshot.

User Impact

Doctor retires the private database handles before removing the snapshot. Cleanup problems preserve completed findings and check counts; update-marked runs can report incomplete removal as a warning. If database retirement fails, Doctor retains the snapshot and reports the failure. The storage schema and configuration contract stay the same.

Why This Change Was Made

The snapshot owner now settles scoped auth readers and the state database writer before deleting their files, while preserving detector errors when cleanup also fails. The Doctor lint documentation explains the cleanup outcomes.

The current-main integration preserves the Linux/Windows native watcher owner and the macOS parent-entry observation needed when a watched directory moves. Watcher fixtures retain both native recovery checks and synchronization on the actual symlink entry. The outbound recovery fixtures use the canonical readiness repair already on main.

Builds on the work of @giodl73-repo and @fuller-stack-dev, with both contributors' ancestry and credit preserved.

Evidence

The signed candidate is 6f9d20ee252b91e9a61fea625ae3712a3b4b05cc, incorporating fixed main e843a9a1d794e3ddc016e348558df6befa7e0380. Independent review of the complete PR diff found no actionable P0–P2 findings. Formatting and whitespace checks pass. This PR changes no UI runtime source relative to its incorporated main revision.

Exact-head CI passed, including all three macOS Node lanes. The Darwin watcher integration exercised real ancestor moves on macOS 15.7.4 ARM64, Node 24.16.0, and Vitest 5.0.1. Earlier outbound fixture failures are covered by main's canonical readiness/settlement repair; the native-plugin diagnostic preserves its original timeout and error without claiming to fix an unproved startup cause.

Package Acceptance produced the final-source package normally. Producer, integrity, npm 12 installer, and Doctor-switch jobs passed. Artifact 10828298572, run attempt 1, contains openclaw-current.tgz (2026.9.6), SHA-256 c26b3232655af3547840e5ae710d8bc2b2b614843cb27259fa0dd3379a4882c4; its build-info identifies the exact candidate.

The same package passed three additional installed Linux Doctor cases using a real registered synthetic plugin and the public provider-auth SDK. Node 24.19.0/npm 11.17.0 performed a normal production install with lifecycle scripts enabled; the native fs-safe verifier passed. Runtime used an isolated non-root container, synthetic state, no network or host mounts, and the default /tmp permissions.

  • A genuine nonempty pooled agent-state read and private shared-state write complete; their native descriptors close before both nested snapshot directories are removed and the successful report is printed.
  • A real mode-0500 cleanup denial preserves the snapshot and produces an update-marked warning with exit 0.
  • The same OS denial with an invalid tool schema retains both the detector finding and the separate cleanup error, with exit 1.

Native syscall traces establish the ordering and actual EACCES errors; no mocked denial or forced handle closure is involved. The successful reader/writer main descriptors close at epoch 1790280329.231968/.235340, before database unlink at .240073/.240818 and outer-directory removal at .245993. Original source/config bytes remain unchanged after every case. Logical SDK readback uses a finalized copy. The returned schema finding is not described as a thrown detector exception. Two earlier fixture calibration failures are retained: a shallow snapshot-path assumption, then verification that directly read the source and changed SQLite sidecars. The corrected cases use the same immutable package. All containers settled, and the owned Testbox was stopped and verified completed.

Published-updater acceptance passed in artifact-only recovery 36057461016, using the same immutable candidate package and the reviewed harness fix in #157579. The authentic 2026.9.4 updater installed the exact 6f9 build and preserved Projects inventory. Both subsequent selected Doctor invocations and their preservation assertions passed: Projects rows/schema, the then-current configuration and SQLite bytes, and synthetic project files were preserved. The lane completed in 161 seconds. Its phase-evidence artifact records the complete sequence. The earlier failure was the observer counting a defining module and its generated forwarder; the shared resolver now selects the unique definition without weakening integrity checks. The original failure and two admission-only attempts remain recorded. The update-marked selected lint cases above remain separate from the stock updater's intentionally deferred inspection rehearsal; no additional internal first-hop post-core diagnostic claim is made.

A separate persistent-client installed witness found that initial agent creation was acknowledged before the new roster became visible to an immediately following session-creation RPC. That ownership issue is under investigation separately. It failed before deletion and therefore does not establish or clear the earlier CI error, “Agent database resources are closing,” after deletion and recreation. No lifecycle fix or waiver is claimed here.

Related: #149068's prior ordering hold is cleared.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 commands Command implementations size: XS maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 5:33 PM ET / 21:33 UTC (Revision 23).

ClawSweeper review

What this changes

The branch makes OpenClaw’s Doctor health check close private SQLite readers and writers before snapshot cleanup, preserves findings when cleanup fails, observes moved skill directories on macOS, and updates related tests and documentation.

Merge readiness

⛔ Blocked before merge - 3 items remain

Current main and v2026.9.6 still lack Doctor lint’s private auth-reader retirement. This PR remains a distinct, source-aligned fix with substantial installed-runtime proof.

Priority: P2
Reviewed head: 6f9d20ee252b91e9a61fea625ae3712a3b4b05cc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong installed behavior evidence and no identified correctness defect; changed-test cost disclosure remains outstanding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed Doctor snapshot owner is exercised through an installed package with a real synthetic plugin and SQLite readers and writer; the captured native trace reports handle closure before deletion, real OS denial behavior, and preserved output. A linked published-updater recovery run passes with the same candidate package. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed Doctor snapshot owner is exercised through an installed package with a real synthetic plugin and SQLite readers and writer; the captured native trace reports handle closure before deletion, real OS denial behavior, and preserved output. A linked published-updater recovery run passes with the same candidate package. No stored-data contract changes.
Evidence reviewed 9 items Introduced cleanup order: The introduced Doctor hunk closes auth-profile readers scoped to the private state root, then awaits closure of the private state database before deleting snapshot files.
Reader scope: The existing auth-reader pool closes entries only when their database paths lie inside the supplied root, preserving caller-owned readers elsewhere.
Still needed on main: Current main’s snapshot cleanup closes the private state database but has no auth-reader-pool close. The central source files have not changed between the PR base and fetched main.
Findings None None.
Security None None.

How this fits together

Doctor lint runs health checks against a private copy of OpenClaw’s SQLite state and returns findings to CLI users or the installed updater. Its cleanup must release private database handles without disturbing live state.

flowchart LR
A[CLI or updater] --> B[Doctor lint]
C[Live SQLite state] --> D[Private snapshot]
D --> B
B --> E[Close private handles]
E --> F{Cleanup complete?}
F --> G[Findings and status]
Loading

Before merge

  • Resolve merge risk (P1) - Materially changed test files lack the required single-worker wall times and CI seconds in the PR body, leaving recurring CI cost unquantified.
  • Complete next step (P2) - Add measured single-worker wall times and CI seconds for materially changed test files to the PR body.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +94, Tests +778, Docs +5. Total +877 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 3 164 70 +94
Tests 19 1269 491 +778
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 1438 561 +877

Review metrics

Metric Value Why it matters
Production and test line changes production +164/-70; tests and test support +1269/-491 Production growth supports scoped cleanup and result preservation; the larger test change makes measured CI cost useful before merge.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-lint-output.ts, migration/backfill/repair: src/commands/doctor-lint.ts, unknown-data-model-change: src/commands/doctor-lint-output.ts, unknown-data-model-change: src/commands/doctor-lint.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep Doctor’s private snapshot lifecycle responsible for closing its own readers and writer, preserving the live database and a complete health report across cleanup outcomes.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep Doctor’s private snapshot lifecycle responsible for closing its own readers and writer, preserving the live database and a complete health report across cleanup outcomes.

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

Yes. Current-main source leaves private pooled auth readers open before snapshot deletion, and the PR supplies installed-runtime observations of the affected cleanup path; this read-only review did not execute a failing main run.

Is this the best way to solve the issue?

Yes. The branch closes handles through their existing scoped owners and preserves completed findings when cleanup fails, without adding a storage or configuration contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 25f07e880f5d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed Doctor snapshot owner is exercised through an installed package with a real synthetic plugin and SQLite readers and writer; the captured native trace reports handle closure before deletion, real OS denial behavior, and preserved output. A linked published-updater recovery run passes with the same candidate package. No stored-data contract changes.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This repairs a bounded Doctor lint cleanup failure without evidence of a widespread runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed Doctor snapshot owner is exercised through an installed package with a real synthetic plugin and SQLite readers and writer; the captured native trace reports handle closure before deletion, real OS denial behavior, and preserved output. A linked published-updater recovery run passes with the same candidate package. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Doctor snapshot owner is exercised through an installed package with a real synthetic plugin and SQLite readers and writer; the captured native trace reports handle closure before deletion, real OS denial behavior, and preserved output. A linked published-updater recovery run passes with the same candidate package. No stored-data contract changes.

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)
  • vincentkoc: 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.

  • Report single-worker wall times and CI seconds for materially changed test files in the PR body.

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 (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-23T00:35:22.192Z sha b5e698e :: blocked before merge. :: none
  • reviewed 2026-09-23T01:17:57.141Z sha b5e698e :: blocked before merge. :: none
  • reviewed 2026-09-23T05:15:48.934Z sha 2276096 :: blocked before merge. :: none
  • reviewed 2026-09-23T07:09:00.567Z sha 2276096 :: blocked before merge. :: none
  • reviewed 2026-09-23T12:12:40.053Z sha 8612b27 :: blocked before merge. :: none
  • reviewed 2026-09-24T14:54:58.122Z sha 4e87723 :: blocked before merge. :: none
  • reviewed 2026-09-24T16:39:09.700Z sha 5daf7a5 :: blocked before merge. :: none
  • reviewed 2026-09-24T18:33:13.759Z sha 6f9d20e :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added 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: 🦐 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 20, 2026
@steipete

Copy link
Copy Markdown
Contributor

Independent Codex review of the current tip against main (diff-only): clean, no actionable finding. The auth-reader cleanup is scoped to the private snapshot and runs before the existing awaited database shutdown and deletion, which is the right order for the Windows handle case.

The PR is conflicting with main right now (mergeable_state: dirty; the shared worker lifecycle moved today in #153150, which is the likely overlap). Please rebase onto current main; once exact-head CI is green on the rebased tip and ClawSweeper's running re-review has no open finding, I will land it through the maintainer workflow.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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. and removed 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 Sep 20, 2026
@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Sep 20, 2026
Integrate captured main d3160de
while preserving the published PR and original contributor ancestry.
Keep matching participant-event assertions after real execution/effect
joining and retain exact upstream timeout-safe reset-hook cleanup.

Make SSH approval observation abortable with idempotent fixture fallback:
release held locks and probes, join real verifier/approval/preauth work
and the enclosing LAN attempt, and always restore observers. Keep all
distinct regressions, original assertions and published timeout budgets.

Independent full-file API review is scoped-clean. Gateway63/63, Doctor40/40
and SSH11/11 pass; participant and absent-approval negative controls prove
failure visibility and joined cleanup. Local watcher qualification remains
10/11; neither diagnostic success nor graceful-drain success proves the
historical cause fixed. Required checks/actual-head CI and separate
installed published-driver/native acceptance remain gates.
Require both the unchanged source-version advancement and actual parent
watch acquisition before replacing a watched symlink with an ordinary
directory. Exact failing traces showed a late initial-ready event could
satisfy the old version-only wait before the symlink was observed. Keep
the same 3000ms budget, all eleven cases and all admission/discovery checks.

Resolve SSH fixture lint without changing cleanup semantics. Final normal
watcher11/11 and SSH11/11 pass; independent API source review is scoped-clean.
Full required checks and exact-head hosted CI remain required. No broad
historical watcher/graceful-drain repair or installed-acceptance claim.
Wait for terminal execution and abort publication before retaining the
original matching WebSocket assertions. Close task-owned SQLite workers
through the existing scoped state fixture before deleting their directories.
Preserve all regressions, budgets and contributor ancestry for PR openclaw#147281.
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 23, 2026
Retire snapshot-owned auth readers and state writers before removing private
inspection state. Keep completed findings, check counts, cleanup warnings,
and earlier detector errors visible when disposal fails.

Reconcile the original branch with the current runtime-env loader and fixture
owners. Preserve both watcher readiness/error observations and exact path
observations, and document the cleanup behavior.

Fresh independent P0-P2 source review is clean. Package and installed runtime
acceptance remain to be qualified against this exact candidate.

Co-authored-by: Gio Della-Libera <[email protected]>
Co-authored-by: Jason (Json) <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 24, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Sep 24, 2026
Observe delivery callback entry before stopping admission or starting the
reconnect drain. Handle recovery outcomes immediately and release and join
blocked work on failure before shared-state teardown can begin.

Retain synthetic native-plugin phase evidence when the CLI child fails, then
rethrow the original error. Preserve the existing deadlines, assertions and
case order; the initial startup delays remain unexplained.
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Sep 24, 2026
Merge fixed main while preserving Doctor private database retirement and
Darwin parent-entry observation. Keep native watcher recovery coverage and
use the canonical outbound fixture readiness repair.

Co-authored-by: Gio Della-Libera <[email protected]>
Co-authored-by: Jason (Json) <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 24, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 24, 2026
@steipete
steipete merged commit f53cce0 into openclaw:main Sep 24, 2026
251 of 252 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 25, 2026
* fix(doctor): close isolated state handles

* test(doctor): run Windows state isolation before grouped shard

* test(doctor): isolate OAuth source-lock fixture and baseline

* test(doctor): preserve explicit Windows shard target contract

* test(doctor): preserve isolated cleanup and OAuth success proof

* test(doctor): settle snapshot tokens and prepare OAuth worker fixtures

* test(skills): capture watcher failure state before cleanup

* test(gateway): join qualified SSH pairing verification

Consume the main fadc546 prerequisite
and the qualified follow-up from openclaw#147821. Preserve delayed rejection and
in-handshake approval coverage, join real verification and approval work,
and retain policy, scoped-request, mismatch and disabled-path regressions.

The source matches the qualified supplier exactly. No authorization logic,
retry policy or timeout budget changes.

Co-authored-by: Peter Steinberger <[email protected]>

* test(gateway): join lifecycle effects before root and hook assertions

* test(gateway): consume landed reset-hook fixture cleanup

* test(skills): await observed ancestor replacement

Require both the unchanged source-version advancement and actual parent
watch acquisition before replacing a watched symlink with an ordinary
directory. Exact failing traces showed a late initial-ready event could
satisfy the old version-only wait before the symlink was observed. Keep
the same 3000ms budget, all eleven cases and all admission/discovery checks.

Resolve SSH fixture lint without changing cleanup semantics. Final normal
watcher11/11 and SSH11/11 pass; independent API source review is scoped-clean.
Full required checks and exact-head hosted CI remain required. No broad
historical watcher/graceful-drain repair or installed-acceptance claim.

* test(gateway): join publishers and retire fixture state

Wait for terminal execution and abort publication before retaining the
original matching WebSocket assertions. Close task-owned SQLite workers
through the existing scoped state fixture before deleting their directories.
Preserve all regressions, budgets and contributor ancestry for PR openclaw#147281.

* test: preserve recovery and CLI fixture failures

Observe delivery callback entry before stopping admission or starting the
reconnect drain. Handle recovery outcomes immediately and release and join
blocked work on failure before shared-state teardown can begin.

Retain synthetic native-plugin phase evidence when the CLI child fails, then
rethrow the original error. Preserve the existing deadlines, assertions and
case order; the initial startup delays remain unexplained.

---------

Co-authored-by: Jason (Json) <[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

app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

3 participants