Expand description
Tier-1 ephemeral session: a content-addressed snapshot DAG with a HEAD
pointer and a redo stack, persisted under session_dir(doc_id).
Records are STATE snapshots (full content), never operation logs — so an external change (git checkout, hand-edit) is captured as a normal snapshot and is therefore undoable. Undo/redo (next unit) are pure pointer moves over this DAG; this unit provides the state file plus state-recording and current-content readback.
Structs§
- Session
State - The mutable pointer state for a session: HEAD and the redo stack.
Persisted to
state.jsoninsidesession_dir(doc_id).
Enums§
- Record
Outcome - The outcome of a
record_statecall.
Functions§
- clear_
session - Discard all Tier-1 session state for
doc_id(called on workspace close). Idempotent: a no-op if no session exists. Durable Tier-2 history is unaffected. - current_
content - The full content of the current HEAD snapshot, or
Noneif the session is empty (no states recorded yet). - record_
state - Record the current
contentas a new state snapshot fordoc_id. - redo
- Redo: move HEAD forward to the most-recently-undone snapshot. Returns the
content now at HEAD, or
Noneif the redo stack is empty. - undo
- Undo: move HEAD to its parent snapshot. Returns the content now at HEAD, or
Noneif the session is empty or already at the root (nothing to undo). The record we left is pushed onto the redo stack soredocan return to it.