Skip to content
fieldingPublic

About

Event logging system for multi-agent orchestration

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vent - Event Stream

A lightweight event logging system for multi-agent orchestration. Unlike box (addressed messages between agents), vent captures unaddressed system events for observability and debugging.

Philosophy

Box is mail: sender → recipient, with subjects and threading. Vent is a stream: "this happened" with no recipient.

Use vent for:

  • System events (phase transitions, timeouts, circuit breakers)
  • Agent lifecycle (started, stopped, stuck detection)
  • Performance data (timing, costs, resource usage)
  • Debugging breadcrumbs ("about to call API", "received 3 results")

Don't use vent for:

  • Agent-to-agent communication (use box)
  • Things that are already captured in box messages

Usage

vent init                                    # Create .vent store

# Emit events
vent emit orchestrator "agents launched"
vent emit opus "starting code review"
vent emit orchestrator "phase transition" --data '{"from": "review", "to": "discussion"}'
vent emit monitor "agent stuck" --level warn --data '{"agent": "gpt", "idle_seconds": 120}'

# Query events
vent tail                                    # Watch events in real-time
vent tail --source opus                      # Filter by source
vent list                                    # Recent events (last 100)
vent list --since 5m                         # Events from last 5 minutes
vent list --source orchestrator              # Filter by source
vent list --level warn                       # Filter by level

# Search
vent search "stuck"                          # Full-text search
vent search "phase" --source orchestrator

Data Model

Event:
  id: string (evt_ULID)
  source: string              # Who/what emitted this event
  message: string             # Human-readable description
  level: "debug" | "info" | "warn" | "error"  # Default: info
  data: json?                 # Optional structured data
  created_at: ISO8601

Storage

Walk up for .vent/ directory or use VENT_STORE env var.

  • events.jsonl — Append-only source of truth (git-friendly).
  • events.db — A rebuildable SQLite + FTS5 index derived from the JSONL. Delete it and the next vent invocation will rebuild it from scratch.

On startup, SQLite is caught up from the JSONL if they've drifted (same pattern as tix and box). The JSONL is authoritative; the db is a cache.

Concurrency

vent is designed so many processes on the same machine can emit into the same store at the same time without corrupting the JSONL or losing events. The test suite includes a load-bearing multi-process test (8 concurrent shells × 25 emits each, then full DB rebuild from JSONL) that asserts this.

How multi-writer emit works

  1. JSONL append is atomic per record. Each emit opens events.jsonl with O_APPEND | O_CREAT | O_WRONLY and performs a single write() for the whole record. POSIX guarantees that on a regular file opened with O_APPEND, each write() atomically seeks to end-of-file and writes, as long as the payload fits in PIPE_BUF (4096 bytes on Linux and macOS). vent caps records at 4096 bytes; anything larger fails with exit code 7 (RecordTooLarge) rather than risk a torn write.
  2. SQLite is serialized by WAL + busy_timeout. Each process opens its own connection in WAL mode with a 30-second busy timeout, and emit does a bounded exponential backoff retry on SQLITE_BUSY for the odd checkpoint race on a fresh store.
  3. ULIDs are pid-seeded. The ULID generator mixes the pid into its seed so several forked writers in the same millisecond don't collide on the primary key.
  4. The SQLite file is not load-bearing. If you delete events.db after a crash or a weird interleave, the next Store.open rebuilds everything from the JSONL, including --data payloads.

What is not supported

Do not share a .vent store across machines over a network filesystem (NFS, SMB, SSHFS, iCloud Drive, Dropbox, Google Drive, etc.). It will corrupt eventually.

  • O_APPEND atomicity is not guaranteed on network filesystems. Two machines appending can interleave or lose bytes.
  • SQLite WAL mode explicitly does not work over network filesystems — the -wal/-shm files rely on shared-memory semantics that network fs don't provide. See sqlite.org/wal.html. events.db will corrupt.

If you need two machines to observe the same event stream, run one .vent store per machine and ship events between them out-of-band (e.g., another process that tails one JSONL and replays lines into the other). vent itself is intentionally a single-machine tool.

Output Formats

vent list                      # Human-readable (default)
vent list --json               # Machine-readable JSON
vent list --jsonl              # Streaming JSONL

Human-readable format:

10:01:15 [info] orchestrator: agents launched
10:02:33 [info] opus: starting code review
10:02:46 [info] orchestrator: phase transition {"from": "review", "to": "discussion"}
10:05:12 [warn] monitor: agent stuck {"agent": "gpt", "idle_seconds": 120}

Integration Patterns

Orchestrator Event Logging

vent emit orchestrator "starting review session" --data "{\"pr\": \"$PR_NUM\"}"
# ... launch agents ...
vent emit orchestrator "agents launched" --data "{\"agents\": [\"opus\", \"gpt\", \"gemini\"]}"

# Monitor loop
while true; do
    if stuck_detected; then
        vent emit monitor "agent stuck" --level warn --data "{\"agent\": \"$agent\"}"
    fi
    sleep 15
done

Agent Breadcrumbs

# In agent prompt: "Use vent emit to record significant actions"
vent emit opus "found 3 potential issues"
vent emit opus "reading file" --data '{"path": "src/auth.ts"}'
vent emit opus "submitting verdict" --data '{"verdict": "MERGE"}'

Debugging Failed Runs

# What happened in the last 10 minutes?
vent list --since 10m

# What did the orchestrator do?
vent list --source orchestrator

# Any warnings or errors?
vent list --level warn
vent list --level error

# Search for specific issues
vent search "timeout"
vent search "circuit breaker"

Correlation with Box

# Get timeline of events
vent list --since 30m --json > events.json

# Get messages from same period
box list --since 30m --json > messages.json

# Merge and analyze (or use the TUI viewer)

Environment Variables

  • VENT_STORE - Path to .vent directory (default: walk up from cwd)

Exit Codes

Scripts can match on these stable codes:

Code Meaning
0 Success
1 Generic / uncategorized error
2 Usage error (bad flags, missing args)
3 Store not found — run vent init
4 Event not found
5 Ambiguous event id prefix
6 --data is not valid JSON
7 Record exceeds the 4096-byte atomic-append cap
8 Database busy (retry)

Design Notes

Why Not Just Use Box?

Box has sender/recipient semantics. Events like "timeout occurred" or "circuit breaker triggered" don't have a natural recipient. Forcing them into box's model muddies the abstraction.

Why Not Just Print to Stderr?

You could, but:

  • No persistence across sessions
  • No structured data
  • No querying/filtering
  • No correlation with other events

Relationship to TUI Viewer

vent is the agent-facing tool for emitting and querying events. The TUI viewer (separate tool) provides a human-facing dashboard that merges vent events, box messages, and tix tickets into a unified timeline.

Building

Requires Zig 0.16 (the new std.Io APIs). Zig 0.15 will not compile.

cd ~/src/hack/vent
zig build -Doptimize=ReleaseFast

Binary placed in ./zig-out/bin/vent.

Run the test suite (library tests + a multi-process concurrency test that shells out to the installed binary):

zig build test

Part of sprawl

vent is part of sprawl, a collection of composable tools for multi-agent orchestration.

Tool Description
tix Lightweight issue tracker
box Mailbox messaging for agent-to-agent communication
hold Block until a condition is met
mon TUI monitor for humans

License

MIT

About

Event logging system for multi-agent orchestration

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages