Skip to main content

Module event_log

Module event_log 

Source
Expand description

Per-run append-only event log.

Every omne run writes its lifecycle events to .omne/var/runs/<run_id>/events.jsonl — one Event per line as canonical JSON. There is deliberately no shared global log: each run is its own independent stream (plan R3, Mutability notes). This keeps parallel runs’ logs disjoint and makes Unit 13 omne status a filesystem walk, not a parse-and-split.

Atomicity layers, in order:

  1. The file is opened append + create, so each write call is positioned at the current end-of-file by the kernel, not by the writer’s cached cursor. POSIX guarantees that a single write up to PIPE_BUF is atomic against other append writers; the event-line sizes we emit (hundreds of bytes) clear that bar comfortably. Windows’ FILE_APPEND_DATA gives the same guarantee.
  2. A per-instance Mutex<File> serializes appends inside this process so we don’t rely on OS-level atomicity for multi-line bursts or flush ordering.
  3. An fs2 advisory exclusive lock (same helper shape as crate::ulid) serializes appends across processes — the MCP server planned for post-v1 and any other tool that might open the same file.

Lock acquisition uses a 5-second default budget, same as the ULID allocator. Exceeding the budget returns Error::LockTimeout.

Structs§

EventLog
A long-lived writer for one run’s events.jsonl.

Enums§

Error

Constants§

DEFAULT_LOCK_TIMEOUT
Default budget for acquiring the per-file advisory lock. Matches the ULID allocator so callers can reason about one deadline model across both subsystems.

Functions§

enumerate_runs
Enumerate run IDs by walking .omne/var/runs/.
read_run
Read every event in one run’s events.jsonl, in order.
run_exists
Check whether a run’s directory exists. Convenience for preflight paths (omne run collision detection, omne status lookup) that want a typed boolean rather than a read_dir probe.