Skip to content

perf(workboard): hydrate a card once per metadata update - #164120

Merged
steipete merged 1 commit into
mainfrom
steipete/sqlite-workboard-card-hydration
Oct 3, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/sqlite-workboard-card-hydration

Conversation

@steipete

@steipete steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Workboard proof, artifact, and worker-log updates repeatedly hydrate the same card, and rewriting retained child histories repeatedly compiles and prepares identical INSERT statements.

User Impact

Metadata updates perform less SQLite work while preserving concurrent edits, claim checks, validation errors, and attachment cleanup. There is no schema, retention, durability, permission, public API, or configuration change.

Why This Change Was Made

The existing update implementation now accepts the captured card. Metadata updates pass their current snapshot; other callers retain their fresh lookup, including after attachment writes. The transactional revision CAS, retry loop, owner-slot checks, and authority settlement remain in place. Preparation failures reread the revision before reporting validation errors, preserving conflict precedence when another writer removes a hold or changes an invalid patch's target. Writes and cleanup stay outside this error handling.

Each nonempty child collection compiles and prepares one INSERT, then binds deferred payload readers for each row in order. The collection helper owns ordinal binding. This reuse lasts only for that replacement and introduces no persistent cache.

Evidence

Native counters show 26 → 13 hydration SELECTs, and 28 → 15 total SELECTs for uncomplicated successful worker-log/proof metadata updates, excluding broker/admission/transaction housekeeping. This removes one full decode and one worker lookup round trip. The write still performs 13 + N + P writes (N child rows, P optional protocol row).

At both 1 and 40 populated rows, each of the eleven child tables now has one INSERT prepare rather than one per row. Compilation likewise occurs once per nonempty collection. SQL execution remains one DELETE plus N INSERTs. Tests verify complete ordered round trips, later-row constraint and invalid-binding rollback, and native preparation errors before payload getters. Paused-worker tests verify foreign-edit retry, deletion and claim rejection, and conflict-before-validation error ordering.

The work-order audit's real-DDL, foreign-key-enabled native-prepare microbenchmark measured medians of 0.2595 → 0.0572 ms at 50 events and 0.2089 → 0.0471 ms at 40 rows across seven runs. These are component measurements supplied by the audit, not rerun here; they exclude Kysely and worker overhead and do not establish end-to-end card-update latency.

Production diff against the PR merge base: +307 / −311 (net −4). Tests: +279 / −35 (net +244). Baseline regression assertions reproduced two lookups instead of one, 26 hydration SELECTs instead of 13, and 40 INSERT prepares instead of one. A separate regression reproduced the conflict/normalization-error ordering gap before the preparation guard was broadened.

Final validation command:

pnpm test extensions/workboard/src/store.test.ts extensions/workboard/src/sqlite-store-batch-read.test.ts extensions/workboard/src/store.attachments.test.ts extensions/workboard/src/store.promotion.test.ts extensions/workboard/src/store.sessions-board.test.ts extensions/workboard/src/store.sessions-board.reopen.test.ts extensions/workboard/src/store.scoped-list.test.ts --maxWorkers=1

171 tests passed across seven files; 633.99 s wall time.

The standalone store run before the final preparation-guard refinement passed 112 tests in 444.97 s wall time (pnpm test extensions/workboard/src/store.test.ts --maxWorkers=1). These integration files exercise actual SQLite workers, foreign writers, persistence, and cleanup; worker compilation/cache verification and existing integration coverage dominate wrapper wall time. The new performance assertions use counts, with no timing thresholds or sleeps. CI seconds are not yet available.

Formatting and git diff --check pass. Typed lint passed for all eight changed TypeScript files via node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json <changed files>. The repository has no Workboard-only tsgo lane; no repository-wide typecheck was run.

Codex autoreview: scoped-clean through P2, with no accepted/actionable findings. No end-to-end latency benchmark was run.

@clawsweeper

clawsweeper Bot commented Oct 3, 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 3, 2026 07:14
@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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 3:19 AM ET / 07:19 UTC.

ClawSweeper review

What this changes

Workboard, OpenClaw’s local task board, reuses a card snapshot during metadata updates and prepares each child-table INSERT once per replacement.

Warning

SQLite table change

This PR modifies persisted SQLite tables in extensions/workboard/src/sqlite-store-write.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, bounded optimization absent from fetched main. No introduced correctness or security defect was found.

Priority: P2
Reviewed head: 86eb540c1b5aa5da5055dfd12f4134a1c678cc30

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful concurrency and rollback coverage and no actionable introduced defects.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied Repository State identifies a MEMBER author, so ordinary external-contributor proof is exempt. Reported native SQLite counters and worker-conflict tests support the changed store behavior; no independent end-to-end latency run was inspected. No stored-data contract changes.
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 MEMBER author, so ordinary external-contributor proof is exempt. Reported native SQLite counters and worker-conflict tests support the changed store behavior; no independent end-to-end latency run was inspected. No stored-data contract changes.
Evidence reviewed 8 items Introduced patch identity: Reviewed the pinned merge-base-to-head changes. The verified test merge changes the same eight Workboard paths relative to its recorded main parent; unrelated endpoint drift was excluded.
Snapshot reuse preserves conditional writes: Metadata updates pass their captured card into the existing update owner. Revision comparisons, bounded conflict retries, owner-slot checks, and post-write attachment cleanup remain; preparation failures reread the revision before returning validation errors.
Statement reuse preserves storage representation: Each nonempty child collection uses one compiled INSERT and native statement with fresh deferred bindings and ordinals per row. Existing columns, serialization, transaction ownership, and deletion behavior are preserved; no stored-data contract changes.
Findings None None.
Security None None.

