test_each_modality_gets_its_own_note

Tests › tests/test_hook.py

passed Passed in the packaged run.

What this test is for

Why it exists

DRIVEN FROM THE MANIFEST, not from a hard-coded list, so registering a new matcher without giving it text breaks this rather than silently emitting the wrong modality's wording.

Verifies REQ-DDB-WIKI-054

Given

  1. manifest = json.loads((REPO / "hooks" / "hooks.json").read_text(encoding="utf-8"))
  2. commands = [ spec["command"].split() for entry in manifest["hooks"]["PostToolUse"] for spec in entry["hooks"] ]
3 more
  1. flags = {arg for words in commands for arg in words[words.index("clew-hook") + 1 :]}
  2. modalities = flags - {hook.USED_FLAG}
  3. rendered = {}
→

When

  1. for flag in modalities: payload = hook._payload_for(hook._QUIET_BELOW, flag, None) text = json.loads(payload)["hookSpecificOutput"]["additionalContext"] rendered[flag] = text assert text, f"{flag} renders an empty note"
  2. glob_named = hook._payload_for(hook._QUIET_BELOW, hook.GLOB_FLAG, "evil.py")
→

Then

  1. ✓ modalities holds
  2. ✓ modalities is at most set(hook.MODALITY_FLAGS)
  3. ✓ glob_named does not contain "evil.py"

tests/test_hook.py:1244 · its file's page

What it checks (4)

  1. assert modalities, "no modality flags in the manifest — this test would be vacuous" not attributed
  2. assert modalities <= set(hook.MODALITY_FLAGS), ( f"the manifest passes flags the hook does not declare: " f"{sorted(modalities - set(hook.MODALITY_FLAGS))}" ) not attributed
  3. assert text, f"{flag} renders an empty note" not attributed
  4. assert "evil.py" not in glob_named, ( "the glob modality carried a basename; its tool_input is a pattern, and echoing a raw " "glob widens the surface for no gain" ) observes _payload_for via glob_named

Where the product reaches it

Call flow

test_each_modality_gets_its_own_note→_payload_for

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-WIKI-054catalogunknown