Skip to content

fix(doctor): keep database inspection captures out of operator state - #175173

Merged
steipete merged 1 commit into
mainfrom
fix/fix7-doctor-readonly-captures
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/fix7-doctor-readonly-captures

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Read-only Doctor writes plugin-build captures into operator state when its database inspection worker loads plugin APIs. The hosted-Doctor preservation test then follows a capture symlink into the checkout and stalls.

User Impact

Doctor can inspect databases without leaving plugin captures in the profile's state directory. Existing database admission, repair policy and physical inspection remain unchanged.

Why This Change Was Made

The caller's temporary capture context does not cross a Worker boundary. Apply the existing temporary plugin-capture scope inside that worker. Bound the regression snapshot to physical fixture entries with lstat, retaining all entries, file hashes/times and symlink targets; no paths are excluded.

The new descriptor loading in #174912 exposed this missing worker context. This complements #175169: applying that PR's inspection hunk alone still fails this regression with 46 added state entries, including a Reef capture. Avoiding absent-store descriptor loads does not replace the worker's capture-storage context.

Evidence

  • Negative control on main 942df96 with only the no-follow snapshot: the original state-equality assertion fails in 24.5 seconds with 46 added entries beneath state/tmp/plugin-captures.
  • With this fix, both hosted-Doctor process tests pass under Node with one worker; the read-only case takes 20.44 seconds. The existing physical-inspection worker test also passes through pnpm test ... --maxWorkers=1.
  • Production core and owning test typechecks, targeted typed lint, formatting, whitespace checks and independent P2 autoreview pass. Assertions and timeouts are unchanged; no retries or exclusions were added.
  • Main hourly 39002992814, job 117309836533, failed invocation core-unit-src-security-3-hosted-2 with an unexpected Vitest worker exit in this test file. The original local snapshot timed out. The precise CI worker-exit mechanism is unproven; the state mutation and unbounded symlink traversal are directly reproduced.

The separate real-Gateway automation failure from the same hourly remains unattributed. Its local replay timed out earlier during bootstrap, before reaching the CI admin-result assertion. This PR does not claim to fix it.

Ready for maintainer review and landing; auto-merge is not enabled.

The physical database inspection added by #174912 loads plugin descriptors
in a worker that does not inherit the caller's temporary capture scope.
Apply the existing temporary capture context inside that worker so readonly
Doctor does not leave plugin build captures under the operator's state.

Keep the hosted Doctor regression bounded to its own fixture using lstat
traversal, retaining every physical entry and symlink target. The old
recursive snapshot followed capture links into the checkout and timed out.
With only that snapshot correction, unchanged main adds 46 state entries;
the production repair restores the existing unchanged-state assertion.

Both process tests pass on Node with one worker (readonly case 20.44s).
Production and owning test types, typed lint, format and independent P2
review pass. No timeout, retry or state exclusion changes.
@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@steipete
steipete marked this pull request as ready for review October 17, 2026 05:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T05:42:06.571801Z b166a3b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: XS labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR gives database inspection workers the existing temporary plugin-capture context and prevents the regression snapshot from following symlinks outside its fixture.

Example: The setup assistant runs Doctor with plugins disabled and gateway.mode unset.

  • Before: Database descriptor loading can add captures under state/tmp/plugin-captures despite the read-only diagnostic posture.
  • After: Captures use temporary storage while Doctor reports the expected gateway.mode finding without changing the operator-state tree.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with a valuable production-path regression; runtime evidence is harness-based and exact-head CI is still pending.
Proof confidence 🦐 gold shrimp (3/6) Maintainer-authored PR outside the ordinary contributor proof gate: supplied evidence covers the real hosted Doctor process and database worker through tests, rather than a separate shipped-entry-point demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A read-only Doctor diagnostic can leave plugin-build artifacts in the operator’s state directory.
Reason: This restores a documented contract using an existing mechanism, and maintainer authorship supplies direction approval.

Regression provenance

Regression provenance — verified: source commit 6cf7c4775738 by Peter Steinberger; canonical PR #174912 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current-main violation of Doctor’s read-only contract with a focused change and a meaningful regression test; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: b166a3bdba27a732052ade75b27b06760e2374fc

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No separate shipped CLI or setup-session demonstration is supplied; the reported negative control and repaired run exercise the real hosted Doctor process through the regression harness.
Agent review details

How this fits together

Doctor dispatches physical database inspection to a worker, which loads plugin descriptors and returns diagnostic facts; the plugin capture owner controls allocation and retention of any required source artifacts.

flowchart TD
A[Doctor diagnostic request] --> B[Database inspection worker]
B --> C[Temporary capture context]
C --> D[Plugin descriptor loading]
D --> E[Existing capture lifecycle owner]
B --> F[Artifact preserving database reads]
F --> G[Health findings]
Loading

Technical review

Best possible solution:

Use the existing temporary capture owner inside the inspection worker while preserving database admission, artifact protection and diagnostic output.

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

Current-main source shows descriptor loading inside a worker without the caller’s temporary capture context, and the PR reports a negative control producing 46 added state entries; this review ran no target code.

Is this the best way to solve the issue?

The repair belongs at the worker boundary and reuses the established capture lifecycle rather than suppressing state changes or introducing another owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against da3716812df5.

Provenance checked

  • Physical database inspection keeps the original intent (6cf7c47: Report physical store facts through real provider descriptors while preserving database artifacts.)
  • Hosted Doctor preservation regression keeps the original intent (0512f3c: Keep setup diagnostics from repairing or migrating operator state without repair approval.)
  • Temporary plugin-capture lifetime keeps the original intent (3007e63: Keep captures outside disposable inspection snapshots and retain them through their plugin-cache owner.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6cf7c47 adds src/commands/doctor-database-engine-inspection.ts:220 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6cf7c4775738; files: src/commands/doctor-database-engine-inspection.ts)

PR surface

Source +4, Tests +10, Docs +1. Total +15 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 7 3 +4
Tests 1 19 9 +10
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 27 12 +15

Labels

Label changes:

  • add P2: The patch restores read-only diagnostic state preservation with limited scope; no user data loss or blocked first-use workflow is established.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The patch restores read-only diagnostic state preservation with limited scope; no user data loss or blocked first-use workflow is established.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 17, 2026, 1:55 AM ET / 05:55 UTC.

@steipete
steipete merged commit 8c7c9f6 into main Oct 17, 2026
201 of 206 checks passed
@steipete
steipete deleted the fix/fix7-doctor-readonly-captures branch October 17, 2026 06:02
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…w#175173)

The physical database inspection added by openclaw#174912 loads plugin descriptors
in a worker that does not inherit the caller's temporary capture scope.
Apply the existing temporary capture context inside that worker so readonly
Doctor does not leave plugin build captures under the operator's state.

Keep the hosted Doctor regression bounded to its own fixture using lstat
traversal, retaining every physical entry and symlink target. The old
recursive snapshot followed capture links into the checkout and timed out.
With only that snapshot correction, unchanged main adds 46 state entries;
the production repair restores the existing unchanged-state assertion.

Both process tests pass on Node with one worker (readonly case 20.44s).
Production and owning test types, typed lint, format and independent P2
review pass. No timeout, retry or state exclusion changes.
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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