test_build_docs_db.py

tests/test_build_docs_db.py

Per-module unit tests for the clew/ package.

test_a_declaration_still_beats_every_conventional_location

None test_build_docs_db.test_a_declaration_still_beats_every_conventional_location(Path tmp_path)

Declaration outranks the widened convention tier.

tests/test_build_docs_db.py:2224

Checks

  • assert resolve_catalog_path(cfg, tmp_path) == declared.resolve()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_a_declaration_still_beats_every_conventional_location → resolve_catalog_path
Source · 21 lines
def test_a_declaration_still_beats_every_conventional_location(tmp_path: Path) -> None:
    """THE CONTROL on the precedence rule the resolver exists to hold: flag > declaration >
    convention > nothing. Adding a location extends the LAST tier only, so a declared catalog
    must still win even when a file sits at a conventional path — including the new one.

    @brief Declaration outranks the widened convention tier.
    @version 1
    """
    from clew.requirements import resolve_catalog_path

    declared = tmp_path / "spec" / "reqs.yaml"
    declared.parent.mkdir()
    declared.write_text("requirements: {}\n", encoding="utf-8")
    for conventional in (tmp_path / "requirements.yaml", tmp_path / "docs" / "requirements.yaml"):
        conventional.parent.mkdir(exist_ok=True)
        conventional.write_text("requirements: {}\n", encoding="utf-8")

    cfg = {"requirements": {"file": "spec/reqs.yaml"}}
    assert resolve_catalog_path(cfg, tmp_path) == declared.resolve()

Activity · 9 steps
lines 2232–2232from clew.requirements import resolve_catalog_pathlines 2234–2234declared = tmp_path / "spec" / "reqs.yaml"lines 2235–2235declared.parent.mkdir()lines 2236–2236declared.write_text("requirements: {}\n", encoding="utf-8")lines 2237–2237◇ for conventional in (tmp_path / "requirements.yaml", tmp_path / "docs" / "requirements.yaml")lines 2238–2238conventional.parent.mkdir(exist_ok=True)lines 2239–2239conventional.write_text("requirements: {}\n", encoding="utf-8")lines 2241–2241cfg = {"requirements": {"file": "spec/reqs.yaml"}}lines 2242–2242assert resolve_catalog_path(cfg, tmp_path) == declared.resolve()

test_a_declared_catalog_path_is_honoured_without_a_cli_flag

None test_build_docs_db.test_a_declared_catalog_path_is_honoured_without_a_cli_flag(Path tmp_path)

doxygen-guard issue #7: a repo that DECLARES where its catalog lives had that declaration honoured by the gate and ignored by the index. `--requirements` or nothing — so the repo had to say it twice, and through the MCP server (which passes no such flag) the declaration could never be honoured at all. Same argv-only hole `.clew.yaml` exists to close, left open on this one field.

tests/test_build_docs_db.py:2118

Checks

  • assert declared_catalog_path(cfg, tmp_path) == (tmp_path / "docs" / "reqs.yaml").resolve()
  • assert declared_catalog_path({}, tmp_path) is None
  • assert declared_catalog_path(None, tmp_path) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_a_declared_catalog_path_is_honoured_without_a_cli_flag → declared_catalog_path
Source · 21 lines
def test_a_declared_catalog_path_is_honoured_without_a_cli_flag(tmp_path: Path) -> None:
    """doxygen-guard issue #7: a repo that DECLARES where its catalog lives had that
    declaration honoured by the gate and ignored by the index. `--requirements` or nothing
    — so the repo had to say it twice, and through the MCP server (which passes no such
    flag) the declaration could never be honoured at all. Same argv-only hole
    `.clew.yaml` exists to close, left open on this one field.

    Verified end to end on the pinned public integration target: 23 requirements ingest
    with no flag at all."""
    from clew.requirements import declared_catalog_path

    (tmp_path / "docs").mkdir()
    (tmp_path / "docs" / "reqs.yaml").write_text("requirements: {}\n", encoding="utf-8")
    cfg = {"requirements": {"file": "docs/reqs.yaml"}}

    assert declared_catalog_path(cfg, tmp_path) == (tmp_path / "docs" / "reqs.yaml").resolve()
    ## No declaration and no config are both simply "nothing declared", not errors.
    assert declared_catalog_path({}, tmp_path) is None
    assert declared_catalog_path(None, tmp_path) is None

Activity · 7 steps
lines 2127–2127from clew.requirements import declared_catalog_pathlines 2129–2129(tmp_path / "docs").mkdir()lines 2130–2130(tmp_path / "docs" / "reqs.yaml").write_text("requirements: {}\n", encoding="utf-8")lines 2131–2131cfg = {"requirements": {"file": "docs/reqs.yaml"}}lines 2133–2133assert declared_catalog_path(cfg, tmp_path) == (tmp_path / "docs" / "reqs.yaml").resolve()lines 2135–2135assert declared_catalog_path({}, tmp_path) is Nonelines 2136–2136assert declared_catalog_path(None, tmp_path) is None

test_a_declared_catalog_that_does_not_exist_degrades_rather_than_raising

None test_build_docs_db.test_a_declared_catalog_that_does_not_exist_degrades_rather_than_raising(Path tmp_path)

A catalog is OPTIONAL metadata — `req_edges` populate from tags regardless — so a stale declared path must degrade to "no catalog" with a warning, not fail a build that has already spent a doxygen run. Raising here would make a one-line typo in someone else's config cost them the whole index.

tests/test_build_docs_db.py:2245

Checks

  • assert declared_catalog_path(cfg, tmp_path) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_a_declared_catalog_that_does_not_exist_degrades_rather_than_raising → declared_catalog_path
Source · 13 lines
def test_a_declared_catalog_that_does_not_exist_degrades_rather_than_raising(
    tmp_path: Path,
) -> None:
    """A catalog is OPTIONAL metadata — `req_edges` populate from tags regardless — so a
    stale declared path must degrade to "no catalog" with a warning, not fail a build that
    has already spent a doxygen run. Raising here would make a one-line typo in someone
    else's config cost them the whole index."""
    from clew.requirements import declared_catalog_path

    cfg = {"requirements": {"file": "docs/not_here.yaml"}}
    assert declared_catalog_path(cfg, tmp_path) is None

Activity · 3 steps
lines 2252–2252from clew.requirements import declared_catalog_pathlines 2254–2254cfg = {"requirements": {"file": "docs/not_here.yaml"}}lines 2255–2255assert declared_catalog_path(cfg, tmp_path) is None

test_a_declared_shared_key_pattern_beats_a_built_in_default

None test_build_docs_db.test_a_declared_shared_key_pattern_beats_a_built_in_default()

tests/test_build_docs_db.py:2077

Show on the map →

Called by none

Calls _match_accessor, resolve_shared_key_patterns

Checks

  • assert builtin.dispatch_mode != "queued", "fixture assumes the default is not 'queued'"
  • assert mode is not None, "the declared prefix must still match"
  • assert mode[2] == "queued", (f"the DECLARED dispatch_mode must win over the built-in default's; got {mode[2]!r}" )
  • assert _match_accessor(probe, plain_writers)[2] == builtin.dispatch_mode

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_declared_shared_key_pattern_beats_a_built_in_default → resolve_shared_key_patterns
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-005measuredtest_a_declared_shared_key_pattern_beats_a_built_in_default → resolve_shared_key_patterns
REQ-DDB-SCHEMA-012measuredtest_a_declared_shared_key_pattern_beats_a_built_in_default → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 41 lines
def test_a_declared_shared_key_pattern_beats_a_built_in_default() -> None:
    """#32's first defect. `_match_accessor` is FIRST-MATCH, and the resolver used to
    append declared patterns AFTER the built-in defaults — so a declared pattern whose
    prefix collided with a default could never match, and the DEFAULT's `dispatch_mode`
    was stamped on the edge instead. Silently: the edge still appeared, carrying the wrong
    accessor-class provenance, which is worse than no edge because it is plausible.

    That inverted this repo's one universal configuration rule, which every other surface
    follows: a DECLARATION beats a built-in default (scope's declaration > guard >
    Doxyfile; a CLI flag over `.clew.yaml`; `key_alias_prefixes` REPLACING rather
    than extending). This merge was the single place that had it backwards.

    Asserts the OUTCOME — which dispatch_mode a matched name receives — rather than list
    order, because list order is the mechanism and could be satisfied while the matcher
    still picked wrongly."""
    from clew.shared_key_edges import (
        DEFAULT_SHARED_KEY_WRITERS,
        _match_accessor,
        resolve_shared_key_patterns,
    )

    ## Take a real built-in prefix so the collision is genuine rather than hypothetical.
    builtin = next(p for p in DEFAULT_SHARED_KEY_WRITERS if hasattr(p, "prefix"))
    assert builtin.dispatch_mode != "queued", "fixture assumes the default is not 'queued'"

    declared = {"writers": [{"name_prefix": builtin.prefix, "dispatch_mode": "queued"}]}
    writers, _readers, _aliases = resolve_shared_key_patterns(declared)

    probe = f"{builtin.prefix}SOME_KEY"
    mode = _match_accessor(probe, writers)
    assert mode is not None, "the declared prefix must still match"
    assert mode[2] == "queued", (
        f"the DECLARED dispatch_mode must win over the built-in default's; got {mode[2]!r}"
    )

    ## And with nothing declared, the default must still apply — the fix must not have
    ## simply disabled the built-ins.
    plain_writers, _r, _a = resolve_shared_key_patterns(None)
    assert _match_accessor(probe, plain_writers)[2] == builtin.dispatch_mode

Activity · 11 steps
lines 2092–2096from clew.shared_key_edges import ( DEFAULT_SHARED_KEY_WRITERS, _match_accessor, resolve_shared_key_patterns, )lines 2099–2099builtin = next(p for p in DEFAULT_SHARED_KEY_WRITERS if hasattr(p, "prefix"))lines 2100–2100assert builtin.dispatch_mode != "queued", "fixture assumes the default is not 'queued'"lines 2102–2102declared = {"writers": [{"name_prefix": builtin.prefix, "dispatch_mode": "queued"}]}lines 2103–2103writers, _readers, _aliases = resolve_shared_key_patterns(declared)lines 2105–2105probe = f"{builtin.prefix}SOME_KEY"lines 2106–2106mode = _match_accessor(probe, writers)lines 2107–2107assert mode is not None, "the declared prefix must still match"lines 2108–2110assert mode[2] == "queued", ( f"the DECLARED dispatch_mode must win over the built-in default's; got {mode[2]!r}" )lines 2114–2114plain_writers, _r, _a = resolve_shared_key_patterns(None)lines 2115–2115assert _match_accessor(probe, plain_writers)[2] == builtin.dispatch_mode

test_a_header_only_index_does_NOT_warn

None test_build_docs_db.test_a_header_only_index_does_NOT_warn(Path tmp_path)

Headers with no bodies are not a defect and must not warn.

tests/test_build_docs_db.py:1597

Show on the map →

Called by none

Calls _bodies_db, warn_if_no_function_bodies

Checks

  • assert warn_if_no_function_bodies(db_path) == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_a_header_only_index_does_NOT_warn → warn_if_no_function_bodies
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 16 lines
def test_a_header_only_index_does_NOT_warn(tmp_path: Path) -> None:
    """The counter-case, and the reason the check requires implementation files.

    A header-only library, or a docs-oriented Doxyfile carrying
    `FILE_PATTERNS = *.h`, legitimately indexes zero `.c` bodies. Both are real:
    the same C library above ships a Doxyfile that indexes headers ONLY, so a
    naive "no bodies anywhere" check would have fired on a correct build and
    trained the reader to ignore it.

    @brief Headers with no bodies are not a defect and must not warn.
    @version 1
    """
    db_path = _bodies_db(tmp_path, [("include/a.h", False), ("include/b.h", False)])
    assert warn_if_no_function_bodies(db_path) == 0

Activity · 2 steps
lines 1609–1609db_path = _bodies_db(tmp_path, [("include/a.h", False), ("include/b.h", False)])lines 1610–1610assert warn_if_no_function_bodies(db_path) == 0

test_a_macro_with_no_recorded_expansion_is_still_named

None test_build_docs_db.test_a_macro_with_no_recorded_expansion_is_still_named(Path macro_hop_db)

`via_macro` SET with `via_macro_expansion` EMPTY is a real state, not a bug: 17-20% of macro rows on the measured public targets have no `initializer`. "This hop goes through THIS macro and doxygen recorded no body for it" is a different and more useful answer than silence, which is why the two fields are separate rather than one.

tests/test_build_docs_db.py:757

Checks

  • assert edge.via_macro == "noise_macro", "the macro is named even with nothing to quote"
  • assert edge.via_macro_expansion == ""

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_a_macro_with_no_recorded_expansion_is_still_named → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-QUERY-001measuredtest_a_macro_with_no_recorded_expansion_is_still_named → callees
REQ-DDB-QUERY-003measuredtest_a_macro_with_no_recorded_expansion_is_still_named → callees → _call_edges → _dataflow_edges → resolve_rowid
REQ-DDB-QUERY-009measuredtest_a_macro_with_no_recorded_expansion_is_still_named → callees → _call_edges → _direct_call_edges → _implementors_by_identity
REQ-DDB-QUERY-010measuredtest_a_macro_with_no_recorded_expansion_is_still_named → callees
REQ-DDB-SCHEMA-012measured
Source · 25 lines
def test_a_macro_with_no_recorded_expansion_is_still_named(macro_hop_db: Path) -> None:
    """`via_macro` SET with `via_macro_expansion` EMPTY is a real state, not a bug: 17-20% of
    macro rows on the measured public targets have no `initializer`. "This hop goes through
    THIS macro and doxygen recorded no body for it" is a different and more useful answer than
    silence, which is why the two fields are separate rather than one.

    Driven through the same fixture by pointing the edge at `noise_macro`, whose initializer is
    NULL — rather than by mutating the shipped rows, so the assertion is about the read path."""
    from clew import query as q

    build_call_edges(macro_hop_db)
    import_macro_hop_edges(macro_hop_db)
    conn = sqlite3.connect(str(macro_hop_db))
    conn.execute(
        "UPDATE call_edges SET via_macro_rowid=4 WHERE source='macro_hop' AND callee_rowid=3"
    )
    conn.commit()
    conn.close()

    edge = {e.name: e for e in q.callees(macro_hop_db, "producer")}["store_set"]

    assert edge.via_macro == "noise_macro", "the macro is named even with nothing to quote"
    assert edge.via_macro_expansion == ""

Activity · 10 steps
lines 765–765from clew import query as qlines 767–767build_call_edges(macro_hop_db)lines 768–768import_macro_hop_edges(macro_hop_db)lines 769–769conn = sqlite3.connect(str(macro_hop_db))lines 770–772conn.execute( "UPDATE call_edges SET via_macro_rowid=4 WHERE source='macro_hop' AND callee_rowid=3" )lines 773–773conn.commit()lines 774–774conn.close()lines 776–776edge = {e.name: e for e in q.callees(macro_hop_db, "producer")}["store_set"]lines 778–778assert edge.via_macro == "noise_macro", "the macro is named even with nothing to quote"lines 779–779assert edge.via_macro_expansion == ""

test_a_pair_reachable_through_two_macros_names_one_deterministically

None test_build_docs_db.test_a_pair_reachable_through_two_macros_names_one_deterministically(Path macro_hop_db)

THE CHOICE THAT HAD TO BE MADE EXPLICIT. `UNIQUE(caller_rowid, callee_rowid, source)` holds ONE macro-hop row per pair, and this fixture reaches `store_set` from `producer` through both `STORE_SET_FOO` (rowid 2) and `ALT_SET_FOO` (rowid 7). Something must choose.

tests/test_build_docs_db.py:697

Checks

  • assert n == 1, "one row per caller/callee pair — naming the macro must not multiply rows"
  • assert via == 2, "MIN(macro.rowid): deterministic across builds of the same commit"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_a_pair_reachable_through_two_macros_names_one_deterministically → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 34 lines
def test_a_pair_reachable_through_two_macros_names_one_deterministically(
    macro_hop_db: Path,
) -> None:
    """THE CHOICE THAT HAD TO BE MADE EXPLICIT. `UNIQUE(caller_rowid, callee_rowid, source)`
    holds ONE macro-hop row per pair, and this fixture reaches `store_set` from `producer`
    through both `STORE_SET_FOO` (rowid 2) and `ALT_SET_FOO` (rowid 7). Something must choose.

    Joining the macro to the UNIQUE key was the alternative and it is worse: it multiplies rows
    per neighbour, which is the inflation gh#38 removed — every neighbour list doubled and every
    depth cap truncating half the real edges.

    So the pair stays one row and `MIN(macro.rowid)` makes WHICH macro deterministic. A bare
    `DISTINCT` left it to whatever the query planner happened to return first, so two builds of
    the same commit could name different macros — a difference that would look like a change in
    the code. The macro named is therefore one WITNESS, not the only one, and the payload says so.
    """
    build_call_edges(macro_hop_db)
    import_macro_hop_edges(macro_hop_db)

    conn = sqlite3.connect(str(macro_hop_db))
    ## The row count is asserted FIRST: if the pair had split into two rows this test would
    ## still find rowid 2 among them and pass while the inflation shipped.
    n = conn.execute(
        "SELECT COUNT(*) FROM call_edges WHERE source='macro_hop' AND callee_rowid=3"
    ).fetchone()[0]
    via = conn.execute(
        "SELECT via_macro_rowid FROM call_edges WHERE source='macro_hop' AND callee_rowid=3"
    ).fetchone()[0]
    conn.close()

    assert n == 1, "one row per caller/callee pair — naming the macro must not multiply rows"
    assert via == 2, "MIN(macro.rowid): deterministic across builds of the same commit"

Activity · 8 steps
lines 713–713build_call_edges(macro_hop_db)lines 714–714import_macro_hop_edges(macro_hop_db)lines 716–716conn = sqlite3.connect(str(macro_hop_db))lines 719–721n = conn.execute( "SELECT COUNT(*) FROM call_edges WHERE source='macro_hop' AND callee_rowid=3" ).fetchone()[0]lines 722–724via = conn.execute( "SELECT via_macro_rowid FROM call_edges WHERE source='macro_hop' AND callee_rowid=3" ).fetchone()[0]lines 725–725conn.close()lines 727–727assert n == 1, "one row per caller/callee pair — naming the macro must not multiply rows"lines 728–728assert via == 2, "MIN(macro.rowid): deterministic across builds of the same commit"

test_an_unstated_scope_keeps_the_parsers_default

None test_build_docs_db.test_an_unstated_scope_keeps_the_parsers_default(pytest.MonkeyPatch monkeypatch)

An unstated scope inherits the parser default, not a restated one.

tests/test_build_docs_db.py:2258

Show on the map →

Called by none

Calls build_index

Checks

  • assert seen == [SCOPE_FROM_GUARD], "an unstated scope must be the parser's default"
  • assert seen[-1] == SCOPE_DOXYFILE

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CLI-001inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → report_stats
REQ-DDB-CLI-002inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → _doxygen_or_partial → _doxygen_stage → _run_doxygen_from_args → run_doxygen → doxygen_supports_sqlite3
REQ-DDB-CONFIG-001measuredtest_an_unstated_scope_keeps_the_parsers_default → build_index → normalize_scope
REQ-DDB-CONFIG-003inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-CONFIG-004inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_preprocessor
REQ-DDB-CONFIG-005inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig
REQ-DDB-CONFIG-006inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _recorded_entry_patterns → recorded_explicit
REQ-DDB-CONFIG-007inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature
REQ-DDB-CONFIG-009inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _apply_toolchain_exclusions → load_toolchain_config
REQ-DDB-GUARD-012inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → load_guard_config → read_guard_config → read_requirements_section
REQ-DDB-GUARD-019inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → apply_autobrief
REQ-DDB-INDEX-001inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _verify_extra_input_is_read → effective_file_patterns
REQ-DDB-INDEX-002inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → build_lock
REQ-DDB-INDEX-003inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → report_index_coverage
REQ-DDB-INDEX-004inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols
REQ-DDB-INDEX-005inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → stamp_external_provenance
REQ-DDB-INDEX-006inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → record_code_text → code_text_rows
REQ-DDB-INDEX-007inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → record_owners
REQ-DDB-INDEX-008inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_licenses
REQ-DDB-INDEX-009inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc
REQ-DDB-INDEX-010inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes
REQ-DDB-INDEX-011inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_property_keys
REQ-DDB-MCP-001inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _operator_excludes → meta_section
REQ-DDB-PIPE-001catalogtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_database
REQ-DDB-PIPE-003inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → build_call_edges
REQ-DDB-PIPE-004inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → python_entry_seeds
REQ-DDB-PIPE-005inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature
REQ-DDB-PIPE-006inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → run_rustdoc → _require_nightly_rustdoc → clean_subprocess_env
REQ-DDB-PIPE-007inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig_gates
REQ-DDB-PIPE-008inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs
REQ-DDB-PIPE-009inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → prune_dominated_fuzzy_call_edges
REQ-DDB-PIPE-010catalogtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → build_harvest_plan → js_symbol_harvester
REQ-DDB-PIPE-013inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings
REQ-DDB-PIPE-014inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc → within_repo
REQ-DDB-PIPE-015inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_config_defaults
REQ-DDB-QUERY-003inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → mark_test_scope
REQ-DDB-QUERY-011inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads → _ensure_threads_tables
REQ-DDB-SCHEMA-001inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads
REQ-DDB-SCHEMA-002inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-003inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest
REQ-DDB-SCHEMA-005inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_key_alias_prefixes
REQ-DDB-SCHEMA-006inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml
REQ-DDB-SCHEMA-007inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-009inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_event_edges
REQ-DDB-SCHEMA-011inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → extract_context_conflicts
REQ-DDB-SCHEMA-012inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest → declaration_origin
REQ-DDB-SCHEMA-013inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_data_model_keys
REQ-DDB-SCHEMA-014inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs → ensure_file_docs_table
REQ-DDB-SCHEMA-015inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols → _recover_into → all
Source · 39 lines
def test_an_unstated_scope_keeps_the_parsers_default(monkeypatch: pytest.MonkeyPatch) -> None:
    """THE EMBEDDING ENTRY POINT CONTRADICTED ITS OWN DOCSTRING. `build_index` says
    "defaults are sourced by parsing rather than restated here, so a flag added to
    `_build_argparser` reaches this path with its intended default" — and then `scope`
    alone restated one, with the OPPOSITE value: signature `SCOPE_DOXYFILE`, parser
    `SCOPE_FROM_GUARD`.

    That is the gh#333 inversion in the one function written to prevent divergence: an
    embedding caller omitting `scope` got Doxyfile scope, so a repo that ships a Doxyfile
    was indexed to its published-API subset while a repo shipping none got its whole tree —
    punished for documenting itself.

    THE PLAN CALLED THIS A NO-OP because "both callers pass it explicitly". There are NINE
    call sites and FIVE pass no scope at all, so the change is a real behaviour change for
    them. The full integration tier passes either way, which is why this test exists: a
    green suite after the edit is equally consistent with the edit doing NOTHING, and that
    would prove nothing at all.

    `scope` now defaults to None and is assigned only when stated, matching `repo_root`,
    `doxyfile`, `requirements` and `exclude` — so there is ONE source of truth for the
    default instead of two that must be kept in step.

    @brief An unstated scope inherits the parser default, not a restated one.
    @version 1
    """
    from clew import cli
    from clew.scope import SCOPE_DOXYFILE, SCOPE_FROM_GUARD

    seen: list[str] = []
    monkeypatch.setattr(cli, "_run_pipeline", lambda args: seen.append(args.scope))

    cli.build_index(output="/tmp/unused.db")
    assert seen == [SCOPE_FROM_GUARD], "an unstated scope must be the parser's default"

    ## AND A STATED SCOPE STILL WINS, or the fix has made the parameter inert.
    cli.build_index(output="/tmp/unused.db", scope=SCOPE_DOXYFILE)
    assert seen[-1] == SCOPE_DOXYFILE

