test_overrides.py

tests/test_overrides.py

gh#8 — doxygen's `reimplements` relation, made reachable.

test_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors

None test_overrides.test_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors(Path overriding_db)

The `callees` half of gh#8 — and the two things it must NOT do.

tests/test_overrides.py:128

Show on the map →

Called by none

Calls all, callees, rich_db_of

Checks

  • assert set(edge.implementors) == {"telemetry_report", "handle_cloud_command"}
  • assert {(e.name, e.confidence) for e in annotated} == plain
  • assert all(e.implementors == () for e in annotated if e.name != "sensor_poll")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors → callees
REQ-DDB-QUERY-003measuredtest_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors → callees → _call_edges → _dataflow_edges → resolve_rowid
REQ-DDB-QUERY-009measuredtest_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors → callees → _call_edges → _direct_call_edges → _implementors_by_identity
REQ-DDB-QUERY-010measuredtest_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors → callees
REQ-DDB-WIKI-054inferredtest_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors → all
Source · 21 lines
def test_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors(
    overriding_db: Path,
) -> None:
    """The `callees` half of gh#8 — and the two things it must NOT do.

    `app_run` calls `sensor_poll`, which the fixture makes virtual, so that edge names
    the bodies the dispatch can reach. What it must not do is UPGRADE the edge or ADD
    one: `confidence` still grades the call itself, and the neighbour count is
    unchanged, because this repo's rule is that a synthetic edge inherits the weakest
    link and the honest way to respect that is to annotate rather than to mint.
    """
    plain = {(e.name, e.confidence) for e in q.callees(rich_db_of(overriding_db), "app_run")}
    annotated = q.callees(overriding_db, "app_run")

    edge = next(e for e in annotated if e.name == "sensor_poll")
    assert set(edge.implementors) == {"telemetry_report", "handle_cloud_command"}
    # Every OTHER neighbour is untouched, and no neighbour was gained or lost.
    assert {(e.name, e.confidence) for e in annotated} == plain
    assert all(e.implementors == () for e in annotated if e.name != "sensor_poll")

Activity · 6 steps
lines 139–139plain = {(e.name, e.confidence) for e in q.callees(rich_db_of(overriding_db), "app_run")}lines 140–140annotated = q.callees(overriding_db, "app_run")lines 142–142edge = next(e for e in annotated if e.name == "sensor_poll")lines 143–143assert set(edge.implementors) == {"telemetry_report", "handle_cloud_command"}lines 145–145assert {(e.name, e.confidence) for e in annotated} == plainlines 146–146assert all(e.implementors == () for e in annotated if e.name != "sensor_poll")

test_a_dossier_on_an_overridden_function_names_its_implementors

None test_overrides.test_a_dossier_on_an_overridden_function_names_its_implementors(Path overriding_db)

gh#8's "done means", asserted: a consumer can answer "what runs here?".

tests/test_overrides.py:73

Checks

  • assert doss is not None
  • assert doss.rowid == SENSOR_POLL_DEF, "the dossier describes the definition row"
  • assert named == {"telemetry_report", "handle_cloud_command"}
  • assert ref.rowid > 0
  • assert ref.file, "an implementor must be locatable without a second lookup"
  • assert ref.signature, "the signature is what distinguishes same-named overrides"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier
REQ-DDB-QUERY-006measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier
REQ-DDB-QUERY-010measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier
REQ-DDB-QUERY-012measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_a_dossier_on_an_overridden_function_names_its_implementors → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 20 lines
def test_a_dossier_on_an_overridden_function_names_its_implementors(overriding_db: Path) -> None:
    """gh#8's "done means", asserted: a consumer can answer "what runs here?".

    Both implementors are named, with the location and signature that let the consumer
    go and read one — the point of returning a ref rather than a bare name. And the
    relation is found despite being recorded against the declaration while the dossier
    describes the definition, which is the identity resolution doing its job.
    """
    doss = q.function_dossier(overriding_db, "sensor_poll")
    assert doss is not None
    assert doss.rowid == SENSOR_POLL_DEF, "the dossier describes the definition row"

    named = {o.name for o in doss.overridden_by}
    assert named == {"telemetry_report", "handle_cloud_command"}
    for ref in doss.overridden_by:
        assert ref.rowid > 0
        assert ref.file, "an implementor must be locatable without a second lookup"
        assert ref.signature, "the signature is what distinguishes same-named overrides"

