test_dispatch.py

tests/test_dispatch.py

Layer 6: the declared indirect-dispatch recovery (tasks #60 / #30 / #35 / #37).

test_a_declared_alias_prefix_does_not_displace_the_ingot_default

None test_dispatch.test_a_declared_alias_prefix_does_not_displace_the_ingot_default(Path tmp_path)

REWRITTEN FOR gh#319, and the old contract is the point of the rewrite.

tests/test_dispatch.py:650

Show on the map →

Called by none

Calls _key_edges, _wrapper_db, _wrapper_manifest, import_shared_key_edges_inferred, shared_key_document

Checks

  • assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-004measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → shared_key_document
REQ-DDB-SCHEMA-005measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_a_declared_alias_prefix_does_not_displace_the_ingot_default → _wrapper_manifest → load_dispatch_manifest → declaration_origin
Source · 27 lines
def test_a_declared_alias_prefix_does_not_displace_the_ingot_default(tmp_path: Path) -> None:
    """REWRITTEN FOR gh#319, and the old contract is the point of the rewrite.

    This test used to be `..._replace_the_builtin_default` and asserted `[]` — that
    declaring `EXAMPLE_KEY_` KILLED the `DM_KEY_` normalization, so the write half
    became an orphan and no edge formed. It pinned as intended behaviour the one
    constant the gh#319 audit found combining wrongly.

    `DEFAULT_KEY_ALIAS_PREFIXES` is a TIER-4 known-ecosystem signature — the ingot
    generator's own enum prefix, not a guess about anyone's naming — so it
    accumulates and a declaration adds to it. That also makes it consistent with
    the writers and readers from the SAME generator, which have always accumulated.

    `DM_KEY_WIDGET_ENABLED` and `EXAMPLE_KEY_` are INVENTED. Provenance for an
    identifier in a public test is not decidable by reading it — a name lifted from
    a closed repo looks exactly like a name someone made up, which is why this
    project audits SHAPES rather than keeping a list of strings it must hide. The
    fixture only needs a prefix that is not the default.
    """
    db = _wrapper_db(tmp_path)
    import_shared_key_edges_inferred(
        db, tmp_path, None, None, shared_key_document(_wrapper_manifest(["EXAMPLE_KEY_"]))
    )

    assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

Activity · 3 steps
lines 669–669db = _wrapper_db(tmp_path)lines 670–672import_shared_key_edges_inferred( db, tmp_path, None, None, shared_key_document(_wrapper_manifest(["EXAMPLE_KEY_"])) )lines 674–674assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

test_a_declared_alias_prefix_still_normalizes_its_own_spelling

None test_dispatch.test_a_declared_alias_prefix_still_normalizes_its_own_spelling(Path tmp_path)

THE OTHER HALF, without which the test above passes on a build that ignores the declaration entirely.

tests/test_dispatch.py:677

Show on the map →

Called by none

Calls _key_edges, _wrapper_manifest, import_shared_key_edges_inferred, shared_key_document

Checks

  • assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-004measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → shared_key_document
REQ-DDB-SCHEMA-005measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_a_declared_alias_prefix_still_normalizes_its_own_spelling → _wrapper_manifest → load_dispatch_manifest → declaration_origin
Source · 28 lines
def test_a_declared_alias_prefix_still_normalizes_its_own_spelling(tmp_path: Path) -> None:
    """THE OTHER HALF, without which the test above passes on a build that ignores
    the declaration entirely.

    "The default survived" and "the declaration was honoured" are two claims, and
    accumulation is only demonstrated by both. Same fixture with the site keyed on
    `EXAMPLE_KEY_WIDGET_ENABLED` instead.
    """
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "dm.c").write_text(
        _WRAPPER_SRC.replace("DM_KEY_WIDGET_ENABLED", "EXAMPLE_KEY_WIDGET_ENABLED"),
        encoding="utf-8",
    )
    db = _make_db(
        tmp_path,
        [
            (1, "report_stall_state", "void report_stall_state(int v)", 1, 3),
            (2, "read_widget_enabled", "int read_widget_enabled(void)", 5, 7),
        ],
        rel_path="src/dm.c",
    )
    import_shared_key_edges_inferred(
        db, tmp_path, None, None, shared_key_document(_wrapper_manifest(["EXAMPLE_KEY_"]))
    )

    assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

Activity · 5 steps
lines 685–685(tmp_path / "src").mkdir()lines 686–689(tmp_path / "src" / "dm.c").write_text( _WRAPPER_SRC.replace("DM_KEY_WIDGET_ENABLED", "EXAMPLE_KEY_WIDGET_ENABLED"), encoding="utf-8", )lines 690–697db = _make_db( tmp_path, [ (1, "report_stall_state", "void report_stall_state(int v)", 1, 3), (2, "read_widget_enabled", "int read_widget_enabled(void)", 5, 7), ], rel_path="src/dm.c", )lines 698–700import_shared_key_edges_inferred( db, tmp_path, None, None, shared_key_document(_wrapper_manifest(["EXAMPLE_KEY_"])) )lines 702–702assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

test_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site

None test_dispatch.test_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site(Path tmp_path)

The weakest-link rule governs synthetic CALL edges, not boundaries, and the asymmetry is deliberate. A boundary records the AUTHOR's claim that calls to this interface leave the repo — that claim does not become less true because one particular call site was resolved fuzzily, so `_boundary_rows` ignores incoming confidence while `_crossed_edges` respects it.

tests/test_dispatch.py:288

Checks

  • assert _boundaries(db), "the declared boundary must survive a fuzzy call site"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 22 lines
