Repository navigation
perf(workboard): hydrate a card once per metadata update - #164120
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 3, 2026, 3:19 AM ET / 07:19 UTC. ClawSweeper reviewWhat this changesWorkboard, 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 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 Review scores
Verification
How this fits togetherWorkboard 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -4, Tests +244. Total +240 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer disposition for reviewed head The existing focused validation passed all 171 tests across seven files in 633.99 seconds, including complete ordered child round trips, rollback checks, and |
|
Merged via squash.
|
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=1171 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 --checkpass. Typed lint passed for all eight changed TypeScript files vianode scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json <changed files>. The repository has no Workboard-onlytsgolane; 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.