Activity · 8 steps
lines 2283–2283from clew import clilines 2284–2284from clew.scope import SCOPE_DOXYFILE, SCOPE_FROM_GUARDlines 2286–2286seen: list[str] = []lines 2287–2287monkeypatch.setattr(cli, "_run_pipeline", lambda args: seen.append(args.scope))lines 2289–2289cli.build_index(output="/tmp/unused.db")lines 2290–2290assert seen == [SCOPE_FROM_GUARD], "an unstated scope must be the parser's default"lines 2293–2293cli.build_index(output="/tmp/unused.db", scope=SCOPE_DOXYFILE)lines 2294–2294assert seen[-1] == SCOPE_DOXYFILE

test_ast_caller_at_line_finds_match_in_window

None test_build_docs_db.test_ast_caller_at_line_finds_match_in_window()

tests/test_build_docs_db.py:441

Show on the map →

Called by none

Calls _ast_caller_at_line

Checks

  • assert _ast_caller_at_line(funcs, 3) == 10
  • assert _ast_caller_at_line(funcs, 7) == 20
  • assert _ast_caller_at_line(funcs, 99) == 30
  • assert _ast_caller_at_line(funcs, 100) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 15 lines
def test_ast_caller_at_line_finds_match_in_window() -> None:
    funcs = [
        (10, "foo", 1, 5),
        (20, "bar", 6, 12),
        (30, "baz", 13, 99),
    ]
    assert _ast_caller_at_line(funcs, 3) == 10
    assert _ast_caller_at_line(funcs, 7) == 20
    assert _ast_caller_at_line(funcs, 99) == 30
    assert _ast_caller_at_line(funcs, 100) is None


# ─── call_edges._ast_record_call_edge ───────────────────────────────────────

Activity · 5 steps
lines 442–446funcs = [ (10, "foo", 1, 5), (20, "bar", 6, 12), (30, "baz", 13, 99), ]lines 447–447assert _ast_caller_at_line(funcs, 3) == 10lines 448–448assert _ast_caller_at_line(funcs, 7) == 20lines 449–449assert _ast_caller_at_line(funcs, 99) == 30lines 450–450assert _ast_caller_at_line(funcs, 100) is None

test_ast_record_multi_match_records_nothing

None test_build_docs_db.test_ast_record_multi_match_records_nothing()

gh#347. THREE FUNCTIONS NAMED `init` AND ONE CALL SITE. This used to emit three edges, asserting three calls where exactly one occurred — the shape the owner retired: a name is a mutable human convention and proves no linkage, so `init` matching three memberdefs is not three-quarters of an answer, it is no answer.

tests/test_build_docs_db.py:472

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert edges_resolved == []
  • assert edges_fuzzy == [], "one call site must never become three edges"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-WIKI-054inferredtest_ast_record_multi_match_records_nothing → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 23 lines
def test_ast_record_multi_match_records_nothing() -> None:
    """gh#347. THREE FUNCTIONS NAMED `init` AND ONE CALL SITE. This used to emit three edges,
    asserting three calls where exactly one occurred — the shape the owner retired: a name is a
    mutable human convention and proves no linkage, so `init` matching three memberdefs is not
    three-quarters of an answer, it is no answer.

    The pair with `test_ast_record_no_match_silent` below is now the whole specification: an
    unresolved call and an unmatched call are indistinguishable in the table, because neither
    was proven. Only a UNIQUE match creates a row.
    """
    edges_resolved: list = []
    edges_fuzzy: list = []
    _ast_record_call_edge(
        caller_rowid=10,
        callee_name="init",
        name_to_rowids={"init": [42, 43, 44]},
        edges_resolved=edges_resolved,
        edges_fuzzy=edges_fuzzy,
    )
    assert edges_resolved == []
    assert edges_fuzzy == [], "one call site must never become three edges"

Activity · 5 steps
lines 482–482edges_resolved: list = []lines 483–483edges_fuzzy: list = []lines 484–490_ast_record_call_edge( caller_rowid=10, callee_name="init", name_to_rowids={"init": [42, 43, 44]}, edges_resolved=edges_resolved, edges_fuzzy=edges_fuzzy, )lines 491–491assert edges_resolved == []lines 492–492assert edges_fuzzy == [], "one call site must never become three edges"

test_ast_record_no_match_silent

None test_build_docs_db.test_ast_record_no_match_silent()

tests/test_build_docs_db.py:495

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert edges_resolved == []
  • assert edges_fuzzy == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-WIKI-054inferredtest_ast_record_no_match_silent → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 18 lines
def test_ast_record_no_match_silent() -> None:
    edges_resolved: list = []
    edges_fuzzy: list = []
    _ast_record_call_edge(
        caller_rowid=10,
        callee_name="external_symbol",
        name_to_rowids={},
        edges_resolved=edges_resolved,
        edges_fuzzy=edges_fuzzy,
    )
    assert edges_resolved == []
    assert edges_fuzzy == []


# ─── call_edges.build_call_edges (Layer 1) ──────────────────────────────────


@pytest.fixture

test_ast_record_unique_match_resolved

None test_build_docs_db.test_ast_record_unique_match_resolved()

tests/test_build_docs_db.py:456

Show on the map →

Called by none

Calls _ast_record_call_edge

Checks

  • assert edges_resolved == [(10, 42, "ast")]
  • assert edges_fuzzy == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-WIKI-054inferredtest_ast_record_unique_match_resolved → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 16 lines
def test_ast_record_unique_match_resolved() -> None:
    edges_resolved: list = []
    edges_fuzzy: list = []
    _ast_record_call_edge(
        caller_rowid=10,
        callee_name="malloc",
        name_to_rowids={"malloc": [42]},
        edges_resolved=edges_resolved,
        edges_fuzzy=edges_fuzzy,
    )
    # Edges now carry their own provenance so an unwrapped member call is
    # separable from a bare-identifier one; 'ast' is the default.
    assert edges_resolved == [(10, 42, "ast")]
    assert edges_fuzzy == []

Activity · 5 steps
lines 457–457edges_resolved: list = []lines 458–458edges_fuzzy: list = []lines 459–465_ast_record_call_edge( caller_rowid=10, callee_name="malloc", name_to_rowids={"malloc": [42]}, edges_resolved=edges_resolved, edges_fuzzy=edges_fuzzy, )lines 468–468assert edges_resolved == [(10, 42, "ast")]lines 469–469assert edges_fuzzy == []

test_bfs_live_set_walks_from_seeds

None test_build_docs_db.test_bfs_live_set_walks_from_seeds(Path synthetic_reachability_db)

tests/test_build_docs_db.py:899

Checks

  • assert live == {1, 2, 3, 5, 6}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-004measuredtest_bfs_live_set_walks_from_seeds → _bfs_live_set
REQ-DDB-PIPE-010catalog
Source · 11 lines
def test_bfs_live_set_walks_from_seeds(
    synthetic_reachability_db: Path,
) -> None:
    conn = sqlite3.connect(str(synthetic_reachability_db))
    live = _bfs_live_set(conn, {1, 5})  # start from main + app_main
    conn.close()
    # Reachable: main(1), do_init(2), helper(3), app_main(5), boot(6).
    # Not reachable from these seeds alone: unused_helper(4), orphan_func(7).
    assert live == {1, 2, 3, 5, 6}

Activity · 4 steps
lines 902–902conn = sqlite3.connect(str(synthetic_reachability_db))lines 903–903live = _bfs_live_set(conn, {1, 5})lines 904–904conn.close()lines 907–907assert live == {1, 2, 3, 5, 6}

test_build_call_edges_creates_indexes

None test_build_docs_db.test_build_call_edges_creates_indexes(Path synthetic_doxygen_db)

tests/test_build_docs_db.py:811

Checks

  • assert "idx_call_edges_caller" in indexes
  • assert "idx_call_edges_callee" in indexes

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_build_call_edges_creates_indexes → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 20 lines
def test_build_call_edges_creates_indexes(
    synthetic_doxygen_db: Path,
) -> None:
    build_call_edges(synthetic_doxygen_db)
    conn = sqlite3.connect(str(synthetic_doxygen_db))
    indexes = {
        r[0]
        for r in conn.execute(
            "SELECT name FROM sqlite_master WHERE type='index' AND tbl_name='call_edges'",
        ).fetchall()
    }
    conn.close()
    assert "idx_call_edges_caller" in indexes
    assert "idx_call_edges_callee" in indexes


# ─── reachability ────────────────────────────────────────────────────────────


@pytest.fixture

test_build_call_edges_imports_only_function_inline_xrefs

None test_build_docs_db.test_build_call_edges_imports_only_function_inline_xrefs(Path synthetic_doxygen_db)

tests/test_build_docs_db.py:546

Checks

  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_build_call_edges_imports_only_function_inline_xrefs → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 18 lines
def test_build_call_edges_imports_only_function_inline_xrefs(
    synthetic_doxygen_db: Path,
) -> None:
    build_call_edges(synthetic_doxygen_db)
    conn = sqlite3.connect(str(synthetic_doxygen_db))
    rows = conn.execute(
        "SELECT caller_rowid, callee_rowid, source, confidence "
        "FROM call_edges ORDER BY caller_rowid, callee_rowid",
    ).fetchall()
    conn.close()
    # Two function-to-function edges expected. Variable ref dropped.
    # Non-inline xref dropped.
    assert rows == [
        (1, 2, "doxygen_sqlite", "exact"),
        (1, 3, "doxygen_sqlite", "exact"),
    ]

Activity · 5 steps
lines 549–549build_call_edges(synthetic_doxygen_db)lines 550–550conn = sqlite3.connect(str(synthetic_doxygen_db))lines 551–554rows = conn.execute( "SELECT caller_rowid, callee_rowid, source, confidence " "FROM call_edges ORDER BY caller_rowid, callee_rowid", ).fetchall()lines 555–555conn.close()lines 558–561assert rows == [ (1, 2, "doxygen_sqlite", "exact"), (1, 3, "doxygen_sqlite", "exact"), ]

test_build_doxyfile_appends_extra_input_clears_exclude

None test_build_docs_db.test_build_doxyfile_appends_extra_input_clears_exclude(Path tmp_path)

tests/test_build_docs_db.py:253

Checks

  • assert "INPUT += subm/foo" in out
  • assert "INPUT += subm/bar" in out
  • assert "\nEXCLUDE =\n" in out
  • assert "EXCLUDE += subm/foo/deps" in out

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_build_doxyfile_appends_extra_input_clears_exclude → _build_doxyfile_content
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_build_doxyfile_appends_extra_input_clears_exclude → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 18 lines
def test_build_doxyfile_appends_extra_input_clears_exclude(
    tmp_path: Path,
) -> None:
    f = tmp_path / "Doxyfile"
    f.write_text("EXCLUDE = vendor third_party\n")
    out = _build_doxyfile_content(
        f,
        extra_input=["subm/foo", "subm/bar"],
        extra_exclude=["subm/foo/deps"],
    )
    assert "INPUT += subm/foo" in out
    assert "INPUT += subm/bar" in out
    # Clear marker present
    assert "\nEXCLUDE =\n" in out
    # Re-exclude
    assert "EXCLUDE += subm/foo/deps" in out

Activity · 7 steps
lines 256–256f = tmp_path / "Doxyfile"lines 257–257f.write_text("EXCLUDE = vendor third_party\n")lines 258–262out = _build_doxyfile_content( f, extra_input=["subm/foo", "subm/bar"], extra_exclude=["subm/foo/deps"], )lines 263–263assert "INPUT += subm/foo" in outlines 264–264assert "INPUT += subm/bar" in outlines 266–266assert "\nEXCLUDE =\n" in outlines 268–268assert "EXCLUDE += subm/foo/deps" in out

test_build_doxyfile_appends_forced_flags

None test_build_docs_db.test_build_doxyfile_appends_forced_flags(Path tmp_path)

tests/test_build_docs_db.py:236

Checks

  • assert "GENERATE_SQLITE3 = YES" in out
  • assert "GENERATE_XML = YES" not in out
  • assert "EXTRACT_ALL = YES" in out
  • assert "EXTRACT_STATIC = YES" in out
  • assert "RECURSIVE = YES" in out
  • assert "PROJECT_NAME = test" in out # original preserved

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_build_doxyfile_appends_forced_flags → _build_doxyfile_content
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_build_doxyfile_appends_forced_flags → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 17 lines
def test_build_doxyfile_appends_forced_flags(tmp_path: Path) -> None:
    f = tmp_path / "Doxyfile"
    f.write_text("PROJECT_NAME = test\n")
    out = _build_doxyfile_content(f, extra_input=None, extra_exclude=None)
    assert "GENERATE_SQLITE3 = YES" in out
    ## THE INTENT IS "no XML is generated", and asserting the STRING is absent was the
    ## wrong shape for it: the hardening now sets `GENERATE_XML = NO` explicitly, which
    ## satisfies the intent more strongly and tripped a substring check. Assert the VALUE.
    assert "GENERATE_XML = YES" not in out
    assert "EXTRACT_ALL = YES" in out
    # Static funcs (common in generated gen/ code) + nested extra-input trees
    # must be indexed, or setters/callers in those dirs silently vanish.
    assert "EXTRACT_STATIC = YES" in out
    assert "RECURSIVE = YES" in out
    assert "PROJECT_NAME = test" in out  # original preserved

Activity · 9 steps
lines 237–237f = tmp_path / "Doxyfile"lines 238–238f.write_text("PROJECT_NAME = test\n")lines 239–239out = _build_doxyfile_content(f, extra_input=None, extra_exclude=None)lines 240–240assert "GENERATE_SQLITE3 = YES" in outlines 244–244assert "GENERATE_XML = YES" not in outlines 245–245assert "EXTRACT_ALL = YES" in outlines 248–248assert "EXTRACT_STATIC = YES" in outlines 249–249assert "RECURSIVE = YES" in outlines 250–250assert "PROJECT_NAME = test" in out

test_build_doxyfile_extra_exclude_applies_standalone

None test_build_docs_db.test_build_doxyfile_extra_exclude_applies_standalone(Path tmp_path)

--extra-exclude must work WITHOUT --extra-input (the natural way to just trim scope). Regression: the loader early-returned when extra_input was None, silently dropping extra_exclude. It is now APPENDED to the repo's own EXCLUDE (kept, not cleared — no extra_input means no submodule to un-hide).

tests/test_build_docs_db.py:302

Checks

  • assert "EXCLUDE += src/legacy" in out # applied standalone
  • assert "EXCLUDE = vendor" in out # repo's own EXCLUDE preserved (not cleared)
  • assert "EXCLUDE +=" not in plain

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_build_doxyfile_extra_exclude_applies_standalone → _build_doxyfile_content
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_build_doxyfile_extra_exclude_applies_standalone → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 19 lines
def test_build_doxyfile_extra_exclude_applies_standalone(tmp_path: Path) -> None:
    """--extra-exclude must work WITHOUT --extra-input (the natural way to just
    trim scope). Regression: the loader early-returned when extra_input was
    None, silently dropping extra_exclude. It is now APPENDED to the repo's own
    EXCLUDE (kept, not cleared — no extra_input means no submodule to un-hide).
    """
    f = tmp_path / "Doxyfile"
    f.write_text("EXCLUDE = vendor\n")
    out = _build_doxyfile_content(f, extra_input=None, extra_exclude=["src/legacy"])
    assert "EXCLUDE += src/legacy" in out  # applied standalone
    assert "EXCLUDE = vendor" in out  # repo's own EXCLUDE preserved (not cleared)
    # And with no extra args at all, nothing is appended.
    plain = _build_doxyfile_content(f, extra_input=None, extra_exclude=None)
    assert "EXCLUDE +=" not in plain


# ─── doxygen._classify_doxygen_line ─────────────────────────────────────────

Activity · 7 steps
lines 308–308f = tmp_path / "Doxyfile"lines 309–309f.write_text("EXCLUDE = vendor\n")lines 310–310out = _build_doxyfile_content(f, extra_input=None, extra_exclude=["src/legacy"])lines 311–311assert "EXCLUDE += src/legacy" in outlines 312–312assert "EXCLUDE = vendor" in outlines 314–314plain = _build_doxyfile_content(f, extra_input=None, extra_exclude=None)lines 315–315assert "EXCLUDE +=" not in plain

test_chunk_markdown_a_hash_line_in_a_code_fence_is_not_a_heading

None test_build_docs_db.test_chunk_markdown_a_hash_line_in_a_code_fence_is_not_a_heading()

A shell comment or C preprocessor line inside a fence stays in its section.

tests/test_build_docs_db.py:359

