hermes-agent/tests/hermes_cli/test_busy_policy_invariants.py
teknium1 d09dacf66a test: purge low-value tests, lane py10 (412 removed)
Change-detectors, tautologies, source-reading tests, redundant duplicates,
mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane
ledger (category + reason for every removal).
2026-09-23 03:15:26 -07:00

34 lines
1.2 KiB
Python

"""Invariant tests for the declarative busy_policy on CommandDef.
Guards the contract introduced by the Guard-2 refactor (gateway/run.py):
every command's mid-run behavior is declared on its CommandDef via
``busy_policy`` / ``busy_handler`` and the historical
``ACTIVE_SESSION_BYPASS_COMMANDS`` frozenset is DERIVED from the registry
rather than hand-maintained.
"""
from hermes_cli.commands import (
ACTIVE_SESSION_BYPASS_COMMANDS,
COMMAND_REGISTRY,
is_interrupt_then_dispatch,
)
def test_bypass_set_is_derived_from_registry():
expected = frozenset(
cmd.name for cmd in COMMAND_REGISTRY if cmd.busy_policy != "reject"
)
assert ACTIVE_SESSION_BYPASS_COMMANDS == expected
def test_interrupt_then_dispatch_class():
# The cancel-handoff class (Guard 1, gateway/platforms/base.py) must
# contain exactly the /stop and /new (alias /reset) commands today.
assert is_interrupt_then_dispatch("stop")
assert is_interrupt_then_dispatch("new")
assert is_interrupt_then_dispatch("reset") # alias of /new
assert not is_interrupt_then_dispatch("model")
assert not is_interrupt_then_dispatch("status")
assert not is_interrupt_then_dispatch(None)
assert not is_interrupt_then_dispatch("not-a-command")