test_an_undeliverable_payload_is_dropped_silently¶
Tests › tests/test_hook.py
What this test is for
Why it exists
FOUND BY AN ADVERSARIAL AUDIT OF 1.0.10, AND IT FALSIFIED THIS COMPONENT'S CENTRAL CLAIM. `sys.stdout` is a BUFFERED TextIOWrapper, so `write()` alone lands in the buffer and the real I/O is deferred to interpreter shutdown — after `main()` has returned 0, and outside every `try` in the module. When that deferred flush failed, CPython printed "Exception ignored in: <stdout>" to stderr and exited 120.
Verifies REQ-DDB-WIKI-054
Given
marker = tmp_path / f"clew-hook-seen-flush{hook._MISS_SUFFIX}"marker.write_bytes(b"." * (hook._QUIET_BELOW - 1))
3 more
event = json.dumps({"tool_input": {"file_path": "/x/a.py"}})if not Path("/dev/full").exists(): # pragma: no cover - platform guard pytest.skip("/dev/full is Linux-specific")with Path("/dev/full").open("w") as full: result = subprocess.run( [sys.executable, "-m", "clew_hook", hook.READ_FLAG], input=event, stdout=full, stderr=subprocess.PIPE, text=True, cwd=str(REPO), env={**os.environ, "TMPDIR": str(tmp_path), "CLAUDE_CODE_SESSION_ID": "flush"}, check=False, )
When
- —
Then
- ✓ result.returncode equals 0
- ✓ result.stderr equals ""
tests/test_hook.py:1290 · its file's page
What it checks (2)
assert result.returncode == 0, ( f"exit {result.returncode} when stdout could not be written. A non-zero exit on " f"PostToolUse surfaces stderr to the model, which is the channel this component exists " f"to keep shut." )not attributedassert result.stderr == "", ( f"stderr must be EMPTY, not merely traceback-free — the shutdown-flush message says " f"'Exception ignored in:' and contains no 'Traceback', which is why the existing scans " f"missed it. Got: {result.stderr[:300]}" )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 |