test_receiver_resolution.py

tests/test_receiver_resolution.py

Resolving a member call by the receiver's DECLARED type (#482).

test_a_receiver_owned_by_several_classes_refuses

None test_receiver_resolution.test_a_receiver_owned_by_several_classes_refuses()

A receiver whose classes all own the method must refuse.

tests/test_receiver_resolution.py:197

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert not verified, ("two of the receiver's classes own this method, so the class is not pinned and no edge " "may be asserted" )
  • assert survivors == [1, 2], "an unverified narrowing must leave the candidates untouched"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_a_receiver_owned_by_several_classes_refuses → _narrow_by_receiver → _one_class → all
Source · 20 lines
def test_a_receiver_owned_by_several_classes_refuses() -> None:
    """RULE 1, the fan-out. When the method exists on more than one of the receiver's possible
    classes, nothing here distinguishes them — `parse_tool_calls` on entropic exists on five —
    so the narrowing must report NOT verified and let the caller emit nothing. Returning the
    survivors as though they were verified is how 56 groups came to span several classes.

    @brief Several owning classes means unverified.
    @return None.
    @version 1
    """
    scope_of = {1: "ClassA", 2: "ClassB"}
    classes = {"parser": {"ClassA", "ClassB"}}
    survivors, verified = _narrow_by_receiver("parser", 0, [1, 2], classes, scope_of, {})
    assert not verified, (
        "two of the receiver's classes own this method, so the class is not pinned and no edge "
        "may be asserted"
    )
    assert survivors == [1, 2], "an unverified narrowing must leave the candidates untouched"

Activity · 5 steps
lines 207–207scope_of = {1: "ClassA", 2: "ClassB"}lines 208–208classes = {"parser": {"ClassA", "ClassB"}}lines 209–209survivors, verified = _narrow_by_receiver("parser", 0, [1, 2], classes, scope_of, {})lines 210–213assert not verified, ( "two of the receiver's classes own this method, so the class is not pinned and no edge " "may be asserted" )lines 214–214assert survivors == [1, 2], "an unverified narrowing must leave the candidates untouched"

test_an_unknown_receiver_changes_nothing

None test_receiver_resolution.test_an_unknown_receiver_changes_nothing()

An unknown receiver leaves the candidates untouched and unverified.

tests/test_receiver_resolution.py:221

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert not verified, f"receiver {receiver!r} verified nothing"
  • assert survivors == ALL, "candidates must pass through untouched"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_an_unknown_receiver_changes_nothing → _narrow_by_receiver → _one_class → all
Source · 16 lines
def test_an_unknown_receiver_changes_nothing() -> None:
    """RULE 4's other half. A receiver that is a local, a parameter, an `auto`, or simply not
    indexed must return the input unchanged AND `verified=False`, so the caller falls through to
    the existing refusal. Reporting a narrowing here is what let the untouched candidate list be
    emitted as fuzzy — 11,390 edges in one build.

    @brief An unresolvable receiver is not a narrowing.
    @return None.
    @version 1
    """
    for receiver in ("", "not_indexed", "local_var"):
        survivors, verified = _narrow_by_receiver(receiver, 1, ALL, {}, SCOPE_OF, ARGC_OF)
        assert not verified, f"receiver {receiver!r} verified nothing"
        assert survivors == ALL, "candidates must pass through untouched"

Activity · 4 steps
lines 231–231◇ for receiver in ("", "not_indexed", "local_var")lines 232–232survivors, verified = _narrow_by_receiver(receiver, 1, ALL, {}, SCOPE_OF, ARGC_OF)lines 233–233assert not verified, f"receiver {receiver!r} verified nothing"lines 234–234assert survivors == ALL, "candidates must pass through untouched"

test_arity_separates_overloads_when_it_can

None test_receiver_resolution.test_arity_separates_overloads_when_it_can()

Argument count separates overloads when it can.

