Skip to content

fix(workboard): index card child records - #129568

Merged
vincentkoc merged 1 commit into
mainfrom
fix/workboard-sqlite-indexes
Aug 25, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/workboard-sqlite-indexes

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Audit: https://gist.github.com/vincentkoc/10826f918dde7e23020cf2f390af95d3

What Problem This Solves

Fixes an issue where Workboard reads and card deletion scan eight child tables
because their card_id foreign keys and ordinal ordering have no supporting
indexes.

Why This Change Was Made

Adds (card_id, ordinal) indexes for events, attempts, comments, links, proof,
artifacts, notifications, and worker logs. Existing primary keys/indexes already
cover labels, diagnostics, attachments, and worker protocol, so those tables
are intentionally unchanged.

Workboard remains on schema 3. Its canonical schema runs on every open and
restores missing indexes without changing the migration ledger.

User Impact

Single-card reads, whole-board materialization, rewrites, and card deletion stay
fast as child history grows.

Evidence

  • pnpm test:extension workboard: 342 passed.
  • Planner tests cover per-card reads, whole-board ordering, and parent cascades.
  • Reopen coverage drops all eight indexes and proves they are restored while
    preserving the complete migration-ID set.
  • Manual fixture: 2,500 cards, 80,000 rows per table, 640,000 child rows.
    • per-table reads improved 71.7x to 107.9x
    • parent-card cascade: 41.275 ms -> 0.400 ms, 103.2x
    • eight-index build: 166 ms
    • storage: 13.27 MB total, about 1.66 MB per 80,000-row index
  • Production delta: +16 SQL lines. Tests: +121.

Overlap note: #113311 contains an equivalent proof index inside a much broader,
currently conflicting Workboard change. That branch should remove its duplicate
index if it rebases after this PR.

AI-assisted: yes. The implementation, benchmarks, and review findings were
independently verified before push.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc vincentkoc self-assigned this Aug 25, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 25, 2026 19:27
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer decision: accepted for the Workboard same-version rollout.

The eight indexes add 13.27 MB in the manual 640k-child-row fixture, while improving per-child lookups by roughly 72x-108x and parent cascades by roughly 103x. Focused planner and existing-database reopen tests pass. I accept the one-time synchronous index-build and storage tradeoff for existing databases.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 5:00 PM ET / 21:00 UTC.

ClawSweeper review

What this changes

This PR adds (card_id, ordinal) indexes to eight Workboard child tables and tests query plans plus index restoration on database reopen.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review. The index set matches the store’s per-card and batch query shapes and has focused coverage, but it is a material persistent SQLite indexing change that needs explicit owner acceptance of its first-open storage and startup cost.

Priority: P2
Reviewed head: 4f6832f281f2e52697ded621447b355681cb39cc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, aligns with the actual query paths, and has targeted planner and reopen coverage; persistent-store acceptance remains a maintainer decision.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this MEMBER-authored PR is exempt from the external-contributor proof gate; its body describes a benchmark and focused tests, but no independently inspectable benchmark artifact was provided.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this MEMBER-authored PR is exempt from the external-contributor proof gate; its body describes a benchmark and focused tests, but no independently inspectable benchmark artifact was provided.
Evidence reviewed 6 items Changed schema and query owner: The PR adds eight composite indexes in the canonical Workboard schema; the store uses the matching child-table order for both per-card and whole-board reads.
Regression coverage: The added tests assert the selected indexes for ordered reads, whole-board scans, foreign-key cascades, and recreation after a reopen without changing the migration ledger.
Current-main check: Current main contains the same child-table reads but lacks these eight index declarations, so the central performance work is not already implemented.
Findings None None.
Security None None.

Live Verification

Command: OPENCLAW_STATE_DIR=/tmp/openclaw-workboard-index-proof-129568 pnpm openclaw workboard create "Index proof" --json

Result: FAIL (failed) — step 1 run OPENCLAW_STATE_DIR=/tmp/openclaw-workboard-index-proof-129568 pnpm openclaw workboard create "Index proof" --json: previous terminal command was still running after 30 seconds: "OPENCLAW_STATE_DIR=/tmp/openclaw-workboard-index-proof-129568 pnpm openclaw workboard create \"Index proof\" --json"

$ node scripts/run-node.mjs workboard create 'Index proof' --json
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 99.34 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4144ms (slowest: built plugin control-plane loads 3378ms)
{
  "ok": false,
  "error": {
    "type": "cli_error",
    "message": "The ˋopenclaw workboardˋ command is provided by the \"workboard\" plugin, but that bundled plugin is disabled by default. Run ˋopenclaw plugins
enable workboardˋ to enable that CLI surface."
  }
}
The ˋopenclaw workboardˋ command is provided by the "workboard" plugin, but that bundled plugin is disabled by default. Run ˋopenclaw plugins enable workboardˋ
to enable that CLI surface.
[ELIFECYCLE] Command failed with exit code 1.

Assertions:

  • FAIL expect_output: Index proof
  • FAIL expect_output: Index proof

How this fits together

The Workboard plugin stores cards and their events, comments, proof, and worker history in SQLite. Card lookup and whole-board reads hydrate these child tables, while card deletion cascades through them.

