test_graph_stats.py

tests/test_graph_stats.py

gh#7 — the whole-graph aggregate, and the three misreadings it must prevent.

test_an_empty_layer_reads_as_empty_and_a_dropped_one_as_absent

None test_graph_stats.test_an_empty_layer_reads_as_empty_and_a_dropped_one_as_absent(Path own_db)

THIS REPO'S MOST-REPEATED LESSON, asserted rather than written down again.

tests/test_graph_stats.py:167

Show on the map →

Called by none

Calls none

Checks

  • assert before[layer].state == LAYER_STATE_EMPTY
  • assert before[layer].rows == 0
  • assert before["call_edges"].state == LAYER_STATE_POPULATED
  • assert after[layer].state == LAYER_STATE_ABSENT
  • assert after[layer].rows == 0
  • assert after[layer].state != before[layer].state, ("an absent layer must not report the same state as an empty one" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 35 lines
def test_an_empty_layer_reads_as_empty_and_a_dropped_one_as_absent(own_db: Path) -> None:
    """THIS REPO'S MOST-REPEATED LESSON, asserted rather than written down again.

    `'empty'` says a detector ran and found nothing — a measurement, whose meaning
    still depends on whether the detector could see (macro-defined accessors are
    invisible to a `memberdef`-reading detector, and that empty layer was once
    recorded as a correct negative and later retracted). `'absent'` says the table is
    not here at all, which is a fact about the BUILD and no evidence at all about the
    code.

    The control is the DROP: the same layer name is asserted `'empty'` before and
    `'absent'` after, on the same database, so a payload that collapsed the two into
    "no rows" cannot pass both halves.
    """
    layer = "external_boundaries"
    before = {s.layer: s for s in graph_stats(own_db).layers}
    assert before[layer].state == LAYER_STATE_EMPTY
    assert before[layer].rows == 0
    assert before["call_edges"].state == LAYER_STATE_POPULATED

    conn = sqlite3.connect(own_db)
    try:
        conn.execute(f"DROP TABLE {layer}")
        conn.commit()
    finally:
        conn.close()

    after = {s.layer: s for s in graph_stats(own_db).layers}
    assert after[layer].state == LAYER_STATE_ABSENT
    assert after[layer].rows == 0
    assert after[layer].state != before[layer].state, (
        "an absent layer must not report the same state as an empty one"
    )

Activity · 13 steps
lines 181–181layer = "external_boundaries"lines 182–182before = {s.layer: s for s in graph_stats(own_db).layers}lines 183–183assert before[layer].state == LAYER_STATE_EMPTYlines 184–184assert before[layer].rows == 0lines 185–185assert before["call_edges"].state == LAYER_STATE_POPULATEDlines 187–187conn = sqlite3.connect(own_db)lines 188–188trylines 189–189conn.execute(f"DROP TABLE {layer}")lines 190–190conn.commit()lines 194–194after = {s.layer: s for s in graph_stats(own_db).layers}lines 195–195assert after[layer].state == LAYER_STATE_ABSENTlines 196–196assert after[layer].rows == 0lines 197–199assert after[layer].state != before[layer].state, ( "an absent layer must not report the same state as an empty one" )

test_an_index_with_no_call_graph_says_so_instead_of_reporting_a_zero_ratio

None test_graph_stats.test_an_index_with_no_call_graph_says_so_instead_of_reporting_a_zero_ratio(Path own_db)

An empty call graph must not present as a measured `0.00x` inflation.

tests/test_graph_stats.py:260

Show on the map →

Called by none

Calls _set_call_edges

Checks

  • assert emptied.logical_pairs == 0
  • assert emptied.row_inflation == 0.0
  • assert emptied.row_meaning == EMPTY_ROW_MEANING
  • assert "statement about the index" in emptied.row_meaning
  • assert dropped == emptied, "a dropped and an emptied call graph must aggregate alike"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 28 lines
def test_an_index_with_no_call_graph_says_so_instead_of_reporting_a_zero_ratio(
    own_db: Path,
) -> None:
    """An empty call graph must not present as a measured `0.00x` inflation.

    Both empty paths — the table dropped and the table emptied — have to produce the
    identical aggregate, because they are the same fact about the CALL GRAPH even
    though the layer inventory distinguishes them. The `EMPTY_ROW_MEANING` note is
    what stops a consumer reading zero pairs as "this repo has no calls".
    """
    _set_call_edges(own_db, [])
    emptied = graph_stats(own_db).calls
    assert emptied.logical_pairs == 0
    assert emptied.row_inflation == 0.0
    assert emptied.row_meaning == EMPTY_ROW_MEANING
    assert "statement about the index" in emptied.row_meaning

    conn = sqlite3.connect(own_db)
    try:
        conn.execute("DROP TABLE call_edges")
        conn.commit()
    finally:
        conn.close()

    dropped = graph_stats(own_db).calls
    assert dropped == emptied, "a dropped and an emptied call graph must aggregate alike"

Activity · 12 steps
lines 270–270_set_call_edges(own_db, [])lines 271–271emptied = graph_stats(own_db).callslines 272–272assert emptied.logical_pairs == 0lines 273–273assert emptied.row_inflation == 0.0lines 274–274assert emptied.row_meaning == EMPTY_ROW_MEANINGlines 275–275assert "statement about the index" in emptied.row_meaninglines 277–277conn = sqlite3.connect(own_db)lines 278–278trylines 279–279conn.execute("DROP TABLE call_edges")lines 280–280conn.commit()lines 284–284dropped = graph_stats(own_db).callslines 285–285assert dropped == emptied, "a dropped and an emptied call graph must aggregate alike"

test_every_declared_layer_is_reported_with_a_registered_state

None test_graph_stats.test_every_declared_layer_is_reported_with_a_registered_state(Path own_db)

The inventory is TOTAL and its states are vocabulary members.

tests/test_graph_stats.py:202

Show on the map →

Called by none

Calls list

Checks

  • assert [s.layer for s in stats.layers] == list(GRAPH_LAYERS)
  • assert stat.state in LAYER_STATE.values, f"{stat.layer} reports unregistered {stat.state!r}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 14 lines
def test_every_declared_layer_is_reported_with_a_registered_state(own_db: Path) -> None:
    """The inventory is TOTAL and its states are vocabulary members.

    A layer added to the schema and forgotten in `GRAPH_LAYERS` reports as nothing at
    all rather than as `absent`, which is a false negative that does not even look
    like one. And an unregistered state string would defeat the point of putting
    `layer_state` in `vocabulary.py`.
    """
    stats = graph_stats(own_db)
    assert [s.layer for s in stats.layers] == list(GRAPH_LAYERS)
    for stat in stats.layers:
        assert stat.state in LAYER_STATE.values, f"{stat.layer} reports unregistered {stat.state!r}"

Activity · 4 steps
lines 210–210stats = graph_stats(own_db)lines 211–211assert [s.layer for s in stats.layers] == list(GRAPH_LAYERS)lines 212–212◇ for stat in stats.layerslines 213–213assert stat.state in LAYER_STATE.values, f"{stat.layer} reports unregistered {stat.state!r}"

test_file_counts_read_the_persisted_coverage_and_admit_when_it_is_absent

None test_graph_stats.test_file_counts_read_the_persisted_coverage_and_admit_when_it_is_absent(Path own_db)

gh#6's figures are READ, not re-measured — and their absence is disclosed.

tests/test_graph_stats.py:216

Show on the map →

Called by none

Calls none

Checks

  • assert files.coverage_recorded is True
  • assert files.substantive_files == 41
  • assert files.barren_ratio == pytest.approx(0.125)
  • assert files.indexed_files >= files.files_with_symbols >= files.files_with_bodies
  • assert bare.coverage_recorded is False
  • assert bare.substantive_files == 0
  • assert bare.barren_ratio == 0.0
  • assert bare.indexed_files == files.indexed_files

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 44 lines
def test_file_counts_read_the_persisted_coverage_and_admit_when_it_is_absent(
    own_db: Path,
) -> None:
    """gh#6's figures are READ, not re-measured — and their absence is disclosed.

    The first half proves the read reaches `build_meta`: a planted `coverage.*` value
    shows up in the payload, which a re-implementation computing its own barren ratio
    over the fixture could not do. The second half deletes the section and asserts
    `coverage_recorded` goes False with the figures at zero — the distinction between
    "measured healthy" and "never measured", which is the same absent-vs-empty rule
    one level up.
    """
    conn = sqlite3.connect(own_db)
    try:
        conn.executemany(
            "INSERT OR REPLACE INTO build_meta (key, value) VALUES (?,?)",
            [("coverage.substantive_files", "41"), ("coverage.barren_ratio", "0.125")],
        )
        conn.commit()
    finally:
        conn.close()

    files = graph_stats(own_db).files
    assert files.coverage_recorded is True
    assert files.substantive_files == 41
    assert files.barren_ratio == pytest.approx(0.125)
    # The three file counts are separate measurements, not one number restated.
    assert files.indexed_files >= files.files_with_symbols >= files.files_with_bodies

    conn = sqlite3.connect(own_db)
    try:
        conn.execute("DELETE FROM build_meta WHERE key LIKE 'coverage.%'")
        conn.commit()
    finally:
        conn.close()

    bare = graph_stats(own_db).files
    assert bare.coverage_recorded is False
    assert bare.substantive_files == 0
    assert bare.barren_ratio == 0.0
    # ...while the counts this module measures ITSELF are unaffected by the deletion.
    assert bare.indexed_files == files.indexed_files

Activity · 18 steps
lines 228–228conn = sqlite3.connect(own_db)lines 229–229trylines 230–233conn.executemany( "INSERT OR REPLACE INTO build_meta (key, value) VALUES (?,?)", [("coverage.substantive_files", "41"), ("coverage.barren_ratio", "0.125")], )lines 234–234conn.commit()lines 238–238files = graph_stats(own_db).fileslines 239–239assert files.coverage_recorded is Truelines 240–240assert files.substantive_files == 41lines 241–241assert files.barren_ratio == pytest.approx(0.125)lines 243–243assert files.indexed_files >= files.files_with_symbols >= files.files_with_bodieslines 245–245conn = sqlite3.connect(own_db)lines 246–246trylines 247–247conn.execute("DELETE FROM build_meta WHERE key LIKE 'coverage.%'")lines 248–248conn.commit()lines 252–252bare = graph_stats(own_db).fileslines 253–253assert bare.coverage_recorded is Falselines 254–254assert bare.substantive_files == 0lines 255–255assert bare.barren_ratio == 0.0lines 257–257assert bare.indexed_files == files.indexed_files

test_graph_stats_survives_a_database_with_no_tables

None test_graph_stats.test_graph_stats_survives_a_database_with_no_tables(Path tmp_path)

NON-RAISING, on the thinnest possible input.

tests/test_graph_stats.py:288

Show on the map →

Called by none

Calls none

Checks

  • assert stats.symbol_rows == 0
  • assert stats.symbol_provenance == {}
  • assert {s.state for s in stats.layers} == {LAYER_STATE_ABSENT}
  • assert stats.calls.row_meaning == EMPTY_ROW_MEANING

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 18 lines
def test_graph_stats_survives_a_database_with_no_tables(tmp_path: Path) -> None:
    """NON-RAISING, on the thinnest possible input.

    A trust aggregate that raises on a thin index is useless exactly when a consumer
    most needs to discover the index is thin — the same reasoning
    `coverage.measure_index_coverage` states for failing soft. Every layer reports
    `absent`, which is the honest answer and not a claim about any repository.
    """
    bare = tmp_path / "empty.db"
    sqlite3.connect(bare).close()

    stats = graph_stats(bare)
    assert stats.symbol_rows == 0
    assert stats.symbol_provenance == {}
    assert {s.state for s in stats.layers} == {LAYER_STATE_ABSENT}
    assert stats.calls.row_meaning == EMPTY_ROW_MEANING

Activity · 7 steps
lines 296–296bare = tmp_path / "empty.db"lines 297–297sqlite3.connect(bare).close()lines 299–299stats = graph_stats(bare)lines 300–300assert stats.symbol_rows == 0lines 301–301assert stats.symbol_provenance == {}lines 302–302assert {s.state for s in stats.layers} == {LAYER_STATE_ABSENT}lines 303–303assert stats.calls.row_meaning == EMPTY_ROW_MEANING

test_non_fuzzy_evidence_is_tested_per_pair_not_per_row

None test_graph_stats.test_non_fuzzy_evidence_is_tested_per_pair_not_per_row(Path own_db)

A pair with ONE exact row and one fuzzy row has non-fuzzy evidence.

tests/test_graph_stats.py:141

Show on the map →

Called by none

Calls _set_call_edges

Checks

  • assert calls.rows_by_confidence[CALL_MATCH_FUZZY] == 3
  • assert calls.rows_by_confidence[CALL_MATCH_EXACT] == 1
  • assert calls.logical_pairs == 2
  • assert calls.pairs_without_nonfuzzy == 1
  • assert calls.pairs_without_nonfuzzy_share == pytest.approx(0.5)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 26 lines
def test_non_fuzzy_evidence_is_tested_per_pair_not_per_row(own_db: Path) -> None:
    """A pair with ONE exact row and one fuzzy row has non-fuzzy evidence.

    The installed layer has a majority of fuzzy ROWS and zero unresolved PAIRS, so a
    row-level filter would report the exact opposite of the truth. The second pair is
    all-fuzzy, which keeps the assertion from passing on a stubbed zero.
    """
    _set_call_edges(
        own_db,
        [
            (76, 158, CALL_SOURCE_DOXYGEN_SQLITE, CALL_MATCH_EXACT),
            (76, 158, CALL_SOURCE_AST, CALL_MATCH_FUZZY),
            (76, 158, CALL_SOURCE_AST_MEMBER, CALL_MATCH_FUZZY),
            (158, 76, CALL_SOURCE_AST, CALL_MATCH_FUZZY),
        ],
    )
    calls = graph_stats(own_db).calls

    assert calls.rows_by_confidence[CALL_MATCH_FUZZY] == 3
    assert calls.rows_by_confidence[CALL_MATCH_EXACT] == 1
    # Two pairs; only the SECOND lacks non-fuzzy evidence.
    assert calls.logical_pairs == 2
    assert calls.pairs_without_nonfuzzy == 1
    assert calls.pairs_without_nonfuzzy_share == pytest.approx(0.5)

Activity · 7 steps
lines 148–156_set_call_edges( own_db, [ (76, 158, CALL_SOURCE_DOXYGEN_SQLITE, CALL_MATCH_EXACT), (76, 158, CALL_SOURCE_AST, CALL_MATCH_FUZZY), (76, 158, CALL_SOURCE_AST_MEMBER, CALL_MATCH_FUZZY), (158, 76, CALL_SOURCE_AST, CALL_MATCH_FUZZY), ], )lines 157–157calls = graph_stats(own_db).callslines 159–159assert calls.rows_by_confidence[CALL_MATCH_FUZZY] == 3lines 160–160assert calls.rows_by_confidence[CALL_MATCH_EXACT] == 1lines 162–162assert calls.logical_pairs == 2lines 163–163assert calls.pairs_without_nonfuzzy == 1lines 164–164assert calls.pairs_without_nonfuzzy_share == pytest.approx(0.5)

test_rows_and_logical_pairs_are_separate_numbers_and_the_payload_says_which

None test_graph_stats.test_rows_and_logical_pairs_are_separate_numbers_and_the_payload_says_which(Path own_db)

The #38 misreading, refused at the aggregate level.

tests/test_graph_stats.py:102

Show on the map →

Called by none

Calls _set_call_edges

Checks

  • assert calls.rows == 3
  • assert calls.logical_pairs == 2
  • assert calls.rows != calls.logical_pairs, "the two counts must not be conflated"
  • assert calls.row_inflation == pytest.approx(1.5)
  • assert "3 rows" in calls.row_meaning
  • assert "2 distinct" in calls.row_meaning
  • assert "logical_pairs" in calls.row_meaning
  • assert "ONE ROW PER EXTRACTION LAYER" in calls.row_meaning

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
Source · 39 lines
def test_rows_and_logical_pairs_are_separate_numbers_and_the_payload_says_which(
    own_db: Path,
) -> None:
    """The #38 misreading, refused at the aggregate level.

    THREE rows over TWO pairs is installed deliberately, so a payload that reported
    only one count would have to pick a wrong one. The assertions pin: both counts
    present and DIFFERENT, the inflation factor equal to their ratio, and
    `row_meaning` carrying BOTH figures plus the words that say which is the
    relationship count. That last clause is the actual contract — the numbers are
    useless to a consumer who cannot tell them apart, and `row_meaning` is the field
    that makes quoting one of them safe.
    """
    _set_call_edges(
        own_db,
        [
            # ONE relationship, stored once per layer that found it.
            (76, 158, CALL_SOURCE_DOXYGEN_SQLITE, CALL_MATCH_EXACT),
            (76, 158, CALL_SOURCE_AST_MEMBER, CALL_MATCH_EXACT),
            # A second, distinct relationship found by one layer only.
            (76, 76, CALL_SOURCE_AST, CALL_MATCH_FUZZY),
        ],
    )
    calls = graph_stats(own_db).calls

    assert calls.rows == 3
    assert calls.logical_pairs == 2
    assert calls.rows != calls.logical_pairs, "the two counts must not be conflated"
    assert calls.row_inflation == pytest.approx(1.5)

    # The self-describing half. Both numbers appear, and the sentence names which one
    # is the relationship count -- a consumer quoting `rows` as "the number of calls"
    # is the documented failure, so the payload has to refuse it in words.
    assert "3 rows" in calls.row_meaning
    assert "2 distinct" in calls.row_meaning
    assert "logical_pairs" in calls.row_meaning
    assert "ONE ROW PER EXTRACTION LAYER" in calls.row_meaning

Activity · 10 steps
lines 115–124_set_call_edges( own_db, [ # ONE relationship, stored once per layer that found it. (76, 158, CALL_SOURCE_DOXYGEN_SQLITE, CALL_MATCH_EXACT), (76, 158, CALL_SOURCE_AST_MEMBER, CALL_MATCH_EXACT), # A second, distinct relationship found by one layer only. (76, 76, CALL_SOURCE_AST, CALL_MATCH_FUZZY), ], )lines 125–125calls = graph_stats(own_db).callslines 127–127assert calls.rows == 3lines 128–128assert calls.logical_pairs == 2lines 129–129assert calls.rows != calls.logical_pairs, "the two counts must not be conflated"lines 130–130assert calls.row_inflation == pytest.approx(1.5)lines 135–135assert "3 rows" in calls.row_meaninglines 136–136assert "2 distinct" in calls.row_meaninglines 137–137assert "logical_pairs" in calls.row_meaninglines 138–138assert "ONE ROW PER EXTRACTION LAYER" in calls.row_meaning

test_symbol_provenance_is_a_measured_distribution_or_nothing

None test_graph_stats.test_symbol_provenance_is_a_measured_distribution_or_nothing(Path tmp_path, Path own_db)

Provenance is measured or absent, never invented.

tests/test_graph_stats.py:306

Show on the map →

Called by none

Calls ensure_symbol_provenance, seed_doxygen_tables

Checks

  • assert graph_stats(pre19).symbol_provenance == {}, ("an index with no provenance column must report {}, not an invented split" )
  • assert ensure_symbol_provenance(conn) is True
  • assert stats.symbol_provenance == {SYMBOL_SOURCE_DOXYGEN: stats.symbol_rows}
  • assert sum(stats.symbol_provenance.values()) == stats.symbol_rows
  • assert set(shipped.symbol_provenance) == {SYMBOL_SOURCE_DOXYGEN, SYMBOL_SOURCE_AST}, ("the fixture must exercise BOTH provenances, or it cannot represent the " "`dg_source = 'doxygen'` filter every later test depends on" )
  • assert shipped.symbol_provenance[SYMBOL_SOURCE_AST] > 0
  • assert sum(shipped.symbol_provenance.values()) == shipped.symbol_rows

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_symbol_provenance_is_a_measured_distribution_or_nothing → ensure_symbol_provenance
REQ-DDB-MCP-001measured
REQ-DDB-PIPE-005measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-008measured
REQ-DDB-SCHEMA-012measured
Source · 64 lines
def test_symbol_provenance_is_a_measured_distribution_or_nothing(
    tmp_path: Path,
    own_db: Path,
) -> None:
    """`{}` on an index that cannot answer, never an invented all-doxygen split.

    The invented split would be TRUE on such an index and still wrong to publish: a
    consumer cannot tell a measured mix from a fabricated one, so the honest answer
    to "what is the mix" on an index with no provenance column is "not recorded".

    THE `{}` HALF USED TO BE MEASURED ON `rich_db` AS IT SHIPPED, and cannot be any
    more (gh#362): the fixture was missing gh#11's `recover_ast_symbols`, the
    integration tier's fidelity check caught that as real schema drift, and the
    fixture now runs the stage — so it carries the provenance column like every real
    build. The pre-build-19 index is therefore built HERE from `seed_doxygen_tables`
    alone, which is still a genuine doxygen-only index rather than a simulated one:
    doxygen's verbatim schema has no `dg_source`, so nothing about it is hand-faked.
    The populated half then adds the column the way the pipeline does — through
    `ensure_symbol_provenance`, not a hand-written `ALTER TABLE`, so the retroactive
    `NOT NULL DEFAULT 'doxygen'` labelling is the pipeline's own and not this test's
    idea of it.

    `own_db` is kept as the second half's control: it PINS that the fixture now ships
    the column and reports a measured split, so a future fixture that silently loses
    the stage again fails here as well as in the integration tier.

    THAT CONTROL GOT STRONGER AT gh#372, and only because it FAILED. It used to assert
    `{doxygen: symbol_rows}` — an all-doxygen split — which was true of the fixture only
    because `recover_ast_symbols` happened to recover nothing from `csample`: every
    function there is a hand-made `memberdef` row. So the control could not tell "the
    stage ran and found nothing" from "the stage never ran", which is the exact
    distinction gh#362 added it to make. Recovering the six file-scope statics broke it,
    and the assertion now names BOTH provenances, so a fixture that loses the stage
    reports one key and fails rather than quietly matching.

    @brief Provenance is measured or absent, never invented.
    @version 3
    """
    pre19 = tmp_path / "pre19.db"
    seed_doxygen_tables(pre19)
    assert graph_stats(pre19).symbol_provenance == {}, (
        "an index with no provenance column must report {}, not an invented split"
    )

    conn = sqlite3.connect(pre19)
    try:
        assert ensure_symbol_provenance(conn) is True
        conn.commit()
    finally:
        conn.close()

    stats = graph_stats(pre19)
    assert stats.symbol_provenance == {SYMBOL_SOURCE_DOXYGEN: stats.symbol_rows}
    assert sum(stats.symbol_provenance.values()) == stats.symbol_rows

    shipped = graph_stats(own_db)
    assert set(shipped.symbol_provenance) == {SYMBOL_SOURCE_DOXYGEN, SYMBOL_SOURCE_AST}, (
        "the fixture must exercise BOTH provenances, or it cannot represent the "
        "`dg_source = 'doxygen'` filter every later test depends on"
    )
    assert shipped.symbol_provenance[SYMBOL_SOURCE_AST] > 0
    assert sum(shipped.symbol_provenance.values()) == shipped.symbol_rows

Activity · 14 steps
lines 344–344pre19 = tmp_path / "pre19.db"lines 345–345seed_doxygen_tables(pre19)lines 346–348assert graph_stats(pre19).symbol_provenance == {}, ( "an index with no provenance column must report {}, not an invented split" )lines 350–350conn = sqlite3.connect(pre19)lines 351–351trylines 352–352assert ensure_symbol_provenance(conn) is Truelines 353–353conn.commit()lines 357–357stats = graph_stats(pre19)lines 358–358assert stats.symbol_provenance == {SYMBOL_SOURCE_DOXYGEN: stats.symbol_rows}lines 359–359assert sum(stats.symbol_provenance.values()) == stats.symbol_rowslines 361–361shipped = graph_stats(own_db)lines 362–365assert set(shipped.symbol_provenance) == {SYMBOL_SOURCE_DOXYGEN, SYMBOL_SOURCE_AST}, ( "the fixture must exercise BOTH provenances, or it cannot represent the " "`dg_source = 'doxygen'` filter every later test depends on" )lines 366–366assert shipped.symbol_provenance[SYMBOL_SOURCE_AST] > 0lines 367–367assert sum(shipped.symbol_provenance.values()) == shipped.symbol_rows

test_the_aggregate_is_reachable_from_the_package_surface

None test_graph_stats.test_the_aggregate_is_reachable_from_the_package_surface(Path rich_db)

`graph_stats` is exported, and its export is the whole point of gh#7.

tests/test_graph_stats.py:370

Show on the map →

Called by none

Calls graph_stats

Checks

  • assert "graph_stats" in q.__all__
  • assert q.graph_stats(rich_db).calls.logical_pairs > 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_aggregate_is_reachable_from_the_package_surface → graph_stats → _symbol_provenance → records_provenance
REQ-DDB-MCP-001measuredtest_the_aggregate_is_reachable_from_the_package_surface → graph_stats → file_counts → meta_section
REQ-DDB-PIPE-005measuredtest_the_aggregate_is_reachable_from_the_package_surface → graph_stats → read_build_signature
REQ-DDB-QUERY-001measuredtest_the_aggregate_is_reachable_from_the_package_surface → graph_stats → connect
REQ-DDB-QUERY-003measuredtest_the_aggregate_is_reachable_from_the_package_surface → graph_stats → call_edge_counts → table_exists
REQ-DDB-QUERY-008measuredtest_the_aggregate_is_reachable_from_the_package_surface → graph_stats
Source · 10 lines
def test_the_aggregate_is_reachable_from_the_package_surface(rich_db: Path) -> None:
    """`graph_stats` is exported, and its export is the whole point of gh#7.

    The issue is not that the numbers were uncomputable — a consumer could sample
    `callers`/`callees` and estimate, and some benchmark cells did. It is that there
    was no endpoint. A private helper nobody can reach would leave the issue open with
    the code written.
    """
    assert "graph_stats" in q.__all__
    assert q.graph_stats(rich_db).calls.logical_pairs > 0

1 more lines, not shown

Activity · 2 steps
lines 378–378assert "graph_stats" in q.__all__lines 379–379assert q.graph_stats(rich_db).calls.logical_pairs > 0