Repository navigation
improve(gateway): prepare session placement metadata asynchronously - #150270
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. Reviewed September 21, 2026, 6:40 AM ET / 10:40 UTC (Revision 16). ClawSweeper reviewWhat this changesMoves session placement metadata reads into the shared database worker and preserves ordered session notifications, deletion identity, and refresh fallbacks during asynchronous preparation. Merge readiness✅ Ready for maintainer review This remains useful work: current main still reads placement metadata synchronously. The prior code findings are resolved, and this review found no new blocking defect. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway combines stored sessions with worker placement metadata to answer session-list and history requests and publish session updates. Prepared facts feed the existing per-recipient presentation and authorization owners. flowchart TD
A[Session requests and changes] --> B[Resident session projection]
B --> C[Shared database read worker]
C --> D[Committed placement snapshot]
D --> E[Identity and freshness checks]
E --> F[Authorized session responses]
E --> G[Ordered notifications or roster refresh]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +880, Tests +1255, Docs +13. Total +2148 across 53 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep placement preparation within the shared read worker and resident projection, with current identity checks and synchronous recipient presentation. Do we have a high-confidence way to reproduce the issue? Yes: current-main source directly shows synchronous placement SQLite reads during metadata preparation. Timing and concurrency scenarios were not executed in this read-only review. Is this the best way to solve the issue? Yes: reusing the existing shared-state worker and resident projection preserves one owner for stored facts, invalidation, and presentation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0fcbb7040195. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
93fb8cb to
954835f
Compare
Keep collector creation behind the completed preparation hold and avoid fallback resends after publication starts. Measure synchronous session selection CPU and wall time on success and failure. Separate projection type contracts, preserve decoder and attachment error ownership, and align fixture preparation and SQLite snapshot proof with supported Node runtimes.
Map normalized placement reads back to stored session IDs and prepare the existing bounded ancestor chain for complete event snapshots. Keep ordinary exact reads selected-only and omit unavailable synchronous ancestor bundles so clients retain their existing refresh behavior. Real SQLite describe and recipient/UI regressions fail before the repair and pass afterward; private preparation remains scoped to synchronous consumers.
Construct the projection fixture before enabling the session-event fake clock. Its ACP metadata probe can retain a native SQLite coordinator with a 30-minute idle timer, which belongs to fixture setup rather than event publication. Keep every shutdown and zero-event-timer assertion unchanged.
f8e4d4e to
48c8d73
Compare
Preserve worker-backed history deltas, physical row identity bindings, and list candidate invalidation in the placement projection carry. Keep reservation release before lifecycle publication without expanding the spawn module. Prepare the registered history handler in the privacy fixture so source transformation does not consume its RPC deadline. The requests, privacy assertions, and timeout remain unchanged. Release-note context: session placement reads and notifications retain responsive worker-backed preparation and current ownership at publication.
|
Merged via squash.
|
What Problem This Solves
Session metadata refreshes could read placement SQLite data on the Gateway thread. Delayed preparation could also reorder delete/recreate notifications or leave clients with stale roster state.
User Impact
Session reads stay responsive while placement facts load. Clients retain deletion identity and refresh after condensed or unavailable snapshots, and queued collectors no longer briefly announce themselves as running before their preparation hold ends.
Why This Change Was Made
The resident session-row owner now prepares placement, move, pending-result, and environment facts through the existing shared-state read worker. Each batch uses one committed snapshot. Private exact reads remain confined to their synchronous consumer, and archived pages retain bounded selected-row caching. Placement replies preserve the caller’s stored session-ID spelling. Event snapshots prepare the existing bounded ancestor chain so cold archived parents retain placement and move details; incomplete synchronous snapshots request the existing client refresh.
Canonical session notifications have bounded pending state and retain their shutdown owner until late publications settle. Failed preparation preserves keyed plugin notices and sends scoped roster refreshes to WebSocket clients. Publication failures are recorded without retrying a potentially partial send. Selection diagnostics retain synchronous CPU and wall time, including failed reads.
Placement mutations, live-authority checks, public contracts, schema, and retention keep their existing owners and behavior.
Evidence
Current composition at
a1e28a240e32c76e5509cfc267635a58a75f8e0acarries the complete source onto actual mainfd578cb8a62c0ec6c89b58991564622dd5ea1297. It preserves main’s asynchronous transcript-delta reader, abort/incognito semantics, session-list candidate cache, and physical row identity binding. Current integration passed 61 Gateway controls and four maintenance controls, including actual cursor responses and worker-backed history. A session-list privacy fixture hit the unchanged ten-second RPC deadline twice before its first history handler entered. Passive tracing measured 8.9 seconds in the existing lazy handler loader, while the actual history reads were short. The fixture now prepares that real registered handler during setup; every privacy request, assertion, and RPC deadline remains unchanged, and independent lazy-handler tests preserve production loading behavior. All 78 final-scope cases pass, including all 14 privacy cases, 45 queued-collector/lazy-handler cases, and 19 spawn-resource cases. The formerly failing privacy case now completes in 2.46 seconds with its original ten-second deadline. Full selected checks for all 53 changed paths and fresh independent P0–P2 review pass. Exact-head hosted CI and native landing remain pending.48c8d731485d1c6912dca8893967253fe6b64352passed all 165 jobs. The subsequent review identified three placement fixtures that did not await retained read-worker cleanup. They now await the existing async database closer before deletion and schema reopen; their 51 existing cases, 14 lifecycle/resource cases, selected checks, and independent P0–P2 review pass. Production files remain identical to that green head. CI for the fixture follow-up at7d4bec2565f5730ee4b145d01723351573dfa7e7has a task-profile cursor failure: a fresh task list is empty after a profile merge. The exact historical callback cause remains unknown. A separately controlled actual scheduled-maintenance producer/module-transition regression reproduced this empty-projection symptom and was fixed by joining admitted maintenance before Gateway teardown in fix(tasks): finish maintenance before Gateway shutdown #154308, now merged as5b3646d8783ad168235b86d6af0ff6e334f05d49. This establishes that independent repair, without attributing the old CI run to an unobserved callback.Local qualification also recorded an active-parent spawn boundary failure that reproduces unchanged on main and the earlier PR revision; the other eight boundary cases pass. One broader agent-suite terminal-settlement assertion failed locally, then passed in the scoped six-case run. These results remain recorded alongside the required hosted evidence.
Focused test cost on the preceding patch-identical carry
Each file ran through
pnpm test <file> --maxWorkers=1. These real SQLite, worker, recipient, and lifecycle boundaries retain their production owners; import and transform work dominate most standalone wall times.src/gateway/worker-environments/placement-read-projection.worker.test.tssrc/gateway/server-methods/session-row-facts.test.tssrc/gateway/session-row-projection.prepared-read.test.tssrc/gateway/session-row-event-ancestor-placement.test.tssrc/gateway/server-methods/session-change-event.fallback.test.tssrc/gateway/server-lifetime-sidecars.test.tssrc/gateway/server-methods/chat-history-handler.test.tsThe retained detailed Linux log measured the repaired shutdown case at 304ms. The shutdown jobs passed on both preceding published heads; the prior published head retains the historical cursor failure described above. Fresh current-head CI is pending.
Fixture cleanup validation cost
The three existing files ran individually with
pnpm test <file> --maxWorkers=1before and after the cleanup repair. Original macOS cases passed; the repair addresses the source-proven unjoined lifetime, without claiming a reproduced platform deletion failure. Worker disposal now completes within each fixture lifetime.placement-store.move.test.tsplacement-move-schema.test.tsplacement-store.turn-claim-closure.test.tsThe lifecycle/resource cases passed in 18.35s. These command wall measurements include compilation and startup; they are not production performance measurements.