perf(agent-sessions): rank the list page first, then net its sessions alone - #1199
Merged
Merged
Maple Review Bot / Maple / review
succeeded
Oct 1, 2026 in 2m 42s
Confidence 4/5 · No issues found
🟢 Confidence 4/5 · likely safe to merge
The delta is a single clamp on the ranked page read, every production caller of that path passes endTime, and the unit, HTTP and ClickHouse e2e tests pin it.
quality 100/100 · no findings · tests covered · risk medium · 2/2 new units observable
The delta since the last review clamps the ranked page read to the caller's endTime, so a span that starts past the window is no longer netted. The clamp is wired through the one production caller and covered by tests; safe to merge.
indexTracesOfaddsTimestamp <= endTimewheneversessionIdsis set (ai-sessions.ts:554)listAiSessionsthreadspayload.endTimeinto the ranked page'sPageBounds(ai-session-reads.ts:240)- e2e adds a window ending inside a turn to prove rank and single read agree
- SQL baselines and the ranked benchmark fixture carry the new bound
Fixed since the last review
- ✅
F1 · Ranked page read counts spans that start after the caller'sendTime
What was checked
- F1: the ranked read is bounded by
Timestamp <= endTime(ai-sessions.ts:554, baseline SQL line 845) - Both
indexTraces(..., "page")callers leavesessionIdsundefined, so the details reads are untouched (ai-sessions.ts:967) aiSessionRankQuerystill scans the window only (ai-sessions.ts:864)
Observability coverage: 2 of 2 changes observable
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| aiSessionsRank warehouse read | database query | yes | context: "aiSessionsRank"; WarehouseQueryService.test.ts:1387 asserts one database span per compiledQuery |
| aiSessionsPage warehouse read (ranked path) | database query | yes | context: "aiSessionsPage" (ai-session-reads.ts:214), row count annotated as maple.ai.page_size |
854de1c · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Loading