Skip to main content

Module session

Module session 

Source
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:

  • SessionWriterzag-agent/src/session_log.rs:344 SessionLogWriter
  • SessionCoordinatorzag-agent/src/session_log.rs:565 SessionLogCoordinator
  • SessionLogEventzag-agent/src/session_log.rs:182 AgentLogEvent
  • SessionLogIndexzag-agent/src/session_log.rs:197 SessionLogIndex
  • GlobalSessionIndexzag-agent/src/session_log.rs:225 GlobalSessionIndex

On-disk layout (mirrors ~/.zag/... byte-for-byte):

~/.zig/
  projects/<sanitized-project-path>/logs/
    index.json
    sessions/<zig_session_id>.jsonl
  sessions_index.json

Structs§

GlobalSessionEntry
Global cross-project index entry (~/.zig/sessions_index.json).
GlobalSessionIndex
SessionCoordinator
Wraps a SessionWriter in an Arc and runs a background thread that emits a Heartbeat event every 10 seconds. The handle’s Drop impl stops the heartbeat thread and stamps ended_at defensively if finish() was never called (crash/panic safety).
SessionLogEvent
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.
SessionLogIndex
SessionLogIndexEntry
Per-project session index entry (<project>/logs/index.json).
SessionWriter
Append-only writer for a single zig session log file.

Enums§

OutputStream
Stream identifier for step_output events.
SessionEventKind
Event payload variants. The envelope (SessionLogEvent) carries seq, ts, and zig_session_id; this enum carries the type-specific fields.
SessionStatus
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