Expand description
Lifecycle guard for ThreadEvent streams.
The turn and item lifecycle used to be enforced only by call-site
convention, so each violation was repaired by hand where it was noticed
(item.completed after turn.completed, item.completed repeated for one
item, a turn that failed before it started). LifecycleGuard is the one
place that knows the rules. Every emitter funnel passes events through
LifecycleGuard::admit; the pure audit runs the same rules over a
recorded stream.
The guard is pure state: no I/O, no clock, no locking. Callers own the synchronization (the interactive emitter already serializes emission).
§Rules
- An item that was started inside a turn is completed before that turn’s terminal event. Open items are closed by the guard when a producer forgot.
- An item id completes at most once. A repeat is dropped.
- A terminal turn event without a started turn gets a
turn.startedfirst. turn.blockedannotates a turn and never ends it, so the interactive loop (failed, blocked) and the runner (blocked, failed) orderings are both valid.- Harness and error items, items with no
item.started, and exec-session output items are exempt: they legitimately occur outside a turn or outlive one.
Structs§
- Admission
- Result of admitting one event.
- Lifecycle
Guard - Tracks the turn and item lifecycle of one event stream.
- Violation
- One lifecycle violation and the item it concerns, when there is one.
Enums§
- Repair
Policy - What the guard does when it can repair a violation.
- Violation
Kind - A broken lifecycle rule.
Constants§
- EXEC_
SESSION_ OUTPUT_ ITEM_ SUFFIX - Suffix of the item id that tracks a still-running exec session’s output.
Functions§
- audit
- Run the lifecycle rules over a recorded stream without repairing it.