Repository navigation
perf(gateway): reuse committed session projection facts - #168719
Conversation
…odules Merge current main while preserving shared physical admission, cancellation, reader validation birthtime, and live deletion authority. Split worker usage, pool construction, failure settlement, and schema owner types to keep the existing line caps.
Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress.
Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions.
Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity.
Merge current main and preserve its optional settlement-only receipt delivery through the extracted owner. Keep the worker refusal error with the leaf contract to stay within the existing admission line cap. End the marker-free read-only fixture transaction normally; dedicated rollback and explicit revocation coverage remains unchanged.
Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress.
Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence.
|
Codex review: needs changes before merge. What this changesThis PR reuses committed Gateway session facts and resolves queued Memory session identities once during indexing. Example: Rename agent:main:acp:row-receipts to Published label after its Board and ACP facts are loaded.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: the maintainer-directed optimization remains useful and absent from main, but its changed read behavior still breaks projection fixtures. Three earlier stack-related findings are resolved. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherSession writers publish committed receipts into the Gateway’s resident row projection, which supplies session presentation; Memory queues transcript identities for its indexing owner. flowchart LR
A[Session writers] --> B[Committed receipts]
B --> C[Resident row projection]
C --> D[Session lists and readers]
A --> E[Memory identity queue]
E --> F[Memory indexing owner]
Technical reviewBest possible solution: Retain the receipt-based optimization and repair the affected projection fixtures without restoring redundant reads. Do we have a high-confidence way to reproduce the issue? Source explains the bypassed reads, and exact-head CI confirms foreground and subagent failures; no local tests were run during this read-only review. Is this the best way to solve the issue? Reusing the existing receipt, projection, and indexing owners removes duplicate work without introducing another cache or invalidation protocol. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cb87fd592de3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +83, Tests +185, Docs +11. Total +279 across 12 files. Added test files: 0. 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 (2 earlier review cycles)
Reviewed October 11, 2026, 12:52 AM ET / 04:52 UTC (Revision 3). |
) Reuse committed session projection facts and settle queued Memory work once, reducing redundant row reads while preserving invalidation and transcript publication ownership. Keep concurrency fixtures aligned with committed facts and preserve the transcript publisher receiver. All 250 tests in 11 focused files passed; changed-file type-aware lint, formatting and export-collision checks passed. Knip findings and prior unrelated CI failures reproduce on main. Landed through the explicitly authorized head-pinned REST fallback after native worktree allocation stalled. Inherited CI failures and validation details are recorded in the PR.
What Problem This Solves
Session metadata and transcript publications discard independent Gateway row facts and repeat database reads; Memory also resolves the same queued session corpus twice.
This is Phase C
pcrows, integrated with #168602 and targetingmain.User Impact
Session lists and channel readers retain current Board, ACP, workspace, and summary freshness facts with fewer database round trips. Streaming presentation keeps its existing coalescing window. Memory indexing observes appends and forgetting tombstones committed while notifications are queued.
There is no schema, SDK, retention, configuration, update, Doctor, plugin-loading, or service-lifecycle change. Target selection, session-entry readers, and B2–B4 write commands are outside this change.
Why This Change Was Made
The existing Gateway projection consumes canonical transcript receipts and keeps independent row facets across same-lifecycle metadata publications. A receipt installs its committed watermark before observers run; an unmatched notification or explicit invalidation follows the existing bounded read path. Shared facts stay reusable only while their bindings match. This uses the existing projection and writer receipt owners without another cache, generation protocol, or cross-thread handshake.
The actor hot snapshot does not contain Board presence, so this reuses the existing projection facets and transcript postimages without expanding the shared actor contract. Remaining initial/fallback row acquisition and activity-summary source reads stay visible in the measurements.
Memory queues session identities directly and resolves corpus membership and tombstones once in the indexing owner. The earlier notification-time resolution is removed. No SQLite-specific SQL is added.
The diff is +80 net production lines, +185 test/support lines, and +11 documentation lines. The extra production code connects existing receipt postimages to the existing row projection and preserves its invalidation/coalescing lifecycle.
Evidence
Three alternating pairs (M,C,M,C,M,C) ran the shared harness on base
6e8a0034934cand candidatefa9baeee005e. Each warmed observation is the mean of ten turns; values below are median [min–max] across the three observations. Every sample completed 13 successful turns, RPCs, cron, compaction and shutdown.Logical requests include CPU and release operations, matching the census. DB requests exclude releases and the two source-identified CPU-only tasks; zero-SQL database commands still count.
session-entryis excluded from this lane because pcentry owns it.session-row-factssessionRows.sharedFactssession-corpus-inventorysession-tombstonessession-row-backfillsession-activity-summary-sourceFirst-turn SQL decreased 1727 [1701–1892] → 1693 [1505–1889]. Entire-workload SQL decreased 15544 [15533–15630] → 15383 [15322–15469], and logical requests decreased 2950 [2950–2969] → 2887 [2885–2903]. Warmed duration ratio was 1.014, with no phase-skew failure. The lane target remains an aim: the remaining row acquisition, preview backfill and summary-source reads are not eliminated by this change.
Phase attribution: boot+connect was +24 SQL (+0.76%); its increases are in unchanged delivery, cron scheduling, plugin-state, image and device owners, with zero lane work in that phase. Startup including the first turn decreased by 14 SQL. Cron performed three additional
session-row-backfillrequests (+15 SQL), and the same +3/+15 remains in the whole-workload backfill total. This is a known cost in the changed projection owner, not attributed to unrelated noise. Warmed backfill remains 1 request / 5 SQL. Receipt-triggered materialization can precede the normal transcript notification; further optional-preview coalescing is a follow-up, preserving immediate summary freshness. No new scheduling or invalidation protocol was added to hide this cost. Whole-workload statements and requests still decrease.Remote focused proof on the candidate used
pnpm test <file> --maxWorkers=1:src/gateway/session-row-projection.publication.test.tssrc/gateway/session-row-projection.accepted-facts.test.tssrc/gateway/session-row-projection.backfill.test.tssrc/gateway/session-row-projection.transcript-regression.test.tssrc/gateway/session-row-projection.worker-read.test.tsextensions/memory-core/src/memory/manager-sync-ops.startup-catchup.test.tsThese 97 tests cover projection publication, archived/current summary freshness, worker-read fallbacks, preview backfill, streaming coalescing, and queued Memory appends/tombstones. The new transcript regression warms the first append before measuring the real row-facts and shared-facts boundaries; it does not count a CPU-only worker wrapper as a SQL read. Focused command wall time totals 318.873 seconds; CI runtime itself has not been measured.
Madge passed (18.914s), T1 passed without growth, and the dialect ratchet passed without added SQLite-specific SQL. Two isolated Codex autoreview rounds were scoped-clean at P2. No SDK surface changed, and the published-driver × candidate update cell does not apply.
check:changed --base 6e8a0034934c --head fa9baeee005ecompleted remotely in 2094.031s. Formatting, all 27 core-test typecheck shards, core/extension/extension-test typechecks, plugin boundaries and the other reported guards passed. Its only failure is the inherited dead-export scan: the update inspection constant, two session fixture exports, and the Solid lint default export. The standalone production/all-exports Knip findings are exactly identical on the pinned base and candidate; none concern changed files. Production Knip also reports the same 16 unused worker/UI files, unused@solidjs/signalsdependency, and unlisted@solidjs/compilerdependency on both sides.The three targeted negative controls fail at the intended assertions on the original production implementation: native metadata performs the redundant read, transcript summary freshness stays incorrectly current, and Memory still performs the earlier notification-time resolution. They passed as negative controls in 36.115s, 39.310s and 41.689s respectively. The temporary test overlay was restored byte-for-byte; the base and candidate were verified clean, and measurement evidence was unchanged. Initial negative-control setup hit missing workspace links and a temporary-volume quota; using the installed base checkout with caches on the larger disk resolved those tooling failures. The separate base dead-export scan reproduces every export failure above.
Landing validation
Integrated main at
c2d584acd704with a conflict-resolution merge, preserving the row-projection changes and current main ownership boundaries. The follow-up repair preserves the transcript publisher receiver, explicitly invalidates the concurrency fixtures that need a pending read, and asserts zero redundant reads after committed metadata updates. The repair-only P0/P1 review found no actionable findings.On final source
32cda4cc0237587424d500fceefcc67a90bdabf6, all 250 tests in 11 focused files passed (pnpm test <files> --maxWorkers=1, 1378.79 seconds including local preparation): 72 Gateway tests, 18 worker-read/runtime-ownership tests, 125 TUI mock-consumer tests, and 35 Memory startup-catchup tests. Formatting and the export-name-collision guard passed. Core type-aware oxlint passed on all changed Gateway files. Memory type-aware oxlint passed on byte-identical source copies using the repository's source type graph and unchanged lint rules; the ordinary generated-boundary preparation timed out before lint, so that compiler timeout is not claimed as a pass.Knip's only production findings are
SQLITE_DATABASE_GENERATION_LENGTHinsrc/infra/sqlite-database-admission-record.tsand the four existing exports inui/src/components/lobster-pet-look.ts; the full-tree scan reports the same three UI helper exports. These exact rules and files also fail on main in run 38112256403, and those source files are unchanged here.That main run independently reproduces the same notification corruption failure (job 114390202032), public-session corruption failure (job 114390202044), and worker-launcher invalid-transcript failure (job 114390202043) seen by the prior PR attempt. Their test files are byte-identical to the tested main baseline. The prior attempt also reported a worker-runtime capacity admission failure; it is recorded as an environment failure, not a passing test.
The native worktree allocator stalled for more than 15 minutes before creating review artifacts. Its lock was recovered after confirming no native children remained. Landing uses the explicitly authorized head-pinned REST squash fallback and inherited-CI exception. The update cell does not apply; no update, Doctor, schema/migration, plugin-loading, or service-lifecycle surface changes.
The final-head production typecheck reports
TS2353atsrc/cli/gateway-cli/run-loop-startup.test-support.ts:380(the newruntimeargument). The identical error independently fails on main atd4e9d09e9422in job 114398621086. That test and the called production owner are unchanged by this PR; the test blob is also identical on current main8267c24051ff. All security reviews andsecurity-fastpassed for the final PR head. The approved inherited-failure override leaves CI recorded as failed/pending, not green.