Skip to main content

Module session

Module session 

Source
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).
FlareJobRow
One child of a run, as the ledger keeps it.
FlareOrigin
What a flare session says about itself: the run that started it and its position in that run.
FlareRunRow
One flare run’s ledger row (#171) — what flares list prints 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.
HeldLock
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.
PrunePlan
What a retention policy would delete, and what it refuses to touch.
Record
SearchHit
One search result: where the match is and enough text to recognise it.
SessionInfo
SessionLock
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).
SessionStore
StaleLock
A lock file nobody is holding: its holder is gone, so the kernel released the lock and the file is left behind. eclipse doctor --fix removes these.
SubagentOrigin
What a subagent session says about itself: the session whose run started it and the route it ran on.
TurnCost
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§

AutoPrune
Result of SessionStore::auto_prune.
ExportFormat
TitleSource
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. 1 was the model-written summary alone and, having no version field, is what a file without one means; 2 adds 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 by SessionStore::auto_prune.

Functions§

ago_words
How long ago a stored timestamp is, in the words a person would use. 0 says 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 dir are locked by a live run.
now_ms
stale_locks
The <id>.lock files in dir that are not held by a live process.
validate_id
Ids become file names, so only a conservative character set is accepted.