test_every_renderer_is_vetted¶
Tests › tests/test_hook.py
What this test is for
Why it exists
2.1 COMMENT NOTE (owner Q/A 2026-11-24). A second renderer is a second way for a value to become TEXT, and `test_no_run_time_value_can_reach_the_output` scans `_payload_for` alone, so a renderer it does not name would sit outside the security argument. Every function that calls `json.dumps` must be named here; the comment renderer interpolates exactly one value, bound from `int()`, and serialises once with no keywords.
Verifies REQ-DDB-WIKI-054
Given
tree = ast.parse(HOOK_SOURCE.read_text(encoding="utf-8"))functions = [n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)]
6 more
def dumps_in(fn: ast.FunctionDef) -> list[ast.Call]: return [ n for n in ast.walk(fn) if isinstance(n, ast.Call) and isinstance(n.func, ast.Attribute) and n.func.attr == "dumps" ]renderers = {fn.name for fn in functions if dumps_in(fn)}fn = next(f for f in functions if f.name == "_comments_payload")subs = [n for n in ast.walk(fn) if isinstance(n, ast.BinOp) and isinstance(n.op, ast.Mod)]operand = subs[0].right.idbinds = [ n.value.func.id for n in ast.walk(fn) if isinstance(n, ast.Assign) and isinstance(n.value, ast.Call) and isinstance(n.value.func, ast.Name) and any(isinstance(t, ast.Name) and t.id == operand for t in n.targets) ]
When
- —
Then
- ✓ renderers equals {"_payload_for", "_comments_payload"}
- ✓ len(subs) equals 1
- ✓ isinstance(subs[0].right, ast.Name) holds
- ✓ binds equals ["int"]
- ✓ len(dumps_in(fn)) equals 1
- ✓ dumps_in(fn)[0].keywords is false
tests/test_hook.py:1423 · its file's page
What it checks (4)
assert renderers == {"_payload_for", "_comments_payload"}, renderersnot attributedassert len(subs) == 1 and isinstance(subs[0].right, ast.Name)not attributedassert binds == ["int"], f"{operand!r} must be bound from int() alone; bound from {binds}"not attributedassert len(dumps_in(fn)) == 1 and not dumps_in(fn)[0].keywordsnot 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 |