Add session message archive table + global sequence_number tracking
Schema:
- session_messages_archive — identical structure, stores old messages.
- sessions.next_sequence    — monotonic seq counter per session.
- sessions.archive_threshold — split point between hot and archive.

Behaviour:
- get() / _build_sessions() load only seq >= archive_threshold (hot).
- save() UPDATEs existing rows (seq >= 0) and INSERTs new ones (seq = -1)
  with auto-assigned sequence_number = next_sequence, next_sequence+1, ...
- archive_old_messages() moves a batch to archive and bumps the threshold.

This keeps the hot table bounded so list/get RAM stays flat regardless
of total session history size.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent cb22a1d commit c7c0479d4b487156b4044593bdf107de9215ef74
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 25 May
Showing 3 changed files
View
navi/core/pg_session_store.py
View
navi/core/session.py
View
navi/llm/base.py