def test_a_declared_boundary_is_recorded_even_from_a_fuzzy_call_site(tmp_path: Path) -> None:
    """The weakest-link rule governs synthetic CALL edges, not boundaries, and the
    asymmetry is deliberate. A boundary records the AUTHOR's claim that calls to
    this interface leave the repo — that claim does not become less true because
    one particular call site was resolved fuzzily, so `_boundary_rows` ignores
    incoming confidence while `_crossed_edges` respects it."""
    db = _make_db(
        tmp_path,
        _IFACE_FUNCTIONS,
        compounds=_IFACE_COMPOUNDS,
        reimplements=[(11, 10)],
        call_edges=[(12, 10)],
        call_confidence=CALL_MATCH_FUZZY,
    )
    manifest = load_dispatch_manifest(
        {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort", "boundary": True}]}
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _boundaries(db), "the declared boundary must survive a fuzzy call site"

Activity · 4 steps
lines 294–301db = _make_db( tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, reimplements=[(11, 10)], call_edges=[(12, 10)], call_confidence=CALL_MATCH_FUZZY, )lines 302–304manifest = load_dispatch_manifest( {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort", "boundary": True}]} )lines 305–305import_declared_dispatch_edges(db, tmp_path, manifest)lines 307–307assert _boundaries(db), "the declared boundary must survive a fuzzy call site"

test_a_manifest_file_that_is_not_a_mapping_refuses_the_build

None test_dispatch.test_a_manifest_file_that_is_not_a_mapping_refuses_the_build(Path tmp_path)

A YAML list (or scalar) where a mapping belongs is refused.

tests/test_dispatch.py:884

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_manifest_file_that_is_not_a_mapping_refuses_the_build → load_dispatch_manifest
REQ-DDB-SCHEMA-012inferredtest_a_manifest_file_that_is_not_a_mapping_refuses_the_build → load_dispatch_manifest → declaration_origin
Source · 6 lines
def test_a_manifest_file_that_is_not_a_mapping_refuses_the_build(tmp_path: Path) -> None:
    """@brief A YAML list (or scalar) where a mapping belongs is refused."""
    path = tmp_path / "dispatch.yaml"
    path.write_text("- interface: ILinkPort\n", encoding="utf-8")
    with pytest.raises(DeclarationError, match="must contain a mapping"):
        load_dispatch_manifest(path)

1 more lines, not shown

Activity · 4 steps
lines 886–886path = tmp_path / "dispatch.yaml"lines 887–887path.write_text("- interface: ILinkPort\n", encoding="utf-8")lines 888–888with pytest.raises(DeclarationError, match="must contain a mapping")lines 889–889load_dispatch_manifest(path)

test_a_missing_required_endpoint_refuses_the_build

None test_dispatch.test_a_missing_required_endpoint_refuses_the_build()

There is no honest default for "which interface" or "which dispatcher" — inventing one binds a call graph the author never described. And an `interfaces:` entry with neither `binds` nor `boundary: true` asks for nothing, which is far more likely a half-finished edit than an intent.

tests/test_dispatch.py:780

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_missing_required_endpoint_refuses_the_build → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_a_missing_required_endpoint_refuses_the_build → load_dispatch_manifest → declaration_origin
Source · 15 lines
def test_a_missing_required_endpoint_refuses_the_build() -> None:
    """There is no honest default for "which interface" or "which dispatcher" —
    inventing one binds a call graph the author never described. And an
    `interfaces:` entry with neither `binds` nor `boundary: true` asks for
    nothing, which is far more likely a half-finished edit than an intent."""
    with pytest.raises(DeclarationError, match="interface"):
        load_dispatch_manifest({"interfaces": [{"binds": "C"}]})
    with pytest.raises(DeclarationError, match="would do nothing"):
        load_dispatch_manifest({"interfaces": [{"interface": "I"}]})
    with pytest.raises(DeclarationError, match="dispatch_via"):
        load_dispatch_manifest({"dispatch_tables": [{"register_via": "r"}]})
    with pytest.raises(DeclarationError, match="pattern"):
        load_dispatch_manifest({"shared_key_wrappers": [{"direction": "write"}]})

Activity · 8 steps
lines 785–785with pytest.raises(DeclarationError, match="interface")lines 786–786load_dispatch_manifest({"interfaces": [{"binds": "C"}]})lines 787–787with pytest.raises(DeclarationError, match="would do nothing")lines 788–788load_dispatch_manifest({"interfaces": [{"interface": "I"}]})lines 789–789with pytest.raises(DeclarationError, match="dispatch_via")lines 790–790load_dispatch_manifest({"dispatch_tables": [{"register_via": "r"}]})lines 791–791with pytest.raises(DeclarationError, match="pattern")lines 792–792load_dispatch_manifest({"shared_key_wrappers": [{"direction": "write"}]})

test_a_misspelled_entry_field_refuses_the_build

None test_dispatch.test_a_misspelled_entry_field_refuses_the_build()

One level down, and worse than "declared nothing": `key_arg_idx` silently defaults the key to argument 0, so a typo does not produce NO dataflow, it produces the WRONG dataflow — a specific, real claim invented from a slip.

tests/test_dispatch.py:764

Checks

  • assert "'key_arg_idx'" in str(exc.value)
  • assert "key_arg_index" in str(exc.value)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_misspelled_entry_field_refuses_the_build → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_a_misspelled_entry_field_refuses_the_build → load_dispatch_manifest → declaration_origin
Source · 16 lines
def test_a_misspelled_entry_field_refuses_the_build() -> None:
    """One level down, and worse than "declared nothing": `key_arg_idx` silently
    defaults the key to argument 0, so a typo does not produce NO dataflow, it
    produces the WRONG dataflow — a specific, real claim invented from a slip."""
    with pytest.raises(DeclarationError) as exc:
        load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "w", "key_arg_idx": 2}]})
    assert "'key_arg_idx'" in str(exc.value)
    assert "key_arg_index" in str(exc.value)
    with pytest.raises(DeclarationError):
        load_dispatch_manifest({"interfaces": [{"interface": "I", "bind": "C"}]})
    with pytest.raises(DeclarationError):
        load_dispatch_manifest(
            {"dispatch_tables": [{"register_via": "r", "dispatch_via": "d", "handler": 0}]}
        )

Activity · 8 steps
lines 768–768with pytest.raises(DeclarationError) as exclines 769–769load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "w", "key_arg_idx": 2}]})lines 770–770assert "'key_arg_idx'" in str(exc.value)lines 771–771assert "key_arg_index" in str(exc.value)lines 772–772with pytest.raises(DeclarationError)lines 773–773load_dispatch_manifest({"interfaces": [{"interface": "I", "bind": "C"}]})lines 774–774with pytest.raises(DeclarationError)lines 775–777load_dispatch_manifest( {"dispatch_tables": [{"register_via": "r", "dispatch_via": "d", "handler": 0}]} )

test_a_misspelled_section_refuses_the_build

None test_dispatch.test_a_misspelled_section_refuses_the_build(Path tmp_path)

The hole in the fail-closed promise, closed. An ABSENT section reads as "declared nothing", so every plausible singular/plural slip — `interface:`, `dispatch_table:`, `shared_key_wrapper:` — used to parse to an empty manifest and build GREEN while the author's declaration did nothing, which is indistinguishable from a repo that never declared anything.

tests/test_dispatch.py:750

Checks

  • assert repr(typo) in message
  • assert "interfaces" in message, "the error must name the allowed sections"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_misspelled_section_refuses_the_build → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_a_misspelled_section_refuses_the_build → load_dispatch_manifest → declaration_origin
Source · 14 lines
def test_a_misspelled_section_refuses_the_build(tmp_path: Path) -> None:
    """The hole in the fail-closed promise, closed. An ABSENT section reads as
    "declared nothing", so every plausible singular/plural slip —
    `interface:`, `dispatch_table:`, `shared_key_wrapper:` — used to parse to an
    empty manifest and build GREEN while the author's declaration did nothing,
    which is indistinguishable from a repo that never declared anything."""
    for typo in ("interface", "dispatch_table", "shared_key_wrapper", "interfacs"):
        with pytest.raises(DeclarationError) as exc:
            load_dispatch_manifest({typo: [{"interface": "I", "boundary": True}]})
        message = str(exc.value)
        assert repr(typo) in message
        assert "interfaces" in message, "the error must name the allowed sections"

Activity · 6 steps
lines 756–756◇ for typo in ("interface", "dispatch_table", "shared_key_wrapper", "interfacs")lines 757–757with pytest.raises(DeclarationError) as exclines 758–758load_dispatch_manifest({typo: [{"interface": "I", "boundary": True}]})lines 759–759message = str(exc.value)lines 760–760assert repr(typo) in messagelines 761–761assert "interfaces" in message, "the error must name the allowed sections"

test_a_section_that_is_not_a_list_of_mappings_refuses_the_build

None test_dispatch.test_a_section_that_is_not_a_list_of_mappings_refuses_the_build()

A section present but mis-SHAPED is a typo, not a declaration. Degrading it to "declared nothing" leaves the author with a green build and the gap they were closing still open.

tests/test_dispatch.py:807

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_section_that_is_not_a_list_of_mappings_refuses_the_build → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_a_section_that_is_not_a_list_of_mappings_refuses_the_build → load_dispatch_manifest → declaration_origin
Source · 9 lines
def test_a_section_that_is_not_a_list_of_mappings_refuses_the_build() -> None:
    """A section present but mis-SHAPED is a typo, not a declaration. Degrading it
    to "declared nothing" leaves the author with a green build and the gap they
    were closing still open."""
    for bad in ("ILinkPort", {"interface": "I"}, ["ILinkPort"], [None]):
        with pytest.raises(DeclarationError, match="must be a list of mappings"):
            load_dispatch_manifest({"interfaces": bad})