Activity · 9 steps
lines 81–81doss = q.function_dossier(overriding_db, "sensor_poll")lines 82–82assert doss is not Nonelines 83–83assert doss.rowid == SENSOR_POLL_DEF, "the dossier describes the definition row"lines 85–85named = {o.name for o in doss.overridden_by}lines 86–86assert named == {"telemetry_report", "handle_cloud_command"}lines 87–87◇ for ref in doss.overridden_bylines 88–88assert ref.rowid > 0lines 89–89assert ref.file, "an implementor must be locatable without a second lookup"lines 90–90assert ref.signature, "the signature is what distinguishes same-named overrides"

test_a_non_virtual_function_gets_no_override_fields

None test_overrides.test_a_non_virtual_function_gets_no_override_fields(Path rich_db)

No spurious polymorphism on the ordinary case, which is almost every function.

tests/test_overrides.py:113

Checks

  • assert doss is not None
  • assert doss.overrides == []
  • assert doss.overridden_by == []
  • assert all(edge.implementors == () for edge in doss.callers + doss.callees)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier
REQ-DDB-QUERY-006measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier
REQ-DDB-QUERY-010measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier
REQ-DDB-QUERY-012measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_a_non_virtual_function_gets_no_override_fields → function_dossier → _dossier_conn → locks_held_for_rowids
REQ-DDB-WIKI-054inferredtest_a_non_virtual_function_gets_no_override_fields → all
Source · 15 lines
def test_a_non_virtual_function_gets_no_override_fields(rich_db: Path) -> None:
    """No spurious polymorphism on the ordinary case, which is almost every function.

    Asserted on the UNMODIFIED fixture, whose `reimplements` table exists and is empty
    — the state a C or Python target is permanently in. Both fields are `[]`, which is
    the measurement "doxygen recorded no override relation", and no call edge claims an
    implementor.
    """
    doss = q.function_dossier(rich_db, "sensor_poll")
    assert doss is not None
    assert doss.overrides == []
    assert doss.overridden_by == []
    assert all(edge.implementors == () for edge in doss.callers + doss.callees)

Activity · 5 steps
lines 121–121doss = q.function_dossier(rich_db, "sensor_poll")lines 122–122assert doss is not Nonelines 123–123assert doss.overrides == []lines 124–124assert doss.overridden_by == []lines 125–125assert all(edge.implementors == () for edge in doss.callers + doss.callees)

test_an_index_without_the_relation_degrades_to_empty

None test_overrides.test_an_index_without_the_relation_degrades_to_empty(Path overriding_db)

`reimplements` is DOXYGEN'S table, not ours — we copy the file doxygen wrote.

tests/test_overrides.py:178

Checks

  • assert doss is not None
  • assert doss.overrides == []
  • assert doss.overridden_by == []
  • assert all(e.implementors == () for e in q.callees(overriding_db, "app_run"))

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_an_index_without_the_relation_degrades_to_empty → callees
REQ-DDB-QUERY-002measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier
REQ-DDB-QUERY-006measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier
REQ-DDB-QUERY-010measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier
REQ-DDB-QUERY-012measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_an_index_without_the_relation_degrades_to_empty → function_dossier → _dossier_conn → locks_held_for_rowids
REQ-DDB-WIKI-054inferredtest_an_index_without_the_relation_degrades_to_empty → all
Source · 21 lines
def test_an_index_without_the_relation_degrades_to_empty(overriding_db: Path) -> None:
    """`reimplements` is DOXYGEN'S table, not ours — we copy the file doxygen wrote.

    So its absence means the index predates that output, and the surface must return
    empty rather than raising: an override query is exactly the kind a consumer runs
    against an old index while investigating why an answer looks thin.
    """
    conn = sqlite3.connect(overriding_db)
    try:
        conn.execute("DROP TABLE reimplements")
        conn.commit()
    finally:
        conn.close()

    doss = q.function_dossier(overriding_db, "sensor_poll")
    assert doss is not None
    assert doss.overrides == []
    assert doss.overridden_by == []
    assert all(e.implementors == () for e in q.callees(overriding_db, "app_run"))

Activity · 9 steps
lines 185–185conn = sqlite3.connect(overriding_db)lines 186–186trylines 187–187conn.execute("DROP TABLE reimplements")lines 188–188conn.commit()lines 192–192doss = q.function_dossier(overriding_db, "sensor_poll")lines 193–193assert doss is not Nonelines 194–194assert doss.overrides == []lines 195–195assert doss.overridden_by == []lines 196–196assert all(e.implementors == () for e in q.callees(overriding_db, "app_run"))

test_the_override_fields_reach_the_mcp_wire

None test_overrides.test_the_override_fields_reach_the_mcp_wire(Path overriding_db, Path repo_root)

gh#8 END TO END, because the query layer is not the surface a model sees.

tests/test_overrides.py:199

Show on the map →

Called by none

Calls all

