Expand description
Cross-process poll leader election.
InstanceLock (see crate::runtime::change_processor) guards single TUI
ownership but is only meaningful for interactive sessions. The poll loop,
however, must be a single writer across processes — an MCP server and a
agent-trace open TUI started against the same store would otherwise both
run a poll loop and duplicate commits / summary_events.jsonl entries.
PollLock provides that election with an OS-level advisory lock (flock on
Unix) over .agent-trace/locks/poll.lock. The first acquirer becomes the
poll leader; subsequent acquirers get None and fall back to HEAD-only
updates. The lock is released when the PollLock is dropped (the file
descriptor closes), so a crashed leader does not leave a stale lock.
Structs§
- Poll
Lock - Advisory, cross-process lock that elects a single poll-loop writer.