Repository navigation
perf(sessions): reuse committed transcript publication tokens - #169627
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. What this changesThis PR carries committed transcript watermarks and rewrite generations through existing writer results instead of selecting them again. Example: Append the first user message to session entry-postimage, then publish its metadata.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still performs the targeted rereads, the previous findings are resolved, and no actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSession SQLite owners receive metadata patches and transcript edits, commit canonical state, and publish facts to session readers and derived caches. flowchart TD
A[Session operation] --> B[SQLite transaction owner]
B --> C[Exact entry selection]
B --> D[Transcript mutation]
C --> E[Committed writer result]
D --> E
E --> F[Session publication and caches]
Technical reviewBest possible solution: Reuse transaction-owned transcript tokens through existing writer results while preserving exact-row comparisons and lifecycle guards. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows the publication watermark read and post-rewrite generation read targeted by this PR; no target code was executed during this review. Is this the best way to solve the issue? Carrying facts from the synchronous writer fits existing ownership and avoids a parallel cache or persistence mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f8ea55fcf7a8. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +69, Tests +81, Docs +8, Other +1. Total +159 across 12 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 HistoryReview history (4 earlier review cycles)
Reviewed October 12, 2026, 2:37 AM ET / 06:37 UTC (Revision 5). |
…aw#169627) Carry transaction-owned transcript watermarks through entry postimages and return rewrite generations directly. Preserve detached-edit predicates and mutation authority checks while removing redundant post-write reads.
What Problem This Solves
Session metadata publication reselects transcript watermarks that the writer already knows, and transcript edits reselect the generation they just created.
User Impact
This reduces SQLite work during ordinary turns without changing session or transcript behavior. It changes no schema, retention, public API, or update contract.
Why This Change Was Made
Carry the transcript token in the existing exact-entry selection and committed entry postimage. A transcript append in the same transaction supersedes the selected token through the existing staged authority owner. Publication consumes that postimage. Transcript rewrites return their minted generation directly; steering-only rewrites preserve the existing generation and acquire it only for callers that need it.
Removed checks and accepted edges:
The predicate comparison across a detached edit remains, as do the existing authority checks at transcript mutation boundaries.
Evidence
One live baseline/candidate SQL harness pair ran in order M1,C1 against integrated main
cde0f8844503f332dcdc1aa1a5453a9a7294d6b8and final headca134ccd4c392fe1e8f5b000dcf5b48a940da19d. The shared workload is unchanged except for the copied workload's output directory; source-mapped builds and all fixture, calibration, and conservation checks passed. Relaxed testing v6 replaces the original three-pair requirement.Observed warmed means fall by 23.5 statements (6.2%) and 5.0 requests (4.3%). The direct owner deltas are
session.entry.patch.commit44.3 → 37.0 statements with 6 requests unchanged, andsession.messageRewrite.commit10 → 9 statements with 1 request unchanged. The exact eliminated reads total 8.0 statements per warmed turn: 6 publication watermark reads in entry patch commit, 1 in lifecycle projection, and 1 rewrite-generation read. These operations keep the same 6/1/1 requests, with no extra IPC. Background memory/index and maintenance scheduling also contributes to the whole-turn difference; this is not a claim that all 23.5 statements or 5 requests come from pubtokens.Whole workload: 10,144 → 9,996 statements; 2,152 → 2,122 requests; 1,997 → 2,001 MAIN statements. First-turn requests are 188 → 197, while whole-workload requests fall by 30; this is phase redistribution, not a raw whole-workload increase. Warmed counts do not increase. The heavily loaded host makes latency comparisons unsuitable. Both runs recorded the same two shutdown-only
BEGIN IMMEDIATElock errors during idle database release, and the same two unresolved boot request targets; the candidate also recorded one recovered boot-time lock refusal in unchanged config revision loading. All remain included in totals. Neither run recorded a SQL error during first or warmed turns. The two warmed MAIN statements in each run were unchanged secret-store reads. No live user state was used.Two Codex autoreview rounds completed with no actionable P0–P2 findings. Final-head ClawSweeper review also has no findings. The second reviewed the selector extraction, type-import cycle repair, and steering-only generation fallback. No ClawSweeper wait is requested under the campaign's relaxed landing rules.
Static inventory: publication/rewrite lane owners have 0 → 0 T1 calls. Shared legacy entry/read/write helpers retain 12 → 12 T1 sites (the selector extraction moves one site without adding one). No shared helper is relabeled worker-only.
Current integrated head: targeted oxfmt, basic oxlint, and
git diff --checkpass. Exact-head CI run 38210838469 passed, including production/test types, lint, source contracts/export collisions, Madge (zero cycles), worker/dialect ratchets, and changed-owner tests. Earlier Knip export scans reported identical unrelated findings on baseline and candidate; no pubtokens export finding was introduced.Earlier remote proof passed core and sessions test typechecks, full-diff type-aware lint, Madge, export collisions, and both database ratchets. Knip findings matched the baseline exactly. The remote run was stopped and the lease released under v6 after the entry-writes suite reported a failure; CI reproduced that result as an incorrect test expectation: the session header occupies sequence 0, so the first message is sequence 1. Commit
33a8834f5066fcorrects the assertion without changing production code. Commit30e110e6e7e16also adds the extracted selector to the PR wrapper source inventory, fixing the closure tests in the next CI attempt. Commitca134ccd4c392corrects the rewrite regression assertion to select the edited message instead of the session header. All final-head CI tests pass. No test-suite pass is claimed for the interrupted remote run.Production TypeScript: +194/-125 lines (includes moving the shared selector to a sibling module). Tests: +86/-5. Documentation: +8/-0. Tooling inventory: +1/-0 to include the extracted selector. No SDK surface or published-driver update cell applies.
Landing uses the campaign-authorized exact-head REST squash fallback after native review preparation spent over twenty minutes in local worktree scans. The owned operation was stopped and its exact lock recovered before fallback; no native merge request was submitted.