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

Show on the map →

Called by none

Calls _nest, depth_limited_paths, derive_scope

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

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_deep_tree_records_where_the_walk_stopped → derive_scope
REQ-DDB-GUARD-012inferredtest_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-054inferredtest_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
lines 74–74_nest(tmp_path, scope._MAX_DEPTH + 3)lines 75–75derive_scope(tmp_path)lines 77–77hit = depth_limited_paths()lines 78–81assert 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" )lines 82–84assert 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]}" )

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

Show on the map →

Called by none

Calls _nest, depth_limited_paths, derive_scope

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

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_a_shallow_tree_records_nothing → derive_scope
REQ-DDB-GUARD-012inferredtest_a_shallow_tree_records_nothing → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node
REQ-DDB-WIKI-054inferredtest_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
lines 98–98_nest(tmp_path, 3)lines 99–99derive_scope(tmp_path)lines 101–104assert depth_limited_paths() == [], ( "a three-deep tree reported a depth limit, so the stamp fires on ordinary repositories " "and tells a reader nothing" )

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

Show on the map →

Called by none

Calls _nest, depth_limited_paths, derive_scope

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

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_record_is_reset_per_derivation → derive_scope
REQ-DDB-GUARD-012inferredtest_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-054inferredtest_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

Activity · 10 steps
lines 118–118deep = tmp_path / "deep"lines 119–119deep.mkdir()lines 120–120_nest(deep, scope._MAX_DEPTH + 3)lines 121–121derive_scope(deep)lines 122–122assert depth_limited_paths(), "the deep derivation recorded nothing; this test is vacuous"lines 124–124shallow = tmp_path / "shallow"lines 125–125shallow.mkdir()lines 126–126_nest(shallow, 2)lines 127–127derive_scope(shallow)lines 129–132assert depth_limited_paths() == [], ( "a shallow derivation inherited the previous one's record, so the stamp describes some " "other repository's walk" )