Skip to content

fix(doctor): stop doctor --lint from creating empty PostgreSQL workboard schemas - #182827

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1897
Oct 24, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1897

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #182771. Every read-only doctor --lint run could leave an empty PostgreSQL Workboard schema behind when Workboard used PostgreSQL.

Supersedes #182790, thanks @etzelm (Mitchell Etzel) for the report and fix direction.

User Impact

Doctor can inspect all Workboard tool schemas without creating a Workboard store or PostgreSQL namespace. Executing a discovered tool still opens the durable store and persists its changes. Normal runtime startup remains eager. Existing orphan schemas are left alone; there is no migration or cleanup of operator data.

Release-note context: Doctor lint no longer creates empty PostgreSQL Workboard schemas during runtime tool-schema inspection. Fixes #182771; supersedes #182790; thanks @etzelm.

Why This Change Was Made

Doctor's private inspection state retains the configured PostgreSQL engine but has no Workboard anchor. Workboard registration eagerly opened its persistence worker, which allocated a fresh PostgreSQL namespace; disposing the temporary state then lost the only anchor to it.

The Workboard persistence owner now defers worker admission for tool-discovery registrations until a tool actually uses storage. Disposal of an unused discovery store does not open it. This preserves standalone tool execution and existing runtime readiness instead of changing the database engine's creation policy globally.

Sibling inspection: the database-diagnostics owner snapshots existing anchors and uses read-only SQLite inspection; Crabbox's Doctor contribution uses its host-provided entry reader. Visitor Access, MCP Events, and IMAP defer their runtime state/services until full registration. No matching eager Workboard-style store allocation was found in those paths.

Simplification: one existing worker owner handles eager runtime and deferred discovery admission. Production delta: +18/-13 (net +5); tests: +53/-0; docs: +4/-0. The five production lines retain eager readiness and support cleanup when discovery never opened a worker; no public config/CLI option, dependency, or database schema changes.

Evidence

  • Regression on the untouched production base: node scripts/run-vitest.mjs extensions/workboard/index.lifecycle.test.ts --maxWorkers=1 failed at expected true to be false because three schema-discovery/disposal passes created workboard.sqlite; six existing lifecycle tests passed. Test time about 2.4 seconds, total runner 75.87 seconds (shared worker/compiler preparation dominated).
  • Fixed regression: the same command passed all 7 tests; 16.46 seconds Vitest wall time, 19.68 seconds total runner (pinned Bun selected by the repository wrapper). The regression checks the complete tool inventory, no storage after repeated discovery and disposal, and persistence after executing a discovered tool and reopening the store.
  • Live integration harness: isolated HOME and OPENCLAW_STATE_DIR; runDoctorLintCli(runtime, { json: true, onlyIds: ['core/doctor/runtime-tool-schemas'] }) completed three passes with checksRun: 1, findings: [], and exit 0. Repeated after installGatewayDatabaseEngine() selected PostgreSQL for Workboard against the intentionally unreachable fixture endpoint postgresql://127.0.0.1:1/unused: all three passes again exited 0 with no findings. This exercises the real Doctor runner and plugin discovery, without opening a PostgreSQL store.
  • PostgreSQL schema-count/anchor/card preservation on a real server was not run: no disposable local PostgreSQL server binaries were available. The PostgreSQL integration cases remain explicitly skipped, not claimed as passing. The source CLI attempt (pnpm openclaw doctor --lint --only core/doctor/runtime-tool-schemas --json) stopped at the runtime-artifact publication guard before Doctor ran; no Gateway was stopped or changed. The in-process integration harness above avoids artifact publication.
  • Explicit Node proof: OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs extensions/workboard/index.lifecycle.test.ts extensions/workboard/src/sqlite-store-policy.test.ts --maxWorkers=1 passed 8 tests in 2 files (56.17 seconds Vitest wall time; 58.43 seconds runner, dominated by shared preparation).
  • Importing suites plus Doctor siblings: 331 passed, 14 PostgreSQL-dependent tests skipped across 30 files (29 passed, 1 skipped), 4 shards, 287.51 seconds runner on pinned Bun. Workboard extension shard: 314 passed / 10 skipped; schema inspection: 10 passed; terminal-hook/mixed-mode: 3 passed / 4 skipped; database diagnostics: 4 passed. No failing, flaky, or individual >30-second test was observed.
  • Targeted tsgo passed for the three production files and regression through an isolated project extending test/tsconfig/tsconfig.extensions.test.json; oxfmt and git diff --check passed. The repository type-aware extension lint wrapper exited 0 (no nested-checkout fallback needed); Madge reported 0 cycles.
  • node scripts/check-changed.mjs passed conflict, line-cap, max-lines/env-name, and assertion-safety checks before its SQLite worker inventory step was intentionally interrupted under the campaign's local gate budget. Full check:changed was not completed; PR CI supplies broad proof.
  • Independent Codex autoreview: scoped clean through P2, no accepted/actionable findings.

