Expand description
Zig session log: a recorded execution of zig run.
A zig session is the parent layer above the zag session log: one zig session orchestrates many child zag sessions (one per workflow step). This module owns the writer, event schema, and on-disk index.
Mirrors zag’s session logging architecture so the two stay structurally aligned and conceptually transferable. Key analogs:
SessionWriter↔zag-agent/src/session_log.rs:344SessionLogWriterSessionCoordinator↔zag-agent/src/session_log.rs:565SessionLogCoordinatorSessionLogEvent↔zag-agent/src/session_log.rs:182AgentLogEventSessionLogIndex↔zag-agent/src/session_log.rs:197SessionLogIndexGlobalSessionIndex↔zag-agent/src/session_log.rs:225GlobalSessionIndex
On-disk layout (mirrors ~/.zag/... byte-for-byte):
~/.zig/
projects/<sanitized-project-path>/logs/
index.json
sessions/<zig_session_id>.jsonl
sessions_index.jsonStructs§
- Global
Session Entry - Global cross-project index entry (
~/.zig/sessions_index.json). - Global
Session Index - Session
Coordinator - Wraps a
SessionWriterin anArcand runs a background thread that emits aHeartbeatevent every 10 seconds. The handle’sDropimpl stops the heartbeat thread and stampsended_atdefensively iffinish()was never called (crash/panic safety). - Session
LogEvent - Event envelope written to the JSONL log. Field naming mirrors zag’s
AgentLogEvent(zag-agent/src/session_log.rs:182):seq,ts, plus a session id and a flattened kind discriminator. - Session
LogIndex - Session
LogIndex Entry - Per-project session index entry (
<project>/logs/index.json). - Session
Writer - Append-only writer for a single zig session log file.
Enums§
- Output
Stream - Stream identifier for
step_outputevents. - Session
Event Kind - Event payload variants. The envelope (
SessionLogEvent) carriesseq,ts, andzig_session_id; this enum carries the type-specific fields. - Session
Status - Final status of a zig session.
Functions§
- find_
session - Find a session by ID (or unique prefix) and return its index entry.
- list_
sessions - List all sessions from the project index.
- load_
global_ index - load_
project_ index - read_
session_ events - Read all events from a session JSONL log file.
- save_
global_ index - save_
project_ index