mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 12:42:38 +00:00
2fe1095758
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>