flowchart LR
  A[Workboard card activity] --> B[SQLite child tables]
  B --> C[Card-child indexes]
  C --> D[Single-card reads]
  C --> E[Whole-board hydration]
  C --> F[Card deletion cascades]
Loading

Decision needed

Question Recommendation
Should Workboard accept the one-time storage and synchronous index-build cost on existing databases to improve card reads and cascaded deletion? Accept the index-build trade-off: Confirm that the documented startup and storage cost is acceptable for existing Workboard databases, then merge after exact-head validation.

Why: Repository policy treats same-version indexing changes as material persistent-store changes requiring explicit maintainer acceptance.

Before merge

  • Resolve merge risk (P1) - Opening an existing large Workboard database will synchronously create eight persistent indexes, consuming disk and startup time; this material indexing change needs explicit owner acceptance before merge.
  • Complete next step (P2) - The remaining blocker is explicit owner acceptance of a material SQLite physical-design change, not a mechanical repair.
Agent review details

Security

None.

PR surface

Source +16, Tests +119. Total +135 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 0 +16
Tests 1 120 1 +119
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 136 1 +135

Review metrics

Metric Value Why it matters
Production versus test delta production +16/-0; tests +120/-1 The small production addition changes persistent SQLite physical design, while the test growth covers planner selection and reopen restoration.

Stored data model

Persistent data-model change detected: database schema: extensions/workboard/src/sqlite-store.ts, serialized state: extensions/workboard/src/store.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the persistent index cost (recommended)
    Approve the measured first-open disk and latency trade-off for existing databases, then merge after exact-head validation.
  2. Pause for a smaller physical design
    Hold the PR if maintainers want a different index scope or deferred-build lifecycle.

Technical review

Best possible solution:

Keep the indexes in the canonical Workboard schema and land them only after the Workboard owner accepts the measured first-open storage and latency trade-off for existing databases.

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

No high-confidence live reproduction was run in this read-only review; source inspection shows the ordered child-table queries that currently lack matching indexes, and the PR supplies focused planner coverage.

Is this the best way to solve the issue?

Yes, conditionally: placing the indexes in the canonical Workboard schema is the owner-boundary solution and preserves reopen repair behavior, subject to maintainer acceptance of the persistent-store trade-off.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded Workboard performance and persistence improvement with limited blast radius.
  • add merge-risk: 🚨 compatibility: Existing databases will receive new persistent indexes on reopen, affecting upgrade-time storage and startup work.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This is a bounded Workboard performance and persistence improvement with limited blast radius.
  • merge-risk: 🚨 compatibility: Existing databases will receive new persistent indexes on reopen, affecting upgrade-time storage and startup work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Changed schema and query owner: The PR adds eight composite indexes in the canonical Workboard schema; the store uses the matching child-table order for both per-card and whole-board reads. (extensions/workboard/src/sqlite-store.ts:212, 4f6832f281f2)
  • Regression coverage: The added tests assert the selected indexes for ordered reads, whole-board scans, foreign-key cascades, and recreation after a reopen without changing the migration ledger. (extensions/workboard/src/store.test.ts:585, 4f6832f281f2)
  • Current-main check: Current main contains the same child-table reads but lacks these eight index declarations, so the central performance work is not already implemented. (extensions/workboard/src/sqlite-store.ts:201, e8b6a04ef5fb)
  • SQLite migration contract: The strict-schema helper recreates canonical objects and preserves database-local indexes during table rebuilds; the PR’s canonical DDL is therefore in the correct schema owner. (src/infra/sqlite-strict.ts:280, 4f6832f281f2)
  • Feature history: Workboard’s relational SQLite store dates to the migration commit, with recent batch-read work on this same store; Vincent Koc has prior merged Workboard SQLite maintenance commits. (extensions/workboard/src/sqlite-store.ts:367, 8d6a6e9d0325)
  • Release check: No release tag or branch contains the PR head; this remains unmerged proposed work rather than a shipped fix. (4f6832f281f2)

Likely related people:

  • steipete: Introduced the relational SQLite Workboard store and has the largest sampled history on the affected store paths. (role: relational Workboard feature owner and frequent recent contributor; confidence: high; commits: 8d6a6e9d0325, dcdfd737e597, c4eb9078d973; files: extensions/workboard/src/sqlite-store.ts, extensions/workboard/src/store.ts)
  • vincentkoc: Has prior merged Workboard SQLite maintenance work and authored the proposed index change. (role: recent Workboard SQLite contributor; confidence: high; commits: 00160ea6ee22, 8fc88be21643, 4f6832f281f2; files: extensions/workboard/src/sqlite-store.ts, extensions/workboard/src/store.test.ts)

Rank-up moves

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

  • Record explicit Workboard-owner acceptance of the existing-database index-build cost before merge.

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.

@vincentkoc
vincentkoc merged commit fab76d4 into main Aug 25, 2026
154 of 162 checks passed
@vincentkoc
vincentkoc deleted the fix/workboard-sqlite-indexes branch August 25, 2026 21:36
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant