Skip to content

The agent that grows with you

fix(kanban): dashboard done/review refusals name the open parents

teknium106350c79d512
diff --git a/plugins/kanban/dashboard/plugin_api.py b/plugins/kanban/dashboard/plugin_api.py
index f60c280cef2..8024035e029 100644
--- a/plugins/kanban/dashboard/plugin_api.py
+++ b/plugins/kanban/dashboard/plugin_api.py
@@ -600,7 +600,7 @@ _OVERRIDE_OPS = (
def _patch_status(conn, task_id: str, payload: UpdateTaskBody, review_assignee_deferred: bool) -> None:
"""PATCH status phase: 400 on a rejected verb, 409 when the transition is refused
- (naming the blocking parent(s) for ``ready`` so the UI renders an actionable toast)."""
+ (naming the blocking parent(s) for ``ready``/``done``/``review`` so the UI renders an actionable toast)."""
s = payload.status
if s == "archived":
ok = kanban_db.archive_task(conn, task_id)
@@ -615,7 +615,19 @@ def _patch_status(conn, task_id: str, payload: UpdateTaskBody, review_assignee_d
if blockers:
names = ", ".join(f"{p['title']!r} ({p['id']}, status={p['status']})" for p in blockers)
raise _conflict(f"Cannot move to 'ready': blocked by parent(s) not done — {names}")
- raise _conflict(f"status transition to {s!r} not valid from current state")
+ raise _conflict(_open_parent_refusal(conn, task_id, s) or f"status transition to {s!r} not valid from current state")
+
+
+def _open_parent_refusal(conn, task_id: str, s: str) -> Optional[str]:
+ """complete_task/request_review return bare False for a dependency refusal too;
+ for a refused ``done``/``review`` name the open parents instead of the generic text."""
+ if s not in ("done", "review"):
+ return None
+ blockers = kanban_db.unsatisfied_parents(conn, task_id)
+ if not blockers:
+ return None
+ detail = ", ".join(f"{pid} ({status})" for pid, status in blockers)
+ return f"cannot move {task_id} to {s!r}: unsatisfied parent dependencies: {detail}; complete the parents first (done or archived)"
def _patch_title_body(conn, task_id: str, payload: UpdateTaskBody, board: Optional[str]) -> None:
@@ -784,7 +796,7 @@ def _bulk_apply_one(conn, tid: str, payload: BulkTaskBody, board: Optional[str],
if payload.status is not None and not payload.archive:
s = payload.status
if not _apply_status(conn, tid, s, payload, f"unknown status {s!r}"):
- entry.update(ok=False, error=f"transition to {s!r} refused")
+ entry.update(ok=False, error=_open_parent_refusal(conn, tid, s) or f"transition to {s!r} refused")
if payload.assignee is not None:
try:
ok = (kanban_db.reassign_task(conn, tid, payload.assignee or None, reclaim_first=True) if payload.reclaim_first
diff --git a/tests/plugins/test_kanban_dashboard_plugin.py b/tests/plugins/test_kanban_dashboard_plugin.py
index 27d7390c042..def9d306885 100644
--- a/tests/plugins/test_kanban_dashboard_plugin.py
+++ b/tests/plugins/test_kanban_dashboard_plugin.py
@@ -686,6 +686,36 @@ def test_bulk_status_done_forwards_completion_summary(client):
conn.close()
+def _gated_child(client):
+ parent = client.post("/api/plugins/kanban/tasks", json={"title": "parent"}).json()["task"]
+ child = client.post(
+ "/api/plugins/kanban/tasks", json={"title": "child", "parents": [parent["id"]]},
+ ).json()["task"]
+ return parent["id"], child["id"]
+
+
+def test_patch_done_or_review_refused_by_open_parent_names_it(client):
+ """A completion refused by the dependency gate must say which parent is open,
+ not the generic 'not valid from current state'."""
+ parent_id, child_id = _gated_child(client)
+ for status in ("done", "review"):
+ r = client.patch(f"/api/plugins/kanban/tasks/{child_id}", json={"status": status})
+ assert r.status_code == 409, r.text
+ detail = r.json()["detail"]
+ assert f"{parent_id} (ready)" in detail, detail
+ assert "unsatisfied parent" in detail, detail
+
+
+def test_bulk_done_refused_by_open_parent_names_it(client):
+ parent_id, child_id = _gated_child(client)
+ r = client.post("/api/plugins/kanban/tasks/bulk", json={"ids": [child_id], "status": "done"})
+ assert r.status_code == 200
+ entry = r.json()["results"][0]
+ assert entry["ok"] is False
+ assert f"{parent_id} (ready)" in entry["error"], entry
+ assert "unsatisfied parent" in entry["error"], entry
+
+
def test_bulk_status_running_rejected(client):
"""Bulk updates must match single-task PATCH: direct 'running' is invalid."""
t = client.post("/api/plugins/kanban/tasks", json={"title": "x"}).json()["task"]
diff --git a/website/docs/user-guide/features/kanban.md b/website/docs/user-guide/features/kanban.md
index 70e8152bd37..8a41a260692 100644
--- a/website/docs/user-guide/features/kanban.md
+++ b/website/docs/user-guide/features/kanban.md
@@ -1277,7 +1277,7 @@ Runs are exposed on the dashboard (Run History section in the drawer, one colour
**Bulk close caveat.** `hermes kanban complete a b c --summary X` is refused — structured handoff is per-run, so copy-pasting the same summary to N tasks is almost always wrong. Bulk close *without* `--summary` / `--metadata` still works for the common "I finished a pile of admin tasks" case.
-**Dependency refusal on complete names the parents.** `kanban_complete` / `hermes kanban complete` on a card whose direct parent is not `done`/`archived` (a parent reopened mid-run, or an edge that predates the running-child refusal) reports `unsatisfied parent dependencies: t_… (todo)` instead of the generic "unknown id, stale run, or already terminal" text; the card stays in-flight. `kanban_show` lists the same parents under `unsatisfied_parents`, and `hermes kanban show` / `hermes kanban diagnostics` / the dashboard raise a `running_with_open_parents` warning on a running card in that state. Finish the parent or `hermes kanban unlink <parent> <child>`; there is no force path through the dependency gate.
+**Dependency refusal on complete names the parents.** `kanban_complete` / `hermes kanban complete` / the dashboard's "mark done" and "request review" actions (single and bulk) on a card whose direct parent is not `done`/`archived` (a parent reopened mid-run, or an edge that predates the running-child refusal) reports `unsatisfied parent dependencies: t_… (todo)` instead of the generic "unknown id, stale run, or already terminal" text; the card stays in-flight. `kanban_show` lists the same parents under `unsatisfied_parents`, and `hermes kanban show` / `hermes kanban diagnostics` / the dashboard raise a `running_with_open_parents` warning on a running card in that state. Finish the parent or `hermes kanban unlink <parent> <child>`; there is no force path through the dependency gate.
**Live-claim guard on complete.** A `running` task whose worker holds a live claim is only completed by that worker (`kanban_complete` from inside the run) or by an explicit operator override: `hermes kanban complete <id> --force` and the dashboard's "mark done" action. A claim-less `hermes kanban complete <id>` or an orchestrator session's `kanban_complete` is refused with a pointer to `--force` / `hermes kanban reclaim`, so a second session can no longer close a live worker's run underneath it. Completing `ready`, `blocked` or `review` cards without a claim is unchanged.