Expand description
Orchestration loop and event channel.
The runner owns the per-phase state machine. It snapshots the planning
artifacts, dispatches the implementer agent, validates the agent’s output,
runs the project tests, and lands a per-phase commit. Every observable
transition is broadcast on a tokio::sync::broadcast channel so the CLI
logger and the (later) TUI can subscribe without changing the runner.
Phase 12 wired the implementer-only flow: agent → validate → tests → commit.
Phase 13 layers a bounded fixer loop on top: when the project tests fail,
the runner dispatches the fixer agent up to
crate::config::RetryBudgets::fixer_max_attempts times, re-running tests
after each attempt, before halting. Phase 14 inserts the auditor pass
between the (passing) test run and the per-phase commit: when
crate::config::AuditConfig::enabled is on the runner stages the
implementer’s diff, hands it to the auditor agent, re-validates the
planning artifacts, and re-runs the tests before letting the commit land.
Modules§
- sweep
- Deferred-sweep trigger logic.
Structs§
- Audit
Context - Payload threaded through the auditor events. Carries the phase id under
which the audit’s attempts are accounted plus the kind discriminator. Sweep
audits set
phase_idto the most recently completed real phase (the same idEvent::SweepStarteduses) so the running attempts counter still keys on a real phase id. - Runner
- Per-phase orchestrator.
Enums§
- Audit
Context Kind - Discriminator on
AuditContext. Tells subscribers whether the audit firing belongs to a regular plan phase or a deferred sweep so the TUI and loggers can render the right header text without inspecting state. - Event
- Streaming events the runner broadcasts to subscribers. Sends are best-effort: a lagging or absent subscriber never blocks the runner.
- Halt
Reason - Why the runner stopped advancing the plan.
- Phase
Result - Outcome of
Runner::run_phase. - RunSummary
- Outcome of
Runner::run.
Constants§
- EVENT_
CHANNEL_ CAPACITY - Capacity of the broadcast channel events fan out on. Enough that a slow subscriber falls behind by hundreds of events before lagging; sends are best-effort so a slow subscriber never blocks the runner.
- STALE_
ITEMS_ DISPLAY_ CAP - Cap on the number of stale items each operator-facing surface (the TUI
stale panel,
pitboss status) renders before truncating with a+N morefooter. Lower thanSTALE_ITEMS_PROMPT_CAPbecause vertical real estate on the operator’s screen is tighter than the auditor’s prompt budget. - STALE_
ITEMS_ PROMPT_ CAP - Cap on the number of stale
## Deferred itemsentries fed into the sweep and sweep-auditor prompts. Past this, the prompt would balloon without adding value: the agent can only meaningfully address a handful of “high-stakes” items per dispatch, and a runaway map (hundreds of stuck items) almost always means the staleness signal needs operator attention, not more agent passes.
Functions§
- budget_
totals - Compute
(total_tokens, total_usd)for aTokenUsageunder the suppliedConfig. - fresh_
run_ state - Build a fresh
RunStatefor a workspace that has not started a run yet. - log_
events - Subscribe to a runner’s event stream and print a human-readable line per event to stderr until a terminal event arrives or the channel closes.