Skip to content

fix(doctor): prevent plugin load errors after read-only inspection - #160446

Merged
steipete merged 4 commits into
mainfrom
fix/doctor-readonly-snapshot-plugin-capture
Sep 28, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/doctor-readonly-snapshot-plugin-capture

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Doctor reporting plugin load errors during upgrades when an earlier read-only inspection has removed native plugin capture files.

User Impact

Channel setup and validation can reuse admitted plugin files after Doctor finishes an inspection. This repairs the candidate-side failure seen when the published 2026.9.6 updater reaches Doctor; the published updater needs no changes.

Why This Change Was Made

Doctor redirects state into disposable SQLite snapshots, but native admission facts live with the plugin cache. Native captures therefore outlived their enclosing directory and later loads failed with ENOENT, including Discord and WhatsApp in Package Acceptance.

Pin source and native capture allocation to the original profile's temporary storage across nested inspections. Existing native integrity checks, custody tokens, cache retirement, and the prohibition on publishing admission receipts during read-only inspection stay in place.

The state-derived capture root was introduced by eeb75c8; 9faa93d subsequently added the cache-retained native admission path seen in this failure. Doctor's ambient state redirection predates both (6f1b678). The separate CPU-bound model-runtime startup stall is not established to have this root cause and is not claimed fixed here.

Evidence

  • Baseline failure: Package Acceptance run 36414106891, job 108910361855, published-upgrade-survivor-2026.9.6, candidate 4e97ea3.
  • New regression runs real Doctor snapshot creation/retirement and the real plugin module loader with a synthetic native addon and companion file. Restoring all production files to base f8ae4fc reproduces ENOENT beneath nested openclaw-sqlite-readonly-v2-* paths.
  • Fixed regression: pnpm test src/commands/doctor-lint.plugin-captures.test.ts --maxWorkers=1 passes; test time 2.578s / cold wrapper wall 33.07s initially; final allocation-expression cleanup also passes, 9.828s test / 159.26s wrapper under heavy host CPU contention (worker preparation dominated). The test needs the real Doctor snapshot and plugin-loader lifetime boundary; no sleeps, polling, or Gateway boots are added.
  • Sibling cleanup, custody/fallback, native admission, and native package-layout suites: 55 tests pass across four files, 57.30s wrapper wall.
  • Codex autoreview on the final diff: scoped-clean through P2, no accepted/actionable findings.
  • Changed-file formatting, ratchets, production type checking, all 26 core-test type graphs, scoped Oxlint, and import-cycle checking pass. The combined changed check stopped at a tooling failure: its pinned Knip cache has no executable (MODULE_NOT_FOUND); a bounded task-local-cache attempt reproduced that failure. The dead-export scan is unverified. All remaining schema, database-policy, media-helper, runtime-sidecar, webhook, and auth guards passed when run separately.

The full published-driver upgrade lane has not been rerun for this patch. No live Gateway or operator state was used by the regression.

Keep cache-owned source and native captures in the original profile's temporary storage while Doctor redirects database state into disposable snapshots. Preserve native admission integrity and custody across later channel setup loads.
@clawsweeper

clawsweeper Bot commented Sep 28, 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 commands Command implementations size: S labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 12:33 PM ET / 16:33 UTC (Revision 4).

ClawSweeper review

What this changes

Doctor lint keeps plugin source and native captures in the original profile’s temporary storage so later channel setup can load them after inspection snapshot cleanup; the branch also adds a regression test and documentation.

Regression provenance

Possible regression — probable (failure trace; reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still has the capture lifetime defect, while this PR has positive published-updater proof and no blocking finding from the introduced change.

Priority: P1
Reviewed head: 59ca12300ad14c215f1c759d3ec046421602ee92

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused lifetime fix is backed by a passing published-updater lane and a regression at the Doctor-to-loader boundary.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): A published 2026.9.6 updater × candidate Docker lane succeeded on the earlier head after the reported baseline Doctor failure. The reviewed head has identical introduced files, and the regression exercises Doctor snapshot retirement followed by a real plugin-loader reuse; the full lane was not rerun on this head. No stored-data model changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): A published 2026.9.6 updater × candidate Docker lane succeeded on the earlier head after the reported baseline Doctor failure. The reviewed head has identical introduced files, and the regression exercises Doctor snapshot retirement followed by a real plugin-loader reuse; the full lane was not rerun on this head. No stored-data model changes.
Evidence reviewed 7 items Introduced allocation scope: Doctor now supplies the original profile state directory through a scoped context while its database inspection uses a disposable snapshot.
Capture owner: The existing capture owner uses the scoped directory when no explicit directory is supplied; its custody and cleanup remain with the retained instance.
Current main still needs the fix: Current main still defaults capture allocation to the ambient state directory. The affected files have no change between the pinned PR base and fetched main.
Findings None None.
Security None None.

How this fits together

Doctor runs health checks during updates using disposable database snapshots. Plugin inspection also creates files that the plugin cache may need for later channel setup.

