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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Mission checks: approving a check on a verified task runs it
Lin (kwant bot)acde18cfe322
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5a36321b..76d3dbac 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -34,6 +34,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).- **Mission API: `checks_summary.required_needs_approval`.** Counts the required checks waiting foryour OK, so a card can tell "needs you" from "a required check is still running while an optionalone waits".+- **"Run this optional check" runs it.** Approving an optional check on a Verified task now runs the+ check and records whether it passed or failed, with its output. The task stays Verified either way+ and its spend doesn't change. Before, the check was only approved and never ran.## [Mac 0.1.3] - 2026-10-26diff --git a/docs/mission-control.md b/docs/mission-control.mdindex a8cf4390..b90bbfde 100644--- a/docs/mission-control.md+++ b/docs/mission-control.md@@ -179,6 +179,8 @@ POST /api/tasks/:id/cancel -> TaskPOST /api/tasks/:id/checks {kind, spec, required?} -> Check (approved, runs if the task is in review)POST /api/tasks/:id/checks/run -> {checks: [Check], task: Task}POST /api/checks/:id/approve -> Check (needs_approval -> runs)+ (runs in review or verified; on a verified task the+ result is recorded and the state never changes)```Errors: `{"error": "plain sentence"}` with 400 (bad input), 404, 409 (illegal transition, budget,diff --git a/src/server/missions/routes.rs b/src/server/missions/routes.rsindex 4bca1137..2bc845e0 100644--- a/src/server/missions/routes.rs+++ b/src/server/missions/routes.rs@@ -769,7 +769,9 @@ pub async fn add_task_check(State(state): State<AppState>, RawQuery(q): RawQueryOk(c) => c,Err(e) => return internal(e),};- let check = if t.state == "review" { checks::run_check(&state, &t, &check).await } else { check };+ // In review the check may decide the task. On a verified task it runs for the record only:+ // `evaluate` leaves a verified task alone, so a failing optional check can't undo it.+ let check = if matches!(t.state.as_str(), "review" | "verified") { checks::run_check(&state, &t, &check).await } else { check };if let Some(t) = evaluate(&state, &id).await {emit_task(&state, &t).await;}@@ -802,7 +804,9 @@ pub async fn approve_check(State(state): State<AppState>, RawQuery(q): RawQuery,}let _ = state.db.log_task_event(&t.id, "check_added", "person", &json!({"check_id": id, "approved": true, "approval": true})).await;let check = state.db.get_check(&id).await.ok().flatten().unwrap_or(check);- let check = if t.state == "review" { checks::run_check(&state, &t, &check).await } else { check };+ // In review the check may decide the task. On a verified task it runs for the record only:+ // `evaluate` leaves a verified task alone, so a failing optional check can't undo it.+ let check = if matches!(t.state.as_str(), "review" | "verified") { checks::run_check(&state, &t, &check).await } else { check };if let Some(t) = evaluate(&state, &t.id).await {emit_task(&state, &t).await;}diff --git a/tests/mission_control_test.rs b/tests/mission_control_test.rsindex cba3c37f..2c5f91d1 100644--- a/tests/mission_control_test.rs+++ b/tests/mission_control_test.rs@@ -479,3 +479,50 @@ async fn every_check_must_pass_one_waiting_for_approval_holds_the_task_in_reviewassert_eq!(t["task"]["state"], "ready", "{t}");assert_eq!(t["task"]["attempts"], 1);}++/// A verified task whose owner added an optional check of its own: returns `(task id, check id)`.+async fn verified_with_optional_check(e: &Env, text: &str) -> (String, String) {+ let (m, tasks) = mission(e, 200_000, json!([{"title": "Notes", "owner": e.bot.id,+ "checks": [{"kind": "file_exists", "spec": {"path": "notes.md"}}]}])).await;+ let tid = id(&tasks[0]);+ std::fs::write(folder(e, &id(&m)).await.join("notes.md"), "release notes").unwrap();+ let token = turn(e, &e.bot, &format!("t-optional-{text}")).await;+ ok(e, &token, "task_claim", json!({"task_id": tid})).await;+ let added = ok(e, &token, "task_request_check",+ json!({"task_id": tid, "kind": "file_contains", "spec": {"path": "notes.md", "text": text}, "required": false})).await;+ let check = added["checks"].as_array().unwrap().iter().find(|c| c["kind"] == "file_contains").unwrap().clone();+ assert_eq!(check["status"], "needs_approval", "{added}");+ ok(e, &token, "task_update", json!({"task_id": tid, "status": "review"})).await;+ assert_eq!(state_of(e, &tid).await, "verified", "an optional waiting check doesn't hold the task");+ (tid, id(&check))+}++#[tokio::test]+async fn approving_an_optional_check_on_a_verified_task_runs_it_and_records_a_pass() {+ let e = setup().await;+ let (tid, cid) = verified_with_optional_check(&e, "release").await;+ let before = task(&e, &tid).await;+ let approved = person(&e, "POST", &format!("/api/checks/{cid}/approve"), None).await;+ assert_eq!((approved["status"].as_str(), approved["approved_by"].as_str()), (Some("passed"), Some("person")), "{approved}");+ assert!(approved["output_excerpt"].as_str().is_some_and(|o| !o.is_empty()), "{approved}");+ assert_eq!(approved["checked_by"], "kwant");+ let t = task(&e, &tid).await;+ assert_eq!(t["task"]["state"], "verified", "{t}");+ assert_eq!(t["task"]["spent_tokens"], before["task"]["spent_tokens"], "running a check spends nothing");+ assert!(t["evidence"].as_array().unwrap().iter().any(|v| v["kind"] == "check_output" && v["run_id"] == cid.as_str()), "{t}");+}++#[tokio::test]+async fn a_failing_optional_check_on_a_verified_task_is_recorded_and_the_task_stays_verified() {+ let e = setup().await;+ let (tid, cid) = verified_with_optional_check(&e, "not in the file").await;+ let before = task(&e, &tid).await;+ let approved = person(&e, "POST", &format!("/api/checks/{cid}/approve"), None).await;+ assert_eq!(approved["status"], "failed", "{approved}");+ assert!(approved["output_excerpt"].as_str().is_some_and(|o| !o.is_empty()), "{approved}");+ let t = task(&e, &tid).await;+ assert_eq!(t["task"]["state"], "verified", "a failing optional check doesn't undo a verified task: {t}");+ assert_eq!(t["task"]["attempts"], before["task"]["attempts"]);+ assert_eq!(t["task"]["spent_tokens"], before["task"]["spent_tokens"]);+ assert_eq!(t["task"]["needs_you"], json!([]));+}