test_long_file_documentation_is_capped_with_an_explicit_notice¶
Tests › tests/test_file_subject.py
What this test is for
Why it exists
THE ONE FIELD ON THIS SUBJECT THAT IS UNBOUNDED BY ANYTHING THE INDEX CONTROLS. `members` is a list and is trimmed by `_DOSSIER_LISTS` like every other list on the surface; `documentation` is a scalar string and is therefore invisible to `_shrink_to_budget`. Measured in this repository: `clew/tiers.py` carries 2,794 characters of module docstring, `clew/cli.py` more, and a generated header's `@file` block has no ceiling at all. An unbounded scalar inside a budgeted payload is how the 65,536-byte cap gets exceeded by a reply that every list-trimmer reports as compliant.
Given
doc = "x" * (DETAIL_CAP + 500)db = tmp_path / "long.db"
6 more
conn = sqlite3.connect(db)conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER)")conn.execute("INSERT INTO path (name, type) VALUES ('src/verbose.c', 1)")conn.execute("CREATE TABLE file_docs (file_path TEXT NOT NULL, doc TEXT NOT NULL)")conn.execute("INSERT INTO file_docs VALUES ('src/verbose.c', ?)", (doc,))conn.commit()
When
built = file_subject(conn, "src/verbose.c")conn.close()
Then
- ✓ len(built.documentation) is less than len(doc)
- ✓ built.documentation contains "truncated"
- ✓ built.documentation contains str(len(doc))
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
Build this wiki from the index · 1 of 400 steps
… 256 earlier steps
… 139 later steps
3 more
- Look up one name: everything the index holds about it · 1 of 226 steps
- clew — `main` (clew/cli.py) · 1 of 400 steps
- `main` (scripts/export_parity.py) · 1 of 203 steps
tests/test_file_subject.py:209 · its file's page
What it checks (3)
assert len(built.documentation) < len(doc), "an unbounded scalar defeats the payload budget"observesfile_subjectviabuiltassert "truncated" in built.documentation, ( f"a silent cut reads as a complete document: {built.documentation[-120:]!r}" )observesfile_subjectviabuiltassert str(len(doc)) in built.documentation, ( "the notice must state the true length, so a reader knows how much it is not seeing" )observesfile_subjectviabuilt
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
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.
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-QUERY-003 measured
- REQ-DDB-QUERY-004 measured