Checks

  • assert chunks == [("Build", "```sh\n# configure first\nmake\n```")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001measuredtest_chunk_markdown_a_hash_line_in_a_code_fence_is_not_a_heading → chunk_markdown
REQ-DDB-PIPE-010catalog
Source · 7 lines
def test_chunk_markdown_a_hash_line_in_a_code_fence_is_not_a_heading() -> None:
    """A shell comment or C preprocessor line inside a fence stays in its section."""
    text = "# Build\n```sh\n# configure first\nmake\n```\n"
    chunks = chunk_markdown(text, "x.md")
    assert chunks == [("Build", "```sh\n# configure first\nmake\n```")]

Activity · 3 steps
lines 361–361text = "# Build\n```sh\n# configure first\nmake\n```\n"lines 362–362chunks = chunk_markdown(text, "x.md")lines 363–363assert chunks == [("Build", "```sh\n# configure first\nmake\n```")]

test_chunk_markdown_empty_section_skipped

None test_build_docs_db.test_chunk_markdown_empty_section_skipped()

Heading with no body in between shouldn't produce empty chunk.

tests/test_build_docs_db.py:351

Checks

  • assert chunks == [("B", "body")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001measuredtest_chunk_markdown_empty_section_skipped → chunk_markdown
REQ-DDB-PIPE-010catalog
Source · 8 lines
def test_chunk_markdown_empty_section_skipped() -> None:
    """Heading with no body in between shouldn't produce empty chunk."""
    text = "# A\n\n# B\nbody\n"
    chunks = chunk_markdown(text, "x.md")
    # Section A has no body — skipped.
    assert chunks == [("B", "body")]

Activity · 3 steps
lines 353–353text = "# A\n\n# B\nbody\n"lines 354–354chunks = chunk_markdown(text, "x.md")lines 356–356assert chunks == [("B", "body")]

test_chunk_markdown_first_chunk_uses_filename

None test_build_docs_db.test_chunk_markdown_first_chunk_uses_filename()

tests/test_build_docs_db.py:334

Checks

  • assert chunks[0] == ("README.md", "Intro before any heading.")
  • assert chunks[1] == ("First heading", "body")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001measuredtest_chunk_markdown_first_chunk_uses_filename → chunk_markdown
REQ-DDB-PIPE-010catalog
Source · 7 lines
def test_chunk_markdown_first_chunk_uses_filename() -> None:
    text = "Intro before any heading.\n\n# First heading\nbody\n"
    chunks = chunk_markdown(text, "README.md")
    assert chunks[0] == ("README.md", "Intro before any heading.")
    assert chunks[1] == ("First heading", "body")

Activity · 4 steps
lines 335–335text = "Intro before any heading.\n\n# First heading\nbody\n"lines 336–336chunks = chunk_markdown(text, "README.md")lines 337–337assert chunks[0] == ("README.md", "Intro before any heading.")lines 338–338assert chunks[1] == ("First heading", "body")

test_chunk_markdown_handles_three_levels

None test_build_docs_db.test_chunk_markdown_handles_three_levels()

tests/test_build_docs_db.py:341

Checks

  • assert [(h, c) for h, c in chunks] == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001measuredtest_chunk_markdown_handles_three_levels → chunk_markdown
REQ-DDB-PIPE-010catalog
Source · 10 lines
def test_chunk_markdown_handles_three_levels() -> None:
    text = "# H1\nbodyA\n\n## H2\nbodyB\n\n### H3\nbodyC\n"
    chunks = chunk_markdown(text, "x.md")
    assert [(h, c) for h, c in chunks] == [
        ("H1", "bodyA"),
        ("H2", "bodyB"),
        ("H3", "bodyC"),
    ]

Activity · 3 steps
lines 342–342text = "# H1\nbodyA\n\n## H2\nbodyB\n\n### H3\nbodyC\n"lines 343–343chunks = chunk_markdown(text, "x.md")lines 344–348assert [(h, c) for h, c in chunks] == [ ("H1", "bodyA"), ("H2", "bodyB"), ("H3", "bodyC"), ]

test_chunk_markdown_splits_on_setext_and_keeps_deeper_headings_inline

None test_build_docs_db.test_chunk_markdown_splits_on_setext_and_keeps_deeper_headings_inline()

`Title` over `=====` is a heading; `####` stays inside the section above it.

tests/test_build_docs_db.py:366

Checks

  • assert chunks == [("x.md", "Intro"), ("Usage", "run it\n\n#### Detail\nmore")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001measuredtest_chunk_markdown_splits_on_setext_and_keeps_deeper_headings_inline → chunk_markdown
REQ-DDB-PIPE-010catalog
Source · 7 lines
def test_chunk_markdown_splits_on_setext_and_keeps_deeper_headings_inline() -> None:
    """`Title` over `=====` is a heading; `####` stays inside the section above it."""
    text = "Intro\n\nUsage\n=====\nrun it\n\n#### Detail\nmore\n"
    chunks = chunk_markdown(text, "x.md")
    assert chunks == [("x.md", "Intro"), ("Usage", "run it\n\n#### Detail\nmore")]

Activity · 3 steps
lines 368–368text = "Intro\n\nUsage\n=====\nrun it\n\n#### Detail\nmore\n"lines 369–369chunks = chunk_markdown(text, "x.md")lines 370–370assert chunks == [("x.md", "Intro"), ("Usage", "run it\n\n#### Detail\nmore")]

test_classify_doxygen_line_buckets

None test_build_docs_db.test_classify_doxygen_line_buckets()

tests/test_build_docs_db.py:321

Show on the map →

Called by none

Calls _classify_doxygen_line

Checks

  • assert _classify_doxygen_line("warning: X") == "warning"
  • assert _classify_doxygen_line("Error: oops") == "warning" # case-insensitive
  • assert _classify_doxygen_line("Preprocessing /a.c...") == "file"
  • assert _classify_doxygen_line("Parsing file /b.h...") == "file"
  • assert _classify_doxygen_line("Generating XML output...") == "phase"
  • assert _classify_doxygen_line("Building member docs...") == "phase"
  • assert _classify_doxygen_line("Doxygen version 1.x") == "other"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 13 lines
def test_classify_doxygen_line_buckets() -> None:
    assert _classify_doxygen_line("warning: X") == "warning"
    assert _classify_doxygen_line("Error: oops") == "warning"  # case-insensitive
    assert _classify_doxygen_line("Preprocessing /a.c...") == "file"
    assert _classify_doxygen_line("Parsing file /b.h...") == "file"
    assert _classify_doxygen_line("Generating XML output...") == "phase"
    assert _classify_doxygen_line("Building member docs...") == "phase"
    assert _classify_doxygen_line("Doxygen version 1.x") == "other"


# ─── prose.chunk_markdown ───────────────────────────────────────────────────

Activity · 7 steps
lines 322–322assert _classify_doxygen_line("warning: X") == "warning"lines 323–323assert _classify_doxygen_line("Error: oops") == "warning"lines 324–324assert _classify_doxygen_line("Preprocessing /a.c...") == "file"lines 325–325assert _classify_doxygen_line("Parsing file /b.h...") == "file"lines 326–326assert _classify_doxygen_line("Generating XML output...") == "phase"lines 327–327assert _classify_doxygen_line("Building member docs...") == "phase"lines 328–328assert _classify_doxygen_line("Doxygen version 1.x") == "other"

test_default_entry_patterns_covers_common_shapes

None test_build_docs_db.test_default_entry_patterns_covers_common_shapes()

Sanity-check the curated default list has the common ones.

tests/test_build_docs_db.py:997

Show on the map →

Called by none

Calls none

Checks

  • assert "main" in DEFAULT_ENTRY_PATTERNS
  • assert "%init%" in DEFAULT_ENTRY_PATTERNS
  • assert "%task%" in DEFAULT_ENTRY_PATTERNS
  • assert "%isr%" in DEFAULT_ENTRY_PATTERNS

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 11 lines
def test_default_entry_patterns_covers_common_shapes() -> None:
    """Sanity-check the curated default list has the common ones."""
    assert "main" in DEFAULT_ENTRY_PATTERNS
    assert "%init%" in DEFAULT_ENTRY_PATTERNS
    assert "%task%" in DEFAULT_ENTRY_PATTERNS
    assert "%isr%" in DEFAULT_ENTRY_PATTERNS


# ─── requirements.ingest_requirements_yaml ──────────────────────────────────

Activity · 4 steps
lines 999–999assert "main" in DEFAULT_ENTRY_PATTERNSlines 1000–1000assert "%init%" in DEFAULT_ENTRY_PATTERNSlines 1001–1001assert "%task%" in DEFAULT_ENTRY_PATTERNSlines 1002–1002assert "%isr%" in DEFAULT_ENTRY_PATTERNS

test_detect_undeclared_accessor_families

None test_build_docs_db.test_detect_undeclared_accessor_families(Path tmp_path)

The advisory diagnostic surfaces set/get accessor FAMILIES (one function per key, shared long prefix) that no active pattern covers — both CamelCase (`Store_SetAreaData`) and snake+underscore (`Foo_Set_BAR`) — while rejecting the shapes that are NOT a data model: an object setter with no leading token (`set_level`), a lowercase command handler (`handle_get_stage_list_cmd`), a family below the key threshold, and a family already covered by a pattern.

tests/test_build_docs_db.py:1675

Show on the map →

Called by none

Calls _make_shared_key_db, detect_undeclared_accessor_families

Checks

  • assert fam_map.get("Store_Set") == 5, (f"Store_Set family (5 keys) should be suggested; got {fams}" )
  • assert not any(p.startswith("set_") for p in prefixes), "object setters must not cluster"
  • assert not any("handle" in p for p in prefixes), "command handler must be excluded"
  • assert "Tiny_Set" not in prefixes, "below-threshold family must be excluded"
  • assert not any(p.startswith("DataModel_Set") for p in prefixes), "covered family excluded"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-007measuredtest_detect_undeclared_accessor_families → detect_undeclared_accessor_families
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-005measuredtest_detect_undeclared_accessor_families → detect_undeclared_accessor_families
Source · 43 lines
def test_detect_undeclared_accessor_families(tmp_path: Path) -> None:
    """The advisory diagnostic surfaces set/get accessor FAMILIES (one function
    per key, shared long prefix) that no active pattern covers — both CamelCase
    (`Store_SetAreaData`) and snake+underscore (`Foo_Set_BAR`) — while rejecting
    the shapes that are NOT a data model: an object setter with no leading token
    (`set_level`), a lowercase command handler (`handle_get_stage_list_cmd`), a
    family below the key threshold, and a family already covered by a pattern."""
    functions = [
        # CamelCase family (5 keys) — should be suggested.
        (1, "Store_SetAreaData", 1, 1),
        (2, "Store_SetBleData", 2, 2),
        (3, "Store_SetCleanStatus", 3, 3),
        (4, "Store_SetDockCoordData", 4, 4),
        (5, "Store_SetHeartbeat", 5, 5),
        # Object setters — no leading token before the verb ⇒ excluded.
        (6, "set_level", 6, 6),
        (7, "set_speed", 7, 7),
        # Lowercase command handler ⇒ excluded (key is a verb phrase, not a key).
        (8, "handle_get_stage_list_cmd", 8, 8),
        # Below-threshold family (only 2 keys) ⇒ excluded.
        (9, "Tiny_SetA", 9, 9),
        (10, "Tiny_SetB", 10, 10),
        # A family that IS covered by an active pattern ⇒ excluded.
        (11, "DataModel_Set_ALPHA", 11, 11),
        (12, "DataModel_Set_BETA", 12, 12),
        (13, "DataModel_Set_GAMMA", 13, 13),
        (14, "DataModel_Set_DELTA", 14, 14),
    ]
    db_path = _make_shared_key_db(tmp_path, functions)
    conn = sqlite3.connect(str(db_path))
    fams = detect_undeclared_accessor_families(conn, [NamePrefixPattern("DataModel_Set_")])
    conn.close()
    fam_map = {f.prefix: f.keys for f in fams}
    assert fam_map.get("Store_Set") == 5, (
        f"Store_Set family (5 keys) should be suggested; got {fams}"
    )
    prefixes = set(fam_map)
    assert not any(p.startswith("set_") for p in prefixes), "object setters must not cluster"
    assert not any("handle" in p for p in prefixes), "command handler must be excluded"
    assert "Tiny_Set" not in prefixes, "below-threshold family must be excluded"
    assert not any(p.startswith("DataModel_Set") for p in prefixes), "covered family excluded"

Activity · 12 steps
lines 1682–1702functions = [ # CamelCase family (5 keys) — should be suggested. (1, "Store_SetAreaData", 1, 1), (2, "Store_SetBleData", 2, 2), (3, "Store_SetCleanStatus", 3, 3), (4, "Store_SetDockCoordData", 4, 4), (5, "Store_SetHeartbeat", 5, 5), # Object setters — no leading token before the verb ⇒ excluded. (6, "set_level", 6, 6), (7, "set_speed", 7, 7), # Lowercase command handler ⇒ excluded (key is a verb phrase, not a key). (8, "handle_get_stage_list_cmd", 8, 8), # Below-threshold family (only 2 keys) ⇒ excluded. (9, "Tiny_SetA", 9, 9), (10, "Tiny_SetB", 10, 10), # A family that IS covered by an active pattern ⇒ excluded. (11, "DataModel_Set_ALPHA", 11, 11), (12, "DataModel_Set_BETA", 12, 12), (13, "DataModel_Set_GAMMA", 13, 13), (14, "DataModel_Set_DELTA", 14, 14), ]lines 1703–1703db_path = _make_shared_key_db(tmp_path, functions)lines 1704–1704conn = sqlite3.connect(str(db_path))lines 1705–1705fams = detect_undeclared_accessor_families(conn, [NamePrefixPattern("DataModel_Set_")])lines 1706–1706conn.close()lines 1707–1707fam_map = {f.prefix: f.keys for f in fams}lines 1708–1710assert fam_map.get("Store_Set") == 5, ( f"Store_Set family (5 keys) should be suggested; got {fams}" )lines 1711–1711prefixes = set(fam_map)lines 1712–1712assert not any(p.startswith("set_") for p in prefixes), "object setters must not cluster"lines 1713–1713assert not any("handle" in p for p in prefixes), "command handler must be excluded"lines 1714–1714assert "Tiny_Set" not in prefixes, "below-threshold family must be excluded"lines 1715–1715assert not any(p.startswith("DataModel_Set") for p in prefixes), "covered family excluded"

test_discover_doxyfile_refuses_to_guess_among_strays

None test_build_docs_db.test_discover_doxyfile_refuses_to_guess_among_strays(Path tmp_path)

tests/test_build_docs_db.py:2047

Checks

  • assert discover_doxyfile(repo) is None, "a fixture Doxyfile must not be adopted"
  • assert discover_doxyfile(repo) == repo / "docs" / "Doxyfile"
  • assert discover_doxyfile(repo) == repo / "Doxyfile"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_discover_doxyfile_refuses_to_guess_among_strays → discover_doxyfile
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 30 lines
def test_discover_doxyfile_refuses_to_guess_among_strays(tmp_path: Path) -> None:
    """#55, found by dogfooding clew on itself. discover_doxyfile used to
    fall back to sorted(repo.glob("*/Doxyfile"))[0] — ANY subdirectory, picked
    alphabetically. On clew that selected sample/Doxyfile, the demobot TEST
    FIXTURE, to index the whole project, and ran doxygen with cwd=sample/.

    It was masked because --scope from-guard replaces INPUT; under
    --scope doxyfile the fixture's own INPUT would have been honoured and
    clew would have indexed demobot instead of itself — silently, producing
    a well-formed database describing the wrong code.

    A wrong Doxyfile is worse than none, because none triggers synthesis from
    the declared scope (#33)."""
    from clew.doxygen import discover_doxyfile

    repo = tmp_path / "repo"
    (repo / "sample").mkdir(parents=True)
    (repo / "sample" / "Doxyfile").write_text("PROJECT_NAME = fixture\n")
    assert discover_doxyfile(repo) is None, "a fixture Doxyfile must not be adopted"

    # Doxygen's own conventional locations ARE trusted.
    (repo / "docs").mkdir()
    (repo / "docs" / "Doxyfile").write_text("PROJECT_NAME = real\n")
    assert discover_doxyfile(repo) == repo / "docs" / "Doxyfile"

    # A root Doxyfile always wins.
    (repo / "Doxyfile").write_text("PROJECT_NAME = root\n")
    assert discover_doxyfile(repo) == repo / "Doxyfile"

Activity · 10 steps
lines 2060–2060from clew.doxygen import discover_doxyfilelines 2062–2062repo = tmp_path / "repo"lines 2063–2063(repo / "sample").mkdir(parents=True)lines 2064–2064(repo / "sample" / "Doxyfile").write_text("PROJECT_NAME = fixture\n")lines 2065–2065assert discover_doxyfile(repo) is None, "a fixture Doxyfile must not be adopted"lines 2068–2068(repo / "docs").mkdir()lines 2069–2069(repo / "docs" / "Doxyfile").write_text("PROJECT_NAME = real\n")lines 2070–2070assert discover_doxyfile(repo) == repo / "docs" / "Doxyfile"lines 2073–2073(repo / "Doxyfile").write_text("PROJECT_NAME = root\n")lines 2074–2074assert discover_doxyfile(repo) == repo / "Doxyfile"

test_extract_req_tags_inferred

None test_build_docs_db.test_extract_req_tags_inferred()

tests/test_build_docs_db.py:1160

Checks

  • assert _extract_req_tags("Handles startup. @req REQ-0042 [inferred]") == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_extract_req_tags_inferred → _extract_req_tags
Source · 6 lines
def test_extract_req_tags_inferred() -> None:
    assert _extract_req_tags("Handles startup. @req REQ-0042 [inferred]") == [
        "REQ-0042",
    ]

Activity · 1 steps
lines 1161–1163assert _extract_req_tags("Handles startup. @req REQ-0042 [inferred]") == [ "REQ-0042", ]

test_extract_req_tags_no_tag_returns_empty

None test_build_docs_db.test_extract_req_tags_no_tag_returns_empty()

tests/test_build_docs_db.py:1166

Checks

  • assert _extract_req_tags("Just a normal description, no requirement tag.") == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_extract_req_tags_no_tag_returns_empty → _extract_req_tags
Source · 4 lines
def test_extract_req_tags_no_tag_returns_empty() -> None:
    assert _extract_req_tags("Just a normal description, no requirement tag.") == []

Activity · 1 steps
lines 1167–1167assert _extract_req_tags("Just a normal description, no requirement tag.") == []

test_extract_req_tags_none_text_returns_empty

None test_build_docs_db.test_extract_req_tags_none_text_returns_empty()

tests/test_build_docs_db.py:1170

Checks

  • assert _extract_req_tags(None) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_extract_req_tags_none_text_returns_empty → _extract_req_tags
Source · 8 lines
def test_extract_req_tags_none_text_returns_empty() -> None:
    assert _extract_req_tags(None) == []


# ─── requirements.import_req_edges ──────────────────────────────────────────


@pytest.fixture

test_extract_req_tags_stated

None test_build_docs_db.test_extract_req_tags_stated()

tests/test_build_docs_db.py:1154

Checks

  • assert _extract_req_tags("Handles startup. @req REQ-0042") == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_extract_req_tags_stated → _extract_req_tags
Source · 6 lines
def test_extract_req_tags_stated() -> None:
    assert _extract_req_tags("Handles startup. @req REQ-0042") == [
        "REQ-0042",
    ]

Activity · 1 steps
lines 1155–1157assert _extract_req_tags("Handles startup. @req REQ-0042") == [ "REQ-0042", ]

test_forced_output_dir_keeps_doxygen_out_of_the_target_repo

None test_build_docs_db.test_forced_output_dir_keeps_doxygen_out_of_the_target_repo(Path tmp_path)

tests/test_build_docs_db.py:184

Checks

  • assert assignments[-1] == f"OUTPUT_DIRECTORY = {scratch.resolve()}", ("the forced absolute path must be the LAST assignment doxygen sees" )
  • assert effective_output_dir(doxyfile, repo, scratch) == scratch.resolve()
  • assert doxygen_db_path(doxyfile, repo, scratch).is_relative_to(scratch.resolve())

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_forced_output_dir_keeps_doxygen_out_of_the_target_repo → _build_doxyfile_content
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_forced_output_dir_keeps_doxygen_out_of_the_target_repo → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 34 lines
def test_forced_output_dir_keeps_doxygen_out_of_the_target_repo(tmp_path: Path) -> None:
    """#53: clew is a READ-ONLY consumer of target repos, but honoring the
    repo's own Doxyfile (#49) meant honoring its OUTPUT_DIRECTORY too — a C++ codebase
    declares `docs/generated/doxygen`, so an index build wrote doxygen's
    sqlite3/xml straight into the working tree. That mutates a repo the operator
    may be mid-edit in, collides between concurrent builds, and shares a
    directory with output clew did not produce.

    The forced value must come LAST so it wins (doxygen takes the final
    assignment) and must be ABSOLUTE, since cwd stays the repo root so relative
    INPUT paths still resolve."""
    from clew.doxygen import (
        doxygen_db_path,
        effective_output_dir,
    )

    repo = tmp_path / "repo"
    repo.mkdir()
    doxyfile = repo / "Doxyfile"
    doxyfile.write_text("PROJECT_NAME = t\nOUTPUT_DIRECTORY = docs/generated/doxygen\n")
    scratch = tmp_path / "scratch.doxygen"

    content = _build_doxyfile_content(doxyfile, None, None, output_dir=scratch)
    assignments = [ln for ln in content.splitlines() if ln.startswith("OUTPUT_DIRECTORY")]
    assert assignments[-1] == f"OUTPUT_DIRECTORY = {scratch.resolve()}", (
        "the forced absolute path must be the LAST assignment doxygen sees"
    )

    # Every output-path resolver must agree with what was forced, or the
    # pipeline would look for its artifacts where they were not written.
    assert effective_output_dir(doxyfile, repo, scratch) == scratch.resolve()
    assert doxygen_db_path(doxyfile, repo, scratch).is_relative_to(scratch.resolve())

Activity · 11 steps
lines 195–198from clew.doxygen import ( doxygen_db_path, effective_output_dir, )lines 200–200repo = tmp_path / "repo"lines 201–201repo.mkdir()lines 202–202doxyfile = repo / "Doxyfile"lines 203–203doxyfile.write_text("PROJECT_NAME = t\nOUTPUT_DIRECTORY = docs/generated/doxygen\n")lines 204–204scratch = tmp_path / "scratch.doxygen"lines 206–206content = _build_doxyfile_content(doxyfile, None, None, output_dir=scratch)lines 207–207assignments = [ln for ln in content.splitlines() if ln.startswith("OUTPUT_DIRECTORY")]lines 208–210assert assignments[-1] == f"OUTPUT_DIRECTORY = {scratch.resolve()}", ( "the forced absolute path must be the LAST assignment doxygen sees" )lines 214–214assert effective_output_dir(doxyfile, repo, scratch) == scratch.resolve()lines 215–215assert doxygen_db_path(doxyfile, repo, scratch).is_relative_to(scratch.resolve())

test_gather_reachability_seeds_pattern_match

None test_build_docs_db.test_gather_reachability_seeds_pattern_match(Path synthetic_reachability_db)

tests/test_build_docs_db.py:874

Checks

  • assert pattern == {1, 2, 5}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-004measuredtest_gather_reachability_seeds_pattern_match → _gather_reachability_seeds
REQ-DDB-PIPE-010catalog
Source · 13 lines
def test_gather_reachability_seeds_pattern_match(
    synthetic_reachability_db: Path,
) -> None:
    conn = sqlite3.connect(str(synthetic_reachability_db))
    pattern, _zero = _gather_reachability_seeds(
        conn,
        ["main", "app_main", "%init%"],
    )
    conn.close()
    # main(1), app_main(5), do_init(2). orphan_func should NOT match.
    assert pattern == {1, 2, 5}

Activity · 4 steps
lines 877–877conn = sqlite3.connect(str(synthetic_reachability_db))lines 878–881pattern, _zero = _gather_reachability_seeds( conn, ["main", "app_main", "%init%"], )lines 882–882conn.close()lines 884–884assert pattern == {1, 2, 5}

test_gather_reachability_seeds_zero_incoming

None test_build_docs_db.test_gather_reachability_seeds_zero_incoming(Path synthetic_reachability_db)

tests/test_build_docs_db.py:887

Checks

  • assert zero == {1, 4, 5, 7}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-004measuredtest_gather_reachability_seeds_zero_incoming → _gather_reachability_seeds
REQ-DDB-PIPE-010catalog
Source · 12 lines
def test_gather_reachability_seeds_zero_incoming(
    synthetic_reachability_db: Path,
) -> None:
    conn = sqlite3.connect(str(synthetic_reachability_db))
    _pattern, zero = _gather_reachability_seeds(conn, ["nope"])
    conn.close()
    # Functions with no non-fuzzy callers: main(1), app_main(5),
    # unused_helper(4), orphan_func(7). do_init(2), helper(3),
    # boot(6) all have callers.
    assert zero == {1, 4, 5, 7}

Activity · 4 steps
lines 890–890conn = sqlite3.connect(str(synthetic_reachability_db))lines 891–891_pattern, zero = _gather_reachability_seeds(conn, ["nope"])lines 892–892conn.close()lines 896–896assert zero == {1, 4, 5, 7}

test_implementation_with_at_least_one_body_does_NOT_warn

None test_build_docs_db.test_implementation_with_at_least_one_body_does_NOT_warn(Path tmp_path)

A partially-extracted index is not the failure this catches.

tests/test_build_docs_db.py:1613

Show on the map →

Called by none

Calls _bodies_db, warn_if_no_function_bodies

Checks

  • assert warn_if_no_function_bodies(db_path) == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_implementation_with_at_least_one_body_does_NOT_warn → warn_if_no_function_bodies
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 10 lines
def test_implementation_with_at_least_one_body_does_NOT_warn(tmp_path: Path) -> None:
    """One real body is enough to prove the preprocessor is satisfied.

    @brief A partially-extracted index is not the failure this catches.
    @version 1
    """
    db_path = _bodies_db(tmp_path, [("src/a.c", True), ("src/b.c", False)])
    assert warn_if_no_function_bodies(db_path) == 0

Activity · 2 steps
lines 1619–1619db_path = _bodies_db(tmp_path, [("src/a.c", True), ("src/b.c", False)])lines 1620–1620assert warn_if_no_function_bodies(db_path) == 0

test_import_req_edges_creates_expected_rows

None test_build_docs_db.test_import_req_edges_creates_expected_rows(Path req_tagged_db)

tests/test_build_docs_db.py:1207

Checks

  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_import_req_edges_creates_expected_rows → import_req_edges
Source · 16 lines
def test_import_req_edges_creates_expected_rows(req_tagged_db: Path) -> None:
    import_req_edges(req_tagged_db)
    conn = sqlite3.connect(str(req_tagged_db))
    rows = conn.execute(
        "SELECT req_id, memberdef_rowid FROM req_edges ORDER BY memberdef_rowid",
    ).fetchall()
    conn.close()
    assert rows == [
        ("REQ-0001", 1),
        ("REQ-0001", 2),
    ]


# ─── requirements._looks_like_test_function / import_req_test_edges ────────

Activity · 5 steps
lines 1208–1208import_req_edges(req_tagged_db)lines 1209–1209conn = sqlite3.connect(str(req_tagged_db))lines 1210–1212rows = conn.execute( "SELECT req_id, memberdef_rowid FROM req_edges ORDER BY memberdef_rowid", ).fetchall()lines 1213–1213conn.close()lines 1214–1217assert rows == [ ("REQ-0001", 1), ("REQ-0001", 2), ]

test_import_shared_key_edges_declared_dedups_decl_def_rows

None test_build_docs_db.test_import_shared_key_edges_declared_dedups_decl_def_rows(Path tmp_path)

tests/test_build_docs_db.py:1990

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_declared

Checks

  • assert rows == [(1, 2, "ROBOT_SOUND_EVENT_TYPE")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-QUERY-003measuredtest_import_shared_key_edges_declared_dedups_decl_def_rows → import_shared_key_edges_declared → _definition_preferring_name_index
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_declared_dedups_decl_def_rows → import_shared_key_edges_declared → _load_declared_keys → _parse_data_model_toml → _declared_keys_from_doc → _coerce_edge_triggered
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_declared_dedups_decl_def_rows → import_shared_key_edges_declared
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_declared_dedups_decl_def_rows → import_shared_key_edges_declared → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measured
Source · 46 lines
def test_import_shared_key_edges_declared_dedups_decl_def_rows(
    tmp_path: Path,
) -> None:
    # A function declared in a header AND defined in a .c file has two
    # memberdef rows (decl: file_id != bodyfile_id; def: file_id ==
    # bodyfile_id). Resolving a manifest writer/reader NAME must NOT
    # cross-product decl x def into duplicate edges — one manifest edge =
    # one row. Regression: previously inserted 4x (2 writers x 2 readers).
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 8)],
    )
    conn = sqlite3.connect(str(db_path))
    # Header-declaration rows for the same two names: file_id (2) != bodyfile_id
    # (1) marks them as declarations, not definitions.
    conn.execute("INSERT INTO path (rowid, name) VALUES (2, 'inc/foo.h')")
    conn.executemany(
        "INSERT INTO memberdef "
        "(rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend) "
        "VALUES (?, 'function', ?, 2, 1, ?, ?)",
        [(3, "handle_ping_cmd", 1, 1), (4, "handle_sound_event_findme", 1, 1)],
    )
    conn.commit()
    conn.close()

    data_model_path = tmp_path / "data_model.toml"
    data_model_path.write_text(
        """
        [[keys]]
        name = "ROBOT_SOUND_EVENT_TYPE"
        event = true
        writers = ["handle_ping_cmd"]
        readers = ["handle_sound_event_findme"]
        """,
    )
    import_shared_key_edges_declared(db_path, data_model_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name FROM shared_key_edges",
    ).fetchall()
    conn.close()
    # Definition rows preferred (1 -> 2), exactly one edge, not four.
    assert rows == [(1, 2, "ROBOT_SOUND_EVENT_TYPE")]

Activity · 13 steps
lines 1998–2001db_path = _make_shared_key_db( tmp_path, [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 8)], )lines 2002–2002conn = sqlite3.connect(str(db_path))lines 2005–2005conn.execute("INSERT INTO path (rowid, name) VALUES (2, 'inc/foo.h')")lines 2006–2011conn.executemany( "INSERT INTO memberdef " "(rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend) " "VALUES (?, 'function', ?, 2, 1, ?, ?)", [(3, "handle_ping_cmd", 1, 1), (4, "handle_sound_event_findme", 1, 1)], )lines 2012–2012conn.commit()lines 2013–2013conn.close()lines 2015–2015data_model_path = tmp_path / "data_model.toml"lines 2016–2024data_model_path.write_text( """ [[keys]] name = "ROBOT_SOUND_EVENT_TYPE" event = true writers = ["handle_ping_cmd"] readers = ["handle_sound_event_findme"] """, )lines 2025–2025import_shared_key_edges_declared(db_path, data_model_path)lines 2027–2027conn = sqlite3.connect(str(db_path))lines 2028–2030rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name FROM shared_key_edges", ).fetchall()lines 2031–2031conn.close()lines 2033–2033assert rows == [(1, 2, "ROBOT_SOUND_EVENT_TYPE")]

test_import_shared_key_edges_declared_event_edge

None test_build_docs_db.test_import_shared_key_edges_declared_event_edge(Path tmp_path)

tests/test_build_docs_db.py:1934

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_declared

Checks

  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-QUERY-003measuredtest_import_shared_key_edges_declared_event_edge → import_shared_key_edges_declared → _definition_preferring_name_index
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_declared_event_edge → import_shared_key_edges_declared → _load_declared_keys → _parse_data_model_toml → _declared_keys_from_doc → _coerce_edge_triggered
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_declared_event_edge → import_shared_key_edges_declared
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_declared_event_edge → import_shared_key_edges_declared → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measured
Source · 30 lines
def test_import_shared_key_edges_declared_event_edge(tmp_path: Path) -> None:
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 8)],
    )
    data_model_path = tmp_path / "data_model.toml"
    data_model_path.write_text(
        """
        [[keys]]
        name = "ROBOT_SOUND_EVENT_TYPE"
        persistent = false
        event = true
        writers = ["handle_ping_cmd"]
        readers = ["handle_sound_event_findme"]
        """,
    )

    import_shared_key_edges_declared(db_path, data_model_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared, "
        "source, confidence FROM shared_key_edges",
    ).fetchall()
    conn.close()
    assert rows == [
        (1, 2, "ROBOT_SOUND_EVENT_TYPE", "event", 1, "shared_key_declared", "high"),
    ]

