From 4c4a3ab2278522e99fc514c7d5ded7f4fe24a776 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 17 Nov 2026 19:56:03 +0000 Subject: [PATCH] fix(orchestrator): Tasks badge counts only open operator work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A console whose operator row is already done stays under Waits on Operator for reading and dismissing, but it is marked settled and no longer counts in the Tasks badge or the tab title. Live hub: 41 done and 14 failed undismissed results kept the badge at 50 with nothing left to do. 🎯 Fix: 95 % 💥 Break: 3 % 💸 Tokens: 100 % ⏱️ Velocity: 100 % 🛡️ Security: 100 % 🏆 Score: 92 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- orchestrator/kvb_orchestrator/inbox.py | 4 ++-- orchestrator/kvb_orchestrator/view.py | 2 +- tests/test_hub_console.py | 5 +++-- tests/test_hub_surface.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/orchestrator/kvb_orchestrator/inbox.py b/orchestrator/kvb_orchestrator/inbox.py index 5f016f8..b3ece4b 100644 --- a/orchestrator/kvb_orchestrator/inbox.py +++ b/orchestrator/kvb_orchestrator/inbox.py @@ -19,7 +19,7 @@ SNOOZE_LIMIT = 8 * 86400 class Inbox: def inbox(self, now: float, tasks: dict[str, dict], directory: Directory) -> list[dict]: claims = read_claims(self.council) - base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None} + base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False} items = [] for review in self.reviews.pending(): created = iso_epoch(review["created"]) or now @@ -46,7 +46,7 @@ class Inbox: listed = {row["task"] for row in rows} for task, job in consoles.items(): if task not in listed: - fields = {"title": job["command"], "command": job["command"], "directory": job["directory"], "job": console_of(job)} + fields = {"title": job["command"], "command": job["command"], "directory": job["directory"], "job": console_of(job), "settled": True} items.append({**base, "kind": "operator", "id": task, "ts": job["created_ts"], **fields}) items += self.request_items(base, now, claims) for item in items: diff --git a/orchestrator/kvb_orchestrator/view.py b/orchestrator/kvb_orchestrator/view.py index 7d77d7c..3f09013 100644 --- a/orchestrator/kvb_orchestrator/view.py +++ b/orchestrator/kvb_orchestrator/view.py @@ -58,7 +58,7 @@ ENCODER_CSP = ( def badges(inbox: list[dict], claims: list[dict], jobs: list[dict], now: float) -> dict[str, int]: return { - "tasks": sum(1 for item in inbox if not item["until"]), + "tasks": sum(1 for item in inbox if not item["until"] and not item["settled"]), "agents": len({claim["agent"] for claim in claims if claim["beat"] is not None and claim["beat"] >= now - ACTIVE}), "artifacts": sum(1 for job in jobs if job["status"] in JOB_OPEN), } diff --git a/tests/test_hub_console.py b/tests/test_hub_console.py index 183d087..b1eb3e7 100644 --- a/tests/test_hub_console.py +++ b/tests/test_hub_console.py @@ -56,8 +56,9 @@ class TestHubConsole(HubCase): self.register("done") kept = self.item("operator/greet") self.assertEqual((kept["kind"], kept["title"], kept["command"], kept["directory"], kept["runnable"], kept["deniable"]), ("operator", COMMAND, COMMAND, str(self.outside), False, False)) - self.assertEqual(kept["job"]["output"], "line 1\nline 2\n") - self.assertEqual(self.snapshot()["badges"]["tasks"], 1) + self.assertEqual((kept["job"]["output"], kept["settled"]), ("line 1\nline 2\n", True)) + self.assertEqual(self.snapshot()["badges"]["tasks"], 0) + self.assertIn("Agent Orchestrator", self.index()) for payload in ({"id": "nope"}, {"id": job["id"], "extra": 1}, {}, [job["id"]]): with self.subTest(payload=payload): self.assertEqual(self.dismiss(payload, self.guard(self.host)), 400) diff --git a/tests/test_hub_surface.py b/tests/test_hub_surface.py index 4ea213c..ff6e507 100644 --- a/tests/test_hub_surface.py +++ b/tests/test_hub_surface.py @@ -26,7 +26,7 @@ class TestHubSurface(HubCase): def test_badges_count_waiting_operator_tasks_on_tasks_active_agents_and_open_runner_jobs(self): now = 1000.0 - inbox = [{"until": None}, {"until": None}, {"until": now + 60}] + inbox = [{"until": None, "settled": False}, {"until": None, "settled": False}, {"until": now + 60, "settled": False}, {"until": None, "settled": True}] claims = [{"agent": "A", "beat": now - 10}, {"agent": "A", "beat": now - 20}, {"agent": "B", "beat": now - 900}, {"agent": "C", "beat": now - 901}, {"agent": "D", "beat": None}] jobs = [{"status": "queued"}, {"status": "running"}, {"status": "done"}, {"status": "failed"}] self.assertEqual(view.badges(inbox, claims, jobs, now), {"tasks": 2, "agents": 2, "artifacts": 2})