test_enum_mirror_tiebreak.py

tests/test_enum_mirror_tiebreak.py

gh#29 — a bare name that is both a generated Python enum mirror and a C++ enum.

test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror

None test_enum_mirror_tiebreak.test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror(Path tmp_path)

The reported case. Nothing about the FILE is consulted — the mirror loses because `compoundref` says it subclasses `IntEnum`, which is the index's own statement that the compound is an enumeration wearing a class's clothes.

tests/test_enum_mirror_tiebreak.py:122

Show on the map →

Called by none

Calls _index, dossier

Checks

  • assert doss is not None
  • assert doss.kind == "enumeration", "the C++ enum is the authoritative reading"
  • assert doss.enumeration is not None
  • assert doss.enumeration.file == "include/engine_types.h"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → connect
REQ-DDB-QUERY-002inferredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-010measuredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013measuredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-WIKI-054inferredtest_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 12 lines
def test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror(tmp_path: Path) -> None:
    """The reported case. Nothing about the FILE is consulted — the mirror loses because
    `compoundref` says it subclasses `IntEnum`, which is the index's own statement that the
    compound is an enumeration wearing a class's clothes."""
    db, repo = _index(tmp_path)
    doss = q.dossier(db, "AgentState", repo_root=repo)
    assert doss is not None
    assert doss.kind == "enumeration", "the C++ enum is the authoritative reading"
    assert doss.enumeration is not None
    assert doss.enumeration.file == "include/engine_types.h"

Activity · 6 steps
lines 126–126db, repo = _index(tmp_path)lines 127–127doss = q.dossier(db, "AgentState", repo_root=repo)lines 128–128assert doss is not Nonelines 129–129assert doss.kind == "enumeration", "the C++ enum is the authoritative reading"lines 130–130assert doss.enumeration is not Nonelines 131–131assert doss.enumeration.file == "include/engine_types.h"

test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading

None test_enum_mirror_tiebreak.test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading(Path tmp_path)

CONTROL. `Settings` collides exactly as `AgentState` does — an ordinary Python class beside a C++ enum of the same name — and must be untouched, because the trigger is the Enum base and not the collision. Without this the rule would be the blanket re-ranking this repository has refused before.

tests/test_enum_mirror_tiebreak.py:149

Show on the map →

Called by none

Calls _index, dossier

Checks

  • assert doss is not None
  • assert doss.kind == "class", "a real class must not lose to a namesake enum"
  • assert doss.compound is not None
  • assert doss.compound.name == "pkg::_bindings::Settings"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004inferredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → connect
REQ-DDB-QUERY-002inferredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-010measuredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013measuredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-WIKI-054inferredtest_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 13 lines
def test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading(tmp_path: Path) -> None:
    """CONTROL. `Settings` collides exactly as `AgentState` does — an ordinary Python class
    beside a C++ enum of the same name — and must be untouched, because the trigger is the
    Enum base and not the collision. Without this the rule would be the blanket re-ranking
    this repository has refused before."""
    db, repo = _index(tmp_path)
    doss = q.dossier(db, "Settings", repo_root=repo)
    assert doss is not None
    assert doss.kind == "class", "a real class must not lose to a namesake enum"
    assert doss.compound is not None
    assert doss.compound.name == "pkg::_bindings::Settings"

Activity · 6 steps
lines 154–154db, repo = _index(tmp_path)lines 155–155doss = q.dossier(db, "Settings", repo_root=repo)lines 156–156assert doss is not Nonelines 157–157assert doss.kind == "class", "a real class must not lose to a namesake enum"lines 158–158assert doss.compound is not Nonelines 159–159assert doss.compound.name == "pkg::_bindings::Settings"

test_a_python_enum_with_no_cpp_namesake_is_still_a_class

None test_enum_mirror_tiebreak.test_a_python_enum_with_no_cpp_namesake_is_still_a_class(Path tmp_path)

THE CONTROL THAT KEEPS PYTHON-ONLY REPOSITORIES WORKING. `EntropicError` subclasses `IntEnum` and has no `memberdef kind='enumeration'` row, which is every enum in a Python-only codebase. Declining the class reading here would resolve it to nothing at all — a definitive miss on a symbol the index plainly holds.

tests/test_enum_mirror_tiebreak.py:162

Show on the map →

Called by none

Calls _index, dossier

