test_bash_speaks_only_for_inspection_commands

Tests › tests/test_hook.py

passed Passed in the packaged run.

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

  1. 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

  1. for command, expected in named.items(): assert hook._safe_token(hook._bash_target(command)) == expected, ( f"{command!r} should have named {expected!r}" )
  2. 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", "", )
  3. 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

  1. —

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

What it checks (2)

  1. assert hook._safe_token(hook._bash_target(command)) == expected, ( f"{command!r} should have named {expected!r}" ) observes _safe_token
  2. assert 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

test_bash_speaks_only_for_inspection_commands→_safe_token→_bash_target

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