Repository navigation
refactor: move session catalog reads off the Gateway thread - #169620
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 changes before merge. What this changesThis PR moves session catalog pages and fallback-title reads into existing workers and removes a redundant identity query from warm entry-cache reads. Example: Session Share opens agent:main:catalog-worker, whose first user message is “Plan the migration.”
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: current main still performs these catalog reads synchronously, and the maintainer has accepted the pagination edge case as a follow-up. No additional blocking code defect was established; failing CI still needs attribution before landing. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherSession Share consumes the public transcript SDK; session-entry and history workers read agent SQLite stores, and the source command checks current sharing eligibility before returning catalog data. flowchart TD
A[Session Share command] --> B[Transcript SDK]
B --> C[Session entry worker]
B --> D[History worker]
C --> E[Agent SQLite database]
D --> E
B --> F[Current sharing checks]
F --> G[Catalog response]
Technical reviewBest possible solution: Land the worker migration once CI failures are attributed, preserving the current SDK compatibility window and the accepted pagination follow-up. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows synchronous SQLite catalog reads and the redundant cache identity query; their latency impact was not reproduced during this read-only review. Is this the best way to solve the issue? Reusing the existing workers and receipt-backed cache owner is appropriate, and retaining the synchronous SDK adapter avoids an immediate plugin break. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2fc20b367b69. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +77, Tests +5, Docs +8. Total +90 across 15 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 HistoryReview history (5 earlier review cycles)
Reviewed October 12, 2026, 4:41 AM ET / 08:41 UTC (Revision 6). |
…e-catalog # Conflicts: # src/config/sessions/session-history-types.ts # src/config/sessions/session-history-worker-runtime.ts
|
The remaining catalog-pagination P2 is recorded as a follow-up under the maintainer's relaxed landing policy. A transcript append between worker replies can reject a valid cursor or repeat a page; clients can restart pagination, and the final source/disclosure checks remain intact. This accepted recoverable edge case does not permit stale sharing authorization or transcript disclosure. The follow-up is to pin both anchor and page reads to absolute sequence bounds through the existing reader operation. |
…#169620) Route catalog pages and fallback titles through the existing history worker, expose the asynchronous SDK title API, and migrate the bundled session-share caller. Remove redundant exact-cache identity and post-clone rechecks under Gateway-owned write receipts. Keep the deprecated synchronous SDK contract until the next major. Validated with focused regression tests, isolated live SQL measurement, Codex review, and CI static gates. Inherited CI failures and the accepted pagination edge case are documented in the PR.
What Problem This Solves
Cached session-entry reads repeated an identity query even though the Gateway already owns write receipts. Session catalog pages and fallback titles also read transcript SQLite on the Gateway thread.
User Impact
No intended user-visible behavior change. Catalog reads run in the existing history worker, and warm entry-cache hits avoid a redundant identity query. No schema, retention, migration, or update changes.
Why This Change Was Made
Reuse entry-cache facts under their existing writer receipts and validate identity when populating the cache. Catalog pages and asynchronous title reads use the existing history worker; title reads select the first 100 messages in one request without a count probe. The bundled session-share plugin uses the async API.
SDK migration:
readSessionTranscriptCatalogTitleis deprecated and warns; usereadSessionTranscriptCatalogTitleAsync. The synchronous public contract remains until a later release after the deprecation has shipped in a stable release.Removed checks and accepted edge cases:
Cursor branch validation and final source-authority checks remain because they protect transcript identity and disclosure.
Evidence
Independent Codex review completed in two scoped rounds with no actionable P0/P1 findings. Exact-read regression suite passed 31/31 (25.772 seconds wall), and six mock-consumer suites passed. The catalog worker test exposed a missing response-decoder case; the pushed head includes the fix. PR CI owns its rerun and the required static checks.
Live SQL measurement
Completed one sequential baseline/candidate repeat on isolated local Gateway state, reusing the existing builds. Baseline
734d5b57f1465527230b46d27da6ba01aef1c8ec; candidate source988e39ac5cc0c1758bb7fef0c17c36a220678606, built production0e7c5976adecc5ea94a25847817b38d389d0d9a6. The only source difference between the candidate build and measured checkout is a test expectation. Both sides passed all 13 turns, control-plane RPCs includingmentions.dismiss, child completion, cron, compaction, shutdown, calibration, and exact request/statement accounting.Within-run warmed distributions (median [min–max], not repeated-run statistics): statements 365.5 [305–494] → 358 [313–463]; requests 109 [94–137] → 109.5 [95–132]; MAIN 0 [0–2] on both sides.
The warmed duration ratio is 1.22×. The first-turn ratio remains 2.27×, so the first-turn count comparison is timing-contaminated and is not a valid first-turn gate. No additional pair was run after this authorized repeat.
The +0.4 warmed requests are the net of unchanged callers: actor reads +0.3, entry-worker reads +0.3, shared facts +0.2, catalog snapshot +0.1 and agent domain bind/execute/close +0.1 each, offset by domain publications −0.3, exact-entry requests −0.4 and ordered entry reads −0.1. Stack attribution found exactly 30.9 warmed SQL statements per turn through changed files on both sides: entry-cache 29.3 and entry-cache projection 1.6. Every ordinary entry-cache SQL class had identical counts. The two extra cold projection reads occur in first-turn and cron; the rest of the observed first-turn increase is outside changed stacks. The shared workload does not invoke the moved transcript catalog reader or the removed exact-cache identity SELECT; focused CI owns those regression contracts.
The shared harness was not changed. The copied harness sets server handshake timeout to 120 seconds (from 15 seconds) and client open/handshake timeouts to 120 seconds (from 8 seconds), equally on both sides. This followed a baseline connection timeout at the original 15-second limit. The first candidate copy lacked generated workspace artifacts; the exact failing import was reproduced and passed after copying existing package build artifacts, with no rebuild or product change. Those failed attempts are retained separately and contribute no measured turns.
The earlier completed pair had a
mentions.dismissfailure and inconsistent timing, and is not used as passing proof. Both sides of this repeat passmentions.dismiss; its earlier underlying exception remains unproven, so it is recorded as a transient observation rather than claimed to be inherited or fixed.Assigned-file inventory under current classification: 45 → 44 T1 call expressions (plus two Doctor T3 calls and one worker call). The deleted expression is the cache identity query. Shared transcript kernels remain conservatively classified while deprecated SDK and native-incognito callers exist; this PR does not relabel mixed kernels worker-only.
Diff: 15 files (+260/−170). No published-driver update cell applies.
CI disposition
Final reviewed head:
3096604ac2881edb553c8726ce02e9213a00bcbc. Main integration was conflict-free; the PR remains 15 files (+260/−170). The integration brings in the already-landed fixes for four unrelated unused exports/types found by the earlier Knip run.Exact-head PR CI 38224202992 passed source contracts, guards, architecture/Madge, baseline ratchets, core lint and security-fast. The changed-tests lane failed only on the previously reproduced raw-cursor continuity failure below. The run was subsequently canceled while remaining static work was active; canceled jobs are not claimed as passing.
Exact-head full CI 38224250243 supplies the remaining static evidence. Production types, all five core test-type stripes, extension test types, all five core lint stripes, lint, source contracts, guards, runtime-topology architecture/Madge and baseline ratchets passed. The exact-head PR extension package boundary and negative canary passed. The full-run plugin contract lane passed 23 files / 251 tests, including the runtime API guardrails. The generated SDK API-diff report passed in job 114728170409. The surface-budget check and runtime API safety gates are also green. The separate exact-head Workflow Sanity run 38224253901 passed the SDK surface-budget check.
Knip found two untouched main-owned items: unused
gateway-prewarm.mjsand unusedrenderPublicSessionCardSvginsrc/gateway/control-ui-public-session-card-render.ts. The identical rules fired on the identical files at current-mainb82b033920ee7a4df6323e3ee2b04ac8c6037fe0in 38224696307, job 114729780159. No PR-owned unused symbol was reported; this static red is inherited.The inherited raw-cursor case is
test/embedded-transcript-cursor.e2e.test.ts→resumes a public raw cursor across /new and the next Gateway turn, returninggeneration_mismatch. An isolated protected-main ancestor0387f4f96a2963409bd0da3aa42f3510459bfea8reproduced the same normalized error; #169469 records that qualification. The raw-delta comparison, cursor encoding and watermark owners are unchanged by this PR. This is inherited red evidence, not a passing cursor test or a claimed repair.The additional full-suite reds are in untouched code: tooling fixture copies cannot find the recently added
control-ui-public-session-card-render.ts; its suppression is absent from the lint-suppression allowlist;run-additional-boundary-checks.test.tsexpects an outdated guard argument list; andsession-transcript-hit.projection.test.tscatches eight backgroundPRAGMA wal_checkpoint(PASSIVE)calls in an empty-SQL assertion. No changed entry-cache SQL appears in that assertion. These are recorded as unrelated findings, without claiming repairs.Earlier built lifecycle CI observed a concurrent-delete run ending with
status: error,AbortError: agent run aborted, andendedAt, but nostopReason. The unchanged proof helper accepts that terminal result only with a named stop reason. Focused baseline/candidate diagnosis was interrupted without a behavior result after module-graph compilation consumed 495.7/398.6 seconds; neither side is claimed to pass or fail. That limitation remains explicit; no product regression was established.The remaining ClawSweeper P2 is accepted as a follow-up: an append between catalog worker replies can reject a valid cursor or repeat a page. Clients can restart pagination; final disclosure checks remain current. The follow-up is absolute sequence bounds, without a new owner or handshake.