Conversation
|
| Filename | Overview |
|---|---|
| api/agent_sessions.py | Adds the index-presence gate and cron-only latest-message CTE fallback; the fallback candidate window still needs deterministic tie handling. |
| tests/test_issue2628_cli_sessions_perf.py | Adds missing-index database helpers and progress-budget coverage for the cron fallback path. |
Reviews (1): Last reviewed commit: "fix(sidebar): restrict cron pre-aggregat..." | Re-trigger Greptile
|
Shipped in v0.51.672 (Release YB, just deployed) — thanks @rodboev! The cron sidebar rescue scan on a state.db missing |
…ering for missing-index scans (nesquena#4962)
Thinking Path
#4842slices already removed the per-row cron sidecar I/O path and the streaming cache churn, but the cron-only sidebar rescue can still hit multi-second cold rebuilds whenstate.dbhas no usableidx_messages_session.What Changed
api/agent_sessions.py: keep the existing indexed ordering path, keep the defensiveidx_messages_sessionprime, and add a cron-only fallback that joins a pre-aggregatedlatest_messagesCTE only when the messages index is still unavailable after that prime.tests/test_issue2628_cli_sessions_perf.py: update the source-shape guard to the missing-index gate, keep the resumed-old-session coverage, and add a deterministic progress-budget proof that compares the old correlated ordering against the new fallback on a read-only missing-index database.Why It Matters
This fixes the cold cron fallback that still goes quadratic on degraded or read-only stores, without regressing the normal indexed sidebar path. Cron-heavy installs keep the same rows and ordering, but the missing-index branch no longer pays one latest-message lookup per session row.
Verification
pytest tests/test_issue2628_cli_sessions_perf.py tests/test_issue3887_index_prime.py tests/test_issue3172_cron_session_limit.py tests/test_issue3930_source_filter_pushdown.py tests/test_issue3585_cron_session_overflow.py -v --timeout=60Full-suite CI context, not a required local check unless requested:
pytest tests/ -v --timeout=60.Upstream
Follow-up for #4842.
Attribution: Nathan's request for help and Rod Boev's profiling plus proposed SQL shape defined this slice.
Model Used
GPT 5.5 via Codex CLI