The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): a caller asserting run ownership cannot classify a parked card
teknium131017b7344bf
diff --git a/hermes_cli/kanban_db.py b/hermes_cli/kanban_db.pyindex 21e4017ce8d..960936560b7 100644--- a/hermes_cli/kanban_db.py+++ b/hermes_cli/kanban_db.py@@ -3147,9 +3147,11 @@ def block_task(# ``block_kind`` and no ``blocked`` event -- the policy is the# supervisor's, not the kernel's -- but the transition guard below only# matches running/ready, so that policy could never be attached later- # (#117363). Classify in place; never re-type or flap status.+ # (#117363). Classify in place; never re-type or flap status. A caller+ # asserting run ownership (``expected_run_id``) cannot own a parked+ # card -- its run is over -- so it is refused like any stale worker.if cur_row["status"] == "blocked":- if kind is None or _row_get(cur_row, "block_kind") is not None:+ if kind is None or expected_run_id is not None or _row_get(cur_row, "block_kind") is not None:return Falseclassified = conn.execute("UPDATE tasks SET block_kind = ?, block_recurrences = 1 "diff --git a/tests/hermes_cli/test_kanban_block_classify.py b/tests/hermes_cli/test_kanban_block_classify.pyindex dd5fb543161..856cc7a5fb2 100644--- a/tests/hermes_cli/test_kanban_block_classify.py+++ b/tests/hermes_cli/test_kanban_block_classify.py@@ -58,8 +58,21 @@ def test_typed_block_classifies_untyped_breaker_block(kanban_home, monkeypatch):assert len(kb.list_runs(conn, tid)) == 2-def test_typed_block_still_refuses_typed_or_live_blocked_cards(kanban_home):+def test_typed_block_still_refuses_typed_or_live_blocked_cards(kanban_home, monkeypatch):+ monkeypatch.setattr(kb, "_pid_alive", lambda pid: False)with kbc.connect() as conn:+ parked = kb.create_task(conn, title="parked", assignee="worker", max_runtime_seconds=1)+ _time_out_once(conn, parked)+ _time_out_once(conn, parked)+ assert kb.get_task(conn, parked).status == "blocked"+ stale_run_id = conn.execute(+ "SELECT MAX(id) FROM task_runs WHERE task_id = ?", (parked,)).fetchone()[0]+ assert stale_run_id is not None+ # A worker asserting ownership of its (ended) run cannot classify a parked card.+ assert kb.block_task(conn, parked, reason="mine", kind="needs_input",+ expected_run_id=stale_run_id) is False+ assert kb.get_task(conn, parked).block_kind is None+typed = kb.create_task(conn, title="typed once", assignee="worker")kb.claim_task(conn, typed)assert kb.block_task(conn, typed, reason="decision", kind="needs_input") is True