Skip to main content

Module runner

Module runner 

Source
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§

AuditContext
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_id to the most recently completed real phase (the same id Event::SweepStarted uses) so the running attempts counter still keys on a real phase id.
Runner
Per-phase orchestrator.

Enums§

AuditContextKind
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.
HaltReason
Why the runner stopped advancing the plan.
PhaseResult
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 more footer. Lower than STALE_ITEMS_PROMPT_CAP because 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 items entries 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 a TokenUsage under the supplied Config.
fresh_run_state
Build a fresh RunState for 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.