Files
hermes-agent/persistence/sqlite
kshitijk4poor 0389da0f73 fix(session_search): recovered tool output survives re-compaction, scrolls, and image turns stay searchable
Three gaps in the recovery path (Greptile review on b2e4cc36cc):

- A demoted tool result's full original was matched only while its stub
  was live. A later compaction archives the stub, so the original
  (active=0, compacted=0) dropped out of every search. The superseded test
  now accepts a live OR archived twin with the same message_uid and
  different content (SUPERSEDED_ORIGINAL_SQL, shared by search and
  message_storage_state).
- Scrolling to such an original was rejected as "already in your active
  context". MessageStorageState gains `superseded`, and the scroll guard
  treats a superseded original like an archived row.
- The footer's all-role search sent every role down the tool route's
  stored-row LIKE scan, which can't read structured content, so a keyword
  in an archived image turn's caption was unreachable. Conversation roles
  and the tool role now search separately (word index vs full-body scan)
  and interleave; discovery and the in-session shape share that helper.

Tests: re-compaction and scroll cases on the verbatim stub call, an image
turn on the verbatim footer call, and the contract case covers the
archived-twin original and the `superseded` flag on both backends.
2026-11-26 18:09:15 -08:00
..