tests/test_receiver_resolution.py:241

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert verified and survivors == [ENGINE_B], (f"a call passing two arguments must select the two-parameter overload: {survivors}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_arity_separates_overloads_when_it_can → _narrow_by_receiver → _one_class → all
Source · 18 lines
def test_arity_separates_overloads_when_it_can() -> None:
    """Arity is the second narrowing, applied only after the class is pinned. On entropic it
    cannot help — both `run_turn` overloads take one argument — which is why the overload set
    is emitted as FUZZY rather than resolved. Where arities differ it does resolve, and that is
    worth pinning so the term is not quietly dropped as useless.

    @brief A differing argument count picks one overload.
    @return None.
    @version 1
    """
    classes = {"engine": {"entropic::AgentEngine"}}
    argc_of = {ENGINE_A: 1, ENGINE_B: 2, HELPER_A: 4, HELPER_B: 4}
    survivors, verified = _narrow_by_receiver("engine", 2, ALL, classes, SCOPE_OF, argc_of)
    assert verified and survivors == [ENGINE_B], (
        f"a call passing two arguments must select the two-parameter overload: {survivors}"
    )

Activity · 4 steps
lines 251–251classes = {"engine": {"entropic::AgentEngine"}}lines 252–252argc_of = {ENGINE_A: 1, ENGINE_B: 2, HELPER_A: 4, HELPER_B: 4}lines 253–253survivors, verified = _narrow_by_receiver("engine", 2, ALL, classes, SCOPE_OF, argc_of)lines 254–256assert verified and survivors == [ENGINE_B], ( f"a call passing two arguments must select the two-parameter overload: {survivors}" )

test_the_intersection_pins_the_class_a_name_alone_cannot

None test_receiver_resolution.test_the_intersection_pins_the_class_a_name_alone_cannot()

The intersection must pin the class even when the receiver name is ambiguous.

tests/test_receiver_resolution.py:81

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert verified, "the receiver's type identified the owning class and should count as such"
  • assert set(survivors) == {ENGINE_A, ENGINE_B}, (f"the two file-local helpers must be ELIMINATED, not merely deprioritised — the " f"receiver's declared type says they cannot be the target. Got {survivors}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_the_intersection_pins_the_class_a_name_alone_cannot → _narrow_by_receiver → _one_class → all
Source · 20 lines
def test_the_intersection_pins_the_class_a_name_alone_cannot() -> None:
    """RULE 2 WAS TOO STRICT AND THIS IS THE CASE THAT PROVES IT. `engine` is declared in four
    classes on entropic, so refusing on an ambiguous receiver name refuses the very call this
    feature exists for. Only ONE of those classes declares `run_turn`, so the PAIR pins it
    where neither half does alone.

    @brief An ambiguous receiver name still resolves when only one of its classes owns the
    method.
    @return None.
    @version 1
    """
    classes = {"engine": {"entropic::AgentEngine", "AgentEngine", "EntropicEngine", "ChessEngine"}}
    survivors, verified = _narrow_by_receiver("engine", 1, ALL, classes, SCOPE_OF, ARGC_OF)
    assert verified, "the receiver's type identified the owning class and should count as such"
    assert set(survivors) == {ENGINE_A, ENGINE_B}, (
        f"the two file-local helpers must be ELIMINATED, not merely deprioritised — the "
        f"receiver's declared type says they cannot be the target. Got {survivors}"
    )

Activity · 4 steps
lines 92–92classes = {"engine": {"entropic::AgentEngine", "AgentEngine", "EntropicEngine", "ChessEngine"}}lines 93–93survivors, verified = _narrow_by_receiver("engine", 1, ALL, classes, SCOPE_OF, ARGC_OF)lines 94–94assert verified, "the receiver's type identified the owning class and should count as such"lines 95–98assert set(survivors) == {ENGINE_A, ENGINE_B}, ( f"the two file-local helpers must be ELIMINATED, not merely deprioritised — the " f"receiver's declared type says they cannot be the target. Got {survivors}" )

test_the_same_bare_name_in_two_namespaces_still_refuses

None test_receiver_resolution.test_the_same_bare_name_in_two_namespaces_still_refuses()

Two genuinely different namespaces are still two owners.

tests/test_receiver_resolution.py:170

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert not verified, ("two namespaces owning the same bare class name is a genuine ambiguity, not a spelling" )
  • assert survivors == [1, 2], "an unverified narrowing must leave the candidates untouched"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_the_same_bare_name_in_two_namespaces_still_refuses → _narrow_by_receiver → _one_class → all
Source · 23 lines
def test_the_same_bare_name_in_two_namespaces_still_refuses() -> None:
    """THE CONTROL for the test above, and the line the collapse must not cross. Widening
    "one class, two spellings" into "any two scopes sharing a tail" would re-admit exactly the
    fan-out rule 1 removed: `a::Session` and `b::Session` are DIFFERENT classes that happen to
    end in the same word, and nothing here can say which one a bare receiver denotes.

    `_scope_is` already refuses that pair in both directions — neither is a `::`-boundary
    suffix of the other — so the collapse is transitive only through spellings that genuinely
    match, and this stays refused.

    @brief A shared tail across namespaces is not one owner.
    @return None.
    @version 1
    """
    scope_of = {1: "a::Session", 2: "b::Session"}
    classes = {"session": {"a::Session", "b::Session"}}
    survivors, verified = _narrow_by_receiver("session", 0, [1, 2], classes, scope_of, {})
    assert not verified, (
        "two namespaces owning the same bare class name is a genuine ambiguity, not a spelling"
    )
    assert survivors == [1, 2], "an unverified narrowing must leave the candidates untouched"

Activity · 5 steps
lines 184–184scope_of = {1: "a::Session", 2: "b::Session"}lines 185–185classes = {"session": {"a::Session", "b::Session"}}lines 186–186survivors, verified = _narrow_by_receiver("session", 0, [1, 2], classes, scope_of, {})lines 187–189assert not verified, ( "two namespaces owning the same bare class name is a genuine ambiguity, not a spelling" )lines 190–190assert survivors == [1, 2], "an unverified narrowing must leave the candidates untouched"

test_two_spellings_of_one_SCOPE_are_one_owner

None test_receiver_resolution.test_two_spellings_of_one_SCOPE_are_one_owner()

A method's own decl/def scope spellings are one owner, not two.

tests/test_receiver_resolution.py:126

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert verified, ("one class written two ways is one owner; counting scope strings refused a call whose " "receiver type the index holds unambiguously" )
  • assert set(survivors) == {decl, defn}, (f"both rows are the same method on the pinned class and must survive: {survivors}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_two_spellings_of_one_SCOPE_are_one_owner → _narrow_by_receiver → _one_class → all
Source · 40 lines
def test_two_spellings_of_one_SCOPE_are_one_owner() -> None:
    """gh#15. RULE 3'S MIRROR, and the reason rule 3 was only half fixed. The spelling duality
    was moved off the receiver's TYPE and onto the candidate's SCOPE, where it is just as real:
    doxygen emits a method twice — a header declaration and a definition — and writes the two
    rows' `scope` column differently. Measured on entropic, `ServerManager::init_builtins`:

        rowid 4651  scope 'entropic::ServerManager'   (declaration)
        rowid 4720  scope 'ServerManager'             (definition)

    `_scope_is` matches BOTH against the receiver's one declared class, so the pair is one
    owner. Counting the scope STRINGS saw two and refused — the identical mistake rule 3
    records, one level down.

    The cost was a silent false negative on a real chain: `init_builtins` and `load_plugins`
    each have exactly one production caller, through `h->server_manager->`, and both reported
    `callers: []`.

    THE SET IS NOT COLLAPSED TO ONE SPELLING ARBITRARILY. Every row whose scope denotes the
    pinned class survives, because which of the two rows a consumer wants — the declaration or
    the definition — is not this layer's call to make.

    @brief A declaration/definition scope pair does not make the owner ambiguous.
    @return None.
    @version 1
    """
    decl, defn = 4651, 4720
    scope_of = {decl: "entropic::ServerManager", defn: "ServerManager"}
    classes = {"server_manager": {"entropic::ServerManager"}}
    survivors, verified = _narrow_by_receiver(
        "server_manager", 3, [decl, defn], classes, scope_of, {decl: 3, defn: 3}
    )
    assert verified, (
        "one class written two ways is one owner; counting scope strings refused a call whose "
        "receiver type the index holds unambiguously"
    )
    assert set(survivors) == {decl, defn}, (
        f"both rows are the same method on the pinned class and must survive: {survivors}"
    )

Activity · 6 steps
lines 151–151decl, defn = 4651, 4720lines 152–152scope_of = {decl: "entropic::ServerManager", defn: "ServerManager"}lines 153–153classes = {"server_manager": {"entropic::ServerManager"}}lines 154–156survivors, verified = _narrow_by_receiver( "server_manager", 3, [decl, defn], classes, scope_of, {decl: 3, defn: 3} )lines 157–160assert verified, ( "one class written two ways is one owner; counting scope strings refused a call whose " "receiver type the index holds unambiguously" )lines 161–163assert set(survivors) == {decl, defn}, ( f"both rows are the same method on the pinned class and must survive: {survivors}" )

test_two_spellings_of_one_class_are_one_owner

None test_receiver_resolution.test_two_spellings_of_one_class_are_one_owner()

Two spellings of one class are one owner, not two.

tests/test_receiver_resolution.py:105

Show on the map →

Called by none

Calls _narrow_by_receiver

Checks

  • assert verified and set(survivors) == {ENGINE_A, ENGINE_B}, (f"two spellings of one class were treated as two owners: verified={verified} " f"survivors={survivors}" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-054inferredtest_two_spellings_of_one_class_are_one_owner → _narrow_by_receiver → _one_class → all
Source · 17 lines
def test_two_spellings_of_one_class_are_one_owner() -> None:
    """RULE 3. `std::unique_ptr< entropic::AgentEngine >` and `AgentEngine *` are the same
    class; the index holds ONE scope for it. Counting type spellings saw two owners and refused,
    which is why the fix counts distinct SCOPES instead.

    @brief A qualified and an unqualified spelling do not make the receiver ambiguous.
    @return None.
    @version 1
    """
    classes = {"engine": {"entropic::AgentEngine", "AgentEngine"}}
    survivors, verified = _narrow_by_receiver("engine", 1, ALL, classes, SCOPE_OF, ARGC_OF)
    assert verified and set(survivors) == {ENGINE_A, ENGINE_B}, (
        f"two spellings of one class were treated as two owners: verified={verified} "
        f"survivors={survivors}"
    )

Activity · 3 steps
lines 114–114classes = {"engine": {"entropic::AgentEngine", "AgentEngine"}}lines 115–115survivors, verified = _narrow_by_receiver("engine", 1, ALL, classes, SCOPE_OF, ARGC_OF)lines 116–119assert verified and set(survivors) == {ENGINE_A, ENGINE_B}, ( f"two spellings of one class were treated as two owners: verified={verified} " f"survivors={survivors}" )