Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions hermes_cli/kanban_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,23 @@ def create_task(
"goal_mode": bool(goal_mode) or None,
},
)
if task_status == "blocked":
# A task born blocked is an explicit human/ops gate, not a
# transient circuit-breaker block. Emit the same sticky
# signal used by block_task() so recompute_ready() cannot
# silently promote it on the next dispatcher tick.
_append_event(
conn,
task_id,
"blocked",
{
"reason": "initial_status=blocked",
"kind": None,
"recurrences": 1,
},
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block_recurrences remains at the task schema default of 0, while block_task() later reads that column to calculate re-block loops. Either initialize the task row consistently or omit this event-only recurrences value so the lifecycle audit does not claim state the loop breaker cannot see.

return task_id

except sqlite3.IntegrityError:
if attempt == 1:
raise
Expand Down
29 changes: 29 additions & 0 deletions tests/hermes_cli/test_kanban_blocked_sticky.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,35 @@ def test_protocol_violation_loop_is_broken(kanban_home: Path) -> None:
assert kb.get_task(conn, tid).status == "blocked"


# ---------------------------------------------------------------------------
# Create-time blocked cards are also sticky
# ---------------------------------------------------------------------------


def test_initial_status_blocked_is_not_auto_promoted_by_recompute_ready(kanban_home: Path) -> None:
"""A card created directly in ``blocked`` is an explicit human gate,
not a transient dependency/circuit-breaker block.

Regression for JT's 2026-07-05 board drift: ``hermes kanban create
--initial-status blocked`` wrote only a ``created`` event with
``status='blocked'``. Because no ``blocked`` event existed,
``recompute_ready`` treated the task as non-sticky and silently
promoted it to ``ready`` on the next dispatcher tick.
"""
with kb.connect() as conn:
tid = kb.create_task(
conn,
title="approval-gated reminder",
initial_status="blocked",
)
assert kb.get_task(conn, tid).status == "blocked"

promoted = kb.recompute_ready(conn)

assert promoted == 0
assert kb.get_task(conn, tid).status == "blocked"


# ---------------------------------------------------------------------------
# Schema-init recovery on legacy DBs is covered by
# tests/hermes_cli/test_kanban_db.py::test_connect_migrates_legacy_db_before_optional_column_indexes
Expand Down