Skip to content

The agent that grows with you

fix(kanban): make can_move total over task statuses; stats derives from the workflow

kshitijk4poor650b294151da
diff --git a/hermes_cli/kanban.py b/hermes_cli/kanban.py
index ee72d97754d..0dbc6edd7e0 100644
--- a/hermes_cli/kanban.py
+++ b/hermes_cli/kanban.py
@@ -22,6 +22,7 @@ from hermes_cli import kanban_db_dispatch as kbd
from hermes_cli import kanban_db_workspace as kbw
from hermes_cli import kanban_db_notify as kbn
from hermes_cli import kanban_swarm as ks
+from hermes_cli import kanban_workflow
from hermes_cli.kanban_output import (
_ATTACHMENT_FIELDS, _RUNS_RUN_FIELDS, _SHOW_RUN_FIELDS, _bulk_apply, _err,
_fmt_counts, _fmt_task_line, _fmt_ts, _json_out, _obj_dict, _print_json,
@@ -1139,7 +1140,7 @@ def _cmd_stats(args: argparse.Namespace) -> int:
if _json_out(args, stats):
return 0
print("By status:")
- for k in ("triage", "todo", "scheduled", "ready", "running", "blocked", "done"):
+ for k in kanban_workflow.DEFAULT_WORKFLOW.keys():
print(f" {k:8s} {stats['by_status'].get(k, 0)}")
if stats["by_assignee"]:
print("\nBy assignee:")
diff --git a/hermes_cli/kanban_workflow.py b/hermes_cli/kanban_workflow.py
index 93912ff8d8d..0ba61021940 100644
--- a/hermes_cli/kanban_workflow.py
+++ b/hermes_cli/kanban_workflow.py
@@ -67,8 +67,12 @@ class Workflow:
return col
def can_move(self, src: str, dst: str) -> bool:
- """True when a human may request ``src -> dst`` (archive always allowed)."""
- self._require(src)
+ """True when a human may request ``src -> dst``. Archiving is always allowed;
+ ``archived`` is a valid source (restore). ``src == dst`` is not a move."""
+ if src != ARCHIVED:
+ self._require(src)
+ if src == dst:
+ return False
if dst == ARCHIVED:
return True
self._require(dst)
@@ -94,7 +98,7 @@ class Workflow:
raise ValueError(f"{ARCHIVED!r} is reserved and cannot be a column")
known = set(keys)
for src, dsts in self.manual.items():
- if src not in known or not set(dsts) <= known:
+ if src not in known | {ARCHIVED} or not set(dsts) <= known:
raise ValueError(f"manual moves from {src!r} reference unknown columns")
@@ -128,6 +132,7 @@ DEFAULT_WORKFLOW = Workflow(
# (reopen_review_task ignores the requested target). Phase 1 fixes it.
"review": ("triage", "todo", "ready", "done"),
"done": ("triage", "todo", "ready"),
+ ARCHIVED: ("triage", "todo", "ready"), # restore from the archive filter
}),
)
DEFAULT_WORKFLOW.validate()
diff --git a/tests/hermes_cli/test_kanban_workflow.py b/tests/hermes_cli/test_kanban_workflow.py
index 1b95f7ced0e..3e414b29365 100644
--- a/tests/hermes_cli/test_kanban_workflow.py
+++ b/tests/hermes_cli/test_kanban_workflow.py
@@ -26,8 +26,7 @@ def test_default_workflow_is_valid_and_excludes_archived():
assert kw.ARCHIVED not in W.keys()
-def test_status_copies_derive_from_the_workflow():
- assert kb.VALID_STATUSES == set(W.keys()) | {kw.ARCHIVED}
+def test_cli_icon_for_every_status():
# CLI: every listable status has a glyph (was missing triage + review).
assert set(kanban_output._STATUS_ICONS) == kb.VALID_STATUSES
@@ -50,6 +49,13 @@ def test_archive_is_always_a_manual_move():
assert not any(W.can_move(k, "running") for k in W.keys())
+def test_can_move_is_total_over_task_statuses():
+ # Every value tasks.status can hold is a valid source; a same-column drop is not a move.
+ for src in kb.VALID_STATUSES:
+ assert not W.can_move(src, src)
+ assert any(W.can_move(src, dst) for dst in kb.VALID_STATUSES)
+
+
@pytest.mark.parametrize("call", [
lambda: W.can_move("bogus", kw.ARCHIVED),
lambda: W.can_move("ready", "bogus"),
diff --git a/tests/plugins/test_kanban_workflow_matrix.py b/tests/plugins/test_kanban_workflow_matrix.py
index 8a4248d4c20..4ab271c5bf1 100644
--- a/tests/plugins/test_kanban_workflow_matrix.py
+++ b/tests/plugins/test_kanban_workflow_matrix.py
@@ -2,7 +2,7 @@
Every ``src -> dst`` pair is requested through the dashboard API on a parentless task.
The workflow allow-list must agree with what the server accepts, in both directions.
-Also covers ``GET /workflow`` and ``GET /board`` column order.
+Also covers ``GET /workflow``.
"""
from __future__ import annotations
@@ -62,11 +62,13 @@ def _task_in(client, src: str) -> str:
assert kb.request_review(conn, tid, summary="s", force=True)
elif src == "done":
assert kb.complete_task(conn, tid, summary="s", force=True)
+ elif src == kw.ARCHIVED:
+ assert kb.archive_task(conn, tid)
assert kb.get_task(conn, tid).status == src
return tid
[email protected]("src", W.keys())
[email protected]("src", (*W.keys(), kw.ARCHIVED))
def test_manual_moves_match_server(client, src):
mismatches = []
for dst in (*W.keys(), kw.ARCHIVED):
@@ -95,8 +97,3 @@ def test_get_workflow(client):
r = client.get("/k/workflow")
assert r.status_code == 200
assert r.json() == W.to_dict()
-
-
-def test_board_columns_follow_workflow_order(client):
- names = [c["name"] for c in client.get("/k/board").json()["columns"]]
- assert names == list(W.keys())