Skip to content

fix(workboard): doctor --lint creates a new empty PostgreSQL workboard schema on every run - #182790

Closed
etzelm wants to merge 1 commit into
openclaw:mainfrom
etzelm:fix/workboard-lint-postgres-schema
Closed

etzelm wants to merge 1 commit into
openclaw:mainfrom
etzelm:fix/workboard-lint-postgres-schema

Conversation

@etzelm

@etzelm etzelm commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Closes #182771

What Problem This Solves

Fixes: every openclaw doctor --lint run leaves a new, empty <prefix>_workboard_<hex> schema in PostgreSQL when the Workboard store is on PostgreSQL.

User Impact

User impact: doctor --lint no longer creates Workboard database objects, so repeated lint runs (including from update wrappers) stop piling up orphan schemas. Workboard tools still work in standalone tool serving; the store opens on the first tool call. This PR does not clean up orphan schemas that already exist.

Why This Change Was Made

The lint tool-schema check registers plugins in tool-discovery mode against a private temp state dir. Workboard opened its durable store eagerly at registration. With no engine anchor in the temp dir, that minted a new anchor and ran CREATE SCHEMA plus the full table bootstrap. In tool-discovery mode the store is now opened lazily, on the first real store operation. Full (Gateway) mode still opens eagerly as before. Tool discovery is also used by standalone tool serving, where tools execute, so skipping the store entirely in that mode was not an option.

Evidence

New regression test in extensions/workboard/index.lifecycle.test.ts (real SQLite store in a temp state dir, no mocks, no PostgreSQL). It registers Workboard in tool-discovery mode, builds every workboard tool from the factories, releases the runtime like lint does, and asserts that no plugins/workboard/workboard.sqlite was created. A second registration then runs workboard_list and asserts that it succeeds and creates the store.

On main (fix reverted, test kept):

 × extensions/workboard/index.lifecycle.test.ts > opens the store only when a discovered tool runs
AssertionError: expected true to be false // Object.is equality
 ❯ extensions/workboard/index.lifecycle.test.ts:229:38
    228|     await inspected.release();
    229|     expect(existsSync(databasePath)).toBe(false);
 Tests  1 failed | 6 passed (7)

With this change:

 ✓ extensions/workboard/index.lifecycle.test.ts > opens the store only when a discovered tool runs
 Test Files  2 passed (2)
      Tests  8 passed (8)

Also passing: index.test.ts, src/tools.test.ts, src/sqlite-store.lifecycle.test.ts, src/sqlite-store.recovery.test.ts, src/store-lifecycle.test.ts and src/change-events.test.ts. src/postgres-store.test.ts was skipped locally because it needs a database. Format, oxlint and typecheck are clean for the touched files.

Gap: I did not re-run the PostgreSQL doctor --lint schema-count repro from the issue against this branch. The schema is created by the same eager worker open that the test covers for SQLite, and the PostgreSQL path goes through the same openEngineWorkerStore call.

@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.

@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 real behavior proof before merge.

What this changes

This PR defers Workboard store initialization during tool discovery until a tool performs a database operation.

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

  • Before: The reported schema count increases from 1 to 2, then 3, then 4.
  • After: Tool discovery no longer opens the store, preventing that schema-creation path.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source-consistent, with a useful regression, but test-only evidence does not satisfy the external PR's shipped-behavior proof gate; no persisted format or migration changes are introduced.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
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 health check leaves an additional empty PostgreSQL Workboard schema on every run.
Reason: The change restores Doctor's documented read-only behavior without adding operator configuration or removing standalone tool execution.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR narrowly addresses a confirmed current-main Doctor side effect; no superseding fix was identified and no introduced correctness defect was found.

Priority: P2
Reviewed head: 7dbb032732f1f0fec4c59e504989aaca6583bd68

Before merge

  • Add real behavior proof - The supplied evidence exercises real Workboard registration and SQLite persistence inside a test harness, with reported red/green results, but does not exercise the fixed shipped CLI against PostgreSQL. Contributor action: provide redacted terminal output or logs showing repeated doctor --lint runs leave namespace inventory, the live anchor, and seeded cards unchanged, demonstrate standalone tool execution, and verify an upgrade preserves existing settings and data; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Show the fixed CLI preserving PostgreSQL schemas, anchor identity, and seeded cards across repeated lint runs, plus standalone tool execution and an upgrade retaining existing settings and data.
Agent review details

How this fits together

Doctor inspects plugin tool schemas using temporary local state; Workboard registration supplies tool factories backed by its existing database 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 database worker]
  F --> G[SQLite or PostgreSQL store]
Loading

Technical review

Best possible solution:

Keep discovery free of durable initialization while opening the existing worker on first database use and preserving normal Gateway startup and cleanup.

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

Current-main source confirms the reported path from temporary inspection state to eager PostgreSQL initialization, and the linked report supplies isolated CLI results; this read-only review executed no target code.

Is this the best way to solve the issue?

Deferring initialization at the existing Workboard persistence owner is the smallest complete fix: discovery remains usable, actual tools retain persistence, and no parallel store or global inspection policy is introduced.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Registration-time store initialization changes intended behavior with a stated reason (38fb08d: Move Workboard database work off the Gateway event loop while preserving initialization and lifecycle ownership.)
  • Database-family selection and PostgreSQL opening keeps the original intent (995a9ae: Route Workboard through its configured database family using the shared effective engine selection.)
  • Worker cleanup and recovery keeps the original intent (069d40e: Keep recovery with the existing broker, drain admitted operations, and avoid replaying uncertain writes.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 38fb08d adds extensions/workboard/index.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 38fb08d04bd4; files: extensions/workboard/index.ts)

PR surface

Source +6, Tests +52. Total +58 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 19 13 +6
Tests 1 52 0 +52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 71 13 +58

Review metrics

Metric Value Why it matters
Production versus test changes Production +19/-13 lines; tests +52/-0 lines The small production increase reuses the existing opener; the regression covers both inspection without creation and later executable tools.

Labels

Label changes:

  • add P2: Repeated lint runs accumulate orphan schemas on PostgreSQL-backed Workboard installations, with operational cleanup cost but no reported loss of live data.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: Repeated lint runs accumulate orphan schemas on PostgreSQL-backed Workboard installations, with operational cleanup cost but no reported loss of live data.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the PostgreSQL CLI and existing-installation evidence described in the proof assessment.

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:16 PM ET / 19:16 UTC.

steipete added a commit that referenced this pull request Oct 24, 2026
…ard schemas (#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 #182771. Supersedes #182790. Thanks @etzelm.

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

Copy link
Copy Markdown
Contributor

Thank you @etzelm. We re-implemented this in #182827, now on main, with you credited as co-author: Workboard no longer opens its store while Doctor discovers tool schemas, so doctor --lint stops creating empty PostgreSQL schemas. Closing as superseded.

@steipete steipete closed this Oct 24, 2026
@etzelm
etzelm deleted the fix/workboard-lint-postgres-schema branch October 24, 2026 20:44
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

P2 Normal backlog priority with limited blast radius. plugin: workboard rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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

2 participants