Freshness: fetched current origin/main immediately before publication; #182771 remains open, with no intervening main commit touching the three production owners.

Defer Workboard persistence-worker admission during tool discovery so
read-only Doctor inspection cannot allocate an unanchored PostgreSQL
namespace. Keep normal runtime readiness and durable tool execution.

Fixes #182771. Supersedes #182790, thanks @etzelm.

Co-authored-by: Mitchell Etzel <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 24, 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 plugin: workboard size: S labels Oct 24, 2026
@steipete
steipete marked this pull request as ready for review October 24, 2026 19:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 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-24T19:40:26.676813Z 38f6ba4 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.

@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. 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. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defers Workboard storage initialization during tool discovery until a tool actually accesses storage.

Example: Run doctor --lint three times with PostgreSQL Workboard configured under schema prefix issue2.

  • Before: The reported namespace count grows from 1 to 4.
  • After: Schema discovery leaves storage unopened, preventing those additional namespaces.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and reported red/green boundary regression support correctness; supplied behavioral evidence remains at the in-process harness level, with no persisted-format or migration change.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports repeated real Doctor-runner inspection with PostgreSQL selected against an unreachable fixture, but discloses that shipped-CLI PostgreSQL preservation and stable-upgrade runs were not completed.
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 check leaves another empty PostgreSQL Workboard schema after every run.
Reason: The maintainer-authored change restores the documented read-only contract without changing operator configuration, stored formats, or standalone tool capability.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete current-main side effect with a focused change to Workboard’s existing persistence owner; no actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 38f6ba4618363f1bf75ff7f34159a5fadb092f18

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate the shipped CLI against a real PostgreSQL server or an upgrade from the latest stable release.
Agent review details

How this fits together

Doctor discovers plugin tool schemas against temporary state; Workboard supplies tool factories whose database operations use its existing worker and lifecycle owner.

flowchart TD
  A[Doctor lint] --> B[Tool discovery registration]
  B --> C[Workboard tool factories]
  C --> D[Schema inspection]
  C --> E[Tool execution]
  E --> F[Existing persistence worker]
  F --> G[SQLite or PostgreSQL]
Loading

Technical review

Best possible solution:

Keep schema discovery free of durable initialization while preserving eager runtime startup and opening the existing worker on first storage use.

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

Current-main source confirms the path from temporary inspection state through eager worker startup to fresh PostgreSQL namespace creation, and the linked issue provides isolated CLI results; this review executed no target code.

Is this the best way to solve the issue?

The patch is the smallest complete fix using existing owners: it delays admission at the producer, preserves executable discovery tools, and retains runtime readiness, operation draining, recovery, and write-authority checks.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Registration-time worker initialization changes intended behavior with a stated reason (38fb08d: Move Workboard database operations off the Gateway event loop while preserving startup readiness and lifecycle ownership.)
  • Configured database-family selection keeps the original intent (995a9ae: Route Workboard through the shared effective database-family selection without silently switching engines.)
  • Worker cleanup and recovery keeps the original intent (069d40e: Let the existing broker recover failed workers while draining accepted work and never replaying uncertain writes.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 995a9ae adds extensions/workboard/src/sqlite-store.ts:31 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 995a9ae02145; files: extensions/workboard/src/sqlite-store.ts)

PR surface

Source +5, Tests +53, Docs +4. Total +62 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 18 13 +5
Tests 1 53 0 +53
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 75 13 +62

Review metrics

Metric Value Why it matters
Production versus test changes Production +18/-13 lines; tests +53/-0 lines The small production increase reuses the existing worker owner; the regression protects discovery without creation and subsequent durable execution.

Labels

Label changes:

  • add P2: Repeated lint runs accumulate orphan PostgreSQL schemas on affected Workboard installations, creating operational cleanup cost without reported loss of live data.
  • 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: Repeated lint runs accumulate orphan PostgreSQL schemas on affected Workboard installations, creating operational cleanup cost without reported loss of live data.
  • 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 24, 2026, 3:54 PM ET / 19:54 UTC.

@steipete
steipete merged commit ae180dc into main Oct 24, 2026
240 of 243 checks passed
@steipete
steipete deleted the upd/upd-l1897 branch October 24, 2026 20:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…ard schemas (openclaw#182827)

Workboard tool registration eagerly opened its store while Doctor discovered runtime tool schemas in anchorless temporary state, so every doctor --lint on a PostgreSQL workboard allocated a new orphan <prefix>_workboard_<hex> schema. Worker admission is now deferred from tool discovery to tool execution. Fixes openclaw#182771. Supersedes openclaw#182790. Thanks @etzelm.

Co-authored-by: Mitchell Etzel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. plugin: workboard rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

[Bug]: doctor --lint creates a new empty PostgreSQL workboard schema on every run when Workboard is on PostgreSQL

1 participant