Activity · 3 steps
lines 811–811◇ for bad in ("ILinkPort", {"interface": "I"}, ["ILinkPort"], [None])lines 812–812with pytest.raises(DeclarationError, match="must be a list of mappings")lines 813–813load_dispatch_manifest({"interfaces": bad})

test_a_standalone_manifest_file_and_a_declaration_section_share_one_parser

None test_dispatch.test_a_standalone_manifest_file_and_a_declaration_section_share_one_parser(Path tmp_path)

Both delivery routes converge on one parser, so `--dispatch` and the `.clew.yaml` `dispatch:` section are guaranteed to have exactly one format — and one set of error messages, which name the FILE when there is one.

tests/test_dispatch.py:816

Checks

  • assert len(from_file.interfaces) == len(from_section.interfaces) == 1
  • assert from_file.interfaces[0].binds == from_section.interfaces[0].binds
  • assert str(bad) in str(exc.value), "a file-sourced error must name the file to edit"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_standalone_manifest_file_and_a_declaration_section_share_one_parser → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_a_standalone_manifest_file_and_a_declaration_section_share_one_parser → load_dispatch_manifest → declaration_origin
Source · 25 lines
def test_a_standalone_manifest_file_and_a_declaration_section_share_one_parser(
    tmp_path: Path,
) -> None:
    """Both delivery routes converge on one parser, so `--dispatch` and the
    `.clew.yaml` `dispatch:` section are guaranteed to have exactly one format
    — and one set of error messages, which name the FILE when there is one."""
    path = tmp_path / "dispatch.yaml"
    path.write_text(
        "interfaces:\n  - interface: ILinkPort\n    binds: SerialLinkPort\n",
        encoding="utf-8",
    )
    from_file = load_dispatch_manifest(path)
    from_section = load_dispatch_manifest(
        {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]}
    )
    assert len(from_file.interfaces) == len(from_section.interfaces) == 1
    assert from_file.interfaces[0].binds == from_section.interfaces[0].binds

    bad = tmp_path / "bad.yaml"
    bad.write_text("interfaces:\n  - binds: OnlyThis\n", encoding="utf-8")
    with pytest.raises(DeclarationError) as exc:
        load_dispatch_manifest(bad)
    assert str(bad) in str(exc.value), "a file-sourced error must name the file to edit"

Activity · 11 steps
lines 822–822path = tmp_path / "dispatch.yaml"lines 823–826path.write_text( "interfaces:\n - interface: ILinkPort\n binds: SerialLinkPort\n", encoding="utf-8", )lines 827–827from_file = load_dispatch_manifest(path)lines 828–830from_section = load_dispatch_manifest( {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]} )lines 831–831assert len(from_file.interfaces) == len(from_section.interfaces) == 1lines 832–832assert from_file.interfaces[0].binds == from_section.interfaces[0].bindslines 834–834bad = tmp_path / "bad.yaml"lines 835–835bad.write_text("interfaces:\n - binds: OnlyThis\n", encoding="utf-8")lines 836–836with pytest.raises(DeclarationError) as exclines 837–837load_dispatch_manifest(bad)lines 838–838assert str(bad) in str(exc.value), "a file-sourced error must name the file to edit"

test_a_typod_direction_refuses_instead_of_filing_the_opposite_role

None test_dispatch.test_a_typod_direction_refuses_instead_of_filing_the_opposite_role()

A `direction` of 'wrtie' normalized to a reader would invert the dataflow the entry exists to reveal, and the build would still succeed. The message names the origin, the token and the full allowed set.

tests/test_dispatch.py:795

Checks

  • assert ".clew.yaml [dispatch]" in message
  • assert "'wrtie'" in message
  • assert "write, read" in message

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_a_typod_direction_refuses_instead_of_filing_the_opposite_role → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_a_typod_direction_refuses_instead_of_filing_the_opposite_role → load_dispatch_manifest → declaration_origin
Source · 12 lines
def test_a_typod_direction_refuses_instead_of_filing_the_opposite_role() -> None:
    """A `direction` of 'wrtie' normalized to a reader would invert the dataflow
    the entry exists to reveal, and the build would still succeed. The message
    names the origin, the token and the full allowed set."""
    with pytest.raises(DeclarationError) as exc:
        load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "w", "direction": "wrtie"}]})
    message = str(exc.value)
    assert ".clew.yaml [dispatch]" in message
    assert "'wrtie'" in message
    assert "write, read" in message

Activity · 6 steps
lines 799–799with pytest.raises(DeclarationError) as exclines 800–800load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "w", "direction": "wrtie"}]})lines 801–801message = str(exc.value)lines 802–802assert ".clew.yaml [dispatch]" in messagelines 803–803assert "'wrtie'" in messagelines 804–804assert "write, read" in message

test_ambiguous_handler_name_records_NOTHING_rather_than_guessing

None test_dispatch.test_ambiguous_handler_name_records_NOTHING_rather_than_guessing(Path tmp_path)

gh#347, reaching the DECLARED dispatch layer through the shared resolution helper — and it belongs here as much as in the ast layer. A dispatch manifest declares that a handler is registered; the handler is named at the registration SITE, so when that name matches two indexed functions the declaration has told us a dispatch exists and NOT which target it reaches. Emitting both asserted two dispatches where one was registered.

tests/test_dispatch.py:490