flowchart LR
  A[Published updater] --> B[Doctor lint]
  B --> C[Disposable database snapshot]
  B --> D[Plugin inspection]
  D --> E[Profile temporary captures]
  E --> F[Plugin cache]
  F --> G[Later channel setup]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +12, Tests +92, Docs +4. Total +108 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 16 4 +12
Tests 1 92 0 +92
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 112 4 +108

Review metrics

Metric Value Why it matters
Production and regression growth production +12 net lines, tests +92 lines The small runtime addition has a stated capture-custody purpose and a boundary regression.

Technical review

Best possible solution:

Keep captured plugin files under cache custody in the profile’s protected temporary storage while Doctor isolates database inspection in disposable snapshots.

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

Yes. Current-main source retains the snapshot-bound allocation path, and the reported baseline Package Acceptance run failed in Doctor; this read-only review did not execute a fresh current-main reproduction.

Is this the best way to solve the issue?

Yes. Scoping the existing capture allocator to the original profile addresses the lifetime mismatch while preserving Doctor’s disposable database reads and existing capture cleanup.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Doctor plugin load failures can interrupt an established update and channel validation workflow.
  • merge-risk: 🚨 compatibility: The PR changes where Doctor allocates temporary plugin files during upgrades; the published-updater lane supports the intended path.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): A published 2026.9.6 updater × candidate Docker lane succeeded on the earlier head after the reported baseline Doctor failure. The reviewed head has identical introduced files, and the regression exercises Doctor snapshot retirement followed by a real plugin-loader reuse; the full lane was not rerun on this head. No stored-data model changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. A published 2026.9.6 updater × candidate Docker lane succeeded on the earlier head after the reported baseline Doctor failure. The reviewed head has identical introduced files, and the regression exercises Doctor snapshot retirement followed by a real plugin-loader reuse; the full lane was not rerun on this head. No stored-data model changes.

Evidence

What I checked:

  • Introduced allocation scope: Doctor now supplies the original profile state directory through a scoped context while its database inspection uses a disposable snapshot. (src/commands/doctor-lint-runner.ts:589, 59ca12300ad1)
  • Capture owner: The existing capture owner uses the scoped directory when no explicit directory is supplied; its custody and cleanup remain with the retained instance. (src/plugins/plugin-source-capture-directory.ts:587, 59ca12300ad1)
  • Current main still needs the fix: Current main still defaults capture allocation to the ambient state directory. The affected files have no change between the pinned PR base and fetched main. (src/plugins/plugin-source-capture-directory.ts:585, b4e363171c93)
  • Lifetime regression: The new test runs Doctor with a synthetic native plugin, checks that the private state is removed, and loads the plugin again from the retained cache. (src/commands/doctor-lint.plugin-captures.test.ts:69, 59ca12300ad1)
  • Published-updater behavior proof: The published-upgrade-survivor-2026.9.6 Docker job and its run and summary steps succeeded on head 85b4fb7. The earlier Package Acceptance job failed; the PR body identifies a Doctor snapshot-path ENOENT. GitHub lists a retained artifact for the successful lane. Job logs could not be downloaded through the review host’s network allowlist. (85b4fb767e63)
  • Proof carries to reviewed head: All five introduced files are byte-identical between the successful lane’s head and the current reviewed head; the full published-driver lane was not rerun on the latter. (59ca12300ad1)

Likely related people:

  • Peter Steinberger: Raw commit 439940b adds src/commands/doctor-lint-runner.ts:534 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 439940bf0bf5; files: src/commands/doctor-lint-runner.ts)
  • Vyctor H. Brzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

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

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

Workflow

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

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-28T12:39:39.384Z sha 85b4fb7 :: blocked before merge. :: none
  • reviewed 2026-09-28T12:49:44.487Z sha 85b4fb7 :: blocked before merge. :: none
  • reviewed 2026-09-28T14:04:27.548Z sha 12580b0 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 28, 2026 12:43
@steipete

Copy link
Copy Markdown
Contributor Author

CI note: 85b4fb7 failed only ui/src/e2e/session-progress-widget.e2e.test.ts > keeps target liveness when the selected agent scope changes (Control UI), which this Doctor/plugin-capture change does not touch; re-running the failed job once. Pre-merge proof: the published-upgrade-survivor-2026.9.6 Docker lane (published 2026.9.6 updater × this candidate) passed from this branch (run 36422729800), where main fails it at phase=doctor with the snapshot-path ENOENT.

@steipete

Copy link
Copy Markdown
Contributor Author

CI note: after the recorded UI rerun, 85b4fb7 failed only test/e2e/qa-lab/runtime/channel-progress-presentation.e2e.test.ts > retires unphased Slack previews across tool-only assistant messages (120 s timeout), unrelated to Doctor/plugin capture. Refreshed onto current main (with the main-side UI and QA-scenario fixes) instead of rerunning again.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Keep cache-owned source and native captures in the original profile's temporary storage while Doctor redirects database state into disposable snapshots. Preserve native admission integrity and custody across later channel setup loads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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