Repository navigation
perf(node-host): return settled turn from journal owner - #183172
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 changes before merge. What this changesThis PR adds a predecessor-recovery measurement workload and regression coverage without changing production behavior. Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Needs changes before merge - 1 item remains Keep this useful maintainer-authored draft open; it preregisters a focused optimization, but its new read-budget assertion cannot pass with the unchanged implementation. Priority: P3 Before merge
Findings
Tests
Agent review detailsHow this fits togetherNode-host supervisors request durable turn receipts through the shared journal worker, whose database kernel reconciles unfinished turns with their physical launch owners. flowchart LR
A[Receipt caller] --> B[Turn store]
B --> C[Journal worker transport]
C --> D[Turn kernel]
D --> E[Physical launch receipt]
D --> F[Turn settlement owner]
F --> G[Durable turn receipt]
Technical reviewBest possible solution: Return the native updated turn from the existing settlement owner and consume it in readReceipt while preserving terminal receipts and other settlement callers. Do we have a high-confidence way to reproduce the issue? Source inspection establishes three receipt SELECTs for predecessor recovery and a new expectation of two; no target code or tests were executed. Is this the best way to solve the issue? The proposed owner-returned postimage follows the prior receipt optimization and needs no new cache or owner, but this draft has not implemented it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2a82eb7795d8. Provenance checked
TestingProof path: none. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +61, Docs +34, Other +140. Total +235 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 11:05 PM ET / October 25, 2026, 03:05 UTC. |
Remove the follow-up turn SELECT after predecessor recovery while retaining both initial authoritative reads. Ordinary physical launch settlement remains non-returning. Use PostgreSQL greatest for the existing timestamp clamp; SQLite keeps max. Synthetic recovery removes one SQL statement per receipt without changing requests or MAIN work.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
) Fix PostgreSQL node-worker turn settlement by using greatest for the timestamp clamp, while retaining SQLite scalar max. Return the transaction-local settled postimage for receipt recovery instead of selecting the turn again. Preserve both initial external-writer reads and ordinary non-returning settlement. Twenty synthetic recoveries fall from 120 to 100 SQL statements with 20 worker requests and zero MAIN SQL; warm target work is unchanged. Native and PostgreSQL regression proof and exact-head CI 40160229397 pass. PR openclaw#183172.
What Problem This Solves
Node-worker turn settlement fails on PostgreSQL with error 42883 because the owner uses SQLite’s scalar three-argument
max(), which PostgreSQL treats as an aggregate-only function. The owner now selectsgreateston PostgreSQL and retainsmaxon SQLite through the existing connection discriminator. The timestamp columns are NOT NULL, so both preserve the timestamp clamp.Receipt recovery also selects the turn immediately after settling it. Return the settlement owner’s native postimage instead, removing one SQL statement from every recovered receipt (120 → 100 SQL for twenty recoveries). Both initial reads remain: a predecessor can update only the physical launch, so its current state must still be observed.
The existing unique partial index permits only one running turn per physical owner. The existing synchronous write transaction and PostgreSQL eager advisory lock therefore already protect this result. The private result option adds
RETURNING *only to receipt recovery; ordinary launch finish/cancel still perform their original non-returning update. No schema, cache, generation, transaction ordering, permission, or retention changes.Evidence
Acceptance was published in this PR before the first run: twenty synthetic launches, ended offline by a predecessor (five each completed, failed, interrupted, cancelled), then twenty recovered and twenty warm receipts through the real journal worker transport under an isolated Gateway. Require exactly one fewer turn SELECT per recovery, unchanged target warm work/requests/MAIN, and preserved result/error/state, timestamp clamp, immutable completed siblings and durable replay. Frozen sqlharness v3.1.4 was verified (36/36 hashes). Host load selected the preregistered one-pair count fallback; no latency or CPU-time improvement is claimed. Per-thread CPU profiles were captured for both arms (29 observed threads each). This proves Gateway ownership and worker transport, not remote node WebSocket or model-turn latency.
Recovery turn SELECTs fall 40 → 20; settlement updates remain 20 → 20. No work moved onto the main thread. Single-pair medians and min/max are the listed values; one sample does not support a useful p95.
The raw warm cell rises 20.24% SQL and 61.90% requests, so the campaign’s stop rule was invoked. Exact shape attribution finds the same 17 statements / 13 requests from background maintenance in base recovery and candidate warm: session event/watch-cursor maintenance, delivery queue readers, restart sentinel, deletion journal, and three config reads. Combined recovery + warm falls 221 → 201 SQL with 54 → 54 requests and MAIN 0. The touched owner’s warm work is unchanged. The coordinator explicitly accepted this phase placement on October 25: the same background work shifted phases, while combined work fell and target warm work stayed unchanged.
Validation: the four-outcome count regression is red on base solely at 3 → 2 SELECTs; candidate owner suites passed 54 tests, and all four count cases passed again on the final source. Actual PostgreSQL17 replay fails on the base with scalar-max error 42883 and passes on the candidate (both engine arms, including zero-row and one-row non-returning settlements). Two independent Codex rounds completed; the final round’s sole finding concerned the deliberately red preparation commit lacking the unstaged implementation, resolved by committing the reviewed implementation with it. No additional P0–P2 defects were reported in the combined candidate. Initial CI identified TS7030 / consistent-return because two no-result paths lacked explicit returns. Commit d07d02e adds only
return undefinedon those paths; runtime values and SQL are unchanged. Formatting, basic lint, the commit hook, and diff checks pass. Exact-head CI 40160229397 passed, including all three PostgreSQL shards, production/test types, typed lint, source contracts, architecture, and worker/dialect ratchets. Local Madge passed with zero cycles. Canonical Knip baseline/candidate sets match exactly: 14 production, 22 full-tree, and 14 script findings, zero new findings and zero resolution errors. The local check:changed run completed with its type setup blocked by the mandated virtual store location and its Knip findings verified against the base; normal-install CI supplies the successful type-aware gates. The initial PR-context failure was corrected by adding the required body sections; edited-event run 40160678154 passed on the same head. pgprep approved this exact head on October 25 (REVIEW-OK OWNERREDESIGN2 item 6 #183172 d07d02e48b46), including the PostgreSQL function repair and bounded postimage.The simplification removes the trailing turn SELECT and keeps settlement policy in its existing owner. Production delta is +7 lines (native result selection and the PostgreSQL function repair); test/workload growth provides the committed reproduction and affected-engine proof. No forwarding owner, duplicate state calculation, or retained result cache.
Rerun instructions and the original acceptance contract:
scripts/perf/node-worker-journal-measure.md. Final open-main overlap audit: the refreshed, complete 2,657-PR index (completed 2026-10-25T05:00:13Z) matches only this PR across all six files. There are no other overlapping heads to compare, zero new merge conflicts, and the approved head merges cleanly with current main.PostgreSQL review checklist:
idx_node_worker_turns_active_owner. No iterator, larger scan, or unbounded buffered result is introduced.