Skip to main content

Module session

Module session 

Source

Structs§

KeepwarmTokens
Keep-warm token subtotal persisted in the snapshot (see Session::keepwarm_tokens).
ResolvedSession
Result of resolving a session that may have been compacted into a successor.
Session
SessionInfo
Lightweight info for listing sessions without loading full message history

Functions§

delete_session_file
Remove a persisted session file (compaction-transition rollback) AND its journal, when one exists (Task 35) — a session and its journal live and die together. A missing file is not an error — rollback must be idempotent.
find_session
Find a session by full or partial ID match
find_session_by_name
Find a session by its assigned name (not partial ID). Iterates session headers one file at a time and returns on first match, avoiding a full directory scan when the named session appears early.
follow_compaction_chain
Follow the compacted_into chain from session to its final successor. Returns the final session and a notice if any hops were taken. Errors on cycles, missing successors, or exceeding the hop limit.
latest_session
Load the most recently updated session
list_recent_sessions
The limit most-recently-modified sessions (by file mtime), most-recent first. Sorts the directory entries by mtime WITHOUT parsing, then reads only the top limit headers — so /sessions is O(limit) reads instead of O(#sessions). mtime is an exact proxy for updated_at (the file is rewritten on every save).
list_sessions
List all sessions, sorted by most recently updated.
read_compacted_into
Read only the compacted_into field from a session’s header on disk, without loading the full message history.
read_compacted_into_in_dir
Like read_compacted_into but for a caller-selected sessions directory.
resolve_session
Resolve a query string to a Session. Resolution order:
user_content_for_display
Project canonical user content for display/title/compaction, never for inference. Only top-level text and attachment labels are visible; in particular, tool results are NOT user prompts and their nested content is never traversed. The original message (including attachment sources) is left untouched.
validate_name
Validate a session or chain name: [a-z0-9-]{1,40}.