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
Checks
assert doss is not Noneassert doss.kind == "enumeration", "the C++ enum is the authoritative reading"assert doss.enumeration is not Noneassert doss.enumeration.file == "include/engine_types.h"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → connect |
| REQ-DDB-QUERY-002 | inferred | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _chain_for → chain_trace |
| REQ-DDB-QUERY-003 | measured | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → identity_rowids |
| REQ-DDB-QUERY-004 | measured | |
| REQ-DDB-QUERY-005 | inferred | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _chain_for → chain_trace → _make_node |
| REQ-DDB-QUERY-010 | measured | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → identity_rowids |
| REQ-DDB-QUERY-012 | measured | |
| REQ-DDB-QUERY-013 | measured | test_a_bare_name_prefers_the_cpp_enum_over_its_python_mirror → dossier → _qualified_reread → _split_qualified → bare_tail |
| REQ-DDB-WIKI-054 | inferred | test_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
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
Checks
assert doss is not Noneassert doss.kind == "class", "a real class must not lose to a namesake enum"assert doss.compound is not Noneassert doss.compound.name == "pkg::_bindings::Settings"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | inferred | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → connect |
| REQ-DDB-QUERY-002 | inferred | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _chain_for → chain_trace |
| REQ-DDB-QUERY-003 | measured | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → identity_rowids |
| REQ-DDB-QUERY-004 | measured | |
| REQ-DDB-QUERY-005 | inferred | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _chain_for → chain_trace → _make_node |
| REQ-DDB-QUERY-010 | measured | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → identity_rowids |
| REQ-DDB-QUERY-012 | measured | |
| REQ-DDB-QUERY-013 | measured | test_a_colliding_class_that_is_not_an_enum_keeps_the_class_reading → dossier → _qualified_reread → _split_qualified → bare_tail |
| REQ-DDB-WIKI-054 | inferred | test_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
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
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 Noneassert doss.compound.name == "pkg::_bindings::EntropicError"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | inferred | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → connect |
| REQ-DDB-QUERY-002 | inferred | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _chain_for → chain_trace |
| REQ-DDB-QUERY-003 | measured | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → identity_rowids |
| REQ-DDB-QUERY-004 | measured | |
| REQ-DDB-QUERY-005 | inferred | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _chain_for → chain_trace → _make_node |
| REQ-DDB-QUERY-010 | measured | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → identity_rowids |
| REQ-DDB-QUERY-012 | measured | |
| REQ-DDB-QUERY-013 | measured | test_a_python_enum_with_no_cpp_namesake_is_still_a_class → dossier → _qualified_reread → _split_qualified → bare_tail |
| REQ-DDB-WIKI-054 | inferred | test_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
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
Checks
assert doss is not Noneassert "class" in doss.also, "the reading that lost must still be named"assert mirror is not Noneassert mirror.kind == "class"assert mirror.compound is not Noneassert mirror.compound.name == "pkg::_bindings::AgentState"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_the_mirror_stays_disclosed_and_reachable → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_the_mirror_stays_disclosed_and_reachable → dossier → connect |
| REQ-DDB-QUERY-002 | inferred | test_the_mirror_stays_disclosed_and_reachable → dossier → _chain_for → chain_trace |
| REQ-DDB-QUERY-003 | measured | test_the_mirror_stays_disclosed_and_reachable → dossier → identity_rowids |
| REQ-DDB-QUERY-004 | measured | |
| REQ-DDB-QUERY-005 | inferred | test_the_mirror_stays_disclosed_and_reachable → dossier → _chain_for → chain_trace → _make_node |
| REQ-DDB-QUERY-010 | measured | test_the_mirror_stays_disclosed_and_reachable → dossier → identity_rowids |
| REQ-DDB-QUERY-012 | measured | |
| REQ-DDB-QUERY-013 | measured | test_the_mirror_stays_disclosed_and_reachable → dossier → _qualified_reread → _split_qualified → bare_tail |
| REQ-DDB-WIKI-054 | inferred | test_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"