Checks

  • assert doss["overrides"] == [], "an envelope key survives at empty"
  • assert {o["name"] for o in doss["overridden_by"]} == {
  • assert set(edge["implementors"]) == {"telemetry_report", "handle_cloud_command"}
  • assert others, "the control needs at least one unannotated neighbour"
  • assert all("implementors" not in e for e in others), ("an empty implementors list is a ROW field and must be elided, not shipped" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measured
REQ-DDB-MCP-003measured
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measured
REQ-DDB-QUERY-001measured
REQ-DDB-QUERY-002measured
REQ-DDB-QUERY-003measured
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-006measured
REQ-DDB-QUERY-009measured
REQ-DDB-QUERY-010measured
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-014measured
REQ-DDB-SCHEMA-011measured
REQ-DDB-WIKI-054inferredtest_the_override_fields_reach_the_mcp_wire → all
Source · 42 lines
def test_the_override_fields_reach_the_mcp_wire(overriding_db: Path, repo_root: Path) -> None:
    """gh#8 END TO END, because the query layer is not the surface a model sees.

    Two elision rules meet here and they pull opposite ways. `overrides` /
    `overridden_by` are ENVELOPE keys, so they survive at `[]` and a consumer can read
    "no override recorded" without guessing. `implementors` is a field of a ROW, so it
    is elided when empty — which is correct and is why the assertion checks the
    ANNOTATED row rather than merely that the key exists somewhere.

    An empty `implementors` shipping as `[]` on every one of a hub symbol's neighbours
    would be pure noise; an absent `overrides` on a dossier would be a question the
    caller has to ask again.
    """
    pytest.importorskip(
        "mcp",
        reason="the MCP SDK is a REQUIRED dependency, so this skipping means a BROKEN install, not an unselected extra",
    )
    from clew.mcp_server.tools_query import QueryTools

    tools = QueryTools(lambda: overriding_db, lambda: repo_root)

    doss = tools.dossier("sensor_poll")
    assert doss["overrides"] == [], "an envelope key survives at empty"
    assert {o["name"] for o in doss["overridden_by"]} == {
        "telemetry_report",
        "handle_cloud_command",
    }

    ## Read off `dossier`'s own `callees` since gh#372 folded the neighbour tools into it.
    ## The rows are the same rows, which is exactly the claim that fold rests on — and
    ## `implementors` is the field most able to be lost in a re-serialization, because it
    ## is a ROW field that is elided when empty.
    callees = tools.dossier("app_run")["callees"]
    edge = next(e for e in callees if e["name"] == "sensor_poll")
    assert set(edge["implementors"]) == {"telemetry_report", "handle_cloud_command"}
    others = [e for e in callees if e["name"] != "sensor_poll"]
    assert others, "the control needs at least one unannotated neighbour"
    assert all("implementors" not in e for e in others), (
        "an empty implementors list is a ROW field and must be elided, not shipped"
    )

Activity · 12 steps
lines 212–215pytest.importorskip( "mcp", reason="the MCP SDK is a REQUIRED dependency, so this skipping means a BROKEN install, not an unselected extra", )lines 216–216from clew.mcp_server.tools_query import QueryToolslines 218–218tools = QueryTools(lambda: overriding_db, lambda: repo_root)lines 220–220doss = tools.dossier("sensor_poll")lines 221–221assert doss["overrides"] == [], "an envelope key survives at empty"lines 222–225assert {o["name"] for o in doss["overridden_by"]} == { "telemetry_report", "handle_cloud_command", }lines 231–231callees = tools.dossier("app_run")["callees"]lines 232–232edge = next(e for e in callees if e["name"] == "sensor_poll")lines 233–233assert set(edge["implementors"]) == {"telemetry_report", "handle_cloud_command"}lines 234–234others = [e for e in callees if e["name"] != "sensor_poll"]lines 235–235assert others, "the control needs at least one unannotated neighbour"lines 236–238assert all("implementors" not in e for e in others), ( "an empty implementors list is a ROW field and must be elided, not shipped" )

test_the_override_surface_is_reachable_from_the_package

None test_overrides.test_the_override_surface_is_reachable_from_the_package(Path overriding_db)

Exported, because "populated and unreachable" was the whole defect.

tests/test_overrides.py:241

Checks

  • assert "overrides_of" in q.__all__
  • assert "overridden_by" in q.__all__
  • assert "OverrideRef" in q.__all__
  • assert {o.name for o in q.overridden_by(conn, "sensor_poll")} == {
  • assert q.overrides_of(conn, "sensor_poll") == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_the_override_surface_is_reachable_from_the_package → overridden_by
REQ-DDB-QUERY-003measuredtest_the_override_surface_is_reachable_from_the_package → overridden_by → _override_refs → table_exists
REQ-DDB-QUERY-009measuredtest_the_override_surface_is_reachable_from_the_package → overridden_by
REQ-DDB-QUERY-010measuredtest_the_override_surface_is_reachable_from_the_package → overridden_by
Source · 20 lines
def test_the_override_surface_is_reachable_from_the_package(overriding_db: Path) -> None:
    """Exported, because "populated and unreachable" was the whole defect.

    The accessors are also usable directly, not only through `dossier`: a consumer that
    already has a name and wants only the dispatch answer should not have to compose a
    whole dossier for it.
    """
    assert "overrides_of" in q.__all__
    assert "overridden_by" in q.__all__
    assert "OverrideRef" in q.__all__

    conn = sqlite3.connect(overriding_db)
    try:
        assert {o.name for o in q.overridden_by(conn, "sensor_poll")} == {
            "telemetry_report",
            "handle_cloud_command",
        }
        assert q.overrides_of(conn, "sensor_poll") == []
    finally:
        conn.close()

1 more lines, not shown

Activity · 7 steps
lines 248–248assert "overrides_of" in q.__all__lines 249–249assert "overridden_by" in q.__all__lines 250–250assert "OverrideRef" in q.__all__lines 252–252conn = sqlite3.connect(overriding_db)lines 253–253trylines 254–257assert {o.name for o in q.overridden_by(conn, "sensor_poll")} == { "telemetry_report", "handle_cloud_command", }lines 258–258assert q.overrides_of(conn, "sensor_poll") == []

test_the_two_directions_are_not_the_same_question

None test_overrides.test_the_two_directions_are_not_the_same_question(Path overriding_db)

`overrides` and `overridden_by` must not be each other.

tests/test_overrides.py:93

Checks

  • assert base is not None
  • assert impl is not None
  • assert base.overrides == [], "the base method reimplements nothing"
  • assert len(base.overridden_by) == 2
  • assert {o.name for o in impl.overrides} == {"sensor_poll"}
  • assert impl.overridden_by == [], "nothing reimplements the leaf implementor"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → symbol_provenance
REQ-DDB-PIPE-003inferredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_harvest_calls → is_python_tree
REQ-DDB-PIPE-011inferredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → _body_and_external → external_callees → _harvest_file → _ast_parse_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → _body_and_external → external_callees → _ts_language_for → _grammar_available → has_language
REQ-DDB-QUERY-001measuredtest_the_two_directions_are_not_the_same_question → function_dossier → connect
REQ-DDB-QUERY-002measuredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → unresolved_inbound_for_rowids
REQ-DDB-QUERY-003measuredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → function_candidates
REQ-DDB-QUERY-004measuredtest_the_two_directions_are_not_the_same_question → function_dossier
REQ-DDB-QUERY-006measuredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → gates_covering
REQ-DDB-QUERY-009measuredtest_the_two_directions_are_not_the_same_question → function_dossier
REQ-DDB-QUERY-010measuredtest_the_two_directions_are_not_the_same_question → function_dossier
REQ-DDB-QUERY-012measuredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → _macro_dossier
REQ-DDB-QUERY-013inferredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → config_defaults_conn
REQ-DDB-SCHEMA-011measuredtest_the_two_directions_are_not_the_same_question → function_dossier → _dossier_conn → locks_held_for_rowids
Source · 20 lines
def test_the_two_directions_are_not_the_same_question(overriding_db: Path) -> None:
    """`overrides` and `overridden_by` must not be each other.

    A single relation table read in one direction only is the easy mistake here, and it
    would present a base method as overriding its own implementors. The base's
    `overrides` is EMPTY (it reimplements nothing) while an implementor's names it —
    asserted on the same database so a symmetric bug cannot satisfy both halves.
    """
    base = q.function_dossier(overriding_db, "sensor_poll")
    impl = q.function_dossier(overriding_db, "telemetry_report")
    assert base is not None
    assert impl is not None

    assert base.overrides == [], "the base method reimplements nothing"
    assert len(base.overridden_by) == 2

    assert {o.name for o in impl.overrides} == {"sensor_poll"}
    assert impl.overridden_by == [], "nothing reimplements the leaf implementor"

Activity · 8 steps
lines 101–101base = q.function_dossier(overriding_db, "sensor_poll")lines 102–102impl = q.function_dossier(overriding_db, "telemetry_report")lines 103–103assert base is not Nonelines 104–104assert impl is not Nonelines 106–106assert base.overrides == [], "the base method reimplements nothing"lines 107–107assert len(base.overridden_by) == 2lines 109–109assert {o.name for o in impl.overrides} == {"sensor_poll"}lines 110–110assert impl.overridden_by == [], "nothing reimplements the leaf implementor"