Skip to main content

Module log

Module log 

Source
Expand description

The append-only JSONL event log: SessionEventLog.

Mirrors the append + fsync pattern of zeph-durable’s JournalWriter (crates/zeph-durable/src/writer.rs) at the conversation-semantics level, but persists to a plain JSONL file rather than a SQLite-backed journal (spec-068 §3, §14).

§Invariants

  • INV-SP-1 (log-first ordering): callers must append to this log before updating any downstream projection (SQLite messages, acp_sessions.last_seq).
  • INV-SP-2 (torn-append truncation): every read validates each line and drops a garbled/ incomplete trailing line from the in-memory result, which can only occur as the very last line because appends are serialized through a single writer (INV-D2). Only SessionEventLog::open_exclusive additionally repairs the torn tail physically on disk — a lockless SessionEventLog::open/SessionEventLog::read_all cannot prove a “torn” line isn’t a live writer’s in-flight, not-yet-fsynced append, so it must never mutate the file (#5487 Finding B).
  • INV-D2 (single writer): only the session’s owning actor/agent process may hold a SessionEventLog for a given session directory at a time. SessionEventLog::open does not itself enforce cross-process exclusion — it is also used by read-only tooling (session export/inspection) that may legitimately run alongside a live writer. The session’s owning actor/agent process should instead use SessionEventLog::open_exclusive, which takes a non-blocking flock(2) advisory lock (Unix only) and fails with SessionError::AlreadyLocked if another writer already holds the session directory.

Structs§

SessionEventLog

Constants§

CHAIN_DOMAIN
Domain-separation tag for this subsystem’s hash chain (issue #6360) — distinct from zeph-subagent’s so a chain from one subsystem can never verify against the other.

Functions§

configure_anchor_store
Configure (or disable, with None) the vault-anchor store for every SessionEventLog operation in this process from this point forward.
configure_history_integrity
Configure (or disable, with None) history-chain verification for every SessionEventLog operation in this process from this point forward. See zeph_subagent::transcript::configure_history_integrity’s doc for the full contract — this mirrors it exactly.