test_the_tally_holds_across_different_parent_processes¶
Tests › tests/test_hook.py
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
env = {**os.environ, "TMPDIR": str(tmp_path), "CLAUDE_CODE_SESSION_ID": "fixed-session-key"}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() )spoke = [once() for _ in range(hook._QUIET_BELOW)]
When
- —
Then
- ✓ spoke[-1] holds
- ✓ any(spoke[:-1]) is false
tests/test_hook.py:689 · its file's page
What it checks (2)
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 attributedassert 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)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-WIKI-054 | catalog | unknown |