Add Needs-you queue and goal view with acceptance checks
- needs table: human steps, permission requests and agent questions wait
for an answer written to the database; a/c/d, y/Y/n, r keys in the TUI
- goal view (g): task graph, critical path, decisions, acceptance checks;
e edit goal, + add check, R run all checks on main
- checks.rs: acceptance checks on a branch or on main in a clean worktree
- runner: wait for --after dependencies, one session in merge at a time,
all checks again on main after each merge
- orch goal / check / checks commands, ORCH_DB and {{repo}} for machine steps
- example machines merge with git merge --ff-only
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5b659fa8ba
commit
7bf0986640
16 files changed
+2551
-105
No files matched your search
+89
-7
@@ -64,12 +64,45 @@ pub struct Row {
|
||||
pub last: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub enum NeedKind {
|
||||
/// A `human` step (review gate): approve or send back with a comment.
|
||||
Review,
|
||||
/// hx asks to run a tool: allow once, always, or deny.
|
||||
Permission,
|
||||
/// hx asks a question: reply with text.
|
||||
Input,
|
||||
/// The session ended in `escalated`. Derived from the session, nothing to answer in the queue.
|
||||
Escalated,
|
||||
}
|
||||
|
||||
/// One item of the Needs-you box.
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Need {
|
||||
/// Row id in the `needs` table; 0 for derived items.
|
||||
pub id: i64,
|
||||
pub kind: NeedKind,
|
||||
pub session: String,
|
||||
pub task: String,
|
||||
/// `review ready`, `permission`, `question`, `escalated`.
|
||||
pub what: String,
|
||||
pub detail: String,
|
||||
pub age_secs: u64,
|
||||
}
|
||||
|
||||
impl Need {
|
||||
/// The key line under the item, like `[y] allow once [Y] always for s4 [n] deny`.
|
||||
pub fn keys(&self) -> String {
|
||||
match self.kind {
|
||||
NeedKind::Review => "[a] approve [d] open diff [c] comment back".into(),
|
||||
NeedKind::Permission => format!(
|
||||
"[y] allow once [Y] always for {} [n] deny",
|
||||
self.session
|
||||
),
|
||||
NeedKind::Input => "[r] reply".into(),
|
||||
NeedKind::Escalated => String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
@@ -106,6 +139,11 @@ pub struct Input<'a> {
|
||||
pub events: &'a [Event],
|
||||
/// Loaded machine files by name; a missing one only costs the strip.
|
||||
pub machines: &'a HashMap<String, Machine>,
|
||||
/// Unanswered items of the Needs-you queue, oldest first.
|
||||
pub needs: &'a [crate::db::NeedRow],
|
||||
/// Acceptance checks with their last result on main.
|
||||
pub checks: &'a [crate::db::CheckRow],
|
||||
pub decisions: &'a [crate::db::DecisionRow],
|
||||
pub now_ms: u64,
|
||||
}
|
||||
|
||||
@@ -126,6 +164,31 @@ pub fn build(i: &Input) -> Overview {
|
||||
.find(|t| t.id == sid)
|
||||
.map_or_else(String::new, |t| t.name.clone())
|
||||
};
|
||||
let mut escalated = vec![];
|
||||
for n in i.needs {
|
||||
let Some(task) = i
|
||||
.sessions
|
||||
.iter()
|
||||
.find(|s| s.id == n.session)
|
||||
.and_then(|s| i.tasks.iter().find(|t| t.id == s.task_id))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let text = |k: &str| n.payload[k].as_str().unwrap_or_default().to_string();
|
||||
o.needs.push(Need {
|
||||
id: n.id,
|
||||
kind: match n.kind.as_str() {
|
||||
"permission" => NeedKind::Permission,
|
||||
"input" => NeedKind::Input,
|
||||
_ => NeedKind::Review,
|
||||
},
|
||||
session: n.session.clone(),
|
||||
task: task.name.clone(),
|
||||
what: text("title"),
|
||||
detail: text("detail"),
|
||||
age_secs: i.now_ms.saturating_sub(n.at) / 1000,
|
||||
});
|
||||
}
|
||||
for s in i.sessions {
|
||||
let Some(task) = i.tasks.iter().find(|t| t.id == s.task_id) else {
|
||||
continue;
|
||||
@@ -155,17 +218,18 @@ pub fn build(i: &Input) -> Overview {
|
||||
}
|
||||
_ => evs.last().map_or_else(String::new, |e| describe(e)),
|
||||
};
|
||||
if status == Status::Wait {
|
||||
o.needs.push(Need {
|
||||
if s.status == "escalated" {
|
||||
let end = evs.iter().rev().find(|e| e.kind == "end");
|
||||
escalated.push(Need {
|
||||
id: 0,
|
||||
kind: NeedKind::Escalated,
|
||||
session: s.id.clone(),
|
||||
task: task.name.clone(),
|
||||
what: s.status.clone(),
|
||||
detail: evs
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|e| e.kind == "end")
|
||||
what: "escalated".into(),
|
||||
detail: end
|
||||
.and_then(|e| e.payload["reason"].as_str().map(String::from))
|
||||
.unwrap_or_default(),
|
||||
age_secs: end.map_or(0, |e| i.now_ms.saturating_sub(e.at) / 1000),
|
||||
});
|
||||
}
|
||||
match status {
|
||||
@@ -192,6 +256,15 @@ pub fn build(i: &Input) -> Overview {
|
||||
last,
|
||||
});
|
||||
}
|
||||
o.needs.extend(escalated);
|
||||
if !i.checks.is_empty() {
|
||||
let green = i
|
||||
.checks
|
||||
.iter()
|
||||
.filter(|c| c.last_status.as_deref() == Some("pass"))
|
||||
.count();
|
||||
o.checks = Some((green, i.checks.len()));
|
||||
}
|
||||
o.events = i
|
||||
.events
|
||||
.iter()
|
||||
@@ -522,6 +595,9 @@ mod tests {
|
||||
sessions: &sessions,
|
||||
events: &events,
|
||||
machines: &m,
|
||||
needs: &[],
|
||||
checks: &[],
|
||||
decisions: &[],
|
||||
now_ms: 20_000,
|
||||
});
|
||||
let r = &o.rows[0];
|
||||
@@ -564,6 +640,9 @@ mod tests {
|
||||
sessions: &sessions,
|
||||
events: &events,
|
||||
machines: &m,
|
||||
needs: &[],
|
||||
checks: &[],
|
||||
decisions: &[],
|
||||
now_ms: 0,
|
||||
});
|
||||
assert_eq!(o.rows[0].retry, "");
|
||||
@@ -599,6 +678,9 @@ mod tests {
|
||||
sessions: &sessions,
|
||||
events: &events,
|
||||
machines: &m,
|
||||
needs: &[],
|
||||
checks: &[],
|
||||
decisions: &[],
|
||||
now_ms: 61_000,
|
||||
});
|
||||
let s: Vec<_> = o.rows.iter().map(|r| r.status).collect();
|
||||
|
||||
Reference in new issue
Block a user