The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): gate create-with-parents like link; archived parent is terminal
teknium16f24245532ad
diff --git a/hermes_cli/kanban_db.py b/hermes_cli/kanban_db.pyindex d7503417cd6..c4219fa0b3c 100644--- a/hermes_cli/kanban_db.py+++ b/hermes_cli/kanban_db.py@@ -1375,6 +1375,17 @@ def create_task("blocked",{"reason": "initial_status", "status": "blocked", "actor": created_by or "user"},)+ if task_status == "todo":+ # Parked behind an open parent: record why, exactly as+ # link_tasks does, so the board never shows an unexplained todo.+ gating = [p for p in parents if _task_status(conn, p) not in ("done", "archived")]+ if gating:+ _append_event(+ conn,+ task_id,+ "dependency_wait",+ {"reason": "parent_not_done", "parent": gating[0]},+ )# ACK-edge: the originating channel hears a child BLOCK, not just the fan-in.inherit_creator_origin(conn, task_id, creator_task_id, created_at=now)_inherit_notify_subs(conn, task_id, parents, created_at=now)@@ -1595,8 +1606,9 @@ def link_tasks(conn: sqlite3.Connection, parent_id: str, child_id: str) -> bool:if _would_cycle(conn, parent_id, child_id):raise ValueError(f"linking {parent_id} -> {child_id} would create a cycle")_link(conn, parent_id, child_id)- # If child was ready but parent is not yet done, demote child to todo.- if _task_status(conn, parent_id) != "done":+ # If child was ready but parent is not yet terminal, demote child to todo+ # (archived counts as terminal, matching _parents_satisfied/recompute_ready).+ if _task_status(conn, parent_id) not in ("done", "archived"):cur = conn.execute("UPDATE tasks SET status = 'todo' WHERE id = ? AND status = 'ready'",(child_id,),diff --git a/tests/hermes_cli/test_kanban_db.py b/tests/hermes_cli/test_kanban_db.pyindex 6d9646d4b71..28dd29c7507 100644--- a/tests/hermes_cli/test_kanban_db.py+++ b/tests/hermes_cli/test_kanban_db.py@@ -1196,6 +1196,38 @@ def test_link_tasks_no_dependency_wait_when_parent_done(kanban_home):assert "dependency_wait" not in kinds+def test_create_task_with_open_parent_emits_dependency_wait(kanban_home):+ """create-with-parents is the incident path: a card parked in todo behind an+ unfinished parent must carry the same dependency_wait as a link-time gate."""+ with kbc.connect() as conn:+ parent = kb.create_task(conn, title="blocked parent")+ kb.block_task(conn, parent, reason="waiting on files")++ child = kb.create_task(conn, title="support card", parents=(parent,))++ assert kb.get_task(conn, child).status == "todo"+ wait = [e for e in kb.list_events(conn, child) if e.kind == "dependency_wait"]+ assert wait, "parking behind an open parent must be recorded"+ assert wait[-1].payload["reason"] == "parent_not_done"+ assert wait[-1].payload["parent"] == parent+++def test_link_tasks_archived_parent_is_terminal_no_gate(kanban_home):+ """archived is terminal for recompute_ready, so linking under an archived+ parent must not demote a ready child (it would only flap back to ready)."""+ with kbc.connect() as conn:+ parent = kb.create_task(conn, title="archived parent")+ kb.archive_task(conn, parent)+ child = kb.create_task(conn, title="child")+ assert kb.get_task(conn, child).status == "ready"++ gated = kb.link_tasks(conn, parent, child)++ assert gated is False+ assert kb.get_task(conn, child).status == "ready"+ assert "dependency_wait" not in [e.kind for e in kb.list_events(conn, child)]++def test_unlink_tasks_triggers_recompute_ready(kanban_home):"""Regression test for issue #22459.diff --git a/tests/tools/test_kanban_tools.py b/tests/tools/test_kanban_tools.pyindex 1542e06957e..a7b64bd630e 100644--- a/tests/tools/test_kanban_tools.py+++ b/tests/tools/test_kanban_tools.py@@ -458,6 +458,7 @@ def test_create_happy_path(worker_env):assert d["ok"] is Trueassert d["task_id"]assert d["status"] == "todo" # parent isn't done yet+ assert d["gated"] is True and d["gated_by"] == worker_envfrom hermes_cli import kanban_db as kbfrom hermes_cli import kanban_db_connect as kbcconn = kbc.connect()diff --git a/tools/kanban_tools.py b/tools/kanban_tools.pyindex 333db70108f..233846ea765 100644--- a/tools/kanban_tools.py+++ b/tools/kanban_tools.py@@ -895,7 +895,10 @@ def _handle_create(args: dict, **kw) -> str:initial_status=str(args.get("initial_status") or "running"),created_by=os.environ.get("HERMES_PROFILE") or "worker", session_id=session_id)landed = _fields(kb.get_task(conn, new_tid), _CREATED_FIELDS)- return _ok(task_id=new_tid, **landed, subscribed=_maybe_auto_subscribe(conn, new_tid))+ wait = [e for e in kb.list_events(conn, new_tid) if e.kind == "dependency_wait"]+ gate = {"gated": True, "gated_by": wait[-1].payload["parent"]} if wait else {"gated": False}+ return _ok(task_id=new_tid, **landed, **gate,+ subscribed=_maybe_auto_subscribe(conn, new_tid))def _resolve_notify_target() -> Optional[dict[str, Any]]:diff --git a/website/docs/user-guide/features/kanban.md b/website/docs/user-guide/features/kanban.mdindex cc8a2b9028e..f78e32a6cc6 100644--- a/website/docs/user-guide/features/kanban.md+++ b/website/docs/user-guide/features/kanban.md@@ -100,7 +100,7 @@ They look similar; they are not the same primitive.**One-sentence distinction:** `delegate_task` is a function call; Kanban is a work queue where every handoff is a row any profile (or human) can see and edit.:::caution Don't link a support card to the card it is meant to unblock-A worker that is blocked on `t_parent` and creates a support card for the missing piece must **not** `kanban_link(t_parent, t_support)`: the link makes the support card a *child* of the blocked parent, so it is gated behind the parent it exists to unblock and neither card ever runs. Reference the parent id in the support card's body instead. `link`/`kanban_link` now report `gated: true` and record a `dependency_wait` event when they demote a `ready` child, so the deadlock is visible on the board; `hermes kanban unlink <parent> <child>` releases it.+A worker that is blocked on `t_parent` and creates a support card for the missing piece must **not** `kanban_link(t_parent, t_support)`: the link makes the support card a *child* of the blocked parent, so it is gated behind the parent it exists to unblock and neither card ever runs. Reference the parent id in the support card's body instead. `link`/`kanban_link` report `gated: true` and record a `dependency_wait` event when they demote a `ready` child (and `kanban_create` with `parents` does the same when it parks the new card), so the deadlock is visible on the board; `hermes kanban unlink <parent> <child>` releases it.:::**Use `delegate_task` when** the parent agent needs a short reasoning answer before continuing, no humans involved, result goes back into the parent's context.@@ -404,7 +404,7 @@ Dispatcher-owned workers receive their task lifecycle tools automatically.| `kanban_attach` | Attach a file to a task by passing its bytes inline (base64); stored under the task's attachments dir (25 MB cap). | file bytes + name || `kanban_attach_url` | Attach a file to a task by URL. | `url` || `kanban_attachments` | List a task's attachments. | — |-| `kanban_create` | (Orchestrators) fan out into child tasks with an `assignee`, optional `parents`, `skills`, etc. | `title`, `assignee` |+| `kanban_create` | (Orchestrators) fan out into child tasks with an `assignee`, optional `parents`, `skills`, etc. Returns `gated: true` + `gated_by` when an open parent parked the new card in `todo`. | `title`, `assignee` || `kanban_link` | (Orchestrators) add a `parent_id → child_id` dependency edge after the fact. Returns `gated: true` when the child was `ready` and got demoted back to `todo` because the parent is not done — the child will only run after the parent completes. | `parent_id`, `child_id` || `kanban_unblock` | (Orchestrators) restore a blocked task to its source phase (`review` or `ready`), or `todo` while a parent remains open. | `task_id` |