test_each_modality_gets_its_own_note¶
Tests › tests/test_hook.py
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
manifest = json.loads((REPO / "hooks" / "hooks.json").read_text(encoding="utf-8"))commands = [ spec["command"].split() for entry in manifest["hooks"]["PostToolUse"] for spec in entry["hooks"] ]
3 more
flags = {arg for words in commands for arg in words[words.index("clew-hook") + 1 :]}modalities = flags - {hook.USED_FLAG}rendered = {}
When
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"glob_named = hook._payload_for(hook._QUIET_BELOW, hook.GLOB_FLAG, "evil.py")
Then
- ✓ modalities holds
- ✓ modalities is at most set(hook.MODALITY_FLAGS)
- ✓ glob_named does not contain "evil.py"
tests/test_hook.py:1244 · its file's page
What it checks (4)
assert modalities, "no modality flags in the manifest — this test would be vacuous"not attributedassert modalities <= set(hook.MODALITY_FLAGS), ( f"the manifest passes flags the hook does not declare: " f"{sorted(modalities - set(hook.MODALITY_FLAGS))}" )not attributedassert text, f"{flag} renders an empty note"not attributedassert "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_forviaglob_named
Where the product reaches it
main→_payload_for(flow)
Call flow
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)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-WIKI-054 | catalog | unknown |