Skip to content

The agent that grows with you

fix: gate kanban.default_assignee through the dispatch_profiles allowlist

teknium1bbe13059bc38
diff --git a/hermes_cli/kanban_db_dispatch.py b/hermes_cli/kanban_db_dispatch.py
index d443ce147bd..d0b0056c4d1 100644
--- a/hermes_cli/kanban_db_dispatch.py
+++ b/hermes_cli/kanban_db_dispatch.py
@@ -1779,18 +1779,17 @@ def _any_spawnable_review(review_rows: list[sqlite3.Row]) -> bool:
def _resolve_default_assignee(default_assignee: Optional[str]) -> Optional[str]:
- """``kanban.default_assignee`` when it names a real profile. When the
- profiles module isn't importable trust the operator's config: the
- downstream profile_exists check still buckets a missing profile as
- nonspawnable."""
+ """``kanban.default_assignee`` when it names a real profile this home may
+ claim (``kanban.dispatch_profiles`` gated, same predicate as the spawn
+ gate). Otherwise ``None`` so an unassigned shared-board card is never
+ written to. When the profiles module isn't importable trust the
+ operator's config: the downstream check still buckets a missing profile
+ as nonspawnable."""
name = (default_assignee or "").strip() or None
if name:
- try:
- from hermes_cli.profiles import profile_exists
- if not profile_exists(name):
- return None
- except Exception:
- pass
+ profile_exists = _profile_exists_fn()
+ if profile_exists is not None and not profile_exists(name):
+ return None
return name
diff --git a/tests/hermes_cli/test_kanban_dispatch_claim_allowlist.py b/tests/hermes_cli/test_kanban_dispatch_claim_allowlist.py
index 1b869c4185e..4af8efa7df4 100644
--- a/tests/hermes_cli/test_kanban_dispatch_claim_allowlist.py
+++ b/tests/hermes_cli/test_kanban_dispatch_claim_allowlist.py
@@ -44,6 +44,30 @@ def test_allowlist_without_default_skips_default_card(kanban_home, all_assignees
assert res.skipped_nonspawnable == [tid]
+def test_default_assignee_outside_allowlist_leaves_card_unassigned(
+ kanban_home, all_assignees_spawnable,
+):
+ """Invariant: a ``default_assignee`` this home may not claim must not be
+ persisted onto an unassigned shared-board card (no row write, no
+ ``assigned`` event) — another home owns that card."""
+ (kanban_home / "config.yaml").write_text(
+ "kanban:\n dispatch_profiles:\n - sage\n default_assignee: default\n",
+ encoding="utf-8",
+ )
+ with kbc.connect() as conn:
+ tid = kb.create_task(conn, title="unassigned card")
+ res = kbd.dispatch_once(
+ conn, dry_run=False, spawn_fn=lambda _t, _w: 4242,
+ default_assignee="default",
+ )
+ task = kb.get_task(conn, tid)
+ kinds = [e.kind for e in kb.list_events(conn, tid)]
+ assert res.spawned == []
+ assert res.auto_assigned_default == []
+ assert task.assignee is None
+ assert "assigned" not in kinds
+
+
def test_unset_allowlist_keeps_default_claimable(kanban_home, all_assignees_spawnable):
"""No key = upstream behaviour: any existing profile, ``default`` included."""
with kbc.connect() as conn: