Repository navigation
perf(gateway): retain cold session list selections - #166405
Conversation
Keep principal-scoped list views on the selection revision so display-only materialization does not repeatedly filter the roster. Preserve sharing revisions for authorization receipts and refresh views on selection or context publication.
|
🦞👀 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 October 6, 2026, 10:57 PM ET / October 7, 2026, 02:57 UTC. ClawSweeper reviewWhat this changesThe Gateway reuses principal-specific session-list selections while cold display rows materialize, with regression coverage and an opt-in benchmark. Merge readiness✅ Ready for maintainer review This remains a useful, focused optimization absent from current main. No introduced correctness defect was found; the evidence supports reduced selection work without establishing a fix for the broader production stall. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway turns session metadata and a caller's visibility policy into paginated session lists. Its projection prepares selected display rows before presenting and serializing responses. flowchart TD
A[Session metadata] --> B[Session projection]
C[Caller and list filters] --> D[Principal-specific selection]
B --> D
D --> E[Prepare selected display rows]
E --> F[Current policy and row presentation]
F --> G[Serialized session list]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -5, Tests +180. Total +175 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep selection reuse within the existing projection owner while preserving current principal policy, metadata invalidation, and synchronous row presentation. Do we have a high-confidence way to reproduce the issue? Yes, for selection amplification: current main retires cached selections during display-only materialization, and the reported baseline regression observes three selections instead of one. The broader multi-second production stall remains unconfirmed. Is this the best way to solve the issue? Yes. Using the existing metadata-selection revision removes unnecessary invalidation without adding another cache owner or changing authorization receipts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c48607980ace. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Keep principal-scoped list views on the selection revision so display-only materialization does not repeatedly filter the roster. Preserve sharing revisions for authorization receipts and refresh views on selection or context publication.
What Problem This Solves
Cold
sessions.listpages repeat full-roster selection while their selected display rows materialize. Each display-only publication retires the cached principal/filter view even when selection metadata is unchanged.User Impact
Cold list requests retain their shared selection across row-preparation slices. Different principals and filters keep separate views, and each response still authorizes and presents current rows synchronously.
Why This Change Was Made
Use the projection's existing selection revision plus row-context identity for list views. Keep the broader sharing revision unchanged for authorization receipts and asynchronous read fences. Existing request/row-read coalescing stays with its owners; this adds no cache, configuration, or schema.
Production LOC: −5 (
session-row-presentation.ts: 3 additions, 8 deletions).Evidence
A six-request cold-owner benchmark over 5,000 synthetic sessions, calibrated to 562,014-byte responses, ran three fresh projections per version on one Blacksmith Testbox, candidate first:
Calibration used the committed benchmark with labels ending in
"界".repeat(324)andprocess.threadCpuUsage()around the six-request burst. The committed opt-in fixture uses larger, 781 KB responses. These are small samples, not p99 estimates. One calibrated candidate cold-owner burst reached 530.8 ms.The real Gateway restart rig used two fresh processes per version, 5,000 synthetic sessions, six concurrent sidebar lists and 560,465-byte responses. All requests were below 500 ms: baseline 99–188 ms, candidate 116–256 ms. It did not reproduce the reported multi-second production stall or establish an end-to-end speedup. Gateway startup already awaits initial roster materialization before exposing the request context. The cold-owner probe isolates metadata-ready/display-cold rebuilding. This PR removes that independently reproduced selection amplification; the production stall and possible later invalidation or worker contention remain investigation gaps.
Validation:
blacksmith-testbox, leasetbx_01m4a2b6sdmm3nk4rmv15es9t2: baseline regression fails specifically with 3 selections instead of 1; candidate passes. Focused serialization, viewer, presentation and list-page suites: 18 passed (node scripts/run-vitest.mjs … --maxWorkers=1). Combined command: 168.2 s.pnpm test src/gateway/session-list-serialization.test.ts --maxWorkers=1: 4 passed, 3.14 s test time / 41.05 s command wall time (30.79 s inside the test wrapper). New regression: 1.60 s. The large benchmark is opt-in (OPENCLAW_DB_WORKER_BENCH=1), not ordinary CI test work.node scripts/check-changed.mjs --staged, exit 0; all 27 core test typecheck groups, lint, dead-code and required guards passed. Baseline and candidate runtime builds and isolated Gateway restart runs also passed.git range-diffreports equality).Measurements and the changed-file gate used base
7880834c1961. The branch was then rebased without conflicts onto27ba9720f2c5. Exact-head CI passed for3f6c2159f2db, including Node tests and typechecks. Selected Node CI jobs took 84–296 s each; per-file CI timing was not exported. The fresh-head Testbox lease remained queued and was stopped after CI verified the rebased head; it supplied no additional test result. All task leases and rig checkouts are cleaned up.