Expand description
Session storage: one SQLite database per state directory, one row per message.
Why a database rather than the JSONL files this used to write: listing sessions, finding
one by what was said in it, keeping a title or a memory summary beside it, and pruning by
age are all index problems. Doing them by walking files meant an O(sessions) read of
every transcript to render a list, and sidecar files that could be orphaned by a rename
or a delete. The database is sessions.db in the session directory, 0600, WAL so a
reader never blocks a write.
Old .jsonl transcripts are imported once, in one transaction, and left on disk: a
database that turns out to be wrong must never be the reason someone’s transcript is
gone. export still produces the JSONL shape, which makes it the interchange format.
Structs§
- BotSessions
- One bot’s conversations, as the Bots tab reads them (
#509). - Flare
JobRow - One child of a run, as the ledger keeps it.
- Flare
Origin - What a flare session says about itself: the run that started it and its position in that run.
- Flare
RunRow - One flare run’s ledger row (
#171) — whatflares listprints and what a cancel addresses. - Handoff
- The deterministic handoff compiled from the dropped middle, stored beside the summary so the work is done once per covered range rather than once per request.
- Held
Lock - A session some process is running right now, as seen by
held_locks. - Judgement
- One accepted judgement pass: what the model said about why, and which model said it.
- Memory
- Per-session memory, stored beside the transcript: the compiled handoff that stands in for the dropped middle of the conversation, and what range of the transcript it covers. It never replaces the transcript.
- Prune
Plan - What a retention policy would delete, and what it refuses to touch.
- Record
- Search
Hit - One search result: where the match is and enough text to recognise it.
- Session
Info - Session
Lock - A held session lock. Dropping it releases the lock (the OS does the same if the process dies, so a crash cannot leave a session permanently locked).
- Session
Store - Stale
Lock - A lock file nobody is holding: its holder is gone, so the kernel released the lock and the
file is left behind.
eclipse doctor --fixremoves these. - Subagent
Origin - What a subagent session says about itself: the session whose run started it and the route it ran on.
- Turn
Cost - What the last turn on a session cost, kept in the store so a row can be honest about a session nothing is running any more (#344).
Enums§
- Auto
Prune - Result of
SessionStore::auto_prune. - Export
Format - Title
Source - Who wrote a session’s title. The order is the precedence: a name a person typed is never replaced, a name a model wrote is replaced only by a person, and the derived name is a placeholder that either of the other two may take over.
Constants§
- LOCK_
WAIT - How long a run waits for another process to release a session before giving up.
- MEMORY_
VERSION - Schema of the stored memory.
1was the model-written summary alone and, having noversionfield, is what a file without one means;2adds the compiled handoff (Handoff), which is what lets a long session reuse one instead of recompiling it on every request. - PRUNE_
CONFIRM_ ABOVE - Pruning more sessions than this at once needs an explicit
--force(manual prune) and is refused outright bySessionStore::auto_prune.
Functions§
- ago_
words - How long ago a stored timestamp is, in the words a person would use.
0says nothing rather than claiming 1970: a session imported with no readable record has no time. - db_path
- The file a store keeps its sessions in, under the directory it was given.
- format_
utc - Format unix milliseconds as
YYYY-MM-DD HH:MM(UTC). - held_
locks - Which sessions in
dirare locked by a live run. - now_ms
- stale_
locks - The
<id>.lockfiles indirthat are not held by a live process. - validate_
id - Ids become file names, so only a conservative character set is accepted.