Repository navigation
perf(sessions): reuse actor projection receipts for history reads - #170127
Conversation
Publish compact projection metadata with actor hot postimages and carry it through existing history worker requests. Add stale-after-write coverage for transcript mutation classes. Replica accessor integration follows the pending hydration owner change.
|
🦞👀 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 carries committed actor projection facts into history-worker reads and preserves session receipts across trajectory-only writes. Example: Read a warmed session containing user message "question" and assistant message "answer".
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this useful maintainer-authored performance PR open; the prior wrapper finding is fixed, and no new actionable patch defect was established. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe session writer publishes actor postimages to the host replica; existing history-worker requests carry their projection receipts, and the worker returns bounded transcript results using validated facts or the canonical SQL fallback. flowchart LR
A[Session writer] --> B[Actor postimage]
B --> C[Host replica]
C --> D[History worker request]
D --> E[Scoped receipt validation]
E --> F[Actor facts or SQL fallback]
F --> G[Bounded transcript result]
Technical reviewBest possible solution: Reuse the existing actor's committed projection receipts while preserving scoped invalidation, bounded SQL payload reads, and the canonical fallback. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the redundant projection query outside actor transactions; this review ran no target code and does not establish a measured performance gain. Is this the best way to solve the issue? The change coherently extends existing actor ownership and receipt invalidation instead of adding a competing cache, while preserving SQL payload bounds and cold or invalidated fallbacks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 70eb60085510. Provenance checked
TestingProof path: none. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +140, Tests +413, Docs +9, Other +3. Total +565 across 14 files. Added test files: 1. 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 HistoryReview history (2 earlier review cycles)Reviewed October 12, 2026, 3:43 PM ET / 19:43 UTC (Revision 3). |
…enclaw#170127) Publish compact projection facts with the session actor hot postimage and carry them through existing history-worker requests. Reuse committed session write receipts, and preserve them across trajectory-only writes. Cold or invalidated readers retain the canonical SQL path. The matched live harness attributes six fewer SQL statements and three fewer worker requests per warmed turn to session reads. Projection snapshot reads fall from four to one; warmed main-thread SQL remains zero. Add stale-after-write regressions across transcript writer classes. Retain cold-marker checks that protect rewrite data. The remaining synchronous incognito and shipped catalog-title API paths need a separate custody/API cutover. Exact-head static and focused checks pass apart from documented inherited Knip findings; remaining CI test failures reproduce on main or the baseline.
What Problem This Solves
Warmed session-history reads repeat projection metadata queries after the session actor has already computed the same facts.
User Impact
Reduces SQLite work for warmed history reads without changing transcript contents, persistence, retention, permissions, or update behavior. No migration or operator action is required.
Why This Change Was Made
Warmed history consumers repeatedly query transcript projection metadata that the session actor already owns. Publish that compact projection with the actor's existing hot postimage and carry it on the existing history-worker request. The worker uses the existing session-scoped write receipt to select those facts; cold or invalidated actors still use the canonical SQL reader. Transcript bodies remain bounded SQL reads, and no worker request or independent cache is added. Trajectory append/trim now declares its empty session write scope: it changes only trajectory rows, so unrelated runtime bookkeeping no longer expires session receipts.
Append, rewrite, rewind, reset, compaction, archive/restore and index rebuild all update actor facts or invalidate their existing write scopes. The regressions cover stale receipts after those writer classes, postimage publication, request-local consumption, and trajectory append/trim preserving transcript receipts before a real transcript write invalidates them. Schemas, stored bytes, retention, permissions and update behavior are unchanged.
Removed rechecks and retained boundaries
readSnapshotEventRowsalso serves the process-held incognito SQLite owner and the synchronous SDK catalog-title API shipped in v2026.10.2. Moving that call requires the separate incognito custody/API cutover; it is not falsely classified as worker-only.Measurement
Shared harness v2, one matched baseline/candidate pair under the campaign's relaxed testing policy: base
8cee6f65b819→ head48f429d610cce. Each run completed ten warmed turns, all with causal SQL/request coverage. Both used Node 24.19.0, SQLite 3.53.3, identical harness sources and isolated Linux Testboxes with 99.75% idle CPU before the run. The baseline includes the landed hydration and cold-marker fixes.Attributable session savings are 6 statements and 3 requests per turn: three fewer projection queries, one fewer exact-entry read and two fewer actor hydrations; actual history requests fall 9→8 (
readEntryResultdisappears), and actor requests fall 11→9. Every other history operation keeps its request count. The remaining observed saving is 7 statements/1.4 requests from auth-profile helper reads (2.4→1.0 requests); treat that as scheduling/cache variation, not a promised benefit of this PR. Removing SQL inside an existing request is not counted as a request saving. No shared family increases, and both lane family targets are met. The retained projection read is the write-side patch predicate; cold-marker checks protect rewrite data.Whole-workload statements fall 7,282→7,093 and requests 1,271→1,212; whole-workload MAIN stays 1,100 (including boot admission), while warmed MAIN remains zero. Baseline/candidate live workload times are 45.7/47.7 seconds; these instrumented runs do not establish a latency improvement.
Evidence
Two Codex review rounds completed with no unresolved P0/P1 finding. The CI follow-up fixes a type-import cycle, a widened file-target test fixture, and missing wrapper inventory entries. On final head
48f429d610cce, the ten new receipt cases pass in CI (1.081 seconds combined case time; 96–126 ms per case; 141.03-second enclosing 17-file shard). The existing actor tests (15 cases) and replica tests (11 cases) also pass. The focused wrapper inventory test passes. An intermittent savepoint database-lock failure did not reproduce in focused baseline or candidate runs; it remains recorded separately from confirmed inherited failures. Final-head CI passes production and test types, all lint lanes, source contracts, Madge (zero cycles), and the T1/dialect ratchets. The security review passes. The aggregate CI gate remains red on inherited test failures. Knip has no findings in touched files: its 34 production findings match scheduled main, its 22 full-tree findings reproduce exactly on baseline8cee6f65b819, and its script scan passes with zero entries. The remaining Copilot fixture failure reproduces identically on baseline and candidate (36 failed tests, one pass). Local preflight uses changed-file format/lint and diff sanity; focused baseline/candidate runs diagnose unmatched CI failures, and local Knip completes its inherited-finding classification. No update cell is required because this change does not touch update, Doctor, schema/migrations, plugin loading or service lifecycle.Changed-file format/lint and
git diff --checkpass. Diff: 14 files, +633/−68 lines: production +208/−68, tests +413/−0, documentation/inventory +12/−0.Inherited CI evidence
Final-head CI and security review. The following untouched failures match scheduled main or the focused baseline comparison. No failing check is described as passing.
message-tool.internal-source-reply.integration.test.tslegacy-main-session-migration.test.tssession-accessor.sqlite-replacement-receipts.test.tssession-history-worker-errors.test.tssession-accessor.pending-inputs.test.tssession-accessor.test.tsheartbeat-runner.webchat-exec-completion.test.tsserver-methods.canonical-validation.test.tssession-cost-usage-cache.creation-race.test.tsembedded-agent-runner.run-embedded-agent.finalization-scope.test.tsattempt-transcript-journal.test.tspnpm test extensions/copilot/src/attempt-transcript-journal.test.ts --maxWorkers=1on8cee6f65b819and48f429d610cce: identical 36 failures / 1 pass; runtime-config preparation error. Wall times 610.22 s / 444.37 s include cold worker compilation.Knip: 34 production findings match scheduled main; all 22 full-tree findings reproduce exactly on baseline
8cee6f65b819with the repository’s pinned Knip runner and config. Script exports pass. None of the findings are in touched files.