test_reads_outside_the_repository_are_not_counted

Tests › tests/test_hook.py

passed Passed in the packaged run.

What this test is for

Why it exists

gh#44. THE NOTE COUNTED INSPECTIONS ANYWHERE ON DISK AND CALLED THEM "in this repository". A session auditing markdown under `~/.claude/projects/<id>/memory/` — outside the tree entirely — accumulated pressure from those reads and was told that 45 file-inspection calls in this repository had gone without an index call. Every one of the calls that incremented that counter was outside it, and none had a definition or callers to find.

Verifies REQ-DDB-WIKI-054

Given

  1. repo = tmp_path / "repo"
  2. repo.mkdir()
5 more
  1. state = tmp_path / "state"
  2. state.mkdir()
  3. outside = json.dumps( { "hook_event_name": "PostToolUse", "tool_name": "Read", "tool_input": {"file_path": "/etc/hosts"}, "tool_response": "127.0.0.1 localhost", } )
  4. env = {"CLAUDE_CODE_SESSION_ID": "outside-session", "CLAUDE_PROJECT_DIR": str(repo)}
  5. spoke = [bool(_run(outside, state, env).stdout.strip()) for _ in range(hook._LOUD_AT + 4)]
→

When

  1. —
→

Then

  1. ✓ any(spoke) is false

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

What it checks (1)

  1. assert not any(spoke), ( f"reads outside the repository must never drive the note; it spoke {sum(spoke)} time(s)" ) observes _run via spoke

Where the product reaches it

Call flow

test_reads_outside_the_repository_are_not_counted→_run

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