Files
AutopilotMonitor/docs
Oliver Kieselbach 2fe1095758 perf(raw-events): budgeted, resumable cross-session scan; tenant from index rows; MCP pageSize override + timeout retry
query_raw_events timed out twice on the same continuation and lost all work each time. Per page the
cross-session path resolved every session's tenant through a SessionsIndex full-table scan (the
EventTypeIndex row already carries TenantId), ran up to 1000 per-session queries serially, applied the
date window last and against the Azure system Timestamp, and had no deadline; the retry was identical
because the nextLink freezes pageSize and the explicit value was dropped.

Backend
- RawEventsScan: index walked in chunks of 100, 20 parallel session fetches, 15 s budget checked
  between chunks; cursor always after the last fully processed chunk; QueryRawEventsResponse.Partial
  marks a budget-ended page (nothing missing up to nextLink).
- Date window pushed down: Events RowKey range inside the session partition
  (BusinessTimestamp.EventDateFrom/ToClause) + sound index write-time pre-filter
  (startedAfter - MaxFutureToleranceHours - 1h). The session-StartedAt RowKey was rejected as a
  prefilter (WhiteGlove Part 2 emits weeks later).
- Raw date filters and ordering now use the business time (RawEventTime: OccurredUtc -> RowKey ->
  system Timestamp); unparsable startedAfter/startedBefore is a 400; bare values are UTC.
- Same scan sat behind search_sessions_by_event, search_sessions_by_cve and the deviceProperties path
  of search_sessions: all read Sessions by point read with the tenant their index row carries
  (BatchGetSessionsByKeyAsync, IndexRowKeys.ResolveTenantId); the scan-based batch helper is gone.

MCP
- followNextLink(..., overrides): an explicit pageSize (and fields on the raw tools) applies to a
  continuation in every nextLink-paginated tool; pageSize schemas lose their .default(),
  pageSizeForCall sends the first-page default only on a first-page call.
- scanWithTimeoutFallback on the auto-exhaust tools: one retry with a halved pageSize on the same
  cursor, marked retriedWithPageSize; timeout error text distinguishes continuation calls.
- Generated wire types regenerated (partial?: boolean).

Docs: docs/backend/raw-events-scan-budget.md (design, invariants, audit of the remaining unbounded
cross-tenant aggregations with live durations), business-timestamps.md consequences.

Deploy backend first (additive field), then MCP.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-01 22:35:46 +02:00
..
2026-07-31 18:48:12 +02:00