Repository navigation
perf(sessions): reuse actor facts for row projections - #169100
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 reuses committed actor entry, Board, and transcript-watermark facts when preparing session rows. Example: Refresh agent:main:actor-row-facts after its label changes to Committed metadata.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it provides a focused session-performance improvement that current main still needs, resolves the earlier wrapper-dependency finding, and has no actionable introduced defect identified in this review. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway row preparer combines agent-database facts with independent shared-state and runtime-ownership facts, then supplies resident rows for session presentation. flowchart TD
A[Agent database writer] --> B[Bounded actor replica]
B --> D[Session row preparer]
C[History worker fallback] --> D
E[Shared and runtime facts] --> D
D --> F[Resident session rows]
F --> G[Session presentation]
Technical reviewBest possible solution: Reuse complete committed facts through the existing bounded actor replica and retain authoritative worker reads whenever coverage is missing or invalidated. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the redundant worker-read path, and the PR reports a baseline-failing regression; no target code was executed during this read-only review. Is this the best way to solve the issue? The implementation fits the existing ownership model, preserves independent sharing and runtime-ownership responsibilities, and avoids introducing a competing cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7872bfbef116. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +93, Tests +166, Docs +8, Other +1. Total +268 across 18 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 HistoryReviewed October 11, 2026, 8:59 AM ET / 12:59 UTC (Revision 3). |
|
Merged via squash.
|
* perf(sessions): reuse actor row facts during projection * test(sessions): exercise sealed row projection receipts * refactor(gateway): split session row database preparation * test(sessions): retain host ownership for actor projection proof
What Problem This Solves
Session row refreshes reread entry, Board presence, and transcript summary facts already held by the session actor after its own writes.
User Impact
No visible behavior change. Resident session rows reuse committed actor facts with fewer SQLite statements and worker requests. Cold or incomplete rows keep the existing worker read.
Why This Change Was Made
Carry the already-hydrated Board presence in the actor postimage and expose a list-sized projection from the existing bounded replica. Use it before constructing history-worker read groups. Complete actor receipts supply transcript watermarks; same-lifecycle metadata receipts can retain Board facts but cannot certify a new summary watermark. Generic write notifications revoke row-fact coverage, including Board writes followed by metadata writes. Saved prompt snapshots are excluded before cloning, and existing SQL-side large-payload projections remain unchanged.
Removed checks and accepted cases:
No schema, migration, retention, SDK surface, update, Doctor, plugin-loading, or service-lifecycle change.
Evidence
Three alternating pairs (M,C,M,C,M,C), shared warmed-turn harness. Measured base
599d0dec55e461775cc2a8de4ccb959098588c33, candidate937ce9d0bbde23f26e6aed14ece78a2af30d7b1e; final changes only split the same function/test into sibling modules and integrate main.Whole workload: 10067 [9982–10075] → 9892 [9871–9921] statements; 1733 [1729–1738] → 1708 [1704–1716] requests. First turn: 1277 [1188–1299] → 1224 [1194–1225] statements. Warm duration 1538.8 → 1472.8 ms. No extra pair needed: all candidate warmed statement samples are below every base sample.
Small non-turn fluctuations are within the ≤10-statement tolerance: connect +2 (unassigned startup), cron +1 (open), shutdown +3 (audit.writer.prune, +1 request); the changed row-fact path adds no request. The reduction is smaller than the census aim of 24–34 because cold, evicted, incomplete and uncertified summary facts still use the authoritative worker read.
T1 inventory: measured base 629 → candidate 629; final integrated raw inventory 623 → 623 (normalized 621 → 621); zero new main-thread SQLite calls. The first PR in this lane removed six T1 calls; this follow-up removes repeated worker SQL.
Proof completed before final mechanical split: 58 tests in five actor/projection suites passed (48.80 s runner wall time). The new row-projection regression fails on the base at the expected extra
readRowFactsrequest. It covers real SDK metadata writes, a real Board write, and metadata after Board invalidation. Two Codex autoreview rounds found no P0/P1 issues. The final split is byte-identical for the moved production function and test.Final integrated-head affected tests passed on Testbox (190.86 s wall time), including all changed suites, the incognito reader, the moved metadata/Board regression, both tooling dependency-closure regressions, and the Vitest project/configuration checks. Final-head type-aware oxlint (15 changed source files, zero warnings/errors), export-name collisions, Madge (zero cycles), line-count ratchets, T1 and dialect ratchets passed. Knip found 38 UI export entries, identical file/symbol sets on the integrated main baseline
3a0db8a3a05283c21600bc39e2772bf1432f7d0e; no changed-file or PR-only findings. The broad remotecheck:changedinvocation was stopped after ten minutes without progress; its completed exact-head CI equivalents and the direct remote static checks supply the proof. CI run 38140428595 passed all jobs and required/security gates. CI initially exposed two split-registration errors (test host ownership and wrapper dependency inventory); both are fixed. The unrelated duplicate-scan failure was fixed by integrating its existing main fix. No published-driver update cell or SDK API diff applies.LOC against integrated main: +543/−275 across 18 files, including a 276-line function moved into its own module and a 115-line focused regression module; no compatibility alias remains.