Activity · 8 steps
lines 1935–1938db_path = _make_shared_key_db( tmp_path, [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 8)], )lines 1939–1939data_model_path = tmp_path / "data_model.toml"lines 1940–1949data_model_path.write_text( """ [[keys]] name = "ROBOT_SOUND_EVENT_TYPE" persistent = false event = true writers = ["handle_ping_cmd"] readers = ["handle_sound_event_findme"] """, )lines 1951–1951import_shared_key_edges_declared(db_path, data_model_path)lines 1953–1953conn = sqlite3.connect(str(db_path))lines 1954–1957rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared, " "source, confidence FROM shared_key_edges", ).fetchall()lines 1958–1958conn.close()lines 1959–1961assert rows == [ (1, 2, "ROBOT_SOUND_EVENT_TYPE", "event", 1, "shared_key_declared", "high"), ]

test_import_shared_key_edges_declared_no_path_skips

None test_build_docs_db.test_import_shared_key_edges_declared_no_path_skips(Path tmp_path)

tests/test_build_docs_db.py:2036

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_declared

Checks

  • assert has_table is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-QUERY-003inferredtest_import_shared_key_edges_declared_no_path_skips → import_shared_key_edges_declared → _definition_preferring_name_index
REQ-DDB-SCHEMA-002inferredtest_import_shared_key_edges_declared_no_path_skips → import_shared_key_edges_declared → _load_declared_keys → _parse_data_model_toml → _declared_keys_from_doc → _coerce_edge_triggered
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_declared_no_path_skips → import_shared_key_edges_declared
REQ-DDB-SCHEMA-007inferredtest_import_shared_key_edges_declared_no_path_skips → import_shared_key_edges_declared → _ensure_shared_key_edges_table
Source · 11 lines
def test_import_shared_key_edges_declared_no_path_skips(tmp_path: Path) -> None:
    db_path = _make_shared_key_db(tmp_path, [])
    import_shared_key_edges_declared(db_path, None)
    conn = sqlite3.connect(str(db_path))
    has_table = conn.execute(
        "SELECT 1 FROM sqlite_master WHERE type='table' AND name='shared_key_edges'",
    ).fetchone()
    conn.close()
    assert has_table is None

Activity · 6 steps
lines 2037–2037db_path = _make_shared_key_db(tmp_path, [])lines 2038–2038import_shared_key_edges_declared(db_path, None)lines 2039–2039conn = sqlite3.connect(str(db_path))lines 2040–2042has_table = conn.execute( "SELECT 1 FROM sqlite_master WHERE type='table' AND name='shared_key_edges'", ).fetchone()lines 2043–2043conn.close()lines 2044–2044assert has_table is None

test_import_shared_key_edges_declared_yaml_manifest

None test_build_docs_db.test_import_shared_key_edges_declared_yaml_manifest(Path tmp_path)

tests/test_build_docs_db.py:1964

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_declared

Checks

  • assert rows == [(1, 2, "ROBOT_SOUND_EVENT_TYPE", "event", 1)]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-QUERY-003measuredtest_import_shared_key_edges_declared_yaml_manifest → import_shared_key_edges_declared → _definition_preferring_name_index
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_declared_yaml_manifest → import_shared_key_edges_declared → _load_declared_keys → _parse_data_model_toml → _declared_keys_from_doc → _coerce_edge_triggered
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_declared_yaml_manifest → import_shared_key_edges_declared
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_declared_yaml_manifest → import_shared_key_edges_declared → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measured
Source · 26 lines
def test_import_shared_key_edges_declared_yaml_manifest(tmp_path: Path) -> None:
    # data-model-style YAML manifest (same keys: shape as the ingot TOML) — the
    # --data-model parser dispatches on suffix (.yaml/.yml -> YAML).
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 8)],
    )
    data_model_path = tmp_path / "data_model.yaml"
    data_model_path.write_text(
        "keys:\n"
        "  - name: ROBOT_SOUND_EVENT_TYPE\n"
        "    event: true\n"
        "    writers: [handle_ping_cmd]\n"
        "    readers: [handle_sound_event_findme]\n",
    )

    import_shared_key_edges_declared(db_path, data_model_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared FROM shared_key_edges",
    ).fetchall()
    conn.close()
    assert rows == [(1, 2, "ROBOT_SOUND_EVENT_TYPE", "event", 1)]

Activity · 8 steps
lines 1967–1970db_path = _make_shared_key_db( tmp_path, [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 8)], )lines 1971–1971data_model_path = tmp_path / "data_model.yaml"lines 1972–1978data_model_path.write_text( "keys:\n" " - name: ROBOT_SOUND_EVENT_TYPE\n" " event: true\n" " writers: [handle_ping_cmd]\n" " readers: [handle_sound_event_findme]\n", )lines 1980–1980import_shared_key_edges_declared(db_path, data_model_path)lines 1982–1982conn = sqlite3.connect(str(db_path))lines 1983–1985rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared FROM shared_key_edges", ).fetchall()lines 1986–1986conn.close()lines 1987–1987assert rows == [(1, 2, "ROBOT_SOUND_EVENT_TYPE", "event", 1)]

test_import_shared_key_edges_inferred_case_label_is_a_reader_site

None test_build_docs_db.test_import_shared_key_edges_inferred_case_label_is_a_reader_site(Path tmp_path)

A `switch (key) { case KEY_X: ...; }` dispatch is a real-world reader shape with no accessor call at all — a plain writer call plus a case label sharing the same literal must still produce an edge.

tests/test_build_docs_db.py:1870

Show on the map →

Called by none

Calls _make_shared_key_db, _write_shared_key_patterns_yaml, import_shared_key_edges_inferred

Checks

  • assert rows == [(1, 2, "KEY_A")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_case_label_is_a_reader_site → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 38 lines
def test_import_shared_key_edges_inferred_case_label_is_a_reader_site(
    tmp_path: Path,
) -> None:
    """A `switch (key) { case KEY_X: ...; }` dispatch is a real-world
    reader shape with no accessor call at all — a plain writer call plus a
    case label sharing the same literal must still produce an edge."""
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void caller_a(void) {\n"
        '    datamodel_set("KEY_A");\n'
        "}\n"
        "\n"
        "void dispatcher(int key) {\n"
        "    switch (key) {\n"
        "        case KEY_A:\n"
        "            break;\n"
        "        default:\n"
        "            break;\n"
        "    }\n"
        "}\n",
    )
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "caller_a", 1, 3), (2, "dispatcher", 5, 12)],
    )
    patterns_path = _write_shared_key_patterns_yaml(tmp_path)

    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name FROM shared_key_edges",
    ).fetchall()
    conn.close()
    assert rows == [(1, 2, "KEY_A")]

Activity · 10 steps
lines 1876–1876src_dir = tmp_path / "src"lines 1877–1877src_dir.mkdir()lines 1878–1891(src_dir / "foo.c").write_text( "void caller_a(void) {\n" ' datamodel_set("KEY_A");\n' "}\n" "\n" "void dispatcher(int key) {\n" " switch (key) {\n" " case KEY_A:\n" " break;\n" " default:\n" " break;\n" " }\n" "}\n", )lines 1892–1895db_path = _make_shared_key_db( tmp_path, [(1, "caller_a", 1, 3), (2, "dispatcher", 5, 12)], )lines 1896–1896patterns_path = _write_shared_key_patterns_yaml(tmp_path)lines 1898–1898import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1900–1900conn = sqlite3.connect(str(db_path))lines 1901–1903rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name FROM shared_key_edges", ).fetchall()lines 1904–1904conn.close()lines 1905–1905assert rows == [(1, 2, "KEY_A")]

test_import_shared_key_edges_inferred_default_case_is_not_a_match

None test_build_docs_db.test_import_shared_key_edges_inferred_default_case_is_not_a_match(Path tmp_path)

`default:` has no value field — it must be skipped silently, never counted unresolved and never matched as a key.

tests/test_build_docs_db.py:1908

Show on the map →

Called by none

Calls _make_shared_key_db, _write_shared_key_patterns_yaml, import_shared_key_edges_inferred

Checks

  • assert count == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_default_case_is_not_a_match → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 26 lines
def test_import_shared_key_edges_inferred_default_case_is_not_a_match(
    tmp_path: Path,
) -> None:
    """`default:` has no value field — it must be skipped silently, never
    counted unresolved and never matched as a key."""
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void dispatcher(int key) {\n"
        "    switch (key) {\n"
        "        default:\n"
        "            break;\n"
        "    }\n"
        "}\n",
    )
    db_path = _make_shared_key_db(tmp_path, [(1, "dispatcher", 1, 6)])
    patterns_path = _write_shared_key_patterns_yaml(tmp_path)

    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    count = conn.execute("SELECT COUNT(*) FROM shared_key_edges").fetchone()[0]
    conn.close()
    assert count == 0

Activity · 10 steps
lines 1913–1913src_dir = tmp_path / "src"lines 1914–1914src_dir.mkdir()lines 1915–1922(src_dir / "foo.c").write_text( "void dispatcher(int key) {\n" " switch (key) {\n" " default:\n" " break;\n" " }\n" "}\n", )lines 1923–1923db_path = _make_shared_key_db(tmp_path, [(1, "dispatcher", 1, 6)])lines 1924–1924patterns_path = _write_shared_key_patterns_yaml(tmp_path)lines 1926–1926import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1928–1928conn = sqlite3.connect(str(db_path))lines 1929–1929count = conn.execute("SELECT COUNT(*) FROM shared_key_edges").fetchone()[0]lines 1930–1930conn.close()lines 1931–1931assert count == 0

test_import_shared_key_edges_inferred_ingot_defaults_fire

None test_build_docs_db.test_import_shared_key_edges_inferred_ingot_defaults_fire(Path tmp_path)

The heart of the default: a repo using the ingot per-key accessor convention (DataModel_Set_<KEY> / DataModel_Get_<KEY>) gets its shared-key seam WITHOUT passing --shared-key-patterns. This is what a bare build_or_refresh must do so chain_trace has seams to cross.

tests/test_build_docs_db.py:1509

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_inferred

Checks

  • assert ("producer", "consumer", "SOUND_EVENT") in edges, (f"ingot default should link producer->consumer on SOUND_EVENT; got {edges}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_ingot_defaults_fire → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 35 lines
def test_import_shared_key_edges_inferred_ingot_defaults_fire(
    tmp_path: Path,
) -> None:
    """The heart of the default: a repo using the ingot per-key accessor
    convention (DataModel_Set_<KEY> / DataModel_Get_<KEY>) gets its shared-key
    seam WITHOUT passing --shared-key-patterns. This is what a bare
    build_or_refresh must do so chain_trace has seams to cross."""
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    src = (
        "void producer(void) {\n"
        "    DataModel_Set_SOUND_EVENT(3);\n"
        "}\n"
        "void consumer(void) {\n"
        "    int v = DataModel_Get_SOUND_EVENT();\n"
        "    (void)v;\n"
        "}\n"
    )
    (src_dir / "foo.c").write_text(src)
    functions = [(1, "producer", 1, 3), (2, "consumer", 4, 7)]
    db_path = _make_shared_key_db(tmp_path, functions)
    # No patterns file — the built-in ingot defaults must supply the edge.
    import_shared_key_edges_inferred(db_path, tmp_path, None)
    conn = sqlite3.connect(str(db_path))
    edges = conn.execute(
        "SELECT w.name, r.name, key_name FROM shared_key_edges s "
        "JOIN memberdef w ON w.rowid=s.writer_rowid "
        "JOIN memberdef r ON r.rowid=s.reader_rowid",
    ).fetchall()
    conn.close()
    assert ("producer", "consumer", "SOUND_EVENT") in edges, (
        f"ingot default should link producer->consumer on SOUND_EVENT; got {edges}"
    )

Activity · 11 steps
lines 1516–1516src_dir = tmp_path / "src"lines 1517–1517src_dir.mkdir()lines 1518–1526src = ( "void producer(void) {\n" " DataModel_Set_SOUND_EVENT(3);\n" "}\n" "void consumer(void) {\n" " int v = DataModel_Get_SOUND_EVENT();\n" " (void)v;\n" "}\n" )lines 1527–1527(src_dir / "foo.c").write_text(src)lines 1528–1528functions = [(1, "producer", 1, 3), (2, "consumer", 4, 7)]lines 1529–1529db_path = _make_shared_key_db(tmp_path, functions)lines 1531–1531import_shared_key_edges_inferred(db_path, tmp_path, None)lines 1532–1532conn = sqlite3.connect(str(db_path))lines 1533–1537edges = conn.execute( "SELECT w.name, r.name, key_name FROM shared_key_edges s " "JOIN memberdef w ON w.rowid=s.writer_rowid " "JOIN memberdef r ON r.rowid=s.reader_rowid", ).fetchall()lines 1538–1538conn.close()lines 1539–1541assert ("producer", "consumer", "SOUND_EVENT") in edges, ( f"ingot default should link producer->consumer on SOUND_EVENT; got {edges}" )

test_import_shared_key_edges_inferred_literal_key_match

None test_build_docs_db.test_import_shared_key_edges_inferred_literal_key_match(Path tmp_path)

tests/test_build_docs_db.py:1392

Show on the map →

Called by none

Calls _make_shared_key_db, _write_shared_key_patterns_yaml, import_shared_key_edges_inferred

Checks

  • assert rows == [(1, 2, "KEY_A", "unknown", 0, "shared_key_inferred", "medium")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_literal_key_match → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 29 lines
def test_import_shared_key_edges_inferred_literal_key_match(tmp_path: Path) -> None:
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void caller_a(void) {\n"
        '    datamodel_set("KEY_A");\n'
        "}\n"
        "\n"
        "void caller_b(void) {\n"
        '    datamodel_get("KEY_A");\n'
        "}\n",
    )
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "caller_a", 1, 3), (2, "caller_b", 5, 7)],
    )
    patterns_path = _write_shared_key_patterns_yaml(tmp_path)

    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared, "
        "source, confidence FROM shared_key_edges",
    ).fetchall()
    conn.close()
    assert rows == [(1, 2, "KEY_A", "unknown", 0, "shared_key_inferred", "medium")]

Activity · 10 steps
lines 1393–1393src_dir = tmp_path / "src"lines 1394–1394src_dir.mkdir()lines 1395–1403(src_dir / "foo.c").write_text( "void caller_a(void) {\n" ' datamodel_set("KEY_A");\n' "}\n" "\n" "void caller_b(void) {\n" ' datamodel_get("KEY_A");\n' "}\n", )lines 1404–1407db_path = _make_shared_key_db( tmp_path, [(1, "caller_a", 1, 3), (2, "caller_b", 5, 7)], )lines 1408–1408patterns_path = _write_shared_key_patterns_yaml(tmp_path)lines 1410–1410import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1412–1412conn = sqlite3.connect(str(db_path))lines 1413–1416rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared, " "source, confidence FROM shared_key_edges", ).fetchall()lines 1417–1417conn.close()lines 1418–1418assert rows == [(1, 2, "KEY_A", "unknown", 0, "shared_key_inferred", "medium")]

test_import_shared_key_edges_inferred_name_prefix_key_in_callee_name

None test_build_docs_db.test_import_shared_key_edges_inferred_name_prefix_key_in_callee_name(Path tmp_path)

The real generated-data-model convention confirmed live: one accessor function PER KEY, no key argument at all — the key is the remainder of the callee name after a fixed prefix (STORE_SET_ROBOT_SOUND_EVENT_SET(value), STORE_GET_ROBOT_SOUND_EVENT_SET()).

tests/test_build_docs_db.py:1336

Show on the map →

Called by none

Calls _make_shared_key_db, _write_name_prefix_patterns_yaml, import_shared_key_edges_inferred

Checks

  • assert rows == [(1, 2, "ROBOT_SOUND_EVENT_SET")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_name_prefix_key_in_callee_name → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 35 lines
def test_import_shared_key_edges_inferred_name_prefix_key_in_callee_name(
    tmp_path: Path,
) -> None:
    """The real generated-data-model convention confirmed live: one accessor
    function PER KEY, no key argument at all — the key is the remainder
    of the callee name after a fixed prefix
    (STORE_SET_ROBOT_SOUND_EVENT_SET(value),
    STORE_GET_ROBOT_SOUND_EVENT_SET())."""
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void handle_ping_cmd(void) {\n"
        "    STORE_SET_ROBOT_SOUND_EVENT_SET(true);\n"
        "}\n"
        "\n"
        "void handle_sound_event_findme(void) {\n"
        "    STORE_GET_ROBOT_SOUND_EVENT_SET();\n"
        "}\n",
    )
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 7)],
    )
    patterns_path = _write_name_prefix_patterns_yaml(tmp_path)

    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name FROM shared_key_edges",
    ).fetchall()
    conn.close()
    assert rows == [(1, 2, "ROBOT_SOUND_EVENT_SET")]

Activity · 10 steps
lines 1344–1344src_dir = tmp_path / "src"lines 1345–1345src_dir.mkdir()lines 1346–1354(src_dir / "foo.c").write_text( "void handle_ping_cmd(void) {\n" " STORE_SET_ROBOT_SOUND_EVENT_SET(true);\n" "}\n" "\n" "void handle_sound_event_findme(void) {\n" " STORE_GET_ROBOT_SOUND_EVENT_SET();\n" "}\n", )lines 1355–1358db_path = _make_shared_key_db( tmp_path, [(1, "handle_ping_cmd", 1, 3), (2, "handle_sound_event_findme", 5, 7)], )lines 1359–1359patterns_path = _write_name_prefix_patterns_yaml(tmp_path)lines 1361–1361import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1363–1363conn = sqlite3.connect(str(db_path))lines 1364–1366rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name FROM shared_key_edges", ).fetchall()lines 1367–1367conn.close()lines 1368–1368assert rows == [(1, 2, "ROBOT_SOUND_EVENT_SET")]

test_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults

None test_build_docs_db.test_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults(Path tmp_path)

With no --shared-key-patterns, the pass now falls back to the built-in ingot accessor defaults instead of skipping (a repo whose whole causal layer went missing simply because a flag was omitted is the failure this guards against). The fixture has no `DataModel_Set_/Get_` accessors, so the defaults fire but match nothing: the table IS created and holds 0 edges — 'ran and found none', not 'never ran'.

tests/test_build_docs_db.py:1488

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_inferred

Checks

  • assert has_table is not None, "the defaulted pass must run and create the table"
  • assert n == 0, "no ingot accessors in the fixture ⇒ zero edges (no false positives)"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 21 lines
def test_import_shared_key_edges_inferred_no_patterns_uses_ingot_defaults(
    tmp_path: Path,
) -> None:
    """With no --shared-key-patterns, the pass now falls back to the built-in
    ingot accessor defaults instead of skipping (a repo whose whole causal
    layer went missing simply because a flag was omitted is the failure this
    guards against). The fixture has no `DataModel_Set_/Get_` accessors, so the
    defaults fire but match nothing: the table IS created and holds 0 edges —
    'ran and found none', not 'never ran'."""
    db_path = _make_shared_key_db(tmp_path, [])
    import_shared_key_edges_inferred(db_path, tmp_path, None)
    conn = sqlite3.connect(str(db_path))
    has_table = conn.execute(
        "SELECT 1 FROM sqlite_master WHERE type='table' AND name='shared_key_edges'",
    ).fetchone()
    n = conn.execute("SELECT count(*) FROM shared_key_edges").fetchone()[0]
    conn.close()
    assert has_table is not None, "the defaulted pass must run and create the table"
    assert n == 0, "no ingot accessors in the fixture ⇒ zero edges (no false positives)"

Activity · 8 steps
lines 1497–1497db_path = _make_shared_key_db(tmp_path, [])lines 1498–1498import_shared_key_edges_inferred(db_path, tmp_path, None)lines 1499–1499conn = sqlite3.connect(str(db_path))lines 1500–1502has_table = conn.execute( "SELECT 1 FROM sqlite_master WHERE type='table' AND name='shared_key_edges'", ).fetchone()lines 1503–1503n = conn.execute("SELECT count(*) FROM shared_key_edges").fetchone()[0]lines 1504–1504conn.close()lines 1505–1505assert has_table is not None, "the defaulted pass must run and create the table"lines 1506–1506assert n == 0, "no ingot accessors in the fixture ⇒ zero edges (no false positives)"

test_import_shared_key_edges_inferred_non_literal_key_unresolved

None test_build_docs_db.test_import_shared_key_edges_inferred_non_literal_key_unresolved(Path tmp_path)

tests/test_build_docs_db.py:1468

Show on the map →

Called by none

Calls _make_shared_key_db, _write_shared_key_patterns_yaml, import_shared_key_edges_inferred

Checks

  • assert count == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_non_literal_key_unresolved → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 20 lines