Checks

  • assert _declared_edges(db) == [], ("two same-named handlers means the target is unknown; one registration must not " "produce two dispatch edges" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_ambiguous_handler_name_records_NOTHING_rather_than_guessing → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 45 lines
def test_ambiguous_handler_name_records_NOTHING_rather_than_guessing(
    tmp_path: Path,
) -> None:
    """gh#347, reaching the DECLARED dispatch layer through the shared resolution helper — and
    it belongs here as much as in the ast layer. A dispatch manifest declares that a handler is
    registered; the handler is named at the registration SITE, so when that name matches two
    indexed functions the declaration has told us a dispatch exists and NOT which target it
    reaches. Emitting both asserted two dispatches where one was registered.

    THE OLD NAME SAID "degrades to fuzzy", which was a euphemism for "emits all of them".

    Its original reasoning is now stronger rather than discarded: it argued that fuzzy edges are
    skipped by the reachability BFS and thread membership, "so a guess cannot promote itself
    into the liveness answer". Under this rule there is no guess in the table at all, so the
    protection no longer depends on every downstream consumer remembering to filter — which is
    what `dossier`/`callers` failed to do (gh#26, three of four reported callers fabricated).

    WHAT IS DELIBERATELY LOST: a repo with two same-named handlers gets no declared-dispatch
    edge for that registration. That is the correct answer to "which one" being unknown, and the
    manifest can name the handler unambiguously if the author wants the edge."""
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")
    duplicated = [
        *_BROKER_FUNCTIONS,
        (5, "stage_shim", "void other::stage_shim(int key)", 20, 20),
    ]
    db = _make_db(tmp_path, duplicated)
    manifest = load_dispatch_manifest(
        {
            "dispatch_tables": [
                {"register_via": "register_dispatcher", "dispatch_via": "Broker::fan"}
            ]
        }
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _declared_edges(db) == [], (
        "two same-named handlers means the target is unknown; one registration must not "
        "produce two dispatch edges"
    )


# ─── #37: argument-keyed shared-key wrappers ─────────────────────────────────

Activity · 7 steps
lines 510–510(tmp_path / "src").mkdir()lines 511–511(tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")lines 512–515duplicated = [ *_BROKER_FUNCTIONS, (5, "stage_shim", "void other::stage_shim(int key)", 20, 20), ]lines 516–516db = _make_db(tmp_path, duplicated)lines 517–523manifest = load_dispatch_manifest( { "dispatch_tables": [ {"register_via": "register_dispatcher", "dispatch_via": "Broker::fan"} ] } )lines 524–524import_declared_dispatch_edges(db, tmp_path, manifest)lines 526–529assert _declared_edges(db) == [], ( "two same-named handlers means the target is unknown; one registration must not " "produce two dispatch edges" )

test_ambiguous_or_absent_class_is_skipped_not_guessed

None test_dispatch.test_ambiguous_or_absent_class_is_skipped_not_guessed(Path tmp_path)

Two indexed compounds sharing a tail would have DIFFERENT implementors, so picking one fabricates a call graph; and a declared type that is out of this build's scope (conditional compilation) must not fail a build, because a declaration is a standing statement across configurations.

tests/test_dispatch.py:388

Checks

  • assert _declared_edges(db) == []
  • assert _declared_edges(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_ambiguous_or_absent_class_is_skipped_not_guessed → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_ambiguous_or_absent_class_is_skipped_not_guessed → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_ambiguous_or_absent_class_is_skipped_not_guessed → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 24 lines
def test_ambiguous_or_absent_class_is_skipped_not_guessed(tmp_path: Path) -> None:
    """Two indexed compounds sharing a tail would have DIFFERENT implementors, so
    picking one fabricates a call graph; and a declared type that is out of this
    build's scope (conditional compilation) must not fail a build, because a
    declaration is a standing statement across configurations."""
    compounds = dict(_IFACE_COMPOUNDS)
    compounds["other::ILinkPort"] = []
    db = _make_db(tmp_path, _IFACE_FUNCTIONS, compounds=compounds, call_edges=[(12, 10)])
    ambiguous = load_dispatch_manifest(
        {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]}
    )
    import_declared_dispatch_edges(db, tmp_path, ambiguous)
    assert _declared_edges(db) == []

    absent = load_dispatch_manifest(
        {"interfaces": [{"interface": "INotIndexed", "binds": "AlsoAbsent"}]}
    )
    import_declared_dispatch_edges(db, tmp_path, absent)
    assert _declared_edges(db) == []


# ─── #30: dispatch tables ────────────────────────────────────────────────────

Activity · 9 steps
lines 393–393compounds = dict(_IFACE_COMPOUNDS)lines 394–394compounds["other::ILinkPort"] = []lines 395–395db = _make_db(tmp_path, _IFACE_FUNCTIONS, compounds=compounds, call_edges=[(12, 10)])lines 396–398ambiguous = load_dispatch_manifest( {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]} )lines 399–399import_declared_dispatch_edges(db, tmp_path, ambiguous)lines 400–400assert _declared_edges(db) == []lines 402–404absent = load_dispatch_manifest( {"interfaces": [{"interface": "INotIndexed", "binds": "AlsoAbsent"}]} )lines 405–405import_declared_dispatch_edges(db, tmp_path, absent)lines 406–406assert _declared_edges(db) == []

test_an_undeclared_alias_spelling_is_not_normalized

None test_dispatch.test_an_undeclared_alias_spelling_is_not_normalized(Path tmp_path)

THE NEGATIVE CONTROL for the pair above: without the declaration the `EXAMPLE_KEY_` site is NOT stripped, so the write half keys on `EXAMPLE_KEY_WIDGET_ENABLED`, never meets the reader's `WIDGET_ENABLED`, and no edge forms. Without this, the previous test could be passing because some other mechanism strips unknown prefixes.

tests/test_dispatch.py:705

Show on the map →

Called by none

Calls _key_edges, _wrapper_manifest, import_shared_key_edges_inferred, shared_key_document

Checks

  • assert _key_edges(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-004measuredtest_an_undeclared_alias_spelling_is_not_normalized → shared_key_document
REQ-DDB-SCHEMA-005measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_an_undeclared_alias_spelling_is_not_normalized → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_an_undeclared_alias_spelling_is_not_normalized → _wrapper_manifest → load_dispatch_manifest → declaration_origin
Source · 30 lines
def test_an_undeclared_alias_spelling_is_not_normalized(tmp_path: Path) -> None:
    """THE NEGATIVE CONTROL for the pair above: without the declaration the
    `EXAMPLE_KEY_` site is NOT stripped, so the write half keys on
    `EXAMPLE_KEY_WIDGET_ENABLED`, never meets the reader's `WIDGET_ENABLED`, and no
    edge forms. Without this, the previous test could be passing because some other
    mechanism strips unknown prefixes.
    """
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "dm.c").write_text(
        _WRAPPER_SRC.replace("DM_KEY_WIDGET_ENABLED", "EXAMPLE_KEY_WIDGET_ENABLED"),
        encoding="utf-8",
    )
    db = _make_db(
        tmp_path,
        [
            (1, "report_stall_state", "void report_stall_state(int v)", 1, 3),
            (2, "read_widget_enabled", "int read_widget_enabled(void)", 5, 7),
        ],
        rel_path="src/dm.c",
    )
    import_shared_key_edges_inferred(
        db, tmp_path, None, None, shared_key_document(_wrapper_manifest())
    )

    assert _key_edges(db) == []


# ─── fail closed ─────────────────────────────────────────────────────────────

Activity · 5 steps
lines 712–712(tmp_path / "src").mkdir()lines 713–716(tmp_path / "src" / "dm.c").write_text( _WRAPPER_SRC.replace("DM_KEY_WIDGET_ENABLED", "EXAMPLE_KEY_WIDGET_ENABLED"), encoding="utf-8", )lines 717–724db = _make_db( tmp_path, [ (1, "report_stall_state", "void report_stall_state(int v)", 1, 3), (2, "read_widget_enabled", "int read_widget_enabled(void)", 5, 7), ], rel_path="src/dm.c", )lines 725–727import_shared_key_edges_inferred( db, tmp_path, None, None, shared_key_document(_wrapper_manifest()) )lines 729–729assert _key_edges(db) == []

test_boundary_flag_records_the_second_terminus_kind

None test_dispatch.test_boundary_flag_records_the_second_terminus_kind(Path tmp_path)

`external_boundaries` recorded exactly ONE shape — a function pointer forwarded to an out-of-repo registrar — which is why an interface-HAL C++ codebase measured zero termini with the detector working correctly. `boundary: true` records the other shape: a virtual call whose implementor lives outside the index, which only the author can assert.

tests/test_dispatch.py:363

Show on the map →

Called by none

Calls _boundaries, _declared_edges, import_declared_dispatch_edges, load_dispatch_manifest

Checks

  • assert _boundaries(db) == [
  • assert _declared_edges(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_boundary_flag_records_the_second_terminus_kind → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_boundary_flag_records_the_second_terminus_kind → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_boundary_flag_records_the_second_terminus_kind → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 25 lines
def test_boundary_flag_records_the_second_terminus_kind(tmp_path: Path) -> None:
    """`external_boundaries` recorded exactly ONE shape — a function pointer
    forwarded to an out-of-repo registrar — which is why an interface-HAL C++ codebase
    measured zero termini with the detector working correctly. `boundary: true`
    records the other shape: a virtual call whose implementor lives outside the
    index, which only the author can assert."""
    db = _make_db(tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, call_edges=[(12, 10)])
    manifest = load_dispatch_manifest(
        {"interfaces": [{"interface": "ILinkPort", "boundary": True}]}
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _boundaries(db) == [
        (
            12,
            "ILinkPort::transmit",
            BOUNDARY_KIND_INTERFACE,
            CALL_SOURCE_DECLARED_DISPATCH,
            BOUNDARY_STRENGTH_HIGH,
        )
    ]
    # A boundary-only entry declares no implementor, so it must add no call edge.
    assert _declared_edges(db) == []

Activity · 5 steps
lines 369–369db = _make_db(tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, call_edges=[(12, 10)])lines 370–372manifest = load_dispatch_manifest( {"interfaces": [{"interface": "ILinkPort", "boundary": True}]} )lines 373–373import_declared_dispatch_edges(db, tmp_path, manifest)lines 375–383assert _boundaries(db) == [ ( 12, "ILinkPort::transmit", BOUNDARY_KIND_INTERFACE, CALL_SOURCE_DECLARED_DISPATCH, BOUNDARY_STRENGTH_HIGH, ) ]lines 385–385assert _declared_edges(db) == []

test_declared_dispatch_table_connects_the_dispatcher_to_its_handlers

None test_dispatch.test_declared_dispatch_table_connects_the_dispatcher_to_its_handlers(Path tmp_path)

tests/test_dispatch.py:412

Checks

  • assert (3, 2, CALL_MATCH_RESOLVED) in _declared_edges(db)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_declared_dispatch_table_connects_the_dispatcher_to_its_handlers → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 30 lines
def test_declared_dispatch_table_connects_the_dispatcher_to_its_handlers(
    tmp_path: Path,
) -> None:
    """#30's shape, which Layer 4 structurally cannot reach: Layer 4 keys on a
    `GLOBAL = PARAM;` assignment, while a container-held pointer is registered by
    a METHOD CALL whose callee is a `field_expression` and whose argument is a
    `pointer_expression`. Declaring `register_via` + `dispatch_via` names both
    endpoints an edge needs, and the harvested registration site supplies the
    handler."""
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")
    db = _make_db(tmp_path, _BROKER_FUNCTIONS)
    manifest = load_dispatch_manifest(
        {
            "dispatch_tables": [
                {
                    "register_via": "register_dispatcher",
                    "handler_arg_index": 0,
                    "dispatch_via": "Broker::fan",
                }
            ]
        }
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    # `Broker::fan` (rowid 3) now reaches `stage_shim` (rowid 2), so the
    # membership and reachability BFS can flow across the seam.
    assert (3, 2, CALL_MATCH_RESOLVED) in _declared_edges(db)

Activity · 6 steps
lines 421–421(tmp_path / "src").mkdir()lines 422–422(tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")lines 423–423db = _make_db(tmp_path, _BROKER_FUNCTIONS)lines 424–434manifest = load_dispatch_manifest( { "dispatch_tables": [ { "register_via": "register_dispatcher", "handler_arg_index": 0, "dispatch_via": "Broker::fan", } ] } )lines 435–435import_declared_dispatch_edges(db, tmp_path, manifest)lines 439–439assert (3, 2, CALL_MATCH_RESOLVED) in _declared_edges(db)

test_declared_interface_binding_continues_the_chain_to_the_implementor

None test_dispatch.test_declared_interface_binding_continues_the_chain_to_the_implementor(Path tmp_path)

The whole point of #35. A virtual call DOES land on the interface method — it just stops there, so `StageDriver::emit_setpoint` reads as a zero-callee leaf even though its body crosses the HAL. Declaring the binding adds the sibling edge to the concrete override, and it carries the `declared_dispatch` provenance so a consumer can always ask whether the edge would exist without the manifest.

tests/test_dispatch.py:229

Checks

  • assert _declared_edges(db) == [(12, 11, CALL_MATCH_RESOLVED)]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_declared_interface_binding_continues_the_chain_to_the_implementor → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_declared_interface_binding_continues_the_chain_to_the_implementor → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_declared_interface_binding_continues_the_chain_to_the_implementor → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 24 lines
def test_declared_interface_binding_continues_the_chain_to_the_implementor(
    tmp_path: Path,
) -> None:
    """The whole point of #35. A virtual call DOES land on the interface method —
    it just stops there, so `StageDriver::emit_setpoint` reads as a zero-callee
    leaf even though its body crosses the HAL. Declaring the binding adds the
    sibling edge to the concrete override, and it carries the `declared_dispatch`
    provenance so a consumer can always ask whether the edge would exist without
    the manifest."""
    db = _make_db(
        tmp_path,
        _IFACE_FUNCTIONS,
        compounds=_IFACE_COMPOUNDS,
        reimplements=[(11, 10)],
        call_edges=[(12, 10)],
    )
    manifest = load_dispatch_manifest(
        {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]}
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _declared_edges(db) == [(12, 11, CALL_MATCH_RESOLVED)]

Activity · 4 steps
lines 238–244db = _make_db( tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, reimplements=[(11, 10)], call_edges=[(12, 10)], )lines 245–247manifest = load_dispatch_manifest( {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]} )lines 248–248import_declared_dispatch_edges(db, tmp_path, manifest)lines 250–250assert _declared_edges(db) == [(12, 11, CALL_MATCH_RESOLVED)]

test_declared_key_wrapper_produces_the_dataflow_edge

None test_dispatch.test_declared_key_wrapper_produces_the_dataflow_edge(Path tmp_path)

tests/test_dispatch.py:577

Checks

  • assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-004measuredtest_declared_key_wrapper_produces_the_dataflow_edge → load_dispatch_manifest
REQ-DDB-SCHEMA-005measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_declared_key_wrapper_produces_the_dataflow_edge → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_declared_key_wrapper_produces_the_dataflow_edge → load_dispatch_manifest → declaration_origin
Source · 20 lines
def test_declared_key_wrapper_produces_the_dataflow_edge(tmp_path: Path) -> None:
    """#37 end to end. The write half's key is an ARGUMENT to a generic helper and
    the read half's is embedded in the accessor NAME, so neither the literal nor
    the name-embedded inference joins them. Declaring the wrapper feeds the SAME
    Layer 5a matcher through `extra`, and the `DM_KEY_` alias normalization is
    what makes the two spellings of one key meet — without it the declaration
    yields an orphan write-half and no edge at all."""
    db = _wrapper_db(tmp_path)
    manifest = load_dispatch_manifest(
        {
            "shared_key_wrappers": [
                {"pattern": "store_bool_on_delta", "key_arg_index": 0, "direction": "write"}
            ]
        }
    )
    import_shared_key_edges_inferred(db, tmp_path, None, None, shared_key_document(manifest))

    assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

Activity · 4 steps
lines 584–584db = _wrapper_db(tmp_path)lines 585–591manifest = load_dispatch_manifest( { "shared_key_wrappers": [ {"pattern": "store_bool_on_delta", "key_arg_index": 0, "direction": "write"} ] } )lines 592–592import_shared_key_edges_inferred(db, tmp_path, None, None, shared_key_document(manifest))lines 594–594assert _key_edges(db) == [(1, 2, "WIDGET_ENABLED")]

test_declared_wrapper_direction_selects_the_matcher_list

None test_dispatch.test_declared_wrapper_direction_selects_the_matcher_list(Path tmp_path)

`direction` picks WHICH accessor list the wrapper joins. Filed as a READER, the same helper produces a read half with no write half to meet — so a typo'd direction would invert the dataflow the entry exists to reveal, which is exactly why the value is vocabulary-validated rather than defaulted.

tests/test_dispatch.py:608

Checks

  • assert _key_edges(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-004measuredtest_declared_wrapper_direction_selects_the_matcher_list → load_dispatch_manifest
REQ-DDB-SCHEMA-005measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_declared_wrapper_direction_selects_the_matcher_list → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_declared_wrapper_direction_selects_the_matcher_list → load_dispatch_manifest → declaration_origin
Source · 18 lines
def test_declared_wrapper_direction_selects_the_matcher_list(tmp_path: Path) -> None:
    """`direction` picks WHICH accessor list the wrapper joins. Filed as a READER,
    the same helper produces a read half with no write half to meet — so a typo'd
    direction would invert the dataflow the entry exists to reveal, which is
    exactly why the value is vocabulary-validated rather than defaulted."""
    db = _wrapper_db(tmp_path)
    manifest = load_dispatch_manifest(
        {
            "shared_key_wrappers": [
                {"pattern": "store_bool_on_delta", "key_arg_index": 0, "direction": "read"}
            ]
        }
    )
    import_shared_key_edges_inferred(db, tmp_path, None, None, shared_key_document(manifest))

    assert _key_edges(db) == []

Activity · 4 steps
lines 613–613db = _wrapper_db(tmp_path)lines 614–620manifest = load_dispatch_manifest( { "shared_key_wrappers": [ {"pattern": "store_bool_on_delta", "key_arg_index": 0, "direction": "read"} ] } )lines 621–621import_shared_key_edges_inferred(db, tmp_path, None, None, shared_key_document(manifest))lines 623–623assert _key_edges(db) == []

test_inherited_members_do_not_pair_the_interface_with_itself

None test_dispatch.test_inherited_members_do_not_pair_the_interface_with_itself(Path tmp_path)

doxygen lists a base class's members under the DERIVED compound too, with the BASE's rowids — so pairing on membership alone emits `ILinkPort::~ILinkPort -> ILinkPort::~ILinkPort`. The `definition` boundary filter is what keeps a compound's OWNED members only, and without it a declaration fabricates self-recursion on every inherited member.

tests/test_dispatch.py:310

Checks

  • assert (13, 13, CALL_MATCH_RESOLVED) not in edges
  • assert all(caller != callee for caller, callee, _ in edges)
  • assert (12, 11, CALL_MATCH_RESOLVED) in edges

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_inherited_members_do_not_pair_the_interface_with_itself → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_inherited_members_do_not_pair_the_interface_with_itself → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_inherited_members_do_not_pair_the_interface_with_itself → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_inherited_members_do_not_pair_the_interface_with_itself → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_inherited_members_do_not_pair_the_interface_with_itself → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_inherited_members_do_not_pair_the_interface_with_itself → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_inherited_members_do_not_pair_the_interface_with_itself → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_inherited_members_do_not_pair_the_interface_with_itself → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_inherited_members_do_not_pair_the_interface_with_itself → all
Source · 27 lines
def test_inherited_members_do_not_pair_the_interface_with_itself(tmp_path: Path) -> None:
    """doxygen lists a base class's members under the DERIVED compound too, with
    the BASE's rowids — so pairing on membership alone emits
    `ILinkPort::~ILinkPort -> ILinkPort::~ILinkPort`. The `definition`
    boundary filter is what keeps a compound's OWNED members only, and without it
    a declaration fabricates self-recursion on every inherited member."""
    db = _make_db(
        tmp_path,
        _IFACE_FUNCTIONS,
        compounds=_IFACE_COMPOUNDS,
        # No reimplements rows: force the same-name fallback, which is the path
        # that can see the inherited destructor as its own override.
        call_edges=[(12, 10), (12, 13)],
    )
    manifest = load_dispatch_manifest(
        {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]}
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    edges = _declared_edges(db)
    assert (13, 13, CALL_MATCH_RESOLVED) not in edges
    assert all(caller != callee for caller, callee, _ in edges)
    # The same-name fallback still recovers the real override without doxygen's
    # reimplements relation (older doxygen, and C struct-of-fnptr "interfaces").
    assert (12, 11, CALL_MATCH_RESOLVED) in edges

Activity · 7 steps
lines 316–323db = _make_db( tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, # No reimplements rows: force the same-name fallback, which is the path # that can see the inherited destructor as its own override. call_edges=[(12, 10), (12, 13)], )lines 324–326manifest = load_dispatch_manifest( {"interfaces": [{"interface": "ILinkPort", "binds": "SerialLinkPort"}]} )lines 327–327import_declared_dispatch_edges(db, tmp_path, manifest)lines 329–329edges = _declared_edges(db)lines 330–330assert (13, 13, CALL_MATCH_RESOLVED) not in edgeslines 331–331assert all(caller != callee for caller, callee, _ in edges)lines 334–334assert (12, 11, CALL_MATCH_RESOLVED) in edges

test_method_filter_narrows_the_binding

None test_dispatch.test_method_filter_narrows_the_binding(Path tmp_path)

`methods:` restricts an entry to the named methods. A HAL interface whose implementor also overrides lifecycle members should be bindable on the one method that is the seam.

tests/test_dispatch.py:337

Checks

  • assert _declared_edges(db) == [(12, 11, CALL_MATCH_RESOLVED)]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_method_filter_narrows_the_binding → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_method_filter_narrows_the_binding → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_method_filter_narrows_the_binding → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 26 lines
def test_method_filter_narrows_the_binding(tmp_path: Path) -> None:
    """`methods:` restricts an entry to the named methods. A HAL interface whose
    implementor also overrides lifecycle members should be bindable on the one
    method that is the seam."""
    db = _make_db(
        tmp_path,
        _IFACE_FUNCTIONS,
        compounds=_IFACE_COMPOUNDS,
        call_edges=[(12, 10), (12, 13)],
    )
    manifest = load_dispatch_manifest(
        {
            "interfaces": [
                {
                    "interface": "ILinkPort",
                    "binds": "SerialLinkPort",
                    "methods": ["transmit"],
                }
            ]
        }
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _declared_edges(db) == [(12, 11, CALL_MATCH_RESOLVED)]

Activity · 4 steps
lines 341–346db = _make_db( tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, call_edges=[(12, 10), (12, 13)], )lines 347–357manifest = load_dispatch_manifest( { "interfaces": [ { "interface": "ILinkPort", "binds": "SerialLinkPort", "methods": ["transmit"], } ] } )lines 358–358import_declared_dispatch_edges(db, tmp_path, manifest)lines 360–360assert _declared_edges(db) == [(12, 11, CALL_MATCH_RESOLVED)]

test_no_declaration_writes_nothing_at_all

None test_dispatch.test_no_declaration_writes_nothing_at_all(Path tmp_path)

The state every repo is in today. An undeclared repo has no indirection convention clew may assume, so zero synthetic rows is a correct negative — and every existing build must keep reproducing it exactly.

tests/test_dispatch.py:735

Show on the map →

Called by none

Calls _boundaries, _declared_edges, import_declared_dispatch_edges, load_dispatch_manifest

Checks

  • assert manifest.is_empty()
  • assert _declared_edges(db) == []
  • assert _boundaries(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011inferredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003inferredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003inferredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_no_declaration_writes_nothing_at_all → load_dispatch_manifest
REQ-DDB-SCHEMA-007inferredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_no_declaration_writes_nothing_at_all → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_no_declaration_writes_nothing_at_all → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 15 lines
def test_no_declaration_writes_nothing_at_all(tmp_path: Path) -> None:
    """The state every repo is in today. An undeclared repo has no indirection
    convention clew may assume, so zero synthetic rows is a correct negative —
    and every existing build must keep reproducing it exactly."""
    db = _make_db(tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, call_edges=[(12, 10)])
    manifest = load_dispatch_manifest(None)
    assert manifest.is_empty()
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _declared_edges(db) == []
    # Not even the terminus table is created: the stage returns before touching
    # the database at all.
    assert _boundaries(db) == []

Activity · 6 steps
lines 739–739db = _make_db(tmp_path, _IFACE_FUNCTIONS, compounds=_IFACE_COMPOUNDS, call_edges=[(12, 10)])lines 740–740manifest = load_dispatch_manifest(None)lines 741–741assert manifest.is_empty()lines 742–742import_declared_dispatch_edges(db, tmp_path, manifest)lines 744–744assert _declared_edges(db) == []lines 747–747assert _boundaries(db) == []

test_registration_site_is_harvested_but_is_not_itself_a_call_edge

None test_dispatch.test_registration_site_is_harvested_but_is_not_itself_a_call_edge(Path tmp_path)

`wire_up` STORES the handler; it does not invoke it. The registration site is what tells the stage which handler the table holds, but synthesizing `wire_up -> stage_shim` would assert a call that never happens, and an invented call edge is worse than a missing one — it feeds the same liveness and chain-trace surfaces a real edge does. Only the declared DISPATCHER gets the edge.

tests/test_dispatch.py:442

Checks

  • assert edges == [(3, 2, CALL_MATCH_RESOLVED)]
  • assert all(caller != 4 for caller, _callee, _conf in edges), ("the registrar's enclosing function must not be given a synthetic call edge" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_registration_site_is_harvested_but_is_not_itself_a_call_edge → all
Source · 28 lines
def test_registration_site_is_harvested_but_is_not_itself_a_call_edge(
    tmp_path: Path,
) -> None:
    """`wire_up` STORES the handler; it does not invoke it. The registration site
    is what tells the stage which handler the table holds, but synthesizing
    `wire_up -> stage_shim` would assert a call that never happens, and
    an invented call edge is worse than a missing one — it feeds the same
    liveness and chain-trace surfaces a real edge does. Only the declared
    DISPATCHER gets the edge."""
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")
    db = _make_db(tmp_path, _BROKER_FUNCTIONS)
    manifest = load_dispatch_manifest(
        {
            "dispatch_tables": [
                {"register_via": "register_dispatcher", "dispatch_via": "Broker::fan"}
            ]
        }
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    edges = _declared_edges(db)
    assert edges == [(3, 2, CALL_MATCH_RESOLVED)]
    assert all(caller != 4 for caller, _callee, _conf in edges), (
        "the registrar's enclosing function must not be given a synthetic call edge"
    )

Activity · 8 steps
lines 451–451(tmp_path / "src").mkdir()lines 452–452(tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")lines 453–453db = _make_db(tmp_path, _BROKER_FUNCTIONS)lines 454–460manifest = load_dispatch_manifest( { "dispatch_tables": [ {"register_via": "register_dispatcher", "dispatch_via": "Broker::fan"} ] } )lines 461–461import_declared_dispatch_edges(db, tmp_path, manifest)lines 463–463edges = _declared_edges(db)lines 464–464assert edges == [(3, 2, CALL_MATCH_RESOLVED)]lines 465–467assert all(caller != 4 for caller, _callee, _conf in edges), ( "the registrar's enclosing function must not be given a synthetic call edge" )

test_shared_key_document_is_none_when_nothing_contributes

None test_dispatch.test_shared_key_document_is_none_when_nothing_contributes()

A manifest declaring only interfaces or tables must leave the shared-key stage's inputs — and therefore its cache key — completely untouched.

tests/test_dispatch.py:626

Checks

  • assert shared_key_document(only_interfaces) is None
  • assert shared_key_document(empty_manifest()) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-SCHEMA-004measuredtest_shared_key_document_is_none_when_nothing_contributes → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_shared_key_document_is_none_when_nothing_contributes → load_dispatch_manifest → declaration_origin
Source · 8 lines
def test_shared_key_document_is_none_when_nothing_contributes() -> None:
    """A manifest declaring only interfaces or tables must leave the shared-key
    stage's inputs — and therefore its cache key — completely untouched."""
    only_interfaces = load_dispatch_manifest({"interfaces": [{"interface": "I", "boundary": True}]})
    assert shared_key_document(only_interfaces) is None
    assert shared_key_document(empty_manifest()) is None

Activity · 3 steps
lines 629–629only_interfaces = load_dispatch_manifest({"interfaces": [{"interface": "I", "boundary": True}]})lines 630–630assert shared_key_document(only_interfaces) is Nonelines 631–631assert shared_key_document(empty_manifest()) is None

test_the_declaration_route_reaches_the_stage_and_the_flag_wins

None test_dispatch.test_the_declaration_route_reaches_the_stage_and_the_flag_wins(Path tmp_path)

The reason a `dispatch:` section exists at all. The MCP server passes NO manifest arguments — the repo root is the only route it needs — so a convention reachable solely by CLI flag is invisible on the primary surface and the built-in defaults become the whole policy, which is precisely the hardcoded-only assumption the no-hardcoding mandate forbids. Discovery from the repo root is what closes that, and an explicit flag still wins because the file is a standing statement while the flag is a deliberate one-off.

tests/test_dispatch.py:841

Show on the map →

Called by none

Calls _declared_or_flag, load_declaration, load_dispatch_manifest

Checks

  • assert SECTION_DISPATCH in decl
  • assert [b.interface for b in from_declaration.interfaces] == ["FromDeclaration"]
  • assert [b.interface for b in from_flag.interfaces] == ["FromFlag"]
  • assert load_dispatch_manifest(_declared_or_flag(None, {}, SECTION_DISPATCH)).is_empty()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_declaration_route_reaches_the_stage_and_the_flag_wins → load_declaration
REQ-DDB-GUARD-012inferredtest_the_declaration_route_reaches_the_stage_and_the_flag_wins → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node
REQ-DDB-SCHEMA-004measuredtest_the_declaration_route_reaches_the_stage_and_the_flag_wins → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_the_declaration_route_reaches_the_stage_and_the_flag_wins → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_the_declaration_route_reaches_the_stage_and_the_flag_wins → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all
Source · 29 lines
def test_the_declaration_route_reaches_the_stage_and_the_flag_wins(tmp_path: Path) -> None:
    """The reason a `dispatch:` section exists at all. The MCP server passes NO
    manifest arguments — the repo root is the only route it needs — so a convention
    reachable solely by CLI flag is invisible on the primary surface and the
    built-in defaults become the whole policy, which is precisely the
    hardcoded-only assumption the no-hardcoding mandate forbids. Discovery from
    the repo root is what closes that, and an explicit flag still wins because the
    file is a standing statement while the flag is a deliberate one-off."""
    (tmp_path / DECLARATION_NAME).write_text(
        "dispatch:\n  interfaces:\n    - interface: FromDeclaration\n      boundary: true\n",
        encoding="utf-8",
    )
    decl = load_declaration(tmp_path)
    assert SECTION_DISPATCH in decl

    from_declaration = load_dispatch_manifest(_declared_or_flag(None, decl, SECTION_DISPATCH))
    assert [b.interface for b in from_declaration.interfaces] == ["FromDeclaration"]

    override = tmp_path / "override.yaml"
    override.write_text(
        "interfaces:\n  - interface: FromFlag\n    boundary: true\n", encoding="utf-8"
    )
    from_flag = load_dispatch_manifest(_declared_or_flag(str(override), decl, SECTION_DISPATCH))
    assert [b.interface for b in from_flag.interfaces] == ["FromFlag"]

    # A repo declaring nothing reaches the stage with an empty manifest, not None.
    assert load_dispatch_manifest(_declared_or_flag(None, {}, SECTION_DISPATCH)).is_empty()

Activity · 10 steps
lines 849–852(tmp_path / DECLARATION_NAME).write_text( "dispatch:\n interfaces:\n - interface: FromDeclaration\n boundary: true\n", encoding="utf-8", )lines 853–853decl = load_declaration(tmp_path)lines 854–854assert SECTION_DISPATCH in decllines 856–856from_declaration = load_dispatch_manifest(_declared_or_flag(None, decl, SECTION_DISPATCH))lines 857–857assert [b.interface for b in from_declaration.interfaces] == ["FromDeclaration"]lines 859–859override = tmp_path / "override.yaml"lines 860–862override.write_text( "interfaces:\n - interface: FromFlag\n boundary: true\n", encoding="utf-8" )lines 863–863from_flag = load_dispatch_manifest(_declared_or_flag(str(override), decl, SECTION_DISPATCH))lines 864–864assert [b.interface for b in from_flag.interfaces] == ["FromFlag"]lines 867–867assert load_dispatch_manifest(_declared_or_flag(None, {}, SECTION_DISPATCH)).is_empty()

test_the_dispatch_manifest_participates_in_the_stage_cache_key

None test_dispatch.test_the_dispatch_manifest_participates_in_the_stage_cache_key(Path tmp_path)

The declaration decides what the per-file registration harvest MATCHES, so editing it has to re-harvest. A manifest that did not reach the cache key would leave a stale payload in place and the edit would appear to do nothing — the same class of silent failure as a dropped declaration.

tests/test_dispatch.py:870

Checks

  • assert manifest_key(shared_key_document(one)) != manifest_key(shared_key_document(two))
  • assert _inferred_cache_key(None, None) == DEFAULT_SHARED_KEY_PATTERNS_VERSION
  • assert _inferred_cache_key(None, shared_key_document(one)) != _inferred_cache_key(None, None)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-002inferredtest_the_dispatch_manifest_participates_in_the_stage_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_the_dispatch_manifest_participates_in_the_stage_cache_key → manifest_key
REQ-DDB-SCHEMA-004measuredtest_the_dispatch_manifest_participates_in_the_stage_cache_key → load_dispatch_manifest
REQ-DDB-SCHEMA-012measuredtest_the_dispatch_manifest_participates_in_the_stage_cache_key → load_dispatch_manifest → declaration_origin
Source · 14 lines
def test_the_dispatch_manifest_participates_in_the_stage_cache_key(tmp_path: Path) -> None:
    """The declaration decides what the per-file registration harvest MATCHES, so
    editing it has to re-harvest. A manifest that did not reach the cache key
    would leave a stale payload in place and the edit would appear to do nothing —
    the same class of silent failure as a dropped declaration."""
    one = load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "a", "key_arg_index": 0}]})
    two = load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "a", "key_arg_index": 1}]})
    assert manifest_key(shared_key_document(one)) != manifest_key(shared_key_document(two))
    # An undeclared build must keep the exact key it had before this parameter
    # existed, so no existing cache is invalidated by the merge point alone.
    assert _inferred_cache_key(None, None) == DEFAULT_SHARED_KEY_PATTERNS_VERSION
    assert _inferred_cache_key(None, shared_key_document(one)) != _inferred_cache_key(None, None)

Activity · 5 steps
lines 875–875one = load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "a", "key_arg_index": 0}]})lines 876–876two = load_dispatch_manifest({"shared_key_wrappers": [{"pattern": "a", "key_arg_index": 1}]})lines 877–877assert manifest_key(shared_key_document(one)) != manifest_key(shared_key_document(two))lines 880–880assert _inferred_cache_key(None, None) == DEFAULT_SHARED_KEY_PATTERNS_VERSIONlines 881–881assert _inferred_cache_key(None, shared_key_document(one)) != _inferred_cache_key(None, None)

test_unresolvable_dispatch_via_leaves_the_handlers_unconnected

None test_dispatch.test_unresolvable_dispatch_via_leaves_the_handlers_unconnected(Path tmp_path)

A `dispatch_via` that resolves to no unique indexed function fails CLOSED: the handlers stay unconnected rather than being attributed to some other function, because attributing a whole dispatched sub-graph to the wrong caller is the one error here that is indistinguishable from a real graph.

tests/test_dispatch.py:470

Checks

  • assert _declared_edges(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _harvest_sites → run_harvest
REQ-DDB-PIPE-011measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _harvest_sites → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-003measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _table_edges → _definition_preferring_name_index
REQ-DDB-SCHEMA-003measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-004measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → load_dispatch_manifest
REQ-DDB-SCHEMA-007measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _ensure_external_boundaries_table
REQ-DDB-SCHEMA-012measuredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → load_dispatch_manifest → declaration_origin
REQ-DDB-WIKI-054inferredtest_unresolvable_dispatch_via_leaves_the_handlers_unconnected → import_declared_dispatch_edges → _table_edges → _record_handlers → _ast_record_call_edge → _narrow_by_receiver → _one_class → all
Source · 20 lines
def test_unresolvable_dispatch_via_leaves_the_handlers_unconnected(tmp_path: Path) -> None:
    """A `dispatch_via` that resolves to no unique indexed function fails CLOSED:
    the handlers stay unconnected rather than being attributed to some other
    function, because attributing a whole dispatched sub-graph to the wrong
    caller is the one error here that is indistinguishable from a real graph."""
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")
    db = _make_db(tmp_path, _BROKER_FUNCTIONS)
    manifest = load_dispatch_manifest(
        {
            "dispatch_tables": [
                {"register_via": "register_dispatcher", "dispatch_via": "Absent::fan"}
            ]
        }
    )
    import_declared_dispatch_edges(db, tmp_path, manifest)

    assert _declared_edges(db) == []

Activity · 6 steps
lines 475–475(tmp_path / "src").mkdir()lines 476–476(tmp_path / "src" / "broker.cpp").write_text(_BROKER_SRC, encoding="utf-8")lines 477–477db = _make_db(tmp_path, _BROKER_FUNCTIONS)lines 478–484manifest = load_dispatch_manifest( { "dispatch_tables": [ {"register_via": "register_dispatcher", "dispatch_via": "Absent::fan"} ] } )lines 485–485import_declared_dispatch_edges(db, tmp_path, manifest)lines 487–487assert _declared_edges(db) == []

test_without_the_declaration_the_same_dataflow_is_invisible

None test_dispatch.test_without_the_declaration_the_same_dataflow_is_invisible(Path tmp_path)

The correct negative that makes the previous test mean something: the built-in defaults see the name-embedded READ and nothing at all on the write side, so the key has no dataflow. The declaration is what closes it — not some pre-existing inference that would have fired anyway.

tests/test_dispatch.py:597

Show on the map →

Called by none

Calls _key_edges, _wrapper_db, import_shared_key_edges_inferred

Checks

  • assert _key_edges(db) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-006measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns
REQ-DDB-CONFIG-007measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _log_undeclared_accessor_hint → detect_undeclared_accessor_families
REQ-DDB-INDEX-002inferredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → shared_key_harvester → _inferred_cache_key → manifest_key → hash_file
REQ-DDB-PIPE-003measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest
REQ-DDB-PIPE-010measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _build_inferred_edges
REQ-DDB-PIPE-011measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _walk_all_files_for_shared_keys → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-SCHEMA-002measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _writer_dispatch_map
REQ-DDB-SCHEMA-005measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred
REQ-DDB-SCHEMA-007measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → _ensure_shared_key_edges_table
REQ-DDB-SCHEMA-012measuredtest_without_the_declaration_the_same_dataflow_is_invisible → import_shared_key_edges_inferred → shared_key_harvester → resolve_shared_key_patterns → load_shared_key_patterns → declaration_origin
Source · 11 lines
def test_without_the_declaration_the_same_dataflow_is_invisible(tmp_path: Path) -> None:
    """The correct negative that makes the previous test mean something: the
    built-in defaults see the name-embedded READ and nothing at all on the write
    side, so the key has no dataflow. The declaration is what closes it — not some
    pre-existing inference that would have fired anyway."""
    db = _wrapper_db(tmp_path)
    import_shared_key_edges_inferred(db, tmp_path, None, None, None)

    assert _key_edges(db) == []

Activity · 3 steps
lines 602–602db = _wrapper_db(tmp_path)lines 603–603import_shared_key_edges_inferred(db, tmp_path, None, None, None)lines 605–605assert _key_edges(db) == []