Skip to content

fix(doctor): keep SQLite worker debug logs out of JSON output - #150184

Merged
steipete merged 1 commit into
mainfrom
codex/sqlite-worker-json-20260916
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/sqlite-worker-json-20260916

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor JSON output can become invalid when a SQLite worker emits debug diagnostics during a database read.

User Impact

Worker-backed commands preserve machine-readable stdout while keeping subsystem diagnostics visible on stderr, including when OPENCLAW_LOG_LEVEL=debug is enabled.

Why This Change Was Made

SQLite worker results already travel over their host message port. Each worker has separate logging state, so the caller’s JSON routing does not govern its diagnostics. Enable the existing stderr route in the generic worker bootstrap before backend loading and retain it through close. Result framing, database admission and lifetime, log level, and cleanup budgets are unchanged.

Evidence

An isolated published-driver upgrade cell exposed the defect in selected Doctor lint: its complete raw stdout started with a SQLite budget diagnostic and failed JSON parsing. The earlier updater boundary passed independently; the overall cell remains a failure.

A regression using the actual broker and worker thread reproduces the stdout contamination before the fix and checks exact JSON output plus stderr diagnostics through backend close afterward. Its backend is pure and performs no native database work. All 55 focused tests, the full scoped check:changed gate, targeted lint, and fresh P2 review pass. No updater or failing native scenario was replayed. The corrected combined Doctor cell has not been rerun; its original failure remains retained.

@clawsweeper

clawsweeper Bot commented Sep 16, 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 size: S maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 17:06
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 1:13 PM ET / 17:13 UTC.

ClawSweeper review

What this changes

Routes SQLite worker diagnostics to stderr and adds regression coverage that preserves JSON stdout through worker startup, execution, and close.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main still allows worker diagnostics to contaminate structured stdout. The focused repair has no identified blocking correctness or security findings.

Priority: P2
Reviewed head: ca7f245defd0c16ab74fce68d6e830c7078718e8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-level fix with meaningful worker-boundary regression coverage and clearly disclosed validation limits.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from the external-contributor gate. Its regression exercises the actual broker and worker logging lifecycle with a pure backend; the unreplayed combined Doctor cell remains explicitly unproven.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from the external-contributor gate. Its regression exercises the actual broker and worker logging lifecycle with a pure backend; the unreplayed combined Doctor cell remains explicitly unproven.
Evidence reviewed 8 items Introduced repair: The pinned introduction delta adds stderr routing before backend loading. The complete worker module retains the existing message-port result transport and database admission, execution, and cleanup behavior.
Existing logging owner: routeLogsToStderr sets the existing logging-state switch; subsystem output checks that switch before selecting its console sink. The CLI JSON wrapper changes only its own runtime’s logging state, explaining why the worker needs its own initialization.
Worker transport and regression coverage: The broker creates an actual worker thread. The new test exercises that broker with a pure backend, parses the complete captured stdout, and requires stderr diagnostics for open, execute, and close. This covers a worker-boundary gap left by the existing parent-only JSON routing tests.
Findings None None.
Security None None.

How this fits together

SQLite workers perform database operations for OpenClaw commands and return results through a message port. Their separate logging state determines whether diagnostics interfere with the command’s machine-readable output.

flowchart LR
  A[CLI command] --> B[SQLite worker broker]
  B --> C[Worker backend]
  C --> D[Message port results]
  D --> E[JSON stdout]
  C --> F[Worker logging]
  F --> G[Diagnostic stderr]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +78. Total +81 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 2 78 0 +78
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 81 0 +81

Review metrics

None.

Technical review

Best possible solution:

Keep diagnostic routing in the generic worker bootstrap so every backend preserves command stdout throughout its lifetime.

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

Yes, from source: enable debug logging while a worker-backed JSON command runs; the worker’s independent default logging state permits diagnostics on stdout. The supplied regression exercises this boundary, but this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Initializing the existing logging owner before backend loading fixes the producer boundary without adding configuration, changing database contracts, or duplicating routing logic.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Repairs machine-readable command output when SQLite workers emit enabled diagnostics, with a narrow implementation boundary.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from the external-contributor gate. Its regression exercises the actual broker and worker logging lifecycle with a pure backend; the unreplayed combined Doctor cell remains explicitly unproven.

Label justifications:

  • P2: Repairs machine-readable command output when SQLite workers emit enabled diagnostics, with a narrow implementation boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from the external-contributor gate. Its regression exercises the actual broker and worker logging lifecycle with a pure backend; the unreplayed combined Doctor cell remains explicitly unproven.

Evidence

What I checked:

  • Introduced repair: The pinned introduction delta adds stderr routing before backend loading. The complete worker module retains the existing message-port result transport and database admission, execution, and cleanup behavior. (src/infra/sqlite-store.worker.ts:39, ca7f245defd0)
  • Existing logging owner: routeLogsToStderr sets the existing logging-state switch; subsystem output checks that switch before selecting its console sink. The CLI JSON wrapper changes only its own runtime’s logging state, explaining why the worker needs its own initialization. (src/logging/console.ts:81, ca7f245defd0)
  • Worker transport and regression coverage: The broker creates an actual worker thread. The new test exercises that broker with a pure backend, parses the complete captured stdout, and requires stderr diagnostics for open, execute, and close. This covers a worker-boundary gap left by the existing parent-only JSON routing tests. (src/infra/sqlite-worker-logging.test.ts:16, ca7f245defd0)
  • Current-main necessity: The fetched main worker bootstrap lacks the stderr-routing import and call; its existing worker initialization does not implement this repair. (src/infra/sqlite-store.worker.ts:34, a194d5538e46)
  • Release boundary: The supplied latest release does not contain this generic worker file, so it does not establish a shipped version of this repair. (src/infra/sqlite-store.worker.ts, 3a9d69db306c)
  • Captured validation and limits: The complete supplied PR body reports a before-fix Doctor JSON parsing failure, a failing-before/passing-after real-worker regression, 55 focused passing tests, scoped checks, lint, and fresh review. It expressly says the combined Doctor upgrade cell was not rerun; these claims do not establish a successful native upgrade campaign. This review executed no tests. (ca7f245defd0)

Likely related people:

  • Peter Steinberger: 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.

@steipete
steipete merged commit 1368702 into main Sep 16, 2026
220 checks passed
@steipete
steipete deleted the codex/sqlite-worker-json-20260916 branch September 16, 2026 17:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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