test_bash_speaks_only_for_inspection_commands¶
Tests › tests/test_hook.py
What this test is for
Why it exists
BIASED TOWARD SILENCE ON PURPOSE. A note saying "you inspected foo.py" when the agent read `bar.py` costs more credibility than a fileless note costs attention — and this component's own argument is that a payload which lies about itself discredits everything else it says. So every ambiguity resolves to None and the caller falls back to the fileless variant.
Verifies REQ-DDB-WIKI-054
Given
named = { "cat clew/testscope.py": "testscope.py", "head -20 a/b/c.py": "c.py", "sed -n '1,5p' x.py": "x.py", "cat clew/cli.py | head -5": "cli.py", "LC_ALL=C grep pattern file.py": "file.py", }
When
for command, expected in named.items(): assert hook._safe_token(hook._bash_target(command)) == expected, ( f"{command!r} should have named {expected!r}" )refused = ( "npm install", "git commit -m 'read foo.py'", "cat a.py b.py", 'cat "$(evil)"', "cat *.py", "grep -r pattern src/", "echo hi", "cat ~/secrets.py", "cat <<EOF", "cat a.py > b.py", "", )for command in refused: assert hook._bash_target(command) is None, ( f"{command!r} must fall back to the fileless note rather than guess" )
Then
- —
tests/test_hook.py:1057 · its file's page
What it checks (2)
assert hook._safe_token(hook._bash_target(command)) == expected, ( f"{command!r} should have named {expected!r}" )observes_safe_tokenassert hook._bash_target(command) is None, ( f"{command!r} must fall back to the fileless note rather than guess" )observes_bash_target
Where the product reaches it
main→_target_name→_safe_token(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 |