Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Mission API: checks_summary.required_needs_approval

Lin (kwant bot)91110d63da82
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11bf18bf..5a36321b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
optional check".
- **Deciding for you costs fewer tokens.** Before deciding a choice itself, a bot now hears at most one
teammate, and only when the choice or an open check names that teammate.
+- **Mission API: `checks_summary.required_needs_approval`.** Counts the required checks waiting for
+ your OK, so a card can tell "needs you" from "a required check is still running while an optional
+ one waits".
## [Mac 0.1.3] - 2026-10-26
diff --git a/docs/mission-control.md b/docs/mission-control.md
index 3676a618..a8cf4390 100644
--- a/docs/mission-control.md
+++ b/docs/mission-control.md
@@ -126,8 +126,11 @@ outcome_checks(id, task_id, kind, spec JSON, required, approved, status, output_
- A task with no checks stays in `review` ("not checked") until a peer review or the person verifies it.
`checks_summary` on each task: `{"status": "not_checked" | "pending" | "passed" | "failed",
-"passed": n, "failed": n, "needs_approval": n, "total": n}`. `passed`/`failed` count checks that
-count; `needs_approval` counts checks waiting for the person. `status` is `passed` only when the task
+"passed": n, "failed": n, "needs_approval": n, "required_needs_approval": n, "total": n}`.
+`passed`/`failed` count checks that count; `needs_approval` counts checks waiting for the person, and
+`required_needs_approval` how many of those are required (so hold the task in `review`). A card shows
+"Needs you" only when `required_needs_approval > 0`; `status: "pending"` with
+`required_needs_approval: 0` means a required check is still running, not that the person is needed. `status` is `passed` only when the task
could be verified on them, and `pending` while a required check waits for approval (an optional
one waiting is counted in `needs_approval` but doesn't hold the task).
@@ -200,7 +203,7 @@ claim conflict), 403 (bot token on a person route).
"depends_on": ["task id"], "waiting_on": ["task id not verified yet"],
"claim": null | {"kwant_id","claimed_at","expires_at"},
"needs_you": [{"kind": "question"|"approval"|"human_step"|"check_approval", "id", "text"}],
- "checks_summary": {"status","passed","failed","needs_approval","total"}}
+ "checks_summary": {"status","passed","failed","needs_approval","required_needs_approval","total"}}
// needs_you: question/approval/human_step while working or needs_you; check_approval (id = the
// check's id, approve it with POST /api/checks/:id/approve) while in review
diff --git a/frontend/src/missions.ts b/frontend/src/missions.ts
index ba34991d..977e9959 100644
--- a/frontend/src/missions.ts
+++ b/frontend/src/missions.ts
@@ -59,6 +59,8 @@ export interface ChecksSummary {
failed: number;
/** Checks waiting for the person to allow them (older servers leave it out). */
needs_approval?: number;
+ /** How many of `needs_approval` are required, so hold the task (older servers leave it out). */
+ required_needs_approval?: number;
total: number;
}
diff --git a/src/server/missions/mod.rs b/src/server/missions/mod.rs
index 1fab60ec..197610a7 100644
--- a/src/server/missions/mod.rs
+++ b/src/server/missions/mod.rs
@@ -339,12 +339,14 @@ pub async fn evaluate(state: &AppState, task_id: &str) -> Option<Task> {
}
/// `checks_summary` of a task: `passed` only when [`verdict`] could pass on them. Counts the
-/// checks that count (see [`counts`]); `needs_approval` is how many wait for the person.
+/// checks that count (see [`counts`]); `needs_approval` is how many wait for the person, and
+/// `required_needs_approval` how many of those are required, so hold the task.
pub fn checks_summary(task: &Task, checks: &[OutcomeCheck]) -> Value {
let live: Vec<&OutcomeCheck> = checks.iter().filter(|c| counts(task, c)).collect();
let waiting = checks.iter().filter(|c| !c.approved).count();
// An optional check waiting for approval is listed but doesn't hold the task (see [`verdict`])
- let holding = checks.iter().any(|c| c.required && !c.approved);
+ let required_waiting = checks.iter().filter(|c| c.required && !c.approved).count();
+ let holding = required_waiting > 0;
let gating = |c: &&&OutcomeCheck| c.required;
let passed = live.iter().filter(|c| c.status == "passed").count();
let failed = live.iter().filter(gating).filter(|c| matches!(c.status.as_str(), "failed" | "error")).count();
@@ -357,7 +359,14 @@ pub fn checks_summary(task: &Task, checks: &[OutcomeCheck]) -> Value {
} else {
"passed"
};
- json!({"status": status, "passed": passed, "failed": failed, "needs_approval": waiting, "total": checks.len()})
+ json!({
+ "status": status,
+ "passed": passed,
+ "failed": failed,
+ "needs_approval": waiting,
+ "required_needs_approval": required_waiting,
+ "total": checks.len(),
+ })
}
// Budget
@@ -1009,6 +1018,22 @@ mod tests {
assert_eq!(verdict(&t, &[both[0].clone(), waiting], None), Verdict::Pass);
}
+ #[test]
+ fn summary_tells_a_required_waiting_check_from_an_optional_one() {
+ let t = task("bot-a");
+ let mut waiting = check("http", "needs_approval", None, true);
+ (waiting.approved, waiting.approved_by) = (false, None);
+ let s = checks_summary(&t, &[waiting.clone()]);
+ assert_eq!((s["needs_approval"].as_u64(), s["required_needs_approval"].as_u64()), (Some(1), Some(1)));
+ assert_eq!(s["status"], "pending");
+ // A required check still running plus an optional one waiting: pending, but not on the person
+ waiting.required = false;
+ let s = checks_summary(&t, &[check("command", "running", None, true), waiting.clone()]);
+ assert_eq!(s["status"], "pending");
+ assert_eq!((s["needs_approval"].as_u64(), s["required_needs_approval"].as_u64()), (Some(1), Some(0)));
+ assert_eq!(checks_summary(&t, &[])["required_needs_approval"], 0);
+ }
+
#[test]
fn an_old_review_doesnt_count_after_rework() {
let t = task("bot-a");