Repository navigation
perf(sessions): reuse participant and lifecycle read products - #169544
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs changes before merge. What this changesThis PR reuses current participant display facts and combines lifecycle timestamps with the existing fused session-entry read. Example: Read children of agent:main:parent after warming participant facts for agent:main:child and agent:main:sibling.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it provides a focused, maintainer-directed optimization that current main does not contain, with no actionable introduced defect found; the failed CI gate still needs attribution. Priority: P2 Before merge
FindingsNone. Agent review detailsHow this fits togetherSession accessors and read workers turn admitted SQLite session rows into entry, participant, membership, and lifecycle facts consumed by chat preparation and session projections. flowchart TD
A[Session read callers] --> B[Existing entry reader]
B --> C[Participant display cache]
B --> D[Fused SQLite facts]
D --> E[Lifecycle header fallback]
C --> F[Caller owned results]
D --> F
E --> F
G[Committed writer receipts] --> C
Technical reviewBest possible solution: Retain the existing cache and fused-read owners, and land this focused optimization once the failed required check is resolved or demonstrably inherited. Do we have a high-confidence way to reproduce the issue? Base source repeats participant acquisition for these consumers and excludes lifecycle reads from the fused path; the PR reports regressions failing on the baseline, but this review executed no target code. Is this the best way to solve the issue? Reusing the existing revision-checked display product and fused query is a proportionate solution that preserves detached results and lifecycle snapshot consistency. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c0e0bbaf21e7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +13, Tests +67. Total +80 across 4 files. Added test files: 1. View PR surface stats
Review metrics
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 11, 2026, 10:36 PM ET / October 12, 2026, 02:36 UTC. |
…aw#169544) Reuse current entry-cache participant products for cohort and batch projections, query only cache misses, and derive lifecycle facts from the fused worker read. Remove the duplicate physical-owner capture. In-process write receipts preserve freshness; cross-user membership checks stay intact. About two fewer participant SELECTs per warmed turn, with total warmed SQL within measurement noise and zero measured main-thread statements. The shared synchronous SDK participant reader remains an explicit follow-up. Focused owner suites, regression-before/fix-after proof, static checks, and two Codex reviews completed. The unrelated wrapper-inventory duplicate assertion also fails on main.
What Problem This Solves
Session entry reads repeated participant and lifecycle queries even when their current owner had already produced those facts.
User Impact
This reduces SQLite work for session reads without changing stored data, authorization, or public APIs.
Why This Change Was Made
Cohort and child-entry projections now reuse the existing entry cache's participant display product, whose lifetime is governed by in-process write receipts. Mixed batches query only missing products. Lifecycle entry reads use the existing fused entry/participant/membership query and derive timestamps from that same result, retaining the snapshot when a transcript-header fallback is needed.
Removed check: the fused worker read no longer captures the physical owner a second time after its synchronous read. Accepted edge case: a file replacement cannot be observed midway through that owner-held synchronous read; the next operation performs its normal admission. Cross-user membership and effect-boundary authorization remain unchanged.
The shared native participant reader remains one inventoried T1 call site (1 → 1); the changed worker is 0 → 0. This is the requested escape hatch: deprecated synchronous Plugin SDK
getSessionEntry/listSessionEntriesstill reach this shared reader, as do native admission/projection owners. Moving that shared owner wholesale requires their async API/replica cutover; relabeling it worker-only would hide real exposure. No synchronous fallback was added.Evidence
The raw-turn increase triggered the required extra complete-workload pair. M4 → C4: 9,475 → 9,435 statements and 1,779 → 1,777 requests, with warmed statements 328.2 → 318.3 and requests 92.7 → 92.2. Across all four pairs the warmed medians are 324.8 → 325.0 statements (+0.06%), 92.35 → 92.30 requests, and 0 MAIN. Participant SELECTs fall 24.8 → 22.8 per turn. This is a roughly two-statement subsystem saving, not a claim of a large net-turn improvement.
Raw phase medians (first three pairs, statements): boot 2,012 → 2,012; connect 1,058 → 886; first turn 971 → 1,102; second session 1,399 → 1,397; control 15 → 13; cron 523 → 523; compaction 170 → 170; shutdown 89 → 89. The higher first/warmed counts move among existing startup, actor acquisition, lifecycle projection, and row-facts operations; the extra whole-workload pair is lower in both counted metrics. For example the 3.1-SQL warmed
database.prepareWriteburst appears in baseline M3 and candidate C1/C3, and the 13-SQL lifecycle burst appears in baseline M3 and candidate C1/C3. No new request type was introduced. Warm duration median ratios are 1.0003 for the first three pairs and 0.996 across four; every gated phase ratio is below 1.5. Native calibration: 8 calls / 2 prepares / 7 successful statements / 0 failures in each of main and worker.Measured on one AWS Crabbox with the unchanged shared harness workload, alternating M,C,M,C,M,C. Base:
a52a29f82299e563e3a200966a77412dcc3bdc8b; candidate:c36320881ca36435aa9ec6055349c919540d0a37(verified tree). The subsequent main merge was conflict-free and did not change either production file.On the merged head, all four focused suites pass: participant products (corrected fixture: 12.23s), cohort worker (23s), entry-read worker (18s), and SQLite participants (40s). These are
pnpm test <file> --maxWorkers=1equivalent repository-runner wall times on AWS; hosted CI seconds are not yet measured. The lifecycle regression fails on the baseline. Both participant cases fail on baseline with the redundant multi-key SELECT and pass on the candidate. The fixture uses two rows to defeat the pre-existing single-key memo and checks cache freshness after an in-process participant write plus caller-owned nested data.Type-aware Oxlint: 0 warnings/errors. Export-name/source contracts pass. Madge: 0 cycles.
check:changedpasses its typechecks, formatting, contracts and ratchets; its Knip failure is inherited: the exact merged head and its main parent produce the same 88 findings, zero new findings. The full-tree Knip comparison includes production, full-tree and script export scans. T1 ratchet on the merged head: 607 → 607 raw, 605 → 605 normalized; dialect groups: 0 → 0 growth.No schema, migration, update, Doctor, plugin-loading, service lifecycle, or SDK surface change; the published-driver update cell and SDK API diff do not apply. Codex autoreview rounds 1 (production change) and 2 (test-only correction) found no actionable P0/P1 issue.
Scope: production +37/−24 lines; tests +70/−3 lines. No changelog edit; release-note context is this PR's reduction of repeated session read queries.
CI disposition: required run 38196019109 failed only in
checks-node-compact-small-1, attest/scripts/eager-import-closure.test.ts("resolves wrapper package exports and workspace aliases from the extracted dependency context"). This duplicate-entry assertion reportssrc/chat/sender-identity.ts,src/sessions/input-provenance.ts, andsrc/sessions/user-turn-transcript.metadata.ts. An independent current-main checkout at734d5b57f1465527230b46d27da6ba01aef1c8ecfails the exact test with the same three duplicates (15.27s including the runner). The test, helper, and inventory are outside this four-file PR. Native review initialization exceeded ten minutes; landing uses the authorized head-pinned REST fallback with the inherited-CI exception. No ClawSweeper wait was requested.