Add loop detector, budgets, and live session control

Milestone 8: the loop detector alerts when test failures repeat, budget
caps limit context/cost/wall-time per session with compaction support,
and live control lets you interrupt, message, or kill a running session
from the TUI. Decisions can now be vetoed, which sends hx/message and
rewinds the session to code. All 82 tests pass.

- src/budget.rs: pure functions for active time, budgets and loop detect
- src/runner.rs: Ctl control object polls for commands ~100ms, handles
  interrupt/message/abort/stop at every blocking point, re-runs on
  hints, and compacts when context is high
- src/db.rs: commands table for TUI→runner control
- src/detail.rs, src/goal.rs, src/tui/: loop detector box, budget caps,
  session keys (i/m/s/k/r), goal keys (v for veto), state forcing
- tests/fake_acp_hx.py: slow mode and hx/message, hx/compact log
- examples/machines/task.toml: [budget] with wall_secs, cost, compact_at

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
johannesandClaude Haiku 4.5 committed 2026-11-14 12:55:44 +01:00
1 parent 7bf0986640
commit bf609c2e0e
16 files changed
+1694 -55

No files matched your search

+7
View File
@@ -54,6 +54,8 @@ pub struct Row {
pub chips: Vec<Chip>,
/// `↻ fix 2/3` while the session recovers from a catch, else empty.
pub retry: String,
/// The loop detector fired: the last test runs failed on the same tests.
pub looping: bool,
/// `39/41 ✗2`, `18/18 ✓` or `—`.
pub tests: String,
pub tests_ok: Option<bool>,
@@ -248,6 +250,7 @@ pub fn build(i: &Input) -> Overview {
machine: machine.map_or_else(|| task.machine.clone(), |m| format!("{}.toml", m.name)),
chips: scan.chips,
retry: scan.retry,
looping: scan.looping,
tests: scan.tests.0,
tests_ok: scan.tests.1,
added: scan.added,
@@ -286,6 +289,7 @@ pub fn build(i: &Input) -> Overview {
struct Scan {
chips: Vec<Chip>,
retry: String,
looping: bool,
tests: (String, Option<bool>),
added: u32,
removed: u32,
@@ -304,6 +308,7 @@ fn scan(evs: &[&Event], s: &Session, machine: Option<&Machine>) -> Scan {
let mut sc = Scan {
chips: vec![],
retry: String::new(),
looping: false,
tests: ("—".into(), None),
added: 0,
removed: 0,
@@ -394,6 +399,8 @@ fn scan(evs: &[&Event], s: &Session, machine: Option<&Machine>) -> Scan {
};
}
}
sc.looping =
matches!(s.status.as_str(), "running" | "waiting") && crate::budget::looping(evs).is_some();
sc
}