From a146b147ff01c0aaa62c811b01459d6343495fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?m=C3=BCde?= Date: Fri, 15 May 2026 01:21:31 +0200 Subject: [PATCH] dashboard: GC orphan approvals on render (agent state dir missing) --- hive-c0re/src/dashboard.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/hive-c0re/src/dashboard.rs b/hive-c0re/src/dashboard.rs index 2a61c2a..d561ae1 100644 --- a/hive-c0re/src/dashboard.rs +++ b/hive-c0re/src/dashboard.rs @@ -58,7 +58,10 @@ async fn index(headers: HeaderMap, State(state): State) -> Html String { out } +/// Filter out approvals whose agent state dir was wiped out from under us +/// (e.g. by a test script's cleanup). Marks them failed so they fall out of +/// `pending` on next render. +fn gc_orphans(coord: &Coordinator, approvals: Vec) -> Vec { + approvals + .into_iter() + .filter(|a| { + if Coordinator::agent_proposed_dir(&a.agent).exists() { + true + } else { + let _ = coord + .approvals + .mark_failed(a.id, "agent state dir missing"); + tracing::info!(id = a.id, agent = %a.agent, "auto-failed orphan approval"); + false + } + }) + .collect() +} + async fn approval_diff(agent: &str, commit_ref: &str) -> String { let proposed = Coordinator::agent_proposed_dir(agent); if !proposed.exists() {