feat(orchestrator): triage, dialog-bound cards and silent expired drops on the hub
093: triage.py classifies every request as open, failed, expired or stale; POST /api/requests/dismiss hides many requests hub-wide under one passkey signature with the usual undo window, ledger dismissals.json. 094: an ask or hooked decision lives as long as its Claude dialog: the hook waits the hub Settings' hook wait (1-60 min, default 60), PostToolUse, Stop, UserPromptSubmit and SessionEnd hooks close the session's cards, and a card whose hook stopped waiting reads open in Claude. Closes are bound to a per-session closer token whose sha256 the hub stores, so a local process cannot close another session's cards or forge a choice. GET /api/match/closed lets the page drop closed cards within 5 s. 096: the release signs dismissals of dropped expired cards together with the inbox entries; no radio reaches the agent. 088: the prune list is no longer capped at 50 tasks. 091: nvidia-smi's error line reaches the GPU row as its cause; limits take a batch of staged values under one proof. MEDUSA: 57 findings accepted as false positives after an independent skeptic review and the operator's word (MM-SCAN-058 regex PLA matching replay/place/replace, CODEGEN-SCAN-001 on Map.delete and labels, fixed nvidia-smi argv, localhost-only hook URLs, passkey in tooltips). Gate missed on the operator's word: break 8 %, the E2E runs after the page bundle; operator must run make orchestrator-hook and restart every Claude Code session after the install. 🎯 Fix: 92 % 💥 Break: 8 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 85 🚦 Gate: ⛔ break 8 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
909ea85605
commit
8ee52644c8
25 files changed
+1531
-130
No files matched your search
@@ -507,6 +507,51 @@ class TestPermissionHookInstall(Scratch):
|
||||
self.assertEqual((done.returncode, done.stdout, done.stderr), (0, "", ""))
|
||||
self.assertFalse(self.marker.exists())
|
||||
|
||||
def registered(self, saved: dict | None) -> tuple[subprocess.CompletedProcess, dict]:
|
||||
home = self.root / "home"
|
||||
hub = home / ".local" / "share" / "kvb-orchestrator"
|
||||
shutil.rmtree(home, ignore_errors=True)
|
||||
shutil.copytree(CLIENT, hub / "client", ignore=shutil.ignore_patterns("__pycache__"))
|
||||
(hub / ".env").write_text("KVB_ORCHESTRATOR_PORT=1\n", encoding="utf-8")
|
||||
(home / ".claude").mkdir(parents=True)
|
||||
if saved is not None:
|
||||
state = home / ".local" / "state" / "kvb-orchestrator"
|
||||
state.mkdir(parents=True)
|
||||
(state / "settings.json").write_text(json.dumps(saved), encoding="utf-8")
|
||||
done = subprocess.run(["/usr/bin/bash", str(ORCHESTRATOR), "hook"], env={**os.environ, "HOME": str(home)}, capture_output=True, text=True, timeout=60, check=False)
|
||||
path = home / ".claude" / "settings.json"
|
||||
return done, json.loads(path.read_text(encoding="utf-8")) if path.is_file() else {}
|
||||
|
||||
def test_the_hook_waits_the_settings_minutes_and_registers_the_closing_hooks_beside_it(self):
|
||||
for saved, wait in ((None, 3600), ({"hook": {"wait": 5}}, 300), ({"hook": {"wait": 60}}, 3600), ({"hook": {"wait": 61}}, 3600), ({"hook": {"wait": "5"}}, 3600), ({"match": {"refresh": 2}}, 3600)):
|
||||
with self.subTest(saved=saved):
|
||||
done, settings = self.registered(saved)
|
||||
self.assertEqual(done.returncode, 0, done.stderr)
|
||||
hooks = settings["hooks"]
|
||||
asked = hooks["PermissionRequest"][-1]
|
||||
self.assertEqual((asked["matcher"], asked["hooks"][0]["timeout"]), ("*", wait + 10))
|
||||
self.assertNotIn("async", asked["hooks"][0])
|
||||
command = asked["hooks"][0]["command"]
|
||||
self.assertIn(f"--timeout {wait} ", command)
|
||||
self.assertTrue(command.endswith(" --bound"), command)
|
||||
shapes = {event: (entries[-1].get("matcher"), entries[-1]["hooks"][0]["command"], entries[-1]["hooks"][0]["timeout"], entries[-1]["hooks"][0].get("async", False)) for event, entries in hooks.items() if event != "PermissionRequest"}
|
||||
self.assertEqual(shapes, {"PostToolUse": ("*", command, 10, True), "Stop": (None, command, 10, True), "UserPromptSubmit": (None, command, 10, True), "SessionEnd": (None, command, 10, False)})
|
||||
|
||||
def test_a_second_registration_replaces_every_entry_and_a_client_without_bound_is_refused(self):
|
||||
self.registered(None)
|
||||
home = self.root / "home"
|
||||
done = subprocess.run(["/usr/bin/bash", str(ORCHESTRATOR), "hook"], env={**os.environ, "HOME": str(home)}, capture_output=True, text=True, timeout=60, check=False)
|
||||
self.assertEqual(done.returncode, 0, done.stderr)
|
||||
settings = json.loads((home / ".claude" / "settings.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual({event: len(entries) for event, entries in settings["hooks"].items()}, dict.fromkeys(("PermissionRequest", "PostToolUse", "Stop", "UserPromptSubmit", "SessionEnd"), 1))
|
||||
client = home / ".local" / "share" / "kvb-orchestrator" / "client" / "permission_hook.py"
|
||||
client.write_text(client.read_text(encoding="utf-8").replace('"--bound"', '"--other"'), encoding="utf-8")
|
||||
before = (home / ".claude" / "settings.json").read_text(encoding="utf-8")
|
||||
done = subprocess.run(["/usr/bin/bash", str(ORCHESTRATOR), "hook"], env={**os.environ, "HOME": str(home)}, capture_output=True, text=True, timeout=60, check=False)
|
||||
self.assertEqual(done.returncode, 1, done.stderr)
|
||||
self.assertIn("make install first", done.stderr)
|
||||
self.assertEqual((home / ".claude" / "settings.json").read_text(encoding="utf-8"), before)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user