Repository navigation
perf(sessions): fuse cold-patch participant reads - #179164
Conversation
Cold entry patches project ordered participant identities with the authoritative entry SELECT. Preserve native null ordering, actor precedence, patch conflicts, snapshot retention, and PostgreSQL write CTEs while removing CAS-only participant borrowing.
|
🦞👀 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 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR projects participant identities in the existing session-entry query and removes CAS-specific participant borrowing. Example: A cold PostgreSQL session patch updates the label while retaining three participants.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it provides a focused, maintainer-directed optimization, and review found no actionable correctness or security defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe worker-owned session store reads entry metadata and participant identities, applies a patch inside the existing transaction, and publishes the committed entry through the existing receipt owner. flowchart LR
A[Session patch request] --> B[Worker transaction owner]
B --> C[Entry and participant query]
C --> D[Canonical entry decoder]
D --> E[Existing entry writer]
E --> F[Commit and publication]
Technical reviewBest possible solution: Keep participant fusion in the existing entry-query and dialect owners while preserving actor precedence, native ordering, and transaction authority. Do we have a high-confidence way to reproduce the issue? Current-main source shows participant projection following entry selection, and the PR reports baseline failures of the focused work-count regressions; no target code was executed during this review. Is this the best way to solve the issue? The change uses existing query, JSON, identity-validation, and publication owners and removes the replaced borrowing path without adding a cache or transaction layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5e4a348cd24c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +8. Total +31 across 9 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 21, 2026, 4:17 AM ET / 08:17 UTC. |
Cold session patches loaded participants in a separate query after reading the entry. Project ordered identity tuples in that existing SELECT through the dialect owner and remove the CAS-only participant borrowing state, wrapper, and revision comparisons. Keep actor participant precedence, native cold-entry ordering, expected-revision conflict handling, snapshot retention, eager PostgreSQL writer locking, and the existing writable CTEs. No schema, SDK, configuration, or durability change. Proof: the PostgreSQL cold-patch regression observes five database calls on the unchanged base and four on the candidate. The complete changed SQLite/PostgreSQL conformance file passes all ten cases; exact-entry work-count and revision regressions pass in CI. Aggregate workload evidence is deferred to the shared census; no aggregate SQL or latency saving is claimed.
What Problem This Solves
Cold session patches read participant rows separately after already loading the entry and its write facts.
User Impact
Session patches need fewer database statements and PostgreSQL round trips. Stored data, participant ordering, patch conflicts, and snapshot retention are unchanged; no migration or configuration change is required.
Why This Change Was Made
Project ordered participant identities in the existing entry SELECT through the dialect JSON owner. Readers use that projection while preserving actor-owned participant precedence. This deletes the special CAS participant-borrowing state, wrapper, revision comparisons, and obsolete test; ordinary participant record reads and read-scope caching remain.
The cold patch entry read retains NULL-first timestamp ordering on SQLite and NULL-last ordering on PostgreSQL. Actor hydration keeps its existing NULL-first ordering on both engines. PostgreSQL still acquires its advisory lock before the authoritative read, and the existing node/window/snapshot CTE writes are unchanged. There is no new cache, freshness probe, transaction fusion, or accepted durability edge.
The attribution also found that snapshots store cold fields split out of entry JSON, and that later entry reads follow intervening writes or require different facts. Those reads and writes remain. Removing the five pure node-only transaction envelopes could save ten SQLite statements in the census workload, but the current write precedes result/receipt preparation and the final commit grant; that requires a separate terminal-statement owner redesign and is outside this bounded change.
Evidence
The unchanged base fails both exact entry/target work-count regressions: one standalone participant SELECT instead of zero. Candidate CI passes all four entry-write tests and all seven revision tests. Native SQLite/PostgreSQL conformance now passes all ten cases on the final source, covering the four-call cold patch, exact participant ordering at both reader boundaries, retained snapshots, rollback, and refused-commit publication. All nine changed input hashes match the committed files.
The prior PostgreSQL CI failure was a test-boundary error: cold entry results preserve native NULL ordering, while actor hydration normalizes NULL timestamps first. The repair asserts the actual cold-patch postimage and the actor read independently; production is unchanged.
Initial CI found a conditional callback inference error (TS2554), repaired with the existing projector ReturnType annotation without runtime or SQL changes. CI has passed type-aware lint, production types, source contracts, T1/dialect ratchets, and Madge (zero cycles). The local aggregate check was interrupted after conflict, line-cap, and assertion-safety checks passed; three UI max-lines errors match independently observed main failures with identical input files. Supplemental CI39565552123/job119107263459 passed all five canonical Knip scans with zero entries, including the full-tree export scan that timed out locally at its unchanged 600-second limit. Two isolated Codex review rounds found no actionable P0/P1 defects; the later annotation and ordering-test repair preserve the reviewed production behavior.
The census attributes six standalone participant SELECTs to 38 patch commits (171 SQLite statements total). Fusion is expected to remove those six statements with no worker-request change; this is a source estimate, not a measured result. The cold PostgreSQL patch conformance assertion expects four calls instead of five: begin/eager lock, hydrated entry SELECT, existing node/window CTE, commit. The baseline PostgreSQL regression fails at exactly five observed calls versus four expected; the candidate passes at four. Aggregate workload measurement is deferred to the shared census; no measured workload or latency saving is claimed.
Production: +65/-42 lines (net +23), covering the portable projection and decoder plumbing while deleting the borrowing machinery. Tests: +53/-45 (net +8). No SDK, schema, update, or service-lifecycle change.
Final-head CI run 39563009466 completed with all three PostgreSQL conformance shards passing. The root-tooling TS2345 failures at
ci-changed-node-test-plan.test.ts:813/891match a clean-main reproduction at5e9c3fbfd6a2359f5980e75688c08c23a17af592; the CI main parent has identical failing test/planner blobs, neither modified here. The full X publication file passes locally on this exact head (1/1). The full orphan-recovery file reproduces the original-owner zero-call assertion (34 pass, one fail); the unchanged full file also fails on pinned current main7d7cf4e07c55ac9e3e719b5aa23f79b388d8056fwith the same zero-call assertion (34 pass, one fail), establishing inherited behavior. Both main X attempts ended at the unchanged worker/setup watchdog before any assertion verdict, including one replay after successful native worker prewarming. They are setup failures, not baseline passes or matching HTTP 503 failures. The same X case also passed on the preceding production-identical head351ea52a920f835f518639ede5e5946d06be51aain CI39558852021/job119086072374; the remaining nondeterministic X failure is disclosed rather than claimed fixed. No behavioral CI rerun or timeout change has been used. Two CodeQL jobs encountered GitHub installation API rate limits; their one diagnosed infrastructure rerun passed in attempt2.The campaign coordinator folded post-landing pairs into the shared s42 census to reduce host contention. All six per-PR arms remain unrun. The source estimate of six removed statements is not a substitute for a measured aggregate; the direct PostgreSQL five-to-four-call regression and SQLite removal assertions are the completed count evidence.