Repository navigation
perf(sessions): bound history reads and stabilize cursor paging - #146770
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 13, 2026, 5:52 AM ET / 09:52 UTC (Revision 7). ClawSweeper reviewWhat this changesSession-history reads reuse SQLite snapshots, fetch only needed neighboring messages, and validate page continuity across concurrent transcript changes. Merge readiness✅ Ready for maintainer review The PR remains useful: current main still computes cursor offsets separately from page selection. No blocking defect was found, and the current diff plus compatibility discussion resolve the previous migration concern. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway reads session transcripts from SQLite or retained archives, then projects them into chat-history pages and streaming updates. These readers determine which messages clients receive while conversations continue changing. flowchart TD
A[History request and cursor] --> B[Gateway history reader]
B --> C[SQLite snapshot or archive]
C --> D[Bounded page selection]
D --> E[Continuation validation]
E --> F[Chat display projection]
F --> G[History page or stream update]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +294, Tests +676. Total +970 across 21 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep bounded selection and continuity checks in the existing transcript readers while preserving archive behavior, byte limits, and public cursor semantics. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main separates cursor offset calculation from page selection, allowing intervening appends to shift the window. The storage-backed race cases exercise that boundary; this review did not execute them. Is this the best way to solve the issue? Yes. Reusing the validated snapshot and existing recent-read owner addresses the race and redundant work without adding a parallel reader or changing persistent contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a8a9114fb787. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
Maintainer compatibility review is complete. The final diff adds no runtime configuration keys, changes no defaults, and changes no SQLite schema, retention policy, transcript format, or public RPC field. Existing archive, reset-window, ID-less transcript, configured-store, and read-fence behavior is covered by the recorded tests. No state migration or operator action is needed. The continuation metadata is transient read state. It validates the selected source, reset boundary, and original newest row during one logical history read; it is neither persisted nor added to public RPC envelopes. All temporary CI and profiler prerequisites were dropped after the canonical repairs landed on main (#146702/#146672, #146862/#146803, and #146861). This PR now changes only session-history code and tests. Its 21 files and all 14 recorded benchmark hashes remain unchanged. Current CI and integration evidence are in the PR body. |
4f44b86 to
b639d76
Compare
7ae1a2d to
a69b75f
Compare
Reuse validated delta snapshots, share directional range selection, and avoid decoding discarded recovery neighbors. Keep cursor selection in the page snapshot and validate continuation windows across branch or reset changes. Validated with 279 focused tests, affected type and lint checks, independent P2 review, and 23 paired benchmark cases. Guarded recovery decoded 694 to 350 payloads and took 22% less time in warm synthetic measurements.
49c14e8 to
3f5b482
Compare
|
Merged via squash.
|
* refs/heads/temp/pr-146883: (159 commits) fix: retain route ownership while discovering conversations (#146927) refactor: reuse plugin fixture shell runner (#146920) fix(worker): stop preparing disabled live previews (#146896) fix(runtime): support Bun across tooling suite (#146807) chore(i18n): refresh native locales (#146924) perf(secrets): limit expiry metadata to transient credentials (#146882) fix(ui): preserve queued refreshes during session discovery (#146535) test(ui): wait for quiet scrolling and close named file tabs (#146836) fix(ui): prevent Usage hour filters from freezing during DST (#146919) test(ui): share browser page cleanup across layout fixtures (#146805) ci: balance complete PR runtime test groups (#146916) improve(infra): reduce scheduling work for session notice bursts (#146818) improve: prepare Gateway skill commands asynchronously (#146812) improve(agents): skip unused assistant delivery parsing (#146858) improve(ui): reuse date formatters across timestamp lists (#146789) fix(tests): isolate installer and Docker shell snippets (#146897) test(heartbeat): share explicit channel configuration fixtures (#146853) fix: retain conversation reply claims through write admission (#146866) perf(sessions): bound history reads and stabilize cursor paging (#146770) fix(ui): let slow dashboard downloads finish before recovery (#146881) ...
* refs/heads/temp/pr-146833: (43 commits) fix(memory): preserve newer indexes and disclose automatic rebuild costs (#146908) fix: retain route ownership while discovering conversations (#146927) refactor: reuse plugin fixture shell runner (#146920) fix(worker): stop preparing disabled live previews (#146896) fix(runtime): support Bun across tooling suite (#146807) chore(i18n): refresh native locales (#146924) perf(secrets): limit expiry metadata to transient credentials (#146882) fix(ui): preserve queued refreshes during session discovery (#146535) test(ui): wait for quiet scrolling and close named file tabs (#146836) fix(ui): prevent Usage hour filters from freezing during DST (#146919) test(ui): share browser page cleanup across layout fixtures (#146805) ci: balance complete PR runtime test groups (#146916) improve(infra): reduce scheduling work for session notice bursts (#146818) improve: prepare Gateway skill commands asynchronously (#146812) improve(agents): skip unused assistant delivery parsing (#146858) improve(ui): reuse date formatters across timestamp lists (#146789) fix(tests): isolate installer and Docker shell snippets (#146897) test(heartbeat): share explicit channel configuration fixtures (#146853) fix: retain conversation reply claims through write admission (#146866) perf(sessions): bound history reads and stabilize cursor paging (#146770) ...
…ssion-list-roster-batch-20260913 * commit 'f513c0f345f7f2514c49ccfbc00adc3f78b9a755': (46 commits) chore(i18n): refresh native locales (#146924) perf(secrets): limit expiry metadata to transient credentials (#146882) fix(ui): preserve queued refreshes during session discovery (#146535) test(ui): wait for quiet scrolling and close named file tabs (#146836) fix(ui): prevent Usage hour filters from freezing during DST (#146919) test(ui): share browser page cleanup across layout fixtures (#146805) ci: balance complete PR runtime test groups (#146916) improve(infra): reduce scheduling work for session notice bursts (#146818) improve: prepare Gateway skill commands asynchronously (#146812) improve(agents): skip unused assistant delivery parsing (#146858) improve(ui): reuse date formatters across timestamp lists (#146789) fix(tests): isolate installer and Docker shell snippets (#146897) test(heartbeat): share explicit channel configuration fixtures (#146853) fix: retain conversation reply claims through write admission (#146866) perf(sessions): bound history reads and stabilize cursor paging (#146770) fix(ui): let slow dashboard downloads finish before recovery (#146881) fix: share Doctor lifecycle coordination with SQLite workers (#146714) fix: retain native session model provenance (#146801) fix: settle embedded transcript repairs before session cleanup (#146842) feat(macos): improve agent navigation and chat layout (#146531) ...
…claw#146770) Reuse validated delta snapshots, share directional range selection, and avoid decoding discarded recovery neighbors. Keep cursor selection in the page snapshot and validate continuation windows across branch or reset changes. Validated with 279 focused tests, affected type and lint checks, independent P2 review, and 23 paired benchmark cases. Guarded recovery decoded 694 to 350 payloads and took 22% less time in warm synthetic measurements.
Related: #146607
What Problem This Solves
Session-history polling and recovery repeat SQLite work and decode discarded rows, while concurrent appends, branch changes, or resets can invalidate cursor pages.
User Impact
History polling does less work, recovery reads fewer payloads, and cursor pages remain consistent during concurrent history changes. Existing retryable projection errors reject changed continuation windows. No migration or operator action is required.
Why This Change Was Made
Directional reads now request only the required neighbors through shared SQLite/archive range logic. Display deltas reuse their validated snapshot and skip history reconstruction when no events were selected. Cursor selection and the initial page share one snapshot; later reads retain the original upper boundary and validate the source, reset, and newest selected row before loading payloads.
The same recent-read owner preserves byte limits and oversized-newest behavior for cursors at the head, without an extra payload probe. Duplicate range/projection logic and per-row temporary arrays were removed.
Empty or byte-blocked deltas intentionally no longer validate unrelated historical marker/reset payloads. Requested payload errors and admission fences remain enforced. No schema, retention, durability, or public RPC fields change.
Evidence
3f5b482f329aeab5a52efe549be1752e569471f0.The guarded recovery tail decoded 694 → 350 payloads and took 5.184 → 4.041 ms (22% less time), including four additional continuity queries. Marker-heavy idle polling returned 1,003 → 1 SQLite rows and took 4.782 → 0.019 ms. Interior SSE paging used 13 → 7 statements with identical payloads.
These are warm synthetic measurements on Node 24.21.0 / SQLite 3.53.4 against
bd002c80a15f01cc3ecc37401d4599f5e8d092bf: same process and canonical SQLite owner, 13 frozen baseline modules, shared unchanged dependencies, 100 warmups, and 32 alternating batches of 50 reads. Times below are medians of per-read batch averages, not individual-request percentiles. The 2,000-message full-reader guard used 3 warmups and 12 single-read rounds. Measurements use this fixed base; the history implementation and recorded source hashes remain unchanged after refreshing onto main.Controls were roughly flat: centered-anchor median time/CPU increased 5%/7%, and several upper batch quantiles worsened. Nonempty marker-heavy delta CPU was unchanged despite fewer statements. These results do not establish cold-open, whole-RPC/browser, or universal tail-latency improvements.
All paired measurements (baseline → candidate)
Directional cases compare identical retained neighbors with the former centered-read-and-slice path; centered public anchor behavior is unchanged. Ordinary and recovery-tail outputs match except for the explicitly validated private read-window metadata. Past-head SSE decodes exactly the same 421 payloads, with no extra probe.
Error probes verify the same requested malformed-JSON failure and required-byte hint, and that an oversized newest message excludes malformed older JSON while decoding exactly one payload on both implementations.