Files
hermes-agent/tests/persistence_sqlite
outpoints aee57c0538 fix(persistence/sqlite): lineage transcript reads no longer sort through a temp b-tree
Reading a compressed session's transcript ran
`SELECT ... FROM messages WHERE session_id IN (...) ORDER BY id`.
`idx_messages_session_id` returns the rows grouped by session, so SQLite
sorted the full selected rows in a temp b-tree and spilled it to temp
files once it passed `cache_size`. One 120-row Desktop page of a
15-segment lineage wrote about 170 MB.

Select the matching ids first and fetch the rows by rowid. SQLite walks
the id list in ascending order, so `ORDER BY id` needs no sort. The rows
and their order are unchanged.

`_lineage_rows_sql` builds the query for `get_messages` (lineage
branch), `_fetch_conversation_rows`, `_with_removed_identities` and
`worker_history`. The new test traces the SQL the lineage readers run
and fails on any plan with a temp b-tree.

Fixes #160277
2026-11-29 19:52:01 +01:00
..