Checks

  • assert doss is not None, "a Python Enum with no C namesake must still resolve"
  • assert doss.kind == "class"
  • assert doss.compound is not None
  • assert doss.compound.name == "pkg::_bindings::EntropicError"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004inferredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → connect
REQ-DDB-QUERY-002inferredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-010measuredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013measuredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-WIKI-054inferredtest_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 11 lines
def test_a_python_enum_with_no_cpp_namesake_is_still_a_class(tmp_path: Path) -> None:
    """THE CONTROL THAT KEEPS PYTHON-ONLY REPOSITORIES WORKING. `EntropicError` subclasses
    `IntEnum` and has no `memberdef kind='enumeration'` row, which is every enum in a
    Python-only codebase. Declining the class reading here would resolve it to nothing at
    all — a definitive miss on a symbol the index plainly holds."""
    db, repo = _index(tmp_path)
    doss = q.dossier(db, "EntropicError", repo_root=repo)
    assert doss is not None, "a Python Enum with no C namesake must still resolve"
    assert doss.kind == "class"
    assert doss.compound is not None
    assert doss.compound.name == "pkg::_bindings::EntropicError"

1 more lines, not shown

Activity · 6 steps
lines 167–167db, repo = _index(tmp_path)lines 168–168doss = q.dossier(db, "EntropicError", repo_root=repo)lines 169–169assert doss is not None, "a Python Enum with no C namesake must still resolve"lines 170–170assert doss.kind == "class"lines 171–171assert doss.compound is not Nonelines 172–172assert doss.compound.name == "pkg::_bindings::EntropicError"

test_the_mirror_stays_disclosed_and_reachable

None test_enum_mirror_tiebreak.test_the_mirror_stays_disclosed_and_reachable(Path tmp_path)

A TIE-BREAK, NOT A SUPPRESSION. gh#6's contract was that a pick is only safe when the caller can see one was made, so `also` must still name `class` and passing it back must still reach the mirror. Losing the tie-break is not the same as not existing.

tests/test_enum_mirror_tiebreak.py:134

Show on the map →

Called by none

Calls _index, dossier

Checks

  • assert doss is not None
  • assert "class" in doss.also, "the reading that lost must still be named"
  • assert mirror is not None
  • assert mirror.kind == "class"
  • assert mirror.compound is not None
  • assert mirror.compound.name == "pkg::_bindings::AgentState"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_the_mirror_stays_disclosed_and_reachable → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_the_mirror_stays_disclosed_and_reachable → dossier → connect
REQ-DDB-QUERY-002inferredtest_the_mirror_stays_disclosed_and_reachable → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_the_mirror_stays_disclosed_and_reachable → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_the_mirror_stays_disclosed_and_reachable → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-010measuredtest_the_mirror_stays_disclosed_and_reachable → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013measuredtest_the_mirror_stays_disclosed_and_reachable → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-WIKI-054inferredtest_the_mirror_stays_disclosed_and_reachable → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 15 lines
def test_the_mirror_stays_disclosed_and_reachable(tmp_path: Path) -> None:
    """A TIE-BREAK, NOT A SUPPRESSION. gh#6's contract was that a pick is only safe when
    the caller can see one was made, so `also` must still name `class` and passing it back
    must still reach the mirror. Losing the tie-break is not the same as not existing."""
    db, repo = _index(tmp_path)
    doss = q.dossier(db, "AgentState", repo_root=repo)
    assert doss is not None
    assert "class" in doss.also, "the reading that lost must still be named"
    mirror = q.dossier(db, "AgentState", kind="class", repo_root=repo)
    assert mirror is not None
    assert mirror.kind == "class"
    assert mirror.compound is not None
    assert mirror.compound.name == "pkg::_bindings::AgentState"

Activity · 9 steps
lines 138–138db, repo = _index(tmp_path)lines 139–139doss = q.dossier(db, "AgentState", repo_root=repo)lines 140–140assert doss is not Nonelines 141–141assert "class" in doss.also, "the reading that lost must still be named"lines 142–142mirror = q.dossier(db, "AgentState", kind="class", repo_root=repo)lines 143–143assert mirror is not Nonelines 144–144assert mirror.kind == "class"lines 145–145assert mirror.compound is not Nonelines 146–146assert mirror.compound.name == "pkg::_bindings::AgentState"