test_depth_limit_report.py¶
tests/test_depth_limit_report.py
Hitting the scope walk's depth limit must be recorded, not only logged.
test_a_deep_tree_records_where_the_walk_stopped
None test_depth_limit_report.test_a_deep_tree_records_where_the_walk_stopped(Path tmp_path)
A tree deeper than the limit records where the walk stopped.
tests/test_depth_limit_report.py:63
Checks
assert hit, (f"the walk descended {scope._MAX_DEPTH}+ levels and recorded nothing, so an index built " "from this tree cannot say why its corpus is the size it is" )assert any("d0" in str(p) for p in hit), (f"the recorded paths do not point into the deep chain: {[str(p) for p in hit]}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_deep_tree_records_where_the_walk_stopped → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_a_deep_tree_records_where_the_walk_stopped → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_a_deep_tree_records_where_the_walk_stopped → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 24 lines
def test_a_deep_tree_records_where_the_walk_stopped(tmp_path: Path) -> None:
"""FAILS BEFORE THE FIX with an empty list: the condition was detected and logged and then
discarded, so nothing downstream could report it.
Asserts the recorded path is INSIDE the deep chain rather than merely non-empty — a recorder
that noted the repo root on every build would satisfy a count-only assertion while naming
nothing useful.
@brief The depth limit is recorded with its location.
@version 1
"""
_nest(tmp_path, scope._MAX_DEPTH + 3)
derive_scope(tmp_path)
hit = depth_limited_paths()
assert hit, (
f"the walk descended {scope._MAX_DEPTH}+ levels and recorded nothing, so an index built "
"from this tree cannot say why its corpus is the size it is"
)
assert any("d0" in str(p) for p in hit), (
f"the recorded paths do not point into the deep chain: {[str(p) for p in hit]}"
)
Activity · 5 steps
test_a_shallow_tree_records_nothing
None test_depth_limit_report.test_a_shallow_tree_records_nothing(Path tmp_path)
A shallow tree records nothing, so the signal means something.
tests/test_depth_limit_report.py:89
Checks
assert depth_limited_paths() == [], ("a three-deep tree reported a depth limit, so the stamp fires on ordinary repositories " "and tells a reader nothing" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_shallow_tree_records_nothing → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_a_shallow_tree_records_nothing → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_a_shallow_tree_records_nothing → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 18 lines
def test_a_shallow_tree_records_nothing(tmp_path: Path) -> None:
"""THE CONTROL, AND IT CARRIES THE WHOLE VALUE OF THE OTHER TEST. A recorder that fired on
every build would pass the deep case and make the stamp meaningless — every index would
report a depth limit and no reader could tell the affected targets from the rest. The
presence of the key IS the signal, so its absence has to be real.
@brief An ordinary tree hits no limit.
@version 1
"""
_nest(tmp_path, 3)
derive_scope(tmp_path)
assert depth_limited_paths() == [], (
"a three-deep tree reported a depth limit, so the stamp fires on ordinary repositories "
"and tells a reader nothing"
)
Activity · 3 steps
test_the_record_is_reset_per_derivation
None test_depth_limit_report.test_the_record_is_reset_per_derivation(Path tmp_path)
The record describes the latest derivation, not an accumulation.
tests/test_depth_limit_report.py:109
Checks
assert depth_limited_paths(), "the deep derivation recorded nothing; this test is vacuous"assert depth_limited_paths() == [], ("a shallow derivation inherited the previous one's record, so the stamp describes some " "other repository's walk" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_record_is_reset_per_derivation → derive_scope |
| REQ-DDB-GUARD-012 | inferred | test_the_record_is_reset_per_derivation → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_the_record_is_reset_per_derivation → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 24 lines
def test_the_record_is_reset_per_derivation(tmp_path: Path) -> None:
"""A BUILD DERIVES MORE THAN ONCE — `_scope_provenance` re-derives on the whole-repo tier —
so a record that grew across derivations would report the same directory two or three times
and read as a wider problem than exists. Worse, a shallow repo derived after a deep one in
the same process would inherit the deep one's paths.
@brief Each derivation replaces the previous record.
@version 1
"""
deep = tmp_path / "deep"
deep.mkdir()
_nest(deep, scope._MAX_DEPTH + 3)
derive_scope(deep)
assert depth_limited_paths(), "the deep derivation recorded nothing; this test is vacuous"
shallow = tmp_path / "shallow"
shallow.mkdir()
_nest(shallow, 2)
derive_scope(shallow)
assert depth_limited_paths() == [], (
"a shallow derivation inherited the previous one's record, so the stamp describes some "
"other repository's walk"
)1 more lines, not shown