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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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 Noneassert declared_catalog_path(None, tmp_path) is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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
Checks
assert warn_if_no_function_bodies(db_path) == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_a_header_only_index_does_NOT_warn → warn_if_no_function_bodies |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_a_macro_with_no_recorded_expansion_is_still_named → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-QUERY-001 | measured | test_a_macro_with_no_recorded_expansion_is_still_named → callees |
| REQ-DDB-QUERY-003 | measured | test_a_macro_with_no_recorded_expansion_is_still_named → callees → _call_edges → _dataflow_edges → resolve_rowid |
| REQ-DDB-QUERY-009 | measured | test_a_macro_with_no_recorded_expansion_is_still_named → callees → _call_edges → _direct_call_edges → _implementors_by_identity |
| REQ-DDB-QUERY-010 | measured | test_a_macro_with_no_recorded_expansion_is_still_named → callees |
| REQ-DDB-SCHEMA-012 | measured |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_a_pair_reachable_through_two_macros_names_one_deterministically → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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
Checks
assert seen == [SCOPE_FROM_GUARD], "an unstated scope must be the parser's default"assert seen[-1] == SCOPE_DOXYFILE
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → report_stats |
| REQ-DDB-CLI-002 | inferred | test_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-001 | measured | test_an_unstated_scope_keeps_the_parsers_default → build_index → normalize_scope |
| REQ-DDB-CONFIG-003 | inferred | test_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-004 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_preprocessor |
| REQ-DDB-CONFIG-005 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig |
| REQ-DDB-CONFIG-006 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _recorded_entry_patterns → recorded_explicit |
| REQ-DDB-CONFIG-007 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature |
| REQ-DDB-CONFIG-009 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _apply_toolchain_exclusions → load_toolchain_config |
| REQ-DDB-GUARD-012 | inferred | test_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-019 | inferred | test_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-024 | inferred | test_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-001 | inferred | test_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-002 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → build_lock |
| REQ-DDB-INDEX-003 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → report_index_coverage |
| REQ-DDB-INDEX-004 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols |
| REQ-DDB-INDEX-005 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → stamp_external_provenance |
| REQ-DDB-INDEX-006 | inferred | test_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-007 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → record_owners |
| REQ-DDB-INDEX-008 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_licenses |
| REQ-DDB-INDEX-009 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc |
| REQ-DDB-INDEX-010 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes |
| REQ-DDB-INDEX-011 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_property_keys |
| REQ-DDB-MCP-001 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _operator_excludes → meta_section |
| REQ-DDB-PIPE-001 | catalog | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_database |
| REQ-DDB-PIPE-003 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → build_call_edges |
| REQ-DDB-PIPE-004 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → python_entry_seeds |
| REQ-DDB-PIPE-005 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature |
| REQ-DDB-PIPE-006 | inferred | test_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-007 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig_gates |
| REQ-DDB-PIPE-008 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs |
| REQ-DDB-PIPE-009 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → prune_dominated_fuzzy_call_edges |
| REQ-DDB-PIPE-010 | catalog | test_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-011 | inferred | test_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-012 | inferred | test_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-013 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings |
| REQ-DDB-PIPE-014 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc → within_repo |
| REQ-DDB-PIPE-015 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_config_defaults |
| REQ-DDB-QUERY-003 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → mark_test_scope |
| REQ-DDB-QUERY-011 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads → _ensure_threads_tables |
| REQ-DDB-SCHEMA-001 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads |
| REQ-DDB-SCHEMA-002 | inferred | test_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-003 | inferred | test_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-004 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest |
| REQ-DDB-SCHEMA-005 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_key_alias_prefixes |
| REQ-DDB-SCHEMA-006 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-007 | inferred | test_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-009 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_event_edges |
| REQ-DDB-SCHEMA-011 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → extract_context_conflicts |
| REQ-DDB-SCHEMA-012 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest → declaration_origin |
| REQ-DDB-SCHEMA-013 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → import_data_model_keys |
| REQ-DDB-SCHEMA-014 | inferred | test_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-015 | inferred | test_an_unstated_scope_keeps_the_parsers_default → build_index → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_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
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
Checks
assert _ast_caller_at_line(funcs, 3) == 10assert _ast_caller_at_line(funcs, 7) == 20assert _ast_caller_at_line(funcs, 99) == 30assert _ast_caller_at_line(funcs, 100) is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert edges_resolved == []assert edges_fuzzy == [], "one call site must never become three edges"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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
test_ast_record_no_match_silent
None test_build_docs_db.test_ast_record_no_match_silent()
tests/test_build_docs_db.py:495
Checks
assert edges_resolved == []assert edges_fuzzy == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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.fixturetest_ast_record_unique_match_resolved
None test_build_docs_db.test_ast_record_unique_match_resolved()
tests/test_build_docs_db.py:456
Checks
assert edges_resolved == [(10, 42, "ast")]assert edges_fuzzy == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-004 | measured | test_bfs_live_set_walks_from_seeds → _bfs_live_set |
| REQ-DDB-PIPE-010 | catalog |
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
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 indexesassert "idx_call_edges_callee" in indexes
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_build_call_edges_creates_indexes → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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.fixturetest_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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_build_call_edges_imports_only_function_inline_xrefs → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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 outassert "INPUT += subm/bar" in outassert "\nEXCLUDE =\n" in outassert "EXCLUDE += subm/foo/deps" in out
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_build_doxyfile_appends_extra_input_clears_exclude → _build_doxyfile_content |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_build_doxyfile_appends_extra_input_clears_exclude → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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 outassert "GENERATE_XML = YES" not in outassert "EXTRACT_ALL = YES" in outassert "EXTRACT_STATIC = YES" in outassert "RECURSIVE = YES" in outassert "PROJECT_NAME = test" in out # original preserved
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_build_doxyfile_appends_forced_flags → _build_doxyfile_content |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_build_doxyfile_appends_forced_flags → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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 standaloneassert "EXCLUDE = vendor" in out # repo's own EXCLUDE preserved (not cleared)assert "EXCLUDE +=" not in plain
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_build_doxyfile_extra_exclude_applies_standalone → _build_doxyfile_content |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_build_doxyfile_extra_exclude_applies_standalone → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | measured | test_chunk_markdown_a_hash_line_in_a_code_fence_is_not_a_heading → chunk_markdown |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | measured | test_chunk_markdown_empty_section_skipped → chunk_markdown |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | measured | test_chunk_markdown_first_chunk_uses_filename → chunk_markdown |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | measured | test_chunk_markdown_handles_three_levels → chunk_markdown |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | measured | test_chunk_markdown_splits_on_setext_and_keeps_deeper_headings_inline → chunk_markdown |
| REQ-DDB-PIPE-010 | catalog |
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
test_classify_doxygen_line_buckets
None test_build_docs_db.test_classify_doxygen_line_buckets()
tests/test_build_docs_db.py:321
Checks
assert _classify_doxygen_line("warning: X") == "warning"assert _classify_doxygen_line("Error: oops") == "warning" # case-insensitiveassert _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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert "main" in DEFAULT_ENTRY_PATTERNSassert "%init%" in DEFAULT_ENTRY_PATTERNSassert "%task%" in DEFAULT_ENTRY_PATTERNSassert "%isr%" in DEFAULT_ENTRY_PATTERNS
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-007 | measured | test_detect_undeclared_accessor_families → detect_undeclared_accessor_families |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-005 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_discover_doxyfile_refuses_to_guess_among_strays → discover_doxyfile |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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.fixturetest_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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_forced_output_dir_keeps_doxygen_out_of_the_target_repo → _build_doxyfile_content |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_forced_output_dir_keeps_doxygen_out_of_the_target_repo → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-004 | measured | test_gather_reachability_seeds_pattern_match → _gather_reachability_seeds |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-004 | measured | test_gather_reachability_seeds_zero_incoming → _gather_reachability_seeds |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert warn_if_no_function_bodies(db_path) == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_implementation_with_at_least_one_body_does_NOT_warn → warn_if_no_function_bodies |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
test_import_req_test_edges_links_only_test_named_memberdefs
None test_build_docs_db.test_import_req_test_edges_links_only_test_named_memberdefs(Path req_tagged_db)
tests/test_build_docs_db.py:1235
Checks
assert rows == [("REQ-0001", 2)]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_import_req_test_edges_links_only_test_named_memberdefs → import_req_edges |
Source · 17 lines
def test_import_req_test_edges_links_only_test_named_memberdefs(
req_tagged_db: Path,
) -> None:
import_req_edges(req_tagged_db)
import_req_test_edges(req_tagged_db)
conn = sqlite3.connect(str(req_tagged_db))
rows = conn.execute(
"SELECT req_id, test_memberdef_rowid FROM req_test_edges",
).fetchall()
conn.close()
# rowid 2 (test_device_boot) is test-named; rowid 1 (device_boot) is not.
assert rows == [("REQ-0001", 2)]
# ─── shared_key_edges (Layer 5) ──────────────────────────────────────────────
Activity · 6 steps
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_in_doxygen_scope_drops_what_a_full_run_would_not_index → in_doxygen_scope → effective_file_patterns |
| REQ-DDB-INDEX-001 | measured | test_in_doxygen_scope_drops_what_a_full_run_would_not_index → in_doxygen_scope → effective_file_patterns |
| REQ-DDB-INDEX-002 | measured | test_in_doxygen_scope_drops_what_a_full_run_would_not_index → in_doxygen_scope |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert warn_if_no_function_bodies(db_path) == 2
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_indexed_implementation_with_zero_function_bodies_warns → warn_if_no_function_bodies |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert result == 1assert rows[0][0] == "Heading"assert "é" in rows[0][1]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-002 | measured | test_ingest_one_doc_file_accepts_valid_utf8 → _ingest_one_doc_file → memoized |
| REQ-DDB-PIPE-001 | measured | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert result == 0, "non-UTF-8 file must be skipped, not ingested"assert rows[0] == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-002 | measured | test_ingest_one_doc_file_skips_non_utf8 → _ingest_one_doc_file → memoized |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml → resolve_catalog_columns |
| REQ-DDB-CONFIG-003 | measured | test_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-015 | measured | test_ingest_requirements_yaml_loads_rows → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml → resolve_catalog_columns |
| REQ-DDB-CONFIG-003 | inferred | test_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-015 | measured | test_ingest_requirements_yaml_missing_file_creates_empty_table → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | inferred | test_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml → resolve_catalog_columns |
| REQ-DDB-CONFIG-003 | inferred | test_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-015 | measured | test_ingest_requirements_yaml_none_path_creates_empty_table → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml → resolve_catalog_columns |
| REQ-DDB-CONFIG-003 | measured | test_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-015 | measured | test_ingest_requirements_yaml_reads_the_mapping_keyed_shape → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml → resolve_catalog_columns |
| REQ-DDB-CONFIG-003 | measured | test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-015 | measured | test_ingest_requirements_yaml_still_refuses_an_unrecognized_shape → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_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
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
Checks
assert _looks_like_test_function("foo", "tests/test_foo.c") is True
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert _looks_like_test_function("test_foo", "src/foo.c") is True
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
test_looks_like_test_function_neither
None test_build_docs_db.test_looks_like_test_function_neither()
tests/test_build_docs_db.py:1231
Checks
assert _looks_like_test_function("device_boot", "src/startup.c") is False
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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) == 0assert _count_edges(synthetic_doxygen_db) == before
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_macro_hop_adds_nothing_when_no_macro_mediates_a_call → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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) == 2assert rows == [
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_macro_hop_composes_the_two_hops_doxygen_already_recorded → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_macro_hop_is_resolved_not_exact → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_macro_hop_names_the_macro_that_made_the_edge → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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 mainassert statuses[3] == "live" # helper reached from do_initassert statuses[6] == "live" # boot reached from app_main
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-004 | measured | test_mark_reachability_end_to_end → mark_reachability |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-012 | measured |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-004 | measured | test_mark_reachability_no_edges_skips → mark_reachability |
| REQ-DDB-PIPE-010 | catalog |
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
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-006 | measured | test_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns |
| REQ-DDB-CONFIG-007 | measured | test_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-002 | measured | test_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-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_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-010 | measured | test_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _build_inferred_edges |
| REQ-DDB-PIPE-011 | measured | test_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-012 | inferred | test_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-002 | measured | test_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _writer_dispatch_map |
| REQ-DDB-SCHEMA-005 | measured | test_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred |
| REQ-DDB-SCHEMA-007 | measured | test_name_prefix_exact_prefix_match_has_no_key_remainder → import_shared_key_edges_inferred → _ensure_shared_key_edges_table |
| REQ-DDB-SCHEMA-012 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_output_dir_defaults_to_the_doxyfile_when_not_forced → _build_doxyfile_content |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_output_dir_defaults_to_the_doxyfile_when_not_forced → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_parse_doxyfile_value_finds_simple_assignment → parse_doxyfile_value |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_parse_doxyfile_value_handles_inline_comments → parse_doxyfile_value |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_parse_doxyfile_value_returns_empty_for_missing_key → parse_doxyfile_value |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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 keptassert "EXCLUDE_PATTERNS = */extern/* */tests/*" in kept
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_replacing_input_also_clears_the_repo_s_exclude_patterns → _build_doxyfile_content |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_replacing_input_also_clears_the_repo_s_exclude_patterns → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_sanitize_doxygen_text_repairs_invalid_utf8 → sanitize_doxygen_text |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Checks
assert "README.md" in SUPPLEMENTARY_PATTERNSassert "docs/*.md" in SUPPLEMENTARY_PATTERNSassert "docs/**/*.md" in SUPPLEMENTARY_PATTERNS
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog |
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
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
Called by none
Calls _build_doxyfile_content, parse_doxyfile_value, synthesize_doxyfile
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_synthesize_doxyfile_declares_strip_from_path → synthesize_doxyfile |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_synthesize_doxyfile_declares_strip_from_path → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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
Called by none
Calls _build_doxyfile_content, parse_doxyfile_value, synthesize_doxyfile
Checks
assert doxyfile.exists()assert doxyfile.parent == out_dir # its parent is a usable work_dirassert "PROJECT_NAME = myrepo" in textassert f"OUTPUT_DIRECTORY = {out_dir}" in textassert Path(parse_doxyfile_value(doxyfile, "OUTPUT_DIRECTORY")).is_absolute()assert "INPUT =" in textassert "GENERATE_SQLITE3 = YES" in content
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-001 | measured | test_synthesize_doxyfile_writes_minimal_driver → synthesize_doxyfile |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_synthesize_doxyfile_writes_minimal_driver → _build_doxyfile_content → extra_input_clears_exclude |
| REQ-DDB-PIPE-010 | catalog |
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
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) == conventionalassert resolve_catalog_path({}, tmp_path) is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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 == expectedassert expected, "the fixture must carry a non-empty expansion or this asserts nothing"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-003 | measured | test_the_query_layer_quotes_doxygens_own_expansion_verbatim → build_call_edges |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-QUERY-001 | measured | test_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees |
| REQ-DDB-QUERY-003 | measured | test_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees → _call_edges → _dataflow_edges → resolve_rowid |
| REQ-DDB-QUERY-009 | measured | test_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees → _call_edges → _direct_call_edges → _implementors_by_identity |
| REQ-DDB-QUERY-010 | measured | test_the_query_layer_quotes_doxygens_own_expansion_verbatim → callees |
| REQ-DDB-SCHEMA-012 | measured |
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-006 | measured | test_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
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 Noneassert _ts_language_for("dir/file.py") is not Noneassert _ts_language_for("dir/file.rs") is not None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-PIPE-012 | inferred | test_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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-007 | measured | test_undeclared_accessor_families_sees_MACRO_defined_accessors → detect_undeclared_accessor_families |
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-010 | catalog | |
| REQ-DDB-SCHEMA-005 | measured | test_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
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 == 5assert total == 7assert statuses[1] == "live"assert statuses[4] == "orphan"assert statuses[7] == "orphan"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | |
| REQ-DDB-PIPE-004 | measured | test_write_symbol_liveness_marks_correctly → _write_symbol_liveness |
| REQ-DDB-PIPE-010 | catalog |
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"