Repository navigation
improve(node-host): reduce worker turn receipt reads - #154564
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: needs maintainer review before merge. Reviewed September 21, 2026, 5:43 AM ET / 09:43 UTC (Revision 3). ClawSweeper reviewWhat this changesReduces database reads when claiming and finishing worker turns by building receipts from returned write rows and ownership facts already read in the transaction. Merge readiness✅ Ready for maintainer review The optimization remains useful on current main, and the reviewed diff introduces no actionable correctness defect. The transaction retains the ownership checks and receipt semantics needed to safely reuse previously read facts. Priority: P2 Review scores
Verification
How this fits togetherThe node-host turn journal records individual requests handled by a worker process. Its SQLite worker validates ownership, stores outcomes, and returns receipts used by the supervisor for completion, replay, and recovery. flowchart TD
A[Worker supervisor] --> B[Journal worker admission]
B --> C[Synchronous database transaction]
C --> D[Read turn and physical owner]
D --> E[Validate identity and state]
E --> F[Write turn and return stored row]
F --> G[Map receipt using ownership facts]
G --> A
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +9, Tests +46. Total +55 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep receipt construction within the existing journal owner and reuse transaction-local facts without adding caches, storage changes, or parallel APIs. Do we have a high-confidence way to reproduce the issue? Not applicable as a correctness bug: this is a performance optimization, and current-main source directly shows the redundant post-write reads. Is this the best way to solve the issue? Yes. Returning the written row and reusing unchanged ownership facts inside the same transaction is a narrow solution that preserves the existing storage and admission owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 99e7d3e7a5b3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
91ff2b9 to
a101202
Compare
|
Merged via squash auto-merge.
|
What Problem This Solves
Worker turn claims and settlements reread the turn and its physical owner after writing the turn within the same transaction.
User Impact
Claiming or finishing a worker turn uses two receipt reads instead of four. Receipt contents, immutable outcomes, process ownership checks, recovery, and retention remain unchanged.
Why This Change Was Made
The turn INSERT/UPDATE now returns its stored row. The existing receipt mapper combines it with physical-owner facts already read in the same synchronous transaction; turn writes and pruning do not change that owner. There is no schema, configuration, upgrade, admission, or retention change.
Evidence
node scripts/run-vitest.mjs src/node-host/node-worker-turn-store.test.ts --maxWorkers=1passed all 18 tests in 54.55 seconds wall time (Vitest: 51.18 seconds; Node 26.8.2).93be68b967506f7e7c157fa671e09b62e2d41a6b, including9247701e7ae(fixture-owned admission clock and explicit relay-listener retirement), which addresses the unrelated hostednative hook relay not foundfailure. The optimization commit is patch-identical after rebase (git range-diff); new-head CI remains required.