def test_import_shared_key_edges_inferred_non_literal_key_unresolved(
    tmp_path: Path,
) -> None:
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void caller_c(void) {\n    int key = get_key();\n    datamodel_set(key);\n}\n",
    )
    db_path = _make_shared_key_db(tmp_path, [(1, "caller_c", 1, 4)])
    patterns_path = _write_shared_key_patterns_yaml(tmp_path)

    # Must not crash on a computed (non-literal) key argument.
    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    count = conn.execute("SELECT COUNT(*) FROM shared_key_edges").fetchone()[0]
    conn.close()
    assert count == 0

Activity · 10 steps
lines 1471–1471src_dir = tmp_path / "src"lines 1472–1472src_dir.mkdir()lines 1473–1475(src_dir / "foo.c").write_text( "void caller_c(void) {\n int key = get_key();\n datamodel_set(key);\n}\n", )lines 1476–1476db_path = _make_shared_key_db(tmp_path, [(1, "caller_c", 1, 4)])lines 1477–1477patterns_path = _write_shared_key_patterns_yaml(tmp_path)lines 1480–1480import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1482–1482conn = sqlite3.connect(str(db_path))lines 1483–1483count = conn.execute("SELECT COUNT(*) FROM shared_key_edges").fetchone()[0]lines 1484–1484conn.close()lines 1485–1485assert count == 0

test_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped

None test_build_docs_db.test_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped(Path tmp_path)

tests/test_build_docs_db.py:1421

Show on the map →

Called by none

Calls _make_shared_key_db, import_shared_key_edges_inferred

Checks

  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 47 lines
def test_import_shared_key_edges_inferred_queue_handle_pointer_unwrapped(
    tmp_path: Path,
) -> None:
    # Async-queue dataflow: the queue handle is passed by address
    # (`QUEUESEND(&msg_queue, m)`), so _resolve_literal_key must unwrap the
    # pointer_expression to the inner identifier for enqueue->dequeue pairs
    # to compose across the queue boundary.
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void producer_task(void) {\n"
        "    QUEUESEND(&msg_queue, msg);\n"
        "}\n"
        "\n"
        "void consumer_task(void) {\n"
        "    QUEUERECEIVE(&msg_queue, &msg);\n"
        "}\n",
    )
    db_path = _make_shared_key_db(
        tmp_path,
        [(1, "producer_task", 1, 3), (2, "consumer_task", 5, 7)],
    )
    patterns_path = tmp_path / "queue_patterns.yaml"
    patterns_path.write_text(
        """
        writers:
          - pattern: "QUEUESEND"
            key_arg_index: 0
        readers:
          - pattern: "QUEUERECEIVE"
            key_arg_index: 0
        """,
    )

    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    rows = conn.execute(
        "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared, "
        "source, confidence FROM shared_key_edges",
    ).fetchall()
    conn.close()
    assert rows == [
        (1, 2, "msg_queue", "unknown", 0, "shared_key_inferred", "medium"),
    ]

Activity · 11 steps
lines 1428–1428src_dir = tmp_path / "src"lines 1429–1429src_dir.mkdir()lines 1430–1438(src_dir / "foo.c").write_text( "void producer_task(void) {\n" " QUEUESEND(&msg_queue, msg);\n" "}\n" "\n" "void consumer_task(void) {\n" " QUEUERECEIVE(&msg_queue, &msg);\n" "}\n", )lines 1439–1442db_path = _make_shared_key_db( tmp_path, [(1, "producer_task", 1, 3), (2, "consumer_task", 5, 7)], )lines 1443–1443patterns_path = tmp_path / "queue_patterns.yaml"lines 1444–1453patterns_path.write_text( """ writers: - pattern: "QUEUESEND" key_arg_index: 0 readers: - pattern: "QUEUERECEIVE" key_arg_index: 0 """, )lines 1455–1455import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1457–1457conn = sqlite3.connect(str(db_path))lines 1458–1461rows = conn.execute( "SELECT writer_rowid, reader_rowid, key_name, edge_kind, declared, " "source, confidence FROM shared_key_edges", ).fetchall()lines 1462–1462conn.close()lines 1463–1465assert rows == [ (1, 2, "msg_queue", "unknown", 0, "shared_key_inferred", "medium"), ]

test_in_doxygen_scope_drops_what_a_full_run_would_not_index

None test_build_docs_db.test_in_doxygen_scope_drops_what_a_full_run_would_not_index(Path tmp_path)

The incremental plan must not offer out-of-scope files to the splice.

tests/test_build_docs_db.py:2302

Checks

  • assert "src/main.c" in honoured and "src/app.cpp" in honoured, (f"an ordinary source file was filtered out: {honoured}" )
  • assert "docs/notes.txt" not in honoured, ("a .txt file is not in FILE_PATTERNS, so a directory-driven run never indexes it — " "listing it explicitly in a subset run would bypass that" )
  • assert "vendor/third_party.c" not in honoured, ("a file the Doxyfile EXCLUDE_PATTERNS excludes was kept, so the splice would index a " "file no full rebuild produces" )
  • assert "vendor/third_party.c" in ignored, ("EXCLUDE_PATTERNS was applied even though the whole-tree run clears it under " "replace_input, which would make the subset NARROWER than the master and leave real " "files stale" )
  • assert "docs/notes.txt" not in ignored, ("FILE_PATTERNS is forced in both regimes, so it must filter regardless" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_in_doxygen_scope_drops_what_a_full_run_would_not_index → in_doxygen_scope → effective_file_patterns
REQ-DDB-INDEX-001measuredtest_in_doxygen_scope_drops_what_a_full_run_would_not_index → in_doxygen_scope → effective_file_patterns
REQ-DDB-INDEX-002measuredtest_in_doxygen_scope_drops_what_a_full_run_would_not_index → in_doxygen_scope
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 51 lines
def test_in_doxygen_scope_drops_what_a_full_run_would_not_index(tmp_path: Path) -> None:
    """A SCOPE STATEMENT HAS THREE KEYS AND THE TREE SCAN READS ONE. `enumerate_tree` honours
    INPUT and EXCLUDE roots and is deliberately NOT extension-filtered, because its job is
    "did anything change" where a false positive only costs a rebuild. Reusing that set as the
    doxygen INPUT is the defect: doxygen applies FILE_PATTERNS only to DIRECTORY entries, and a
    subset run clears EXCLUDE_PATTERNS in order to list files individually — so both remaining
    keys are bypassed and a glob-excluded file gets spliced INTO the master.

    Measured on the C fixture before the fix: a `vendor/` file the Doxyfile excludes entered
    the changed set and was indexed, giving an incremental index a file no full rebuild would
    ever produce, with a healthy report and nothing in `skipped`.

    The conditional half is asserted too. A repo with a declared scope builds with
    `replace_input`, which clears EXCLUDE_PATTERNS for the WHOLE-TREE run as well, so honouring
    them in the subset would make the subset narrower than the master and leave real files
    stale. Both regimes are pinned so neither can be quietly dropped.

    @brief Out-of-scope candidates are filtered; the exclude half is regime-dependent.
    @return None.
    @version 1
    """
    from clew.doxygen import in_doxygen_scope

    doxyfile = tmp_path / "Doxyfile"
    doxyfile.write_text(
        "PROJECT_NAME = t\nINPUT = .\nEXCLUDE_PATTERNS = */vendor/*\n", encoding="utf-8"
    )
    candidates = ["src/main.c", "vendor/third_party.c", "docs/notes.txt", "src/app.cpp"]

    honoured = in_doxygen_scope(candidates, doxyfile, True)
    assert "src/main.c" in honoured and "src/app.cpp" in honoured, (
        f"an ordinary source file was filtered out: {honoured}"
    )
    assert "docs/notes.txt" not in honoured, (
        "a .txt file is not in FILE_PATTERNS, so a directory-driven run never indexes it — "
        "listing it explicitly in a subset run would bypass that"
    )
    assert "vendor/third_party.c" not in honoured, (
        "a file the Doxyfile EXCLUDE_PATTERNS excludes was kept, so the splice would index a "
        "file no full rebuild produces"
    )

    ignored = in_doxygen_scope(candidates, doxyfile, False)
    assert "vendor/third_party.c" in ignored, (
        "EXCLUDE_PATTERNS was applied even though the whole-tree run clears it under "
        "replace_input, which would make the subset NARROWER than the master and leave real "
        "files stale"
    )
    assert "docs/notes.txt" not in ignored, (
        "FILE_PATTERNS is forced in both regimes, so it must filter regardless"
    )

1 more lines, not shown

Activity · 11 steps
lines 2323–2323from clew.doxygen import in_doxygen_scopelines 2325–2325doxyfile = tmp_path / "Doxyfile"lines 2326–2328doxyfile.write_text( "PROJECT_NAME = t\nINPUT = .\nEXCLUDE_PATTERNS = */vendor/*\n", encoding="utf-8" )lines 2329–2329candidates = ["src/main.c", "vendor/third_party.c", "docs/notes.txt", "src/app.cpp"]lines 2331–2331honoured = in_doxygen_scope(candidates, doxyfile, True)lines 2332–2334assert "src/main.c" in honoured and "src/app.cpp" in honoured, ( f"an ordinary source file was filtered out: {honoured}" )lines 2335–2338assert "docs/notes.txt" not in honoured, ( "a .txt file is not in FILE_PATTERNS, so a directory-driven run never indexes it — " "listing it explicitly in a subset run would bypass that" )lines 2339–2342assert "vendor/third_party.c" not in honoured, ( "a file the Doxyfile EXCLUDE_PATTERNS excludes was kept, so the splice would index a " "file no full rebuild produces" )lines 2344–2344ignored = in_doxygen_scope(candidates, doxyfile, False)lines 2345–2349assert "vendor/third_party.c" in ignored, ( "EXCLUDE_PATTERNS was applied even though the whole-tree run clears it under " "replace_input, which would make the subset NARROWER than the master and leave real " "files stale" )lines 2350–2352assert "docs/notes.txt" not in ignored, ( "FILE_PATTERNS is forced in both regimes, so it must filter regardless" )

test_indexed_implementation_with_zero_function_bodies_warns

None test_build_docs_db.test_indexed_implementation_with_zero_function_bodies_warns(Path tmp_path)

Zero bodies across indexed implementation files is reported.

tests/test_build_docs_db.py:1575

Show on the map →

Called by none

Calls _bodies_db, warn_if_no_function_bodies

Checks

  • assert warn_if_no_function_bodies(db_path) == 2

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_indexed_implementation_with_zero_function_bodies_warns → warn_if_no_function_bodies
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 22 lines
def test_indexed_implementation_with_zero_function_bodies_warns(tmp_path: Path) -> None:
    """A build that indexes source and extracts NOTHING reports success today.

    MEASURED on a real C library whose implementation sits behind
    `#if defined(<FEATURE>_C)` guards: 30 `.c` files in `path`, ZERO functions
    with a body in any of them, and a normal summary printed. The database
    described a library with no implementation, and every AST and call-graph
    layer read empty against it. Supplying PREDEFINED took the same build to 322
    bodies.

    clew must not GUESS a target's feature macros — that is the target's
    declaration to make — so this warns rather than failing or fixing. But the
    ratio is never legitimately zero for a real C/C++ codebase, so silence was
    the wrong default.

    @brief Zero bodies across indexed implementation files is reported.
    @version 1
    """
    db_path = _bodies_db(tmp_path, [("src/a.c", False), ("src/b.c", False)])
    assert warn_if_no_function_bodies(db_path) == 2

Activity · 2 steps
lines 1593–1593db_path = _bodies_db(tmp_path, [("src/a.c", False), ("src/b.c", False)])lines 1594–1594assert warn_if_no_function_bodies(db_path) == 2

test_ingest_one_doc_file_accepts_valid_utf8

None test_build_docs_db.test_ingest_one_doc_file_accepts_valid_utf8(Path tmp_path)

Sanity-check the strict-decode change doesn't reject legitimate UTF-8 (including multi-byte characters).

tests/test_build_docs_db.py:401

Show on the map →

Called by none

Calls _ingest_one_doc_file

Checks

  • assert result == 1
  • assert rows[0][0] == "Heading"
  • assert "é" in rows[0][1]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-002measuredtest_ingest_one_doc_file_accepts_valid_utf8 → _ingest_one_doc_file → memoized
REQ-DDB-PIPE-001measured
REQ-DDB-PIPE-010catalog
Source · 21 lines
def test_ingest_one_doc_file_accepts_valid_utf8(tmp_path: Path) -> None:
    """Sanity-check the strict-decode change doesn't reject legitimate
    UTF-8 (including multi-byte characters)."""
    from clew.prose import _ingest_one_doc_file

    db_path = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db_path))
    conn.execute("CREATE VIRTUAL TABLE supplementary_docs USING fts5(file_path, heading, content)")
    good = tmp_path / "ok.md"
    # Valid UTF-8 including a multi-byte char (é = 0xC3 0xA9).
    good.write_text("# Heading\nbody with é character\n", encoding="utf-8")
    result = _ingest_one_doc_file(conn, good, "ok.md")
    assert result == 1
    rows = conn.execute("SELECT heading, content FROM supplementary_docs").fetchall()
    assert rows[0][0] == "Heading"
    assert "é" in rows[0][1]


# ─── call_edges._ts_language_for ────────────────────────────────────────────

Activity · 11 steps
lines 404–404from clew.prose import _ingest_one_doc_filelines 406–406db_path = tmp_path / "clew.db"lines 407–407conn = sqlite3.connect(str(db_path))lines 408–408conn.execute("CREATE VIRTUAL TABLE supplementary_docs USING fts5(file_path, heading, content)")lines 409–409good = tmp_path / "ok.md"lines 411–411good.write_text("# Heading\nbody with é character\n", encoding="utf-8")lines 412–412result = _ingest_one_doc_file(conn, good, "ok.md")lines 413–413assert result == 1lines 414–414rows = conn.execute("SELECT heading, content FROM supplementary_docs").fetchall()lines 415–415assert rows[0][0] == "Heading"lines 416–416assert "é" in rows[0][1]

test_ingest_one_doc_file_skips_non_utf8

None test_build_docs_db.test_ingest_one_doc_file_skips_non_utf8(Path tmp_path)

Regression for 2026-05-14 mojibake bug: a GBK-encoded markdown file (iot_error_definition.md) was previously ingested via `read_text(errors="replace")`, substituting every invalid byte with U+FFFD. The garbage flowed to the model via `docs.search_prose` and caused hallucinated citations. The fix is strict UTF-8 decode; non-UTF-8 files are skipped + logged.

tests/test_build_docs_db.py:380

Show on the map →

Called by none

Calls _ingest_one_doc_file

Checks

  • assert result == 0, "non-UTF-8 file must be skipped, not ingested"
  • assert rows[0] == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-002measuredtest_ingest_one_doc_file_skips_non_utf8 → _ingest_one_doc_file → memoized
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 21 lines
def test_ingest_one_doc_file_skips_non_utf8(tmp_path: Path) -> None:
    """Regression for 2026-05-14 mojibake bug: a GBK-encoded markdown
    file (iot_error_definition.md) was previously ingested via
    `read_text(errors="replace")`, substituting every invalid byte
    with U+FFFD. The garbage flowed to the model via
    `docs.search_prose` and caused hallucinated citations. The fix
    is strict UTF-8 decode; non-UTF-8 files are skipped + logged."""
    from clew.prose import _ingest_one_doc_file

    db_path = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db_path))
    conn.execute("CREATE VIRTUAL TABLE supplementary_docs USING fts5(file_path, heading, content)")
    # GBK-encoded content with a 0x8F byte that is invalid in UTF-8.
    bad = tmp_path / "iot_error_definition.md"
    bad.write_bytes(b"# Title\n\xb4\x8f\xbf\xed bytes that are not utf-8\n")
    result = _ingest_one_doc_file(conn, bad, "iot_error_definition.md")
    assert result == 0, "non-UTF-8 file must be skipped, not ingested"
    rows = conn.execute("SELECT COUNT(*) FROM supplementary_docs").fetchone()
    assert rows[0] == 0

Activity · 10 steps
lines 387–387from clew.prose import _ingest_one_doc_filelines 389–389db_path = tmp_path / "clew.db"lines 390–390conn = sqlite3.connect(str(db_path))lines 391–391conn.execute("CREATE VIRTUAL TABLE supplementary_docs USING fts5(file_path, heading, content)")lines 393–393bad = tmp_path / "iot_error_definition.md"lines 394–394bad.write_bytes(b"# Title\n\xb4\x8f\xbf\xed bytes that are not utf-8\n")lines 395–395result = _ingest_one_doc_file(conn, bad, "iot_error_definition.md")lines 396–396assert result == 0, "non-UTF-8 file must be skipped, not ingested"lines 397–397rows = conn.execute("SELECT COUNT(*) FROM supplementary_docs").fetchone()lines 398–398assert rows[0] == 0

test_ingest_requirements_yaml_loads_rows

None test_build_docs_db.test_ingest_requirements_yaml_loads_rows(Path tmp_path)

tests/test_build_docs_db.py:1008

Checks

  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003measuredtest_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml → _is_flat_req_list → all
Source · 42 lines
def test_ingest_requirements_yaml_loads_rows(tmp_path: Path) -> None:
    db = tmp_path / "clew.db"
    sqlite3.connect(str(db)).close()
    yaml_path = tmp_path / "requirements.yaml"
    yaml_path.write_text(
        """
        - id: REQ-0001
          block: startup
          title: Device boots and reports ready
          acceptance: Device emits ready event within 30s of power on
          priority: P0
        - id: REQ-0002
          block: connectivity
          title: Device connects to wifi
          acceptance: Device joins configured SSID within 60s
          priority: P1
        """,
    )
    ingest_requirements_yaml(db, yaml_path)
    conn = sqlite3.connect(str(db))
    rows = conn.execute(
        "SELECT id, block, title, acceptance, priority FROM requirements ORDER BY id",
    ).fetchall()
    conn.close()
    assert rows == [
        (
            "REQ-0001",
            "startup",
            "Device boots and reports ready",
            "Device emits ready event within 30s of power on",
            "P0",
        ),
        (
            "REQ-0002",
            "connectivity",
            "Device connects to wifi",
            "Device joins configured SSID within 60s",
            "P1",
        ),
    ]

Activity · 9 steps
lines 1009–1009db = tmp_path / "clew.db"lines 1010–1010sqlite3.connect(str(db)).close()lines 1011–1011yaml_path = tmp_path / "requirements.yaml"lines 1012–1025yaml_path.write_text( """ - id: REQ-0001 block: startup title: Device boots and reports ready acceptance: Device emits ready event within 30s of power on priority: P0 - id: REQ-0002 block: connectivity title: Device connects to wifi acceptance: Device joins configured SSID within 60s priority: P1 """, )lines 1026–1026ingest_requirements_yaml(db, yaml_path)lines 1027–1027conn = sqlite3.connect(str(db))lines 1028–1030rows = conn.execute( "SELECT id, block, title, acceptance, priority FROM requirements ORDER BY id", ).fetchall()lines 1031–1031conn.close()lines 1032–1047assert rows == [ ( "REQ-0001", "startup", "Device boots and reports ready", "Device emits ready event within 30s of power on", "P0", ), ( "REQ-0002", "connectivity", "Device connects to wifi", "Device joins configured SSID within 60s", "P1", ), ]

test_ingest_requirements_yaml_missing_file_creates_empty_table

None test_build_docs_db.test_ingest_requirements_yaml_missing_file_creates_empty_table(Path tmp_path)

tests/test_build_docs_db.py:1139

Checks

  • assert count == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001inferredtest_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003inferredtest_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml → _is_flat_req_list → all
Source · 15 lines
def test_ingest_requirements_yaml_missing_file_creates_empty_table(
    tmp_path: Path,
) -> None:
    db = tmp_path / "clew.db"
    sqlite3.connect(str(db)).close()
    ingest_requirements_yaml(db, tmp_path / "does_not_exist.yaml")
    conn = sqlite3.connect(str(db))
    count = conn.execute("SELECT COUNT(*) FROM requirements").fetchone()[0]
    conn.close()
    assert count == 0


# ─── requirements._extract_req_tags ─────────────────────────────────────────

Activity · 7 steps
lines 1142–1142db = tmp_path / "clew.db"lines 1143–1143sqlite3.connect(str(db)).close()lines 1144–1144ingest_requirements_yaml(db, tmp_path / "does_not_exist.yaml")lines 1145–1145conn = sqlite3.connect(str(db))lines 1146–1146count = conn.execute("SELECT COUNT(*) FROM requirements").fetchone()[0]lines 1147–1147conn.close()lines 1148–1148assert count == 0

test_ingest_requirements_yaml_none_path_creates_empty_table

None test_build_docs_db.test_ingest_requirements_yaml_none_path_creates_empty_table(Path tmp_path)

tests/test_build_docs_db.py:1127

Checks

  • assert count == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001inferredtest_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003inferredtest_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml → _is_flat_req_list → all
Source · 12 lines
def test_ingest_requirements_yaml_none_path_creates_empty_table(
    tmp_path: Path,
) -> None:
    db = tmp_path / "clew.db"
    sqlite3.connect(str(db)).close()
    ingest_requirements_yaml(db, None)
    conn = sqlite3.connect(str(db))
    count = conn.execute("SELECT COUNT(*) FROM requirements").fetchone()[0]
    conn.close()
    assert count == 0

Activity · 7 steps
lines 1130–1130db = tmp_path / "clew.db"lines 1131–1131sqlite3.connect(str(db)).close()lines 1132–1132ingest_requirements_yaml(db, None)lines 1133–1133conn = sqlite3.connect(str(db))lines 1134–1134count = conn.execute("SELECT COUNT(*) FROM requirements").fetchone()[0]lines 1135–1135conn.close()lines 1136–1136assert count == 0

test_ingest_requirements_yaml_reads_the_mapping_keyed_shape

None test_build_docs_db.test_ingest_requirements_yaml_reads_the_mapping_keyed_shape(Path tmp_path)

The shape doxygen-guard 1.3.1 ships for its OWN catalog: a `requirements:` mapping keyed by requirement id, with the id as the key and `name` as the title field. Its schema is why — `formats_using_id_column` lists only csv and json, so a YAML catalog is keyed and self-describing.

tests/test_build_docs_db.py:1050

Checks

  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003measuredtest_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml → _is_flat_req_list → all
Source · 53 lines
def test_ingest_requirements_yaml_reads_the_mapping_keyed_shape(tmp_path: Path) -> None:
    """The shape doxygen-guard 1.3.1 ships for its OWN catalog: a `requirements:`
    mapping keyed by requirement id, with the id as the key and `name` as the title
    field. Its schema is why — `formats_using_id_column` lists only csv and json, so a
    YAML catalog is keyed and self-describing.

    A REGRESSION TEST with a measured origin. Against the pinned public integration
    target (doxygen-guard at its own HEAD) a 9,534-byte catalog of 22 requirements
    ingested ZERO rows, and nothing errored — an empty table reads exactly like a repo
    with no catalog at all. That is the third time in this project that "no rows" turned
    out to be a claim about the DETECTOR rather than the data.

    The fixture deliberately uses `name`, not `title`, because the whole point is that
    the declared field mapping is honoured rather than this repo's own convention.

    Ids are the sanctioned meaningless placeholders, not the real target's. The first
    draft used the target's own real ids and a publishability gate refused them, on the
    rule "allowlist ONLY if invented". That gate is DELETED and NOTHING now checks which
    ids a fixture borrows. The convention still holds for the original reason: the shape
    is what this test asserts, and borrowing real ids to assert a shape buys nothing.
    The real-target verification lives outside the unit suite."""
    db = tmp_path / "clew.db"
    sqlite3.connect(str(db)).close()
    yaml_path = tmp_path / "requirements.yaml"
    yaml_path.write_text(
        """
        requirements:
          REQ-X-FOO-001:
            name: Doxygen presence check
            subsystem: Validate
            min_version: v0.1.0
          REQ-X-BAR-002:
            name: Version staleness detection
            subsystem: Validate
        """,
    )
    ## name_column='name' as the guard's own config declares it; id_column is irrelevant
    ## to this shape and is passed as the csv default to prove it is not consulted.
    guard_cfg = {"requirements": {"name_column": "name", "id_column": "Req ID"}}
    ingest_requirements_yaml(db, yaml_path, guard_cfg)

    conn = sqlite3.connect(str(db))
    rows = conn.execute("SELECT id, title FROM requirements ORDER BY id").fetchall()
    conn.close()
    ## Expected in `ORDER BY id` order, which is not declaration order — BAR sorts
    ## before FOO. Asserting the sorted order rather than reordering the fixture keeps
    ## the fixture reading like a real catalog, where ids are not in alphabetical order.
    assert rows == [
        ("REQ-X-BAR-002", "Version staleness detection"),
        ("REQ-X-FOO-001", "Doxygen presence check"),
    ]

