fix(kanban): ignore stale current board pointers

This commit is contained in:
Steve Kelly 2026-05-05 00:54:07 -04:00 committed by Teknium
parent 2a285d5ec2
commit 8c82d0664d
2 changed files with 14 additions and 5 deletions

View file

@ -190,12 +190,12 @@ def get_current_board() -> str:
1. ``HERMES_KANBAN_BOARD`` env var (set by the dispatcher on worker
spawn, or manually for ad-hoc overrides).
2. ``<root>/kanban/current`` on disk (set by ``hermes kanban boards
switch``).
switch``), but only when that board still exists.
3. ``DEFAULT_BOARD`` (``"default"``).
A malformed slug at any step falls through to the next layer with a
best-effort warning the dispatcher must never crash because a user
hand-edited a file.
A malformed or stale slug at any step falls through to the next layer
with a best-effort warning the dispatcher must never crash because a
user hand-edited a file or removed a board directory.
"""
env = os.environ.get("HERMES_KANBAN_BOARD", "").strip()
if env:
@ -212,7 +212,7 @@ def get_current_board() -> str:
if val:
try:
normed = _normalize_board_slug(val)
if normed:
if normed and board_exists(normed):
return normed
except ValueError:
pass

View file

@ -160,6 +160,15 @@ class TestCurrentBoard:
kb.set_current_board("filepick")
assert kb.get_current_board() == "filepick"
def test_stale_file_pointer_falls_back_to_default(self, fresh_home):
current = fresh_home / "kanban" / "current"
current.parent.mkdir(parents=True, exist_ok=True)
current.write_text("missing-board\n", encoding="utf-8")
assert kb.get_current_board() == "default"
assert not kb.board_exists("missing-board")
assert [b["slug"] for b in kb.list_boards()] == ["default"]
def test_env_beats_file(self, fresh_home, monkeypatch):
kb.create_board("a")
kb.create_board("b")