test_unresolved_inbound.py¶
tests/test_unresolved_inbound.py
What an empty `callers` list is entitled to claim (gh#15).
test_a_callee_outside_the_index_records_nothing
None test_unresolved_inbound.test_a_callee_outside_the_index_records_nothing()
THE OTHER CONTROL, and the one that keeps the measurement attributable. A call to `std::to_string` has no candidate row, so there is no indexed function whose `callers` could be understated — the callee is simply not in the corpus. Counting it would produce a number attached to nothing, and on entropic 299 of 662 qualified sites are that shape.
tests/test_unresolved_inbound.py:92
Checks
assert unresolved == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_callee_outside_the_index_records_nothing → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 10 lines
def test_a_callee_outside_the_index_records_nothing() -> None:
"""THE OTHER CONTROL, and the one that keeps the measurement attributable. A call to
`std::to_string` has no candidate row, so there is no indexed function whose `callers`
could be understated — the callee is simply not in the corpus. Counting it would produce a
number attached to nothing, and on entropic 299 of 662 qualified sites are that shape."""
unresolved: list[list[int]] = []
_ast_record_call_edge(1, "to_string", {}, [], [], SOURCE_AST_MEMBER, unresolved=unresolved)
assert unresolved == []
Activity · 3 steps
test_a_matching_receiver_resolves_rather_than_refusing
None test_unresolved_inbound.test_a_matching_receiver_resolves_rather_than_refusing()
WHY THE CONTROL ABOVE HAD TO CHANGE SHAPE, pinned so the reasoning is not lost. This also caught a real defect: `_scope_is` understood `::` only, so a Python scope (`clew.indexcache.IndexCache`) matched nothing and every Python receiver read as a CONTRADICTION. gh#21's receiver half was inert for the same reason — its measured gain came entirely from the `self.` qualifier path.
tests/test_unresolved_inbound.py:412
Checks
assert resolved == [(1, 620, SOURCE_AST_MEMBER)], ("a dot-separated Python scope must match its bare class name" )assert unresolved == [], "a resolved call is not a refusal"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_matching_receiver_resolves_rather_than_refusing → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 25 lines
def test_a_matching_receiver_resolves_rather_than_refusing() -> None:
"""WHY THE CONTROL ABOVE HAD TO CHANGE SHAPE, pinned so the reasoning is not lost. This
also caught a real defect: `_scope_is` understood `::` only, so a Python scope
(`clew.indexcache.IndexCache`) matched nothing and every Python receiver read as a
CONTRADICTION. gh#21's receiver half was inert for the same reason — its measured gain
came entirely from the `self.` qualifier path.
"""
resolved: list[tuple[int, int, str]] = []
unresolved: list[list[int]] = []
_ast_record_call_edge(
1,
"close",
{"close": [620]},
resolved,
[],
SOURCE_AST_MEMBER,
receiver="cache",
receiver_types={"cache": {"IndexCache"}},
scope_of={620: "clew.indexcache.IndexCache"},
unresolved=unresolved,
)
assert resolved == [(1, 620, SOURCE_AST_MEMBER)], (
"a dot-separated Python scope must match its bare class name"
)
assert unresolved == [], "a resolved call is not a refusal"1 more lines, not shown
Activity · 5 steps
test_a_receiver_with_SEVERAL_owning_classes_is_still_credited
None test_unresolved_inbound.test_a_receiver_with_SEVERAL_owning_classes_is_still_credited()
The other control, and the shape of it is worth stating because writing it revealed a bug. A receiver whose class MATCHES a single candidate does not refuse at all — it RESOLVES, so there is no refusal to credit and no assertion to make. The only way a credited refusal can have a matching receiver is when the receiver denotes SEVERAL classes that each own the name, which `_one_class` refuses to pin.
tests/test_unresolved_inbound.py:384
Checks
assert unresolved == [[620, 700]], ("two owning classes is a genuine ambiguity, not contrary evidence" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_receiver_with_SEVERAL_owning_classes_is_still_credited → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 28 lines
def test_a_receiver_with_SEVERAL_owning_classes_is_still_credited() -> None:
"""The other control, and the shape of it is worth stating because writing it revealed a
bug. A receiver whose class MATCHES a single candidate does not refuse at all — it
RESOLVES, so there is no refusal to credit and no assertion to make. The only way a
credited refusal can have a matching receiver is when the receiver denotes SEVERAL
classes that each own the name, which `_one_class` refuses to pin.
There the call really might have been to any of them: the receiver confirms nothing and
contradicts nothing, so it is credited — which is exactly the case the count exists for.
"""
unresolved: list[list[int]] = []
_ast_record_call_edge(
1,
"close",
{"close": [620, 700]},
[],
[],
SOURCE_AST_MEMBER,
receiver="handle",
receiver_types={"handle": {"a.Cache", "b.Store"}},
scope_of={620: "a.Cache", 700: "b.Store"},
unresolved=unresolved,
)
assert unresolved == [[620, 700]], (
"two owning classes is a genuine ambiguity, not contrary evidence"
)
Activity · 3 steps
test_a_refusal_the_receiver_CONTRADICTS_is_not_credited
None test_unresolved_inbound.test_a_refusal_the_receiver_CONTRADICTS_is_not_credited()
gh#18, unblocked by gh#21. `IndexCache.close` reported 403 unresolved inbound sites because it is the only indexed `close` in a Python repository, so every `conn.close()`, `f.close()` and `proc.close()` in the tree credited it — a number about how often a bare name appears in member-call position, which is the name-as-evidence fallacy the attribution rule was written to avoid. I checked the callee side and never checked whether the site said anything about the receiver.
tests/test_unresolved_inbound.py:323
Checks
assert unresolved == [], ("the receiver is declared sqlite3 and the only candidate is an IndexCache method, " "so this call site is evidence AGAINST that callee, not for it" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_refusal_the_receiver_CONTRADICTS_is_not_credited → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 37 lines
def test_a_refusal_the_receiver_CONTRADICTS_is_not_credited() -> None:
"""gh#18, unblocked by gh#21. `IndexCache.close` reported 403 unresolved inbound sites
because it is the only indexed `close` in a Python repository, so every `conn.close()`,
`f.close()` and `proc.close()` in the tree credited it — a number about how often a bare
name appears in member-call position, which is the name-as-evidence fallacy the
attribution rule was written to avoid. I checked the callee side and never checked
whether the site said anything about the receiver.
IT COULD NOT BE FIXED HERE UNTIL gh#21. Python carried no receiver at all, so every
refusal was blind and three candidate rules were measured and rejected: requiring
receiver evidence made 84% of entropic report "cannot say", and a same-file rule made
82% fire with a maximum of 815. Both traded one over-claim for a larger under-claim.
NOW THERE IS POSITIVE CONTRARY EVIDENCE. `_receiver_types['conn']` is `{'sqlite3'}` and
`IndexCache.close`'s scope is `clew.indexcache.IndexCache`, so the receiver does not
merely fail to confirm the call — it RULES IT OUT. That is different in kind from an
unknown receiver, and only this case is dropped.
"""
unresolved: list[list[int]] = []
_ast_record_call_edge(
1,
"close",
{"close": [620]},
[],
[],
SOURCE_AST_MEMBER,
receiver="conn",
receiver_types={"conn": {"sqlite3"}},
scope_of={620: "clew.indexcache.IndexCache"},
unresolved=unresolved,
)
assert unresolved == [], (
"the receiver is declared sqlite3 and the only candidate is an IndexCache method, "
"so this call site is evidence AGAINST that callee, not for it"
)
Activity · 3 steps
test_a_refused_member_call_records_the_set_it_refused_between
None test_unresolved_inbound.test_a_refused_member_call_records_the_set_it_refused_between()
The refusal path emits no edge — correctly, since a name is not evidence of linkage — and used to leave no trace at all, so the fact that resolution was ATTEMPTED and failed was unrecoverable at query time. The whole candidate SET is kept, not each rowid separately, because whether the refusal is evidence about any one symbol depends on what else was in it.
tests/test_unresolved_inbound.py:47
Checks
assert resolved == [] and fuzzy == [], "premise: this call refuses"assert unresolved == [[30, 31, 32]]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_refused_member_call_records_the_set_it_refused_between → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 22 lines
def test_a_refused_member_call_records_the_set_it_refused_between() -> None:
"""The refusal path emits no edge — correctly, since a name is not evidence of linkage —
and used to leave no trace at all, so the fact that resolution was ATTEMPTED and failed was
unrecoverable at query time. The whole candidate SET is kept, not each rowid separately,
because whether the refusal is evidence about any one symbol depends on what else was in
it."""
resolved: list[tuple[int, int, str]] = []
fuzzy: list[tuple[int, int, str]] = []
unresolved: list[list[int]] = []
_ast_record_call_edge(
1,
"store",
{"store": [30, 31, 32]},
resolved,
fuzzy,
SOURCE_AST_MEMBER,
unresolved=unresolved,
)
assert resolved == [] and fuzzy == [], "premise: this call refuses"
assert unresolved == [[30, 31, 32]]
Activity · 6 steps
test_a_resolved_call_records_nothing
None test_unresolved_inbound.test_a_resolved_call_records_nothing()
THE CONTROL. A call that resolves is not an unresolved one, and counting it would inflate the measurement until every symbol looked doubtful — which is the blanket hedge this design exists to avoid.
tests/test_unresolved_inbound.py:79
Checks
assert resolved == [(1, 7, SOURCE_AST)]assert unresolved == [], "a resolved call is not evidence of an unresolved one"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_resolved_call_records_nothing → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 13 lines
def test_a_resolved_call_records_nothing() -> None:
"""THE CONTROL. A call that resolves is not an unresolved one, and counting it would
inflate the measurement until every symbol looked doubtful — which is the blanket hedge
this design exists to avoid."""
resolved: list[tuple[int, int, str]] = []
unresolved: list[list[int]] = []
_ast_record_call_edge(
1, "free_fn", {"free_fn": [7]}, resolved, [], SOURCE_AST, unresolved=unresolved
)
assert resolved == [(1, 7, SOURCE_AST)]
assert unresolved == [], "a resolved call is not evidence of an unresolved one"
Activity · 5 steps
test_a_single_candidate_with_an_unverified_receiver_is_recorded_too
None test_unresolved_inbound.test_a_single_candidate_with_an_unverified_receiver_is_recorded_too()
The subtlest case and the one that burned gh#15's reporter. `obj.foo()` where exactly ONE indexed `foo` exists still earns no edge — the real receiver may be a class this index never saw — so `foo` reports `callers: []` while a call site plainly named it. That is precisely the empty list that must not read as a measured negative.
tests/test_unresolved_inbound.py:69
Checks
assert unresolved == [[42]]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_a_single_candidate_with_an_unverified_receiver_is_recorded_too → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 10 lines
def test_a_single_candidate_with_an_unverified_receiver_is_recorded_too() -> None:
"""The subtlest case and the one that burned gh#15's reporter. `obj.foo()` where exactly
ONE indexed `foo` exists still earns no edge — the real receiver may be a class this index
never saw — so `foo` reports `callers: []` while a call site plainly named it. That is
precisely the empty list that must not read as a measured negative."""
unresolved: list[list[int]] = []
_ast_record_call_edge(1, "foo", {"foo": [42]}, [], [], SOURCE_AST_MEMBER, unresolved=unresolved)
assert unresolved == [[42]]
Activity · 3 steps
test_an_UNKNOWN_receiver_is_still_credited
None test_unresolved_inbound.test_an_UNKNOWN_receiver_is_still_credited()
THE LINE THIS MUST NOT CROSS, and the reason the rule is 'contradicts' rather than 'does not confirm'. A receiver the index holds no type for says NOTHING — it neither confirms nor rules out — and dropping those was measured to make 84% of entropic report "cannot say", withdrawing confidence from thousands of correct measured negatives.
tests/test_unresolved_inbound.py:360
Checks
assert unresolved == [[620]], "an unknown receiver is not evidence against the callee"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-054 | inferred | test_an_UNKNOWN_receiver_is_still_credited → _ast_record_call_edge → _narrow_by_receiver → _one_class → all |
Source · 24 lines
def test_an_UNKNOWN_receiver_is_still_credited() -> None:
"""THE LINE THIS MUST NOT CROSS, and the reason the rule is 'contradicts' rather than
'does not confirm'. A receiver the index holds no type for says NOTHING — it neither
confirms nor rules out — and dropping those was measured to make 84% of entropic report
"cannot say", withdrawing confidence from thousands of correct measured negatives.
Silence is not contrary evidence.
"""
unresolved: list[list[int]] = []
_ast_record_call_edge(
1,
"close",
{"close": [620]},
[],
[],
SOURCE_AST_MEMBER,
receiver="mystery",
receiver_types={"conn": {"sqlite3"}},
scope_of={620: "clew.indexcache.IndexCache"},
unresolved=unresolved,
)
assert unresolved == [[620]], "an unknown receiver is not evidence against the callee"
Activity · 3 steps
test_an_empty_callers_list_reports_what_was_refused
None test_unresolved_inbound.test_an_empty_callers_list_reports_what_was_refused(Path tmp_path)
gh#15's durable half. Both functions report `callers: []` and the two empty lists mean completely different things — one is a symbol whose callers all failed to resolve, the other is a symbol nothing calls. The reply now separates them.
tests/test_unresolved_inbound.py:234
Checks
assert understated is not None and understated.function is not Noneassert understated.function.callers == [], "premise: no edge survived"assert understated.function.callers_unresolved == 3assert measured is not None and measured.function is not Noneassert measured.function.callers == []assert measured.function.callers_unresolved == 0, ("a genuine measured negative keeps its full confidence — a zero here is the whole " "reason the count is recorded even when nothing refused" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_an_empty_callers_list_reports_what_was_refused → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_an_empty_callers_list_reports_what_was_refused → dossier → connect |
| REQ-DDB-QUERY-002 | measured | test_an_empty_callers_list_reports_what_was_refused → dossier → _chain_for → chain_trace |
| REQ-DDB-QUERY-003 | measured | test_an_empty_callers_list_reports_what_was_refused → dossier → identity_rowids |
| REQ-DDB-QUERY-004 | measured | |
| REQ-DDB-QUERY-005 | inferred | test_an_empty_callers_list_reports_what_was_refused → dossier → _chain_for → chain_trace → _make_node |
| REQ-DDB-QUERY-006 | measured | |
| REQ-DDB-QUERY-009 | measured | |
| REQ-DDB-QUERY-010 | measured | test_an_empty_callers_list_reports_what_was_refused → dossier → identity_rowids |
| REQ-DDB-QUERY-012 | measured | |
| REQ-DDB-QUERY-013 | inferred | test_an_empty_callers_list_reports_what_was_refused → dossier → _qualified_reread → _split_qualified → bare_tail |
| REQ-DDB-SCHEMA-011 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_an_empty_callers_list_reports_what_was_refused → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all |
Source · 20 lines
def test_an_empty_callers_list_reports_what_was_refused(tmp_path: Path) -> None:
"""gh#15's durable half. Both functions report `callers: []` and the two empty lists mean
completely different things — one is a symbol whose callers all failed to resolve, the
other is a symbol nothing calls. The reply now separates them."""
db = _index(tmp_path, with_measurement=True)
understated = q.dossier(db, "reached_only_by_pointer", max_body_lines=0)
assert understated is not None and understated.function is not None
assert understated.function.callers == [], "premise: no edge survived"
assert understated.function.callers_unresolved == 3
measured = q.dossier(db, "genuinely_uncalled", max_body_lines=0)
assert measured is not None and measured.function is not None
assert measured.function.callers == []
assert measured.function.callers_unresolved == 0, (
"a genuine measured negative keeps its full confidence — a zero here is the whole "
"reason the count is recorded even when nothing refused"
)
Activity · 9 steps
test_an_index_without_the_measurement_says_it_cannot_tell
None test_unresolved_inbound.test_an_index_without_the_measurement_says_it_cannot_tell(Path tmp_path)
An index built before this was recorded has no table, and the absence of a count is NOT evidence that nothing was refused. Reporting 0 there would be exactly the substitution the field exists to prevent — "this index cannot tell" answered as "this is measured empty".
tests/test_unresolved_inbound.py:254
Checks
assert doss is not None and doss.function is not Noneassert doss.function.callers_unresolved is None, ("no table means no measurement, which is not the same as a measured zero" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → connect |
| REQ-DDB-QUERY-002 | measured | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → _chain_for → chain_trace |
| REQ-DDB-QUERY-003 | measured | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → identity_rowids |
| REQ-DDB-QUERY-004 | measured | |
| REQ-DDB-QUERY-005 | inferred | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → _chain_for → chain_trace → _make_node |
| REQ-DDB-QUERY-006 | measured | |
| REQ-DDB-QUERY-009 | measured | |
| REQ-DDB-QUERY-010 | measured | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → identity_rowids |
| REQ-DDB-QUERY-012 | measured | |
| REQ-DDB-QUERY-013 | inferred | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → _qualified_reread → _split_qualified → bare_tail |
| REQ-DDB-SCHEMA-011 | measured | |
| REQ-DDB-WIKI-054 | inferred | test_an_index_without_the_measurement_says_it_cannot_tell → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all |
Source · 13 lines
def test_an_index_without_the_measurement_says_it_cannot_tell(tmp_path: Path) -> None:
"""An index built before this was recorded has no table, and the absence of a count is NOT
evidence that nothing was refused. Reporting 0 there would be exactly the substitution the
field exists to prevent — "this index cannot tell" answered as "this is measured empty".
"""
db = _index(tmp_path, with_measurement=False)
doss = q.dossier(db, "reached_only_by_pointer", max_body_lines=0)
assert doss is not None and doss.function is not None
assert doss.function.callers_unresolved is None, (
"no table means no measurement, which is not the same as a measured zero"
)