Activity · 10 steps
lines 1071–1071db = tmp_path / "clew.db"lines 1072–1072sqlite3.connect(str(db)).close()lines 1073–1073yaml_path = tmp_path / "requirements.yaml"lines 1074–1085yaml_path.write_text( """ requirements: REQ-X-FOO-001: name: Doxygen presence check subsystem: Validate min_version: v0.1.0 REQ-X-BAR-002: name: Version staleness detection subsystem: Validate """, )lines 1088–1088guard_cfg = {"requirements": {"name_column": "name", "id_column": "Req ID"}}lines 1089–1089ingest_requirements_yaml(db, yaml_path, guard_cfg)lines 1091–1091conn = sqlite3.connect(str(db))lines 1092–1092rows = conn.execute("SELECT id, title FROM requirements ORDER BY id").fetchall()lines 1093–1093conn.close()lines 1097–1100assert rows == [ ("REQ-X-BAR-002", "Version staleness detection"), ("REQ-X-FOO-001", "Doxygen presence check"), ]

test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape

None test_build_docs_db.test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape(Path tmp_path)

Reading a second shape must not become "read anything". A nested `domains:` tree is parsed only by the owning repo's own scripts, and guessing at it would invent traceability rather than report it — so it stays 0 rows, with the table created so downstream LEFT JOINs still work.

tests/test_build_docs_db.py:1103

Checks

  • assert count == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003measuredtest_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml → _is_flat_req_list → all
Source · 24 lines
def test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape(tmp_path: Path) -> None:
    """Reading a second shape must not become "read anything". A nested `domains:` tree
    is parsed only by the owning repo's own scripts, and guessing at it would invent
    traceability rather than report it — so it stays 0 rows, with the table created so
    downstream LEFT JOINs still work."""
    db = tmp_path / "clew.db"
    sqlite3.connect(str(db)).close()
    yaml_path = tmp_path / "requirements.yaml"
    yaml_path.write_text(
        """
        domains:
          navigation:
            requirements:
              - REQ-X-BAZ-003
        """,
    )
    ingest_requirements_yaml(db, yaml_path)

    conn = sqlite3.connect(str(db))
    count = conn.execute("SELECT COUNT(*) FROM requirements").fetchone()[0]
    conn.close()
    assert count == 0

Activity · 9 steps
lines 1108–1108db = tmp_path / "clew.db"lines 1109–1109sqlite3.connect(str(db)).close()lines 1110–1110yaml_path = tmp_path / "requirements.yaml"lines 1111–1118yaml_path.write_text( """ domains: navigation: requirements: - REQ-X-BAZ-003 """, )lines 1119–1119ingest_requirements_yaml(db, yaml_path)lines 1121–1121conn = sqlite3.connect(str(db))lines 1122–1122count = conn.execute("SELECT COUNT(*) FROM requirements").fetchone()[0]lines 1123–1123conn.close()lines 1124–1124assert count == 0

test_load_shared_key_patterns_parses_name_prefix

None test_build_docs_db.test_load_shared_key_patterns_parses_name_prefix(Path tmp_path)

tests/test_build_docs_db.py:1327

Show on the map →

Called by none

Calls _write_name_prefix_patterns_yaml, load_shared_key_patterns

Checks

  • assert len(writers) == 1
  • assert writers[0].prefix == "STORE_SET_"
  • assert len(readers) == 1
  • assert readers[0].prefix == "STORE_GET_"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-005measuredtest_load_shared_key_patterns_parses_name_prefix → load_shared_key_patterns
REQ-DDB-SCHEMA-012measuredtest_load_shared_key_patterns_parses_name_prefix → load_shared_key_patterns → declaration_origin
Source · 9 lines
def test_load_shared_key_patterns_parses_name_prefix(tmp_path: Path) -> None:
    patterns_path = _write_name_prefix_patterns_yaml(tmp_path)
    writers, readers = load_shared_key_patterns(patterns_path)
    assert len(writers) == 1
    assert writers[0].prefix == "STORE_SET_"
    assert len(readers) == 1
    assert readers[0].prefix == "STORE_GET_"

Activity · 6 steps
lines 1328–1328patterns_path = _write_name_prefix_patterns_yaml(tmp_path)lines 1329–1329writers, readers = load_shared_key_patterns(patterns_path)lines 1330–1330assert len(writers) == 1lines 1331–1331assert writers[0].prefix == "STORE_SET_"lines 1332–1332assert len(readers) == 1lines 1333–1333assert readers[0].prefix == "STORE_GET_"

test_load_shared_key_patterns_parses_writers_and_readers

None test_build_docs_db.test_load_shared_key_patterns_parses_writers_and_readers(Path tmp_path)

tests/test_build_docs_db.py:1302

Show on the map →

Called by none

Calls _write_shared_key_patterns_yaml, load_shared_key_patterns

Checks

  • assert len(writers) == 1
  • assert writers[0].pattern == "datamodel_set"
  • assert writers[0].key_arg_index == 0
  • assert len(readers) == 1
  • assert readers[0].pattern == "datamodel_get"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-005measuredtest_load_shared_key_patterns_parses_writers_and_readers → load_shared_key_patterns
REQ-DDB-SCHEMA-012measuredtest_load_shared_key_patterns_parses_writers_and_readers → load_shared_key_patterns → declaration_origin
Source · 10 lines
def test_load_shared_key_patterns_parses_writers_and_readers(tmp_path: Path) -> None:
    patterns_path = _write_shared_key_patterns_yaml(tmp_path)
    writers, readers = load_shared_key_patterns(patterns_path)
    assert len(writers) == 1
    assert writers[0].pattern == "datamodel_set"
    assert writers[0].key_arg_index == 0
    assert len(readers) == 1
    assert readers[0].pattern == "datamodel_get"

Activity · 7 steps
lines 1303–1303patterns_path = _write_shared_key_patterns_yaml(tmp_path)lines 1304–1304writers, readers = load_shared_key_patterns(patterns_path)lines 1305–1305assert len(writers) == 1lines 1306–1306assert writers[0].pattern == "datamodel_set"lines 1307–1307assert writers[0].key_arg_index == 0lines 1308–1308assert len(readers) == 1lines 1309–1309assert readers[0].pattern == "datamodel_get"

test_looks_like_test_function_file_path

None test_build_docs_db.test_looks_like_test_function_file_path()

tests/test_build_docs_db.py:1227

Show on the map →

Called by none

Calls _looks_like_test_function

Checks

  • assert _looks_like_test_function("foo", "tests/test_foo.c") is True

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 4 lines
def test_looks_like_test_function_file_path() -> None:
    assert _looks_like_test_function("foo", "tests/test_foo.c") is True

Activity · 1 steps
lines 1228–1228assert _looks_like_test_function("foo", "tests/test_foo.c") is True

test_looks_like_test_function_name_prefix

None test_build_docs_db.test_looks_like_test_function_name_prefix()

tests/test_build_docs_db.py:1223

Show on the map →

Called by none

Calls _looks_like_test_function

Checks

  • assert _looks_like_test_function("test_foo", "src/foo.c") is True

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 4 lines
def test_looks_like_test_function_name_prefix() -> None:
    assert _looks_like_test_function("test_foo", "src/foo.c") is True

Activity · 1 steps
lines 1224–1224assert _looks_like_test_function("test_foo", "src/foo.c") is True

test_looks_like_test_function_neither

None test_build_docs_db.test_looks_like_test_function_neither()

tests/test_build_docs_db.py:1231

Show on the map →

Called by none

Calls _looks_like_test_function

Checks

  • assert _looks_like_test_function("device_boot", "src/startup.c") is False

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 4 lines
def test_looks_like_test_function_neither() -> None:
    assert _looks_like_test_function("device_boot", "src/startup.c") is False

Activity · 1 steps
lines 1232–1232assert _looks_like_test_function("device_boot", "src/startup.c") is False

test_macro_hop_adds_nothing_when_no_macro_mediates_a_call

None test_build_docs_db.test_macro_hop_adds_nothing_when_no_macro_mediates_a_call(Path synthetic_doxygen_db)

NO INFLATION RISK, and this is the assertion that says so. Measured on both public targets — entropic (C++) and this repo's own Python self-index — the layer adds ZERO rows, because neither routes calls through wrapper macros. A layer that helps one codebase must not perturb every other.

tests/test_build_docs_db.py:782

Checks

  • assert import_macro_hop_edges(synthetic_doxygen_db) == 0
  • assert _count_edges(synthetic_doxygen_db) == before

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_macro_hop_adds_nothing_when_no_macro_mediates_a_call → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 13 lines
def test_macro_hop_adds_nothing_when_no_macro_mediates_a_call(
    synthetic_doxygen_db: Path,
) -> None:
    """NO INFLATION RISK, and this is the assertion that says so. Measured on both public
    targets — entropic (C++) and this repo's own Python self-index — the layer adds ZERO
    rows, because neither routes calls through wrapper macros. A layer that helps one
    codebase must not perturb every other."""
    build_call_edges(synthetic_doxygen_db)
    before = _count_edges(synthetic_doxygen_db)
    assert import_macro_hop_edges(synthetic_doxygen_db) == 0
    assert _count_edges(synthetic_doxygen_db) == before

Activity · 4 steps
lines 789–789build_call_edges(synthetic_doxygen_db)lines 790–790before = _count_edges(synthetic_doxygen_db)lines 791–791assert import_macro_hop_edges(synthetic_doxygen_db) == 0lines 792–792assert _count_edges(synthetic_doxygen_db) == before

test_macro_hop_composes_the_two_hops_doxygen_already_recorded

None test_build_docs_db.test_macro_hop_composes_the_two_hops_doxygen_already_recorded(Path macro_hop_db)

The measured defect: both Layer-1 importers require BOTH endpoints to be `kind='function'`, so a `#define` in the middle discarded the pair and a caller whose only calls go through macros ended up with ZERO outgoing edges. Verified on a real C fixture — six such callers, six edges recovered.

tests/test_build_docs_db.py:631

Checks

  • assert import_macro_hop_edges(macro_hop_db) == 2
  • assert rows == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_macro_hop_composes_the_two_hops_doxygen_already_recorded → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 25 lines
def test_macro_hop_composes_the_two_hops_doxygen_already_recorded(
    macro_hop_db: Path,
) -> None:
    """The measured defect: both Layer-1 importers require BOTH endpoints to be
    `kind='function'`, so a `#define` in the middle discarded the pair and a caller whose
    only calls go through macros ended up with ZERO outgoing edges. Verified on a real C
    fixture — six such callers, six edges recovered.

    A MULTI-call macro yields several edges and all are real: expanding it at that site
    performs every call in its body. Non-function endpoints compose nothing."""
    build_call_edges(macro_hop_db)
    assert import_macro_hop_edges(macro_hop_db) == 2

    conn = sqlite3.connect(str(macro_hop_db))
    rows = conn.execute(
        "SELECT caller_rowid, callee_rowid, source, confidence FROM call_edges "
        "WHERE source = 'macro_hop' ORDER BY callee_rowid",
    ).fetchall()
    conn.close()
    assert rows == [
        (1, 3, "macro_hop", "resolved"),
        (1, 5, "macro_hop", "resolved"),
    ]

Activity · 6 steps
lines 641–641build_call_edges(macro_hop_db)lines 642–642assert import_macro_hop_edges(macro_hop_db) == 2lines 644–644conn = sqlite3.connect(str(macro_hop_db))lines 645–648rows = conn.execute( "SELECT caller_rowid, callee_rowid, source, confidence FROM call_edges " "WHERE source = 'macro_hop' ORDER BY callee_rowid", ).fetchall()lines 649–649conn.close()lines 650–653assert rows == [ (1, 3, "macro_hop", "resolved"), (1, 5, "macro_hop", "resolved"), ]

test_macro_hop_is_resolved_not_exact

None test_build_docs_db.test_macro_hop_is_resolved_not_exact(Path macro_hop_db)

`exact` is reserved for what doxygen stated DIRECTLY. Both hops here are doxygen's own observations, so this outranks any name match — but the composition is ours, and labelling a joined edge `exact` would make it indistinguishable from an edge doxygen asserted about a single call site.

tests/test_build_docs_db.py:656

Checks

  • assert confidences == {"resolved"}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_macro_hop_is_resolved_not_exact → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 15 lines
def test_macro_hop_is_resolved_not_exact(macro_hop_db: Path) -> None:
    """`exact` is reserved for what doxygen stated DIRECTLY. Both hops here are doxygen's
    own observations, so this outranks any name match — but the composition is ours, and
    labelling a joined edge `exact` would make it indistinguishable from an edge doxygen
    asserted about a single call site."""
    build_call_edges(macro_hop_db)
    import_macro_hop_edges(macro_hop_db)
    conn = sqlite3.connect(str(macro_hop_db))
    confidences = {
        r[0] for r in conn.execute("SELECT confidence FROM call_edges WHERE source='macro_hop'")
    }
    conn.close()
    assert confidences == {"resolved"}

Activity · 6 steps
lines 661–661build_call_edges(macro_hop_db)lines 662–662import_macro_hop_edges(macro_hop_db)lines 663–663conn = sqlite3.connect(str(macro_hop_db))lines 664–666confidences = { r[0] for r in conn.execute("SELECT confidence FROM call_edges WHERE source='macro_hop'") }lines 667–667conn.close()lines 668–668assert confidences == {"resolved"}

test_macro_hop_names_the_macro_that_made_the_edge

None test_build_docs_db.test_macro_hop_names_the_macro_that_made_the_edge(Path macro_hop_db)

gh#350. A macro-hop edge is the ONE layer whose edge corresponds to no text in the caller's body — the call is written as a macro invocation, so searching `producer` for `store_set` finds nothing. Before this the caller saw an edge at confidence `resolved` and could not see what produced it.

tests/test_build_docs_db.py:671

Checks

  • assert rows == [(3, "STORE_SET_FOO"), (5, "STORE_SET_FOO")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_macro_hop_names_the_macro_that_made_the_edge → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 26 lines
def test_macro_hop_names_the_macro_that_made_the_edge(macro_hop_db: Path) -> None:
    """gh#350. A macro-hop edge is the ONE layer whose edge corresponds to no text in the
    caller's body — the call is written as a macro invocation, so searching `producer` for
    `store_set` finds nothing. Before this the caller saw an edge at confidence `resolved` and
    could not see what produced it.

    THE ROWID IS STORED, NOT THE TEXT. doxygen already keeps the expansion in
    `memberdef.initializer`, and copying it onto the edge would create a second place for it to
    go stale.

    Both edges of the MULTI-call macro name the same macro, which is the point: one macro
    invocation performs both calls."""
    build_call_edges(macro_hop_db)
    import_macro_hop_edges(macro_hop_db)

    conn = sqlite3.connect(str(macro_hop_db))
    rows = conn.execute(
        "SELECT e.callee_rowid, m.name FROM call_edges e "
        "JOIN memberdef m ON m.rowid = e.via_macro_rowid "
        "WHERE e.source = 'macro_hop' ORDER BY e.callee_rowid",
    ).fetchall()
    conn.close()

    assert rows == [(3, "STORE_SET_FOO"), (5, "STORE_SET_FOO")]

Activity · 6 steps
lines 683–683build_call_edges(macro_hop_db)lines 684–684import_macro_hop_edges(macro_hop_db)lines 686–686conn = sqlite3.connect(str(macro_hop_db))lines 687–691rows = conn.execute( "SELECT e.callee_rowid, m.name FROM call_edges e " "JOIN memberdef m ON m.rowid = e.via_macro_rowid " "WHERE e.source = 'macro_hop' ORDER BY e.callee_rowid", ).fetchall()lines 692–692conn.close()lines 694–694assert rows == [(3, "STORE_SET_FOO"), (5, "STORE_SET_FOO")]

test_mark_reachability_end_to_end

None test_build_docs_db.test_mark_reachability_end_to_end(Path synthetic_reachability_db)

Full mark_reachability call sets up symbol_liveness correctly.

tests/test_build_docs_db.py:937

Checks

  • assert statuses[1] == "live" # main (seeded by pattern)
  • assert statuses[5] == "live" # app_main (seeded by pattern)
  • assert statuses[2] == "live" # do_init reached from main
  • assert statuses[3] == "live" # helper reached from do_init
  • assert statuses[6] == "live" # boot reached from app_main

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-004measuredtest_mark_reachability_end_to_end → mark_reachability
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-012measured
Source · 26 lines
def test_mark_reachability_end_to_end(
    synthetic_reachability_db: Path,
) -> None:
    """Full mark_reachability call sets up symbol_liveness correctly."""
    mark_reachability(
        synthetic_reachability_db,
        entry_patterns=["main", "app_main"],
    )
    conn = sqlite3.connect(str(synthetic_reachability_db))
    statuses = dict(
        conn.execute(
            "SELECT memberdef_rowid, status FROM symbol_liveness",
        ).fetchall(),
    )
    conn.close()
    assert statuses[1] == "live"  # main (seeded by pattern)
    assert statuses[5] == "live"  # app_main (seeded by pattern)
    assert statuses[2] == "live"  # do_init reached from main
    assert statuses[3] == "live"  # helper reached from do_init
    assert statuses[6] == "live"  # boot reached from app_main
    # unused_helper (4) and orphan_func (7) are seeded as zero-incoming
    # and therefore live (conservative). The pure-orphan case requires
    # a graph where every function is reachable as a callee.
    # Here we just confirm the BFS reaches everything reachable.

Activity · 9 steps
lines 941–944mark_reachability( synthetic_reachability_db, entry_patterns=["main", "app_main"], )lines 945–945conn = sqlite3.connect(str(synthetic_reachability_db))lines 946–950statuses = dict( conn.execute( "SELECT memberdef_rowid, status FROM symbol_liveness", ).fetchall(), )lines 951–951conn.close()lines 952–952assert statuses[1] == "live"lines 953–953assert statuses[5] == "live"lines 954–954assert statuses[2] == "live"lines 955–955assert statuses[3] == "live"lines 956–956assert statuses[6] == "live"

test_mark_reachability_no_edges_skips

None test_build_docs_db.test_mark_reachability_no_edges_skips(Path tmp_path)

Empty call_edges → log warning, leave symbol_liveness absent.

tests/test_build_docs_db.py:963

Checks

  • assert "symbol_liveness" not in tables

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-004measuredtest_mark_reachability_no_edges_skips → mark_reachability
REQ-DDB-PIPE-010catalog
Source · 34 lines
def test_mark_reachability_no_edges_skips(tmp_path: Path) -> None:
    """Empty call_edges → log warning, leave symbol_liveness absent."""
    db = tmp_path / "empty.db"
    conn = sqlite3.connect(str(db))
    conn.executescript(
        """
        CREATE TABLE memberdef (
            rowid INTEGER PRIMARY KEY,
            kind TEXT,
            name TEXT
        );
        CREATE TABLE call_edges (
            caller_rowid INTEGER,
            callee_rowid INTEGER,
            source TEXT,
            confidence TEXT
        );
        INSERT INTO memberdef (rowid, kind, name) VALUES (1, 'function', 'x');
        """,
    )
    conn.commit()
    conn.close()
    mark_reachability(db)  # should not raise
    conn = sqlite3.connect(str(db))
    tables = {
        r[0]
        for r in conn.execute(
            "SELECT name FROM sqlite_master WHERE type='table'",
        ).fetchall()
    }
    conn.close()
    assert "symbol_liveness" not in tables

Activity · 10 steps
lines 965–965db = tmp_path / "empty.db"lines 966–966conn = sqlite3.connect(str(db))lines 967–982conn.executescript( """ CREATE TABLE memberdef ( rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT ); CREATE TABLE call_edges ( caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, confidence TEXT ); INSERT INTO memberdef (rowid, kind, name) VALUES (1, 'function', 'x'); """, )lines 983–983conn.commit()lines 984–984conn.close()lines 985–985mark_reachability(db)lines 986–986conn = sqlite3.connect(str(db))lines 987–992tables = { r[0] for r in conn.execute( "SELECT name FROM sqlite_master WHERE type='table'", ).fetchall() }lines 993–993conn.close()lines 994–994assert "symbol_liveness" not in tables

test_name_prefix_exact_prefix_match_has_no_key_remainder

None test_build_docs_db.test_name_prefix_exact_prefix_match_has_no_key_remainder(Path tmp_path)

A callee name that is EXACTLY the prefix (no remainder) must not match — there is no key to extract, so it's not a valid accessor call for this convention, not an unresolved one.

tests/test_build_docs_db.py:1371

Show on the map →

Called by none

Calls _make_shared_key_db, _write_name_prefix_patterns_yaml, import_shared_key_edges_inferred

Checks

  • assert count == unresolved_before

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 21 lines
def test_name_prefix_exact_prefix_match_has_no_key_remainder(tmp_path: Path) -> None:
    """A callee name that is EXACTLY the prefix (no remainder) must not
    match — there is no key to extract, so it's not a valid accessor call
    for this convention, not an unresolved one."""
    src_dir = tmp_path / "src"
    src_dir.mkdir()
    (src_dir / "foo.c").write_text(
        "void caller(void) {\n    STORE_SET_(1);\n}\n",
    )
    db_path = _make_shared_key_db(tmp_path, [(1, "caller", 1, 3)])
    patterns_path = _write_name_prefix_patterns_yaml(tmp_path)

    import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)

    conn = sqlite3.connect(str(db_path))
    count = conn.execute("SELECT COUNT(*) FROM shared_key_edges").fetchone()[0]
    unresolved_before = 0  # exact-prefix-only is simply not a match, not unresolved
    conn.close()
    assert count == unresolved_before

Activity · 11 steps
lines 1375–1375src_dir = tmp_path / "src"lines 1376–1376src_dir.mkdir()lines 1377–1379(src_dir / "foo.c").write_text( "void caller(void) {\n STORE_SET_(1);\n}\n", )lines 1380–1380db_path = _make_shared_key_db(tmp_path, [(1, "caller", 1, 3)])lines 1381–1381patterns_path = _write_name_prefix_patterns_yaml(tmp_path)lines 1383–1383import_shared_key_edges_inferred(db_path, tmp_path, patterns_path)lines 1385–1385conn = sqlite3.connect(str(db_path))lines 1386–1386count = conn.execute("SELECT COUNT(*) FROM shared_key_edges").fetchone()[0]lines 1387–1387unresolved_before = 0lines 1388–1388conn.close()lines 1389–1389assert count == unresolved_before

