test_the_tally_holds_across_different_parent_processes

Tests › tests/test_hook.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE BUG THE SUITE MISSED. Keyed on `os.getppid()`, the note fired on every tool call in a real session because each invocation had a fresh parent — while the old test passed, because every `subprocess.run` from one pytest process shares a parent.

Verifies REQ-DDB-WIKI-054

Given

  1. env = {**os.environ, "TMPDIR": str(tmp_path), "CLAUDE_CODE_SESSION_ID": "fixed-session-key"}
  2. def once() -> bool: ## `sh -c` gives each invocation its own short-lived parent, so getppid differs per call. return bool( subprocess.run( [ "sh", "-c", f'echo {json.dumps(HOSTILE_EVENT)!r} | "$0" -m clew_hook', sys.executable, ], capture_output=True, text=True, env=env, ).stdout.strip() )
  3. spoke = [once() for _ in range(hook._QUIET_BELOW)]
→

When

  1. —
→

Then

  1. ✓ spoke[-1] holds
  2. ✓ any(spoke[:-1]) is false

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

What it checks (2)

  1. assert spoke[-1], ( "the tally did not accumulate across parent processes — it is keyed on something that is " "not stable across invocations, which is what production does" ) not attributed
  2. assert not any(spoke[:-1]), "and the earlier searches must still have passed in silence" not attributed

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