How this fits together

Workboard receives card edits, proof, attachments, and worker progress from operators and agents. Its store validates those updates and persists cards and ordered histories through SQLite workers.

flowchart TD
  A[Operator and agent updates] --> B[Workboard card store]
  B --> C[Capture card snapshot]
  C --> D[Validate and prepare update]
  D --> E[SQLite revision check]
  E -->|Conflict| C
  E -->|Accepted| F[Write card and ordered histories]
  F --> G[Publish result and clean attachments]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -4, Tests +244. Total +240 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 6 307 311 -4
Tests 2 279 35 +244
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 586 346 +240

Review metrics

Metric Value Why it matters
SQLite work reduction Hydration SELECTs 26 → 13; child INSERT preparation 40 → 1 per populated table Native-count regressions directly measure the intended optimization without claiming end-to-end latency gains.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/workboard/src/sqlite-store-write.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep metadata updates within the existing revision-checked store owner and scope statement reuse to each synchronous child replacement.

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

Yes, source establishes the repeated lookup and per-row preparation on fetched main, and the added native-count regressions target both. Runtime validation was reported by the author, not executed by this review.

Is this the best way to solve the issue?

Yes, the patch optimizes the existing owner while preserving revision checks, fresh reads for other callers, ordered bindings, and transaction rollback.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded performance improvement to metadata persistence in the optional Workboard plugin.
  • 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 MEMBER author, so ordinary external-contributor proof is exempt. Reported native SQLite counters and worker-conflict tests support the changed store behavior; no independent end-to-end latency run was inspected. No stored-data contract changes.

Label justifications:

  • P2: This is a bounded performance improvement to metadata persistence in the optional Workboard plugin.
  • 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 MEMBER author, so ordinary external-contributor proof is exempt. Reported native SQLite counters and worker-conflict tests support the changed store behavior; no independent end-to-end latency run was inspected. No stored-data contract changes.

Evidence

What I checked:

  • Introduced patch identity: Reviewed the pinned merge-base-to-head changes. The verified test merge changes the same eight Workboard paths relative to its recorded main parent; unrelated endpoint drift was excluded. (2cbbfab03597)
  • Snapshot reuse preserves conditional writes: Metadata updates pass their captured card into the existing update owner. Revision comparisons, bounded conflict retries, owner-slot checks, and post-write attachment cleanup remain; preparation failures reread the revision before returning validation errors. (extensions/workboard/src/store-core.ts:713, 86eb540c1b5a)
  • Statement reuse preserves storage representation: Each nonempty child collection uses one compiled INSERT and native statement with fresh deferred bindings and ordinals per row. Existing columns, serialization, transaction ownership, and deletion behavior are preserved; no stored-data contract changes. (extensions/workboard/src/sqlite-store-write.ts:47, 86eb540c1b5a)
  • Current main still performs repeated preparation: Fetched main compiles and prepares an INSERT inside the per-row loop. Its metadata update path also still calls the update owner by identifier, causing another card lookup. (extensions/workboard/src/sqlite-store-write.ts:46, 87e42f7d3497)
  • Focused regression coverage: Added tests exercise native statement counts, ordered round trips, deferred getter error ordering, later-row constraint/binding rollback, and real SQLite worker conflicts involving foreign edits, deletion, and claims. The captured body reports 171 passing tests in 633.99 seconds; these were not rerun during this read-only review. (extensions/workboard/src/store.test.ts:430, 86eb540c1b5a)
  • Prior merged area contribution: GitHub verifies steipete authored the merged feature-plugin refactor at refactor(plugins): deslop feature plugin helpers #162992. Local current-main history records that commit touching the Workboard update owner, supporting routing independently of this proposal. (extensions/workboard/src/store-core.ts, d0f21752ee0d)

Likely related people:

  • steipete: 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 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer disposition for reviewed head 86eb540c1b5aa5da5055dfd12f4134a1c678cc30: the unknown-data-model-change classification is rejected. The diff changes no schema, migration, table/column definition, stored representation, or retention contract. In sqlite-store-write.ts, the same eleven child-table INSERTs retain their column/value mappings, null handling, JSON serialization, and per-row ordinals; compilation and native preparation now happen once per nonempty replacement collection. DELETE behavior and transaction ownership are unchanged. This agrees with the review's own finding that there are no stored-data contract changes.

The existing focused validation passed all 171 tests across seven files in 633.99 seconds, including complete ordered child round trips, rollback checks, and store.sessions-board.reopen.test.ts (preserving prior-schema cards and admitting a new Sessions board through the Gateway method). I verified the retained final test log for this unchanged head during landing. No additional migration or schema change is needed for this optimization; no actionable P1/P2 defect was reported.

@steipete
steipete merged commit d3d225c into main Oct 3, 2026
170 of 171 checks passed
@steipete
steipete deleted the steipete/sqlite-workboard-card-hydration branch October 3, 2026 07:31
@steipete

steipete commented Oct 3, 2026

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

P2 Normal backlog priority with limited blast radius. plugin: workboard rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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