test_output_dir_defaults_to_the_doxyfile_when_not_forced

None test_build_docs_db.test_output_dir_defaults_to_the_doxyfile_when_not_forced(Path tmp_path)

Omitting the override keeps the original behaviour, so a caller that does not force a directory (the tests' own run_doxygen calls) is unchanged.

tests/test_build_docs_db.py:218

Checks

  • assert effective_output_dir(doxyfile, repo) == (repo / "build" / "docs").resolve()
  • assert ("OUTPUT_DIRECTORY" not in _build_doxyfile_content(doxyfile, None, None).split("PROJECT_NAME = t\nOUTPUT_DIRECTORY = build/docs\n" )[-1] )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_output_dir_defaults_to_the_doxyfile_when_not_forced → _build_doxyfile_content
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_output_dir_defaults_to_the_doxyfile_when_not_forced → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 18 lines
def test_output_dir_defaults_to_the_doxyfile_when_not_forced(tmp_path: Path) -> None:
    """Omitting the override keeps the original behaviour, so a caller that
    does not force a directory (the tests' own run_doxygen calls) is unchanged."""
    from clew.doxygen import effective_output_dir

    repo = tmp_path / "repo"
    repo.mkdir()
    doxyfile = repo / "Doxyfile"
    doxyfile.write_text("PROJECT_NAME = t\nOUTPUT_DIRECTORY = build/docs\n")
    assert effective_output_dir(doxyfile, repo) == (repo / "build" / "docs").resolve()
    assert (
        "OUTPUT_DIRECTORY"
        not in _build_doxyfile_content(doxyfile, None, None).split(
            "PROJECT_NAME = t\nOUTPUT_DIRECTORY = build/docs\n"
        )[-1]
    )

Activity · 7 steps
lines 221–221from clew.doxygen import effective_output_dirlines 223–223repo = tmp_path / "repo"lines 224–224repo.mkdir()lines 225–225doxyfile = repo / "Doxyfile"lines 226–226doxyfile.write_text("PROJECT_NAME = t\nOUTPUT_DIRECTORY = build/docs\n")lines 227–227assert effective_output_dir(doxyfile, repo) == (repo / "build" / "docs").resolve()lines 228–233assert ( "OUTPUT_DIRECTORY" not in _build_doxyfile_content(doxyfile, None, None).split( "PROJECT_NAME = t\nOUTPUT_DIRECTORY = build/docs\n" )[-1] )

test_parse_doxyfile_value_finds_simple_assignment

None test_build_docs_db.test_parse_doxyfile_value_finds_simple_assignment(Path tmp_path)

tests/test_build_docs_db.py:161

Checks

  • assert parse_doxyfile_value(f, "OUTPUT_DIRECTORY") == "build/docs"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_parse_doxyfile_value_finds_simple_assignment → parse_doxyfile_value
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 6 lines
def test_parse_doxyfile_value_finds_simple_assignment(tmp_path: Path) -> None:
    f = tmp_path / "Doxyfile"
    f.write_text("OUTPUT_DIRECTORY     = build/docs\n")
    assert parse_doxyfile_value(f, "OUTPUT_DIRECTORY") == "build/docs"

Activity · 3 steps
lines 162–162f = tmp_path / "Doxyfile"lines 163–163f.write_text("OUTPUT_DIRECTORY = build/docs\n")lines 164–164assert parse_doxyfile_value(f, "OUTPUT_DIRECTORY") == "build/docs"

test_parse_doxyfile_value_handles_inline_comments

None test_build_docs_db.test_parse_doxyfile_value_handles_inline_comments(Path tmp_path)

tests/test_build_docs_db.py:175

Checks

  • assert parse_doxyfile_value(f, "XML_OUTPUT") == "xml"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_parse_doxyfile_value_handles_inline_comments → parse_doxyfile_value
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 9 lines
def test_parse_doxyfile_value_handles_inline_comments(tmp_path: Path) -> None:
    f = tmp_path / "Doxyfile"
    f.write_text("# leading comment\nXML_OUTPUT = xml\n")
    assert parse_doxyfile_value(f, "XML_OUTPUT") == "xml"


# ─── doxygen._build_doxyfile_content ────────────────────────────────────────

Activity · 3 steps
lines 176–176f = tmp_path / "Doxyfile"lines 177–177f.write_text("# leading comment\nXML_OUTPUT = xml\n")lines 178–178assert parse_doxyfile_value(f, "XML_OUTPUT") == "xml"

test_parse_doxyfile_value_returns_empty_for_missing_key

None test_build_docs_db.test_parse_doxyfile_value_returns_empty_for_missing_key(Path tmp_path)

tests/test_build_docs_db.py:167

Checks

  • assert parse_doxyfile_value(f, "MISSING_KEY") == ""

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_parse_doxyfile_value_returns_empty_for_missing_key → parse_doxyfile_value
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 8 lines
def test_parse_doxyfile_value_returns_empty_for_missing_key(
    tmp_path: Path,
) -> None:
    f = tmp_path / "Doxyfile"
    f.write_text("OTHER_KEY = whatever\n")
    assert parse_doxyfile_value(f, "MISSING_KEY") == ""

Activity · 3 steps
lines 170–170f = tmp_path / "Doxyfile"lines 171–171f.write_text("OTHER_KEY = whatever\n")lines 172–172assert parse_doxyfile_value(f, "MISSING_KEY") == ""

test_replacing_input_also_clears_the_repo_s_exclude_patterns

None test_build_docs_db.test_replacing_input_also_clears_the_repo_s_exclude_patterns(Path tmp_path)

gh#333. `EXCLUDE_PATTERNS` is the GLOB spelling of `EXCLUDE`, and clearing one while leaving the other standing silently defeated the whole scope change on the target it was built for.

tests/test_build_docs_db.py:271

Checks

  • assert "\nEXCLUDE_PATTERNS =\n" in replaced, ("an INPUT replacement that leaves EXCLUDE_PATTERNS standing admits a tree " "and then drops it again" )
  • assert "\nEXCLUDE_PATTERNS =\n" not in kept
  • assert "EXCLUDE_PATTERNS = */extern/* */tests/*" in kept

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_replacing_input_also_clears_the_repo_s_exclude_patterns → _build_doxyfile_content
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_replacing_input_also_clears_the_repo_s_exclude_patterns → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 31 lines
def test_replacing_input_also_clears_the_repo_s_exclude_patterns(tmp_path: Path) -> None:
    """gh#333. `EXCLUDE_PATTERNS` is the GLOB spelling of `EXCLUDE`, and clearing one
    while leaving the other standing silently defeated the whole scope change on the
    target it was built for.

    Measured on [tvanfossen/entropic](https://github.com/tvanfossen/entropic), whose
    Doxyfile declares `EXCLUDE_PATTERNS = */extern/* */build/* */tests/*`: its
    llama.cpp submodule was added to INPUT by the new whole-repo scope and then
    dropped again by the surviving pattern. The build reported success and indexed 16
    vendored files, which looks exactly like a working measurement.

    ONLY UNDER `replace_input`, asserted in both directions below: a plain
    `--extra-exclude` build must leave the repo's own patterns exactly as written,
    because nothing there asked for the repo's scope statement to be replaced.
    """
    f = tmp_path / "Doxyfile"
    f.write_text("EXCLUDE = vendor\nEXCLUDE_PATTERNS = */extern/* */tests/*\n")

    replaced = _build_doxyfile_content(
        f, extra_input=["/repo"], extra_exclude=None, replace_input=True
    )
    assert "\nEXCLUDE_PATTERNS =\n" in replaced, (
        "an INPUT replacement that leaves EXCLUDE_PATTERNS standing admits a tree "
        "and then drops it again"
    )

    kept = _build_doxyfile_content(f, extra_input=None, extra_exclude=["src/legacy"])
    assert "\nEXCLUDE_PATTERNS =\n" not in kept
    assert "EXCLUDE_PATTERNS = */extern/* */tests/*" in kept

Activity · 7 steps
lines 286–286f = tmp_path / "Doxyfile"lines 287–287f.write_text("EXCLUDE = vendor\nEXCLUDE_PATTERNS = */extern/* */tests/*\n")lines 289–291replaced = _build_doxyfile_content( f, extra_input=["/repo"], extra_exclude=None, replace_input=True )lines 292–295assert "\nEXCLUDE_PATTERNS =\n" in replaced, ( "an INPUT replacement that leaves EXCLUDE_PATTERNS standing admits a tree " "and then drops it again" )lines 297–297kept = _build_doxyfile_content(f, extra_input=None, extra_exclude=["src/legacy"])lines 298–298assert "\nEXCLUDE_PATTERNS =\n" not in keptlines 299–299assert "EXCLUDE_PATTERNS = */extern/* */tests/*" in kept

test_sanitize_doxygen_text_repairs_invalid_utf8

None test_build_docs_db.test_sanitize_doxygen_text_repairs_invalid_utf8(Path tmp_path)

doxygen writes descriptions straight from source comments into its sqlite output; a non-UTF-8 comment lands as raw invalid bytes in a TEXT column. sanitize_doxygen_text must repair them in place (matching the docs server's read-side errors='replace') and leave clean rows untouched.

tests/test_build_docs_db.py:122

Checks

  • assert fixed == 2, "both poisoned columns of the bad row should be repaired"
  • assert rows[0] == (b"clean brief", b"clean detail")
  • assert b"\xef\xbf\xbd" in rows[1][0]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_sanitize_doxygen_text_repairs_invalid_utf8 → sanitize_doxygen_text
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 39 lines
def test_sanitize_doxygen_text_repairs_invalid_utf8(tmp_path: Path) -> None:
    """doxygen writes descriptions straight from source comments into its
    sqlite output; a non-UTF-8 comment lands as raw invalid bytes in a TEXT
    column. sanitize_doxygen_text must repair them in place (matching the docs
    server's read-side errors='replace') and leave clean rows untouched."""
    db = tmp_path / "doxy.db"
    conn = sqlite3.connect(str(db))
    for tbl in ("memberdef", "compounddef"):
        conn.execute(f"CREATE TABLE {tbl} (briefdescription TEXT, detaileddescription TEXT)")
    conn.execute("INSERT INTO memberdef VALUES (?, ?)", ("clean brief", "clean detail"))
    # 0xA4 is an invalid UTF-8 start byte (e.g. a latin-1/GBK source comment).
    conn.execute(
        "INSERT INTO memberdef VALUES (?, ?)",
        (b"bad \xa4 brief", b"detail \xa4\xa4 here"),
    )
    conn.commit()
    conn.close()

    fixed = sanitize_doxygen_text(db)
    assert fixed == 2, "both poisoned columns of the bad row should be repaired"

    check = sqlite3.connect(str(db))
    check.text_factory = bytes
    rows = check.execute(
        "SELECT briefdescription, detaileddescription FROM memberdef ORDER BY rowid"
    ).fetchall()
    check.close()
    # Every column now decodes as valid UTF-8 (would raise if still poisoned).
    for brief, detail in rows:
        brief.decode("utf-8")
        detail.decode("utf-8")
    # The clean row is untouched; the repaired bytes became U+FFFD.
    assert rows[0] == (b"clean brief", b"clean detail")
    assert b"\xef\xbf\xbd" in rows[1][0]


# ─── doxygen.parse_doxyfile_value ───────────────────────────────────────────

Activity · 19 steps
lines 127–127db = tmp_path / "doxy.db"lines 128–128conn = sqlite3.connect(str(db))lines 129–129◇ for tbl in ("memberdef", "compounddef")lines 130–130conn.execute(f"CREATE TABLE {tbl} (briefdescription TEXT, detaileddescription TEXT)")lines 131–131conn.execute("INSERT INTO memberdef VALUES (?, ?)", ("clean brief", "clean detail"))lines 133–136conn.execute( "INSERT INTO memberdef VALUES (?, ?)", (b"bad \xa4 brief", b"detail \xa4\xa4 here"), )lines 137–137conn.commit()lines 138–138conn.close()lines 140–140fixed = sanitize_doxygen_text(db)lines 141–141assert fixed == 2, "both poisoned columns of the bad row should be repaired"lines 143–143check = sqlite3.connect(str(db))lines 144–144check.text_factory = byteslines 145–147rows = check.execute( "SELECT briefdescription, detaileddescription FROM memberdef ORDER BY rowid" ).fetchall()lines 148–148check.close()lines 150–150◇ for brief, detail in rowslines 151–151brief.decode("utf-8")lines 152–152detail.decode("utf-8")lines 154–154assert rows[0] == (b"clean brief", b"clean detail")lines 155–155assert b"\xef\xbf\xbd" in rows[1][0]

test_shared_key_at_the_edge_ceiling_is_admitted

None test_build_docs_db.test_shared_key_at_the_edge_ceiling_is_admitted(Path tmp_path)

A key at exactly the ceiling is admitted; the boundary is inclusive.

tests/test_build_docs_db.py:1838

Show on the map →

Called by none

Calls _key_edge_count, _shared_key_shape

Checks

  • assert _key_edge_count(db_path, "BOUNDARY_KEY") == _MAX_KEY_EDGES

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_shared_key_at_the_edge_ceiling_is_admitted → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 13 lines
def test_shared_key_at_the_edge_ceiling_is_admitted(tmp_path: Path) -> None:
    """8 x 8 = 64 is the OLD rule's maximum admission, and it must still be admitted:
    the product ceiling was chosen to be exactly that number so no key the previous
    rule allowed is newly discarded. A test on the boundary is the only thing that
    holds that promise.

    @brief The 8x8 key the old per-side rule admitted is still admitted.
    @version 1
    """
    db_path = _shared_key_shape(tmp_path, "BOUNDARY_KEY", 8, 8)
    assert _key_edge_count(db_path, "BOUNDARY_KEY") == _MAX_KEY_EDGES

Activity · 2 steps
lines 1847–1847db_path = _shared_key_shape(tmp_path, "BOUNDARY_KEY", 8, 8)lines 1848–1848assert _key_edge_count(db_path, "BOUNDARY_KEY") == _MAX_KEY_EDGES

test_shared_key_broadcast_key_survives_suppression

None test_build_docs_db.test_shared_key_broadcast_key_survives_suppression(Path tmp_path)

A broadcast key — one writer, many readers — survives too.

tests/test_build_docs_db.py:1804

Show on the map →

Called by none

Calls _key_edge_count, _shared_key_shape

Checks

  • assert _key_edge_count(db_path, "BROADCAST_KEY") == n_readers

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_shared_key_broadcast_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 12 lines
def test_shared_key_broadcast_key_survives_suppression(tmp_path: Path) -> None:
    """The funnel's dual, and suppressed by the same per-side test for the same wrong
    reason. `1 x readers` is linear.

    @brief One writer out to many readers is not suppressed.
    @version 1
    """
    n_readers = _MAX_KEY_EDGES // 2
    db_path = _shared_key_shape(tmp_path, "BROADCAST_KEY", 1, n_readers)
    assert _key_edge_count(db_path, "BROADCAST_KEY") == n_readers

Activity · 3 steps
lines 1811–1811n_readers = _MAX_KEY_EDGES // 2lines 1812–1812db_path = _shared_key_shape(tmp_path, "BROADCAST_KEY", 1, n_readers)lines 1813–1813assert _key_edge_count(db_path, "BROADCAST_KEY") == n_readers

test_shared_key_funnel_key_survives_suppression

None test_build_docs_db.test_shared_key_funnel_key_survives_suppression(Path tmp_path)

A funnel key — many writers, ONE reader — survives fan-out suppression.

tests/test_build_docs_db.py:1780

Show on the map →

Called by none

Calls _key_edge_count, _shared_key_shape

Checks

  • assert _key_edge_count(db_path, "FUNNEL_KEY") == n_writers

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_shared_key_funnel_key_survives_suppression → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 22 lines
def test_shared_key_funnel_key_survives_suppression(tmp_path: Path) -> None:
    """THE gh#28 DEFECT, and this test replaces one that asserted the opposite.

    The test that used to live here built 9 writers and 1 reader and asserted the key
    produced ZERO edges. That is exactly the funnel shape gh#28 was filed about, so
    the buggy behaviour was pinned by a passing test — which is why it survived. The
    per-side ceiling is not being loosened out of taste: a funnel contributes
    `writers x 1` edges, which is linear, while the O(n^2) blob the ceiling exists to
    stop needs both sides large.

    A funnel is also the most valuable shape the layer can find — every producer in
    the codebase converging on one consumer, where the single reader is the place the
    meaning lives.

    @brief Many writers into one reader are not suppressed.
    @version 1
    """
    n_writers = _MAX_KEY_EDGES // 2
    db_path = _shared_key_shape(tmp_path, "FUNNEL_KEY", n_writers, 1)
    assert _key_edge_count(db_path, "FUNNEL_KEY") == n_writers

Activity · 3 steps
lines 1797–1797n_writers = _MAX_KEY_EDGES // 2lines 1798–1798db_path = _shared_key_shape(tmp_path, "FUNNEL_KEY", n_writers, 1)lines 1799–1799assert _key_edge_count(db_path, "FUNNEL_KEY") == n_writers

test_shared_key_quadratic_fanout_key_still_suppressed

None test_build_docs_db.test_shared_key_quadratic_fanout_key_still_suppressed(Path tmp_path)

A genuine quadratic fan-out key is still suppressed entirely.

tests/test_build_docs_db.py:1818

Show on the map →

Called by none

Calls _key_edge_count, _shared_key_shape

Checks

  • assert 9 * 9 > _MAX_KEY_EDGES, "fixture must exceed the ceiling to be a control"
  • assert _key_edge_count(db_path, "STATUS_FLAG") == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_shared_key_quadratic_fanout_key_still_suppressed → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 18 lines
def test_shared_key_quadratic_fanout_key_still_suppressed(tmp_path: Path) -> None:
    """THE CONTROL, without which the two tests above only prove the ceiling was
    removed rather than re-aimed. A generic status-flag key touched by many writers
    AND many readers is the noise blob the suppression exists for: 9 x 9 = 81 edges,
    above the 64-edge ceiling, and it must still yield nothing.

    Note how close this sits to the funnel above — 9 writers is FEWER writers than
    the funnel case has, and it is suppressed while the funnel is admitted. That is
    the point: the discriminator is the product, not the size of the larger side.

    @brief A many-to-many key is suppressed.
    @version 1
    """
    db_path = _shared_key_shape(tmp_path, "STATUS_FLAG", 9, 9)
    assert 9 * 9 > _MAX_KEY_EDGES, "fixture must exceed the ceiling to be a control"
    assert _key_edge_count(db_path, "STATUS_FLAG") == 0

Activity · 3 steps
lines 1831–1831db_path = _shared_key_shape(tmp_path, "STATUS_FLAG", 9, 9)lines 1832–1832assert 9 * 9 > _MAX_KEY_EDGES, "fixture must exceed the ceiling to be a control"lines 1833–1833assert _key_edge_count(db_path, "STATUS_FLAG") == 0

test_shared_key_suppressed_key_is_named_in_the_log

None test_build_docs_db.test_shared_key_suppressed_key_is_named_in_the_log(Path tmp_path, pytest.LogCaptureFixture caplog)

A suppressed key is named in the log, not just counted.

tests/test_build_docs_db.py:1853

Show on the map →

Called by none

Calls _shared_key_shape

Checks

  • assert "NOISY_KEY" in caplog.text
  • assert "9 writers x 9 readers" in caplog.text

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_shared_key_suppressed_key_is_named_in_the_log → _shared_key_shape → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 17 lines
def test_shared_key_suppressed_key_is_named_in_the_log(
    tmp_path: Path,
    caplog: pytest.LogCaptureFixture,
) -> None:
    """gh#28's secondary ask. The layer reported `6 fan-out keys suppressed` and never
    which, so a reader whose key returned nothing had no way to learn it was one of
    the six short of reading the module source.

    @brief The suppressed key's name and shape appear at INFO.
    @version 1
    """
    with caplog.at_level(logging.INFO, logger="clew"):
        _shared_key_shape(tmp_path, "NOISY_KEY", 9, 9)
    assert "NOISY_KEY" in caplog.text
    assert "9 writers x 9 readers" in caplog.text

Activity · 4 steps
lines 1864–1864with caplog.at_level(logging.INFO, logger="clew")lines 1865–1865_shared_key_shape(tmp_path, "NOISY_KEY", 9, 9)lines 1866–1866assert "NOISY_KEY" in caplog.textlines 1867–1867assert "9 writers x 9 readers" in caplog.text

test_supplementary_patterns_includes_readme_and_docs

None test_build_docs_db.test_supplementary_patterns_includes_readme_and_docs()

Glob list must cover the standard layouts before runtime adds any.

tests/test_build_docs_db.py:373

Show on the map →

Called by none

Calls none

Checks

  • assert "README.md" in SUPPLEMENTARY_PATTERNS
  • assert "docs/*.md" in SUPPLEMENTARY_PATTERNS
  • assert "docs/**/*.md" in SUPPLEMENTARY_PATTERNS

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
Source · 7 lines
def test_supplementary_patterns_includes_readme_and_docs() -> None:
    """Glob list must cover the standard layouts before runtime adds any."""
    assert "README.md" in SUPPLEMENTARY_PATTERNS
    assert "docs/*.md" in SUPPLEMENTARY_PATTERNS
    assert "docs/**/*.md" in SUPPLEMENTARY_PATTERNS

Activity · 3 steps
lines 375–375assert "README.md" in SUPPLEMENTARY_PATTERNSlines 376–376assert "docs/*.md" in SUPPLEMENTARY_PATTERNSlines 377–377assert "docs/**/*.md" in SUPPLEMENTARY_PATTERNS

test_synthesize_doxyfile_declares_strip_from_path

None test_build_docs_db.test_synthesize_doxyfile_declares_strip_from_path(Path tmp_path)

The synthesized driver must strip the repo root from stored paths.

tests/test_build_docs_db.py:84

Checks

  • assert strip, "the synthesized driver must declare STRIP_FROM_PATH"
  • assert Path(strip).is_absolute(), "a relative strip prefix resolves against cwd"
  • assert Path(strip) == repo.resolve(), "the prefix stripped must be the repo root"
  • assert "STRIP_FROM_PATH" not in _build_doxyfile_content(own, None, None)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_synthesize_doxyfile_declares_strip_from_path → synthesize_doxyfile
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_synthesize_doxyfile_declares_strip_from_path → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 38 lines
def test_synthesize_doxyfile_declares_strip_from_path(tmp_path: Path) -> None:
    """The synthesized driver must strip the repo root from stored paths.

    Without it the #33 synthesis path stored ABSOLUTE paths — measured at 112 of
    112 rows on this repo's own index, each carrying the builder's home directory
    — and MCP publishes that column on every reply that names a file (the `file`
    field of a dossier, a search hit, a caller row). `list_files` used to be the
    example here and is deleted; the exposure is not, and naming a tool rather than
    the COLUMN is what let a deletion look like it had narrowed it. The pipeline's contract is
    that `path.name` is repo-root-relative; `fix_doxygen_paths` exists to restore
    exactly that, and it returned early precisely BECAUSE this key was unset.

    Only the SYNTHESIZED driver may set it. A repo shipping its own Doxyfile owns
    its STRIP_FROM_PATH, so it must not appear in the forced flags — overriding it
    would discard a declaration and defeat `fix_doxygen_paths`' reconstruction.
    Both halves are asserted, because the wrong fix satisfies the first.

    This is a PROXY for doxygen honouring the key; the real column is asserted in
    `tests/integration/test_self_index.py`. Stated because a proxy assertion that
    reads like a direct one is its own hazard."""
    repo = tmp_path / "myrepo"
    repo.mkdir()
    doxyfile = synthesize_doxyfile(repo, tmp_path / "build" / "docs.doxygen")

    strip = parse_doxyfile_value(doxyfile, "STRIP_FROM_PATH")
    assert strip, "the synthesized driver must declare STRIP_FROM_PATH"
    assert Path(strip).is_absolute(), "a relative strip prefix resolves against cwd"
    assert Path(strip) == repo.resolve(), "the prefix stripped must be the repo root"

    # Never forced onto a repo that supplied its own Doxyfile.
    own = tmp_path / "Doxyfile"
    own.write_text("PROJECT_NAME = theirs\n", encoding="utf-8")
    assert "STRIP_FROM_PATH" not in _build_doxyfile_content(own, None, None)


# ─── doxygen.sanitize_doxygen_text ──────────────────────────────────────────

Activity · 10 steps
lines 104–104repo = tmp_path / "myrepo"lines 105–105repo.mkdir()lines 106–106doxyfile = synthesize_doxyfile(repo, tmp_path / "build" / "docs.doxygen")lines 108–108strip = parse_doxyfile_value(doxyfile, "STRIP_FROM_PATH")lines 109–109assert strip, "the synthesized driver must declare STRIP_FROM_PATH"lines 110–110assert Path(strip).is_absolute(), "a relative strip prefix resolves against cwd"lines 111–111assert Path(strip) == repo.resolve(), "the prefix stripped must be the repo root"lines 114–114own = tmp_path / "Doxyfile"lines 115–115own.write_text("PROJECT_NAME = theirs\n", encoding="utf-8")lines 116–116assert "STRIP_FROM_PATH" not in _build_doxyfile_content(own, None, None)

test_synthesize_doxyfile_writes_minimal_driver

None test_build_docs_db.test_synthesize_doxyfile_writes_minimal_driver(Path tmp_path)

A repo that declares its scope but ships no Doxyfile gets a minimal one: PROJECT_NAME, an ABSOLUTE OUTPUT_DIRECTORY (so output resolves regardless of cwd), and an empty INPUT (the derived scope fills it via replace_input). The forced flags append the rest, so this is all the pipeline needs.

tests/test_build_docs_db.py:62

Checks

  • assert doxyfile.exists()
  • assert doxyfile.parent == out_dir # its parent is a usable work_dir
  • assert "PROJECT_NAME = myrepo" in text
  • assert f"OUTPUT_DIRECTORY = {out_dir}" in text
  • assert Path(parse_doxyfile_value(doxyfile, "OUTPUT_DIRECTORY")).is_absolute()
  • assert "INPUT =" in text
  • assert "GENERATE_SQLITE3 = YES" in content

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-001measuredtest_synthesize_doxyfile_writes_minimal_driver → synthesize_doxyfile
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_synthesize_doxyfile_writes_minimal_driver → _build_doxyfile_content → extra_input_clears_exclude
REQ-DDB-PIPE-010catalog
Source · 22 lines
def test_synthesize_doxyfile_writes_minimal_driver(tmp_path: Path) -> None:
    """A repo that declares its scope but ships no Doxyfile gets a minimal one:
    PROJECT_NAME, an ABSOLUTE OUTPUT_DIRECTORY (so output resolves regardless of
    cwd), and an empty INPUT (the derived scope fills it via replace_input).
    The forced flags append the rest, so this is all the pipeline needs."""
    repo = tmp_path / "myrepo"
    repo.mkdir()
    out_dir = tmp_path / "build" / "docs.doxygen"
    doxyfile = synthesize_doxyfile(repo, out_dir)

    assert doxyfile.exists()
    assert doxyfile.parent == out_dir  # its parent is a usable work_dir
    text = doxyfile.read_text()
    assert "PROJECT_NAME = myrepo" in text
    assert f"OUTPUT_DIRECTORY = {out_dir}" in text
    assert Path(parse_doxyfile_value(doxyfile, "OUTPUT_DIRECTORY")).is_absolute()
    assert "INPUT =" in text
    # _build_doxyfile_content appends the forced GENERATE_SQLITE3 etc.
    content = _build_doxyfile_content(doxyfile, None, None, replace_input=False)
    assert "GENERATE_SQLITE3 = YES" in content

Activity · 13 steps
lines 67–67repo = tmp_path / "myrepo"lines 68–68repo.mkdir()lines 69–69out_dir = tmp_path / "build" / "docs.doxygen"lines 70–70doxyfile = synthesize_doxyfile(repo, out_dir)lines 72–72assert doxyfile.exists()lines 73–73assert doxyfile.parent == out_dirlines 74–74text = doxyfile.read_text()lines 75–75assert "PROJECT_NAME = myrepo" in textlines 76–76assert f"OUTPUT_DIRECTORY = {out_dir}" in textlines 77–77assert Path(parse_doxyfile_value(doxyfile, "OUTPUT_DIRECTORY")).is_absolute()lines 78–78assert "INPUT =" in textlines 80–80content = _build_doxyfile_content(doxyfile, None, None, replace_input=False)lines 81–81assert "GENERATE_SQLITE3 = YES" in content

test_the_catalog_precedence_is_declaration_then_convention

None test_build_docs_db.test_the_catalog_precedence_is_declaration_then_convention(Path tmp_path)

Declaration beats convention; convention still resolves when nothing is declared.

tests/test_build_docs_db.py:2139

Checks

  • assert resolve_catalog_path(cfg, tmp_path) == declared.resolve()
  • assert resolve_catalog_path({}, tmp_path) == conventional
  • assert resolve_catalog_path({}, tmp_path) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_the_catalog_precedence_is_declaration_then_convention → resolve_catalog_path
Source · 39 lines
def test_the_catalog_precedence_is_declaration_then_convention(tmp_path: Path) -> None:
    """TWO RESOLVERS DISAGREED, AND ONLY ONE DOOR SHOWED IT. `cli` resolved
    `--requirements or declared_catalog_path(...)` and never looked for a conventional file.
    The MCP server COMPOSED `repo/"requirements.yaml"` and passed it in the EXPLICIT-FLAG
    slot — so through MCP the convention outranked a repo's DECLARED
    `impact.requirements.file`, and through the CLI the convention did not exist at all.

    A repo with both got a different catalog depending on which entry point built it, with no
    warning and two indexes that each looked fine.

    THE HALF A NAIVE FIX BREAKS SILENTLY is asserted second. Deleting the composition without
    moving the discovery would stop ingesting the conventional catalog that this repository
    and most adopters actually use — and nothing would fail, because `@req` edges populate
    from TAGS regardless. Only the catalog metadata would quietly go missing, which is the
    disarmed-gate shape this project keeps finding.

    @brief Declaration beats convention; convention still resolves when nothing is declared.
    @version 1
    """
    from clew.requirements import resolve_catalog_path

    declared = tmp_path / "docs" / "reqs.yaml"
    declared.parent.mkdir()
    declared.write_text("requirements: {}\n", encoding="utf-8")
    conventional = tmp_path / "requirements.yaml"
    conventional.write_text("requirements: {}\n", encoding="utf-8")
    cfg = {"requirements": {"file": "docs/reqs.yaml"}}

    ## BOTH present: the declaration wins. This is the case that differed per entry point.
    assert resolve_catalog_path(cfg, tmp_path) == declared.resolve()

    ## Nothing declared: the convention answers, or adopters lose their catalog in silence.
    assert resolve_catalog_path({}, tmp_path) == conventional

    ## Neither: None, not an invented path.
    conventional.unlink()
    assert resolve_catalog_path({}, tmp_path) is None

Activity · 11 steps
lines 2158–2158from clew.requirements import resolve_catalog_pathlines 2160–2160declared = tmp_path / "docs" / "reqs.yaml"lines 2161–2161declared.parent.mkdir()lines 2162–2162declared.write_text("requirements: {}\n", encoding="utf-8")lines 2163–2163conventional = tmp_path / "requirements.yaml"lines 2164–2164conventional.write_text("requirements: {}\n", encoding="utf-8")lines 2165–2165cfg = {"requirements": {"file": "docs/reqs.yaml"}}lines 2168–2168assert resolve_catalog_path(cfg, tmp_path) == declared.resolve()lines 2171–2171assert resolve_catalog_path({}, tmp_path) == conventionallines 2174–2174conventional.unlink()lines 2175–2175assert resolve_catalog_path({}, tmp_path) is None

test_the_conventional_catalog_is_also_looked_for_under_docs

None test_build_docs_db.test_the_conventional_catalog_is_also_looked_for_under_docs(Path tmp_path)

A catalog under docs/ resolves when nothing is declared.

tests/test_build_docs_db.py:2178

Checks

  • assert resolve_catalog_path({}, tmp_path) == docs_catalog.resolve()
  • assert resolve_catalog_path(None, tmp_path) == docs_catalog.resolve()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_the_conventional_catalog_is_also_looked_for_under_docs → resolve_catalog_path
Source · 25 lines
def test_the_conventional_catalog_is_also_looked_for_under_docs(tmp_path: Path) -> None:
    """gh#13. The convention tier looked in exactly ONE place — `<root>/requirements.yaml` —
    so a repo that keeps its catalog at `docs/requirements.yaml` and declares nothing got no
    catalog at all. That is not a niche layout: `docs/` is where this pipeline already looks
    for a Doxyfile, and where the reporter's repo kept it.

    THE FAILURE WAS SILENT AND THEN CONFIDENT. Nothing errors, because a catalog is optional
    metadata; the build logs "no requirements.yaml found — table empty" and moves on. The
    reader then asks `dossier("REQ-...")` and is told "This is a definitive negative from the
    database, NOT an error" about a requirement their repository plainly declares — the
    strongest possible wording on the weakest possible evidence.

    @brief A catalog under docs/ resolves when nothing is declared.
    @version 1
    """
    from clew.requirements import resolve_catalog_path

    docs_catalog = tmp_path / "docs" / "requirements.yaml"
    docs_catalog.parent.mkdir()
    docs_catalog.write_text("requirements: {}\n", encoding="utf-8")

    assert resolve_catalog_path({}, tmp_path) == docs_catalog.resolve()
    assert resolve_catalog_path(None, tmp_path) == docs_catalog.resolve()

Activity · 6 steps
lines 2193–2193from clew.requirements import resolve_catalog_pathlines 2195–2195docs_catalog = tmp_path / "docs" / "requirements.yaml"lines 2196–2196docs_catalog.parent.mkdir()lines 2197–2197docs_catalog.write_text("requirements: {}\n", encoding="utf-8")lines 2199–2199assert resolve_catalog_path({}, tmp_path) == docs_catalog.resolve()lines 2200–2200assert resolve_catalog_path(None, tmp_path) == docs_catalog.resolve()

test_the_query_layer_quotes_doxygens_own_expansion_verbatim

None test_build_docs_db.test_the_query_layer_quotes_doxygens_own_expansion_verbatim(Path macro_hop_db)

THE CONTROL THIS TASK ASKED FOR: the text a caller reads must be doxygen's own `initializer` for that macro, character for character. Comparing against the fixture's literal would only prove the fixture agrees with itself, so the expected value is READ BACK from `memberdef` in the assertion.

tests/test_build_docs_db.py:731

Checks

  • assert callees["store_set"].via_macro == "STORE_SET_FOO"
  • assert callees["store_set"].via_macro_expansion == expected
  • assert expected, "the fixture must carry a non-empty expansion or this asserts nothing"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-003measuredtest_the_query_layer_quotes_doxygens_own_expansion_verbatim → build_call_edges
REQ-DDB-PIPE-010catalog
REQ-DDB-QUERY-001measuredtest_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees
REQ-DDB-QUERY-003measuredtest_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees → _call_edges → _dataflow_edges → resolve_rowid
REQ-DDB-QUERY-009measuredtest_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees → _call_edges → _direct_call_edges → _implementors_by_identity
REQ-DDB-QUERY-010measuredtest_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees
REQ-DDB-SCHEMA-012measured
Source · 26 lines
def test_the_query_layer_quotes_doxygens_own_expansion_verbatim(macro_hop_db: Path) -> None:
    """THE CONTROL THIS TASK ASKED FOR: the text a caller reads must be doxygen's own
    `initializer` for that macro, character for character. Comparing against the fixture's
    literal would only prove the fixture agrees with itself, so the expected value is READ BACK
    from `memberdef` in the assertion.

    PUBLISHED, NOT INTERPRETED. Nothing infers what the macro is for — that is the deliberate
    opposite of the rejected auto-discovery direction, which tried to derive a role from the
    expansion and could not, because one empty do-while shape is a disabled trace macro and a
    compiler hint and a portability stub at once."""
    from clew import query as q

    build_call_edges(macro_hop_db)
    import_macro_hop_edges(macro_hop_db)

    conn = sqlite3.connect(str(macro_hop_db))
    expected = conn.execute("SELECT initializer FROM memberdef WHERE rowid=2").fetchone()[0]
    conn.close()

    callees = {e.name: e for e in q.callees(macro_hop_db, "producer")}

    assert callees["store_set"].via_macro == "STORE_SET_FOO"
    assert callees["store_set"].via_macro_expansion == expected
    assert expected, "the fixture must carry a non-empty expansion or this asserts nothing"

Activity · 10 steps
lines 741–741from clew import query as qlines 743–743build_call_edges(macro_hop_db)lines 744–744import_macro_hop_edges(macro_hop_db)lines 746–746conn = sqlite3.connect(str(macro_hop_db))lines 747–747expected = conn.execute("SELECT initializer FROM memberdef WHERE rowid=2").fetchone()[0]lines 748–748conn.close()lines 750–750callees = {e.name: e for e in q.callees(macro_hop_db, "producer")}lines 752–752assert callees["store_set"].via_macro == "STORE_SET_FOO"lines 753–753assert callees["store_set"].via_macro_expansion == expectedlines 754–754assert expected, "the fixture must carry a non-empty expansion or this asserts nothing"

test_the_root_catalog_still_outranks_the_docs_one

None test_build_docs_db.test_the_root_catalog_still_outranks_the_docs_one(Path tmp_path)

Root beats docs/ within the convention tier.

tests/test_build_docs_db.py:2203

Checks

  • assert resolve_catalog_path({}, tmp_path) == root_catalog.resolve()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-006measuredtest_the_root_catalog_still_outranks_the_docs_one → resolve_catalog_path
Source · 21 lines
def test_the_root_catalog_still_outranks_the_docs_one(tmp_path: Path) -> None:
    """WIDENING A SEARCH MUST NOT MOVE AN EXISTING ANSWER. Every repo that resolves a catalog
    today does so from the root, and this repository is one of them — so the root keeps the
    first position within the convention tier and a `docs/` copy cannot displace it. Ordering
    the new location first would silently re-point existing indexes at a different file, which
    is the class of change this resolver was written to end.

    @brief Root beats docs/ within the convention tier.
    @version 1
    """
    from clew.requirements import resolve_catalog_path

    root_catalog = tmp_path / "requirements.yaml"
    root_catalog.write_text("requirements: {}\n", encoding="utf-8")
    docs_catalog = tmp_path / "docs" / "requirements.yaml"
    docs_catalog.parent.mkdir()
    docs_catalog.write_text("requirements: {}\n", encoding="utf-8")

    assert resolve_catalog_path({}, tmp_path) == root_catalog.resolve()

Activity · 7 steps
lines 2213–2213from clew.requirements import resolve_catalog_pathlines 2215–2215root_catalog = tmp_path / "requirements.yaml"lines 2216–2216root_catalog.write_text("requirements: {}\n", encoding="utf-8")lines 2217–2217docs_catalog = tmp_path / "docs" / "requirements.yaml"lines 2218–2218docs_catalog.parent.mkdir()lines 2219–2219docs_catalog.write_text("requirements: {}\n", encoding="utf-8")lines 2221–2221assert resolve_catalog_path({}, tmp_path) == root_catalog.resolve()

test_ts_language_for_recognizes_extensions

None test_build_docs_db.test_ts_language_for_recognizes_extensions()

`.py` used to sit here alongside `.txt`/`.rs` as an unrecognised extension. That was the whole of #58's gap: `tree_sitter_python` was already installed and simply never routed, so every tree-sitter R1 layer (call edges, thread spawns, reachability seeds) was silently empty on a Python codebase — including clew itself, which is a pinned MCP target of itself.

tests/test_build_docs_db.py:422

Checks

  • assert _ts_language_for("foo.txt") is None
  • assert _ts_language_for("dir/file.py") is not None
  • assert _ts_language_for("dir/file.rs") is not None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-PIPE-012inferredtest_ts_language_for_recognizes_extensions → _ts_language_for → _grammar_available → has_language
Source · 19 lines
def test_ts_language_for_recognizes_extensions() -> None:
    """`.py` used to sit here alongside `.txt`/`.rs` as an unrecognised
    extension. That was the whole of #58's gap: `tree_sitter_python` was already
    installed and simply never routed, so every tree-sitter R1 layer (call edges,
    thread spawns, reachability seeds) was silently empty on a Python codebase —
    including clew itself, which is a pinned MCP target of itself.

    `.py` and (Rust support) `.rs` now resolve; `.txt` still must not, because a
    grammar this pipeline does not ship must fail closed rather than fall back to
    some other language's parser and FABRICATE structure (#50 is the
    C-grammar-on-a-C++-header version of exactly that mistake)."""
    assert _ts_language_for("foo.txt") is None
    assert _ts_language_for("dir/file.py") is not None
    assert _ts_language_for("dir/file.rs") is not None


# ─── call_edges._ast_caller_at_line ─────────────────────────────────────────

Activity · 3 steps
lines 433–433assert _ts_language_for("foo.txt") is Nonelines 434–434assert _ts_language_for("dir/file.py") is not Nonelines 435–435assert _ts_language_for("dir/file.rs") is not None

test_undeclared_accessor_families_sees_MACRO_defined_accessors

None test_build_docs_db.test_undeclared_accessor_families_sees_MACRO_defined_accessors(Path tmp_path)

Macro-defined accessor families are detected, not invisible.

tests/test_build_docs_db.py:1623

Checks

  • assert fams.get("Store_Set_") == 5, ("a macro-defined accessor family must be surfaced; the diagnostic read " f"only kind='function' and was structurally blind to it. got: {fams}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-007measuredtest_undeclared_accessor_families_sees_MACRO_defined_accessors → detect_undeclared_accessor_families
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-010catalog
REQ-DDB-SCHEMA-005measuredtest_undeclared_accessor_families_sees_MACRO_defined_accessors → detect_undeclared_accessor_families
Source · 52 lines
def test_undeclared_accessor_families_sees_MACRO_defined_accessors(tmp_path: Path) -> None:
    """The diagnostic must read `kind='macro definition'`, not functions alone.

    A repo whose accessor family is macro-defined produces ZERO `kind='function'`
    rows, so a functions-only query stays silent — and that silence reads as
    evidence the repo has no dataflow.

    The literal is load-bearing: `macro definition` is what doxygen emits, and a
    fixture using any other spelling proves only that it agrees with the code.

    @brief Macro-defined accessor families are detected, not invisible.
    @version 2
    """
    db_path = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db_path))
    conn.executescript(
        """
        CREATE TABLE path (name TEXT);
        CREATE TABLE memberdef (
            rowid INTEGER PRIMARY KEY,
            kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER,
            bodystart INTEGER, bodyend INTEGER
        );
        """,
    )
    conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'src/store.h')")
    ## Macros only — deliberately NOT one function row, so the test fails
    ## against a `kind='function'` query rather than passing by accident.
    conn.executemany(
        "INSERT INTO memberdef "
        "(rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend) "
        "VALUES (?, 'macro definition', ?, 1, 1, 0, 0)",
        [
            (1, "Store_Set_ALPHA"),
            (2, "Store_Set_BETA"),
            (3, "Store_Set_GAMMA"),
            (4, "Store_Set_DELTA"),
            (5, "Store_Set_EPSILON"),
        ],
    )
    conn.commit()

    fams = {f.prefix: f.keys for f in detect_undeclared_accessor_families(conn, [])}
    conn.close()
    ## `Store_Set_`, with the separator: the prefix group is what a
    ## `NamePrefixPattern` would be declared as, so it carries the trailing `_`.
    assert fams.get("Store_Set_") == 5, (
        "a macro-defined accessor family must be surfaced; the diagnostic read "
        f"only kind='function' and was structurally blind to it. got: {fams}"
    )

Activity · 9 steps
lines 1636–1636db_path = tmp_path / "clew.db"lines 1637–1637conn = sqlite3.connect(str(db_path))lines 1638–1647conn.executescript( """ CREATE TABLE path (name TEXT); CREATE TABLE memberdef ( rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER ); """, )lines 1648–1648conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'src/store.h')")lines 1651–1662conn.executemany( "INSERT INTO memberdef " "(rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend) " "VALUES (?, 'macro definition', ?, 1, 1, 0, 0)", [ (1, "Store_Set_ALPHA"), (2, "Store_Set_BETA"), (3, "Store_Set_GAMMA"), (4, "Store_Set_DELTA"), (5, "Store_Set_EPSILON"), ], )lines 1663–1663conn.commit()lines 1665–1665fams = {f.prefix: f.keys for f in detect_undeclared_accessor_families(conn, [])}lines 1666–1666conn.close()lines 1669–1672assert fams.get("Store_Set_") == 5, ( "a macro-defined accessor family must be surfaced; the diagnostic read " f"only kind='function' and was structurally blind to it. got: {fams}" )

test_write_symbol_liveness_marks_correctly

None test_build_docs_db.test_write_symbol_liveness_marks_correctly(Path synthetic_reachability_db)

tests/test_build_docs_db.py:910

Checks

  • assert live_count == 5
  • assert total == 7
  • assert statuses[1] == "live"
  • assert statuses[4] == "orphan"
  • assert statuses[7] == "orphan"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-001catalog
REQ-DDB-PIPE-004measuredtest_write_symbol_liveness_marks_correctly → _write_symbol_liveness
REQ-DDB-PIPE-010catalog
Source · 27 lines
def test_write_symbol_liveness_marks_correctly(
    synthetic_reachability_db: Path,
) -> None:
    conn = sqlite3.connect(str(synthetic_reachability_db))
    conn.execute(
        """
        CREATE TABLE symbol_liveness (
            memberdef_rowid INTEGER PRIMARY KEY,
            status TEXT
        )
        """,
    )
    live_count, total = _write_symbol_liveness(conn, {1, 2, 3, 5, 6})
    conn.commit()
    statuses = dict(
        conn.execute(
            "SELECT memberdef_rowid, status FROM symbol_liveness",
        ).fetchall(),
    )
    conn.close()
    assert live_count == 5
    assert total == 7
    assert statuses[1] == "live"
    assert statuses[4] == "orphan"
    assert statuses[7] == "orphan"

Activity · 11 steps
lines 913–913conn = sqlite3.connect(str(synthetic_reachability_db))lines 914–921conn.execute( """ CREATE TABLE symbol_liveness ( memberdef_rowid INTEGER PRIMARY KEY, status TEXT ) """, )lines 922–922live_count, total = _write_symbol_liveness(conn, {1, 2, 3, 5, 6})lines 923–923conn.commit()lines 924–928statuses = dict( conn.execute( "SELECT memberdef_rowid, status FROM symbol_liveness", ).fetchall(), )lines 929–929conn.close()lines 930–930assert live_count == 5lines 931–931assert total == 7lines 932–932assert statuses[1] == "live"lines 933–933assert statuses[4] == "orphan"lines 934–934assert statuses[7] == "orphan"