Skip to content

PHP: clearly-wrong calls edges in the repro neighborhood (.parent() --calls--> .setUp(); .handle() --calls--> test methods) — failure mode #3 evidence #39

Closed

Description

@filipechagas

Observation (evidence capture, not yet diagnosed)

Measured 2026-08-06 on the api.lawnstarter.com repro graph @ d2d4bed7ae (48,529 nodes), probing call-context edges around ChargeCustomerService:

  • app_servicecategory_servicecategory_parent (.parent()) --calls--> .setUp() of both ChargeCustomerServiceTest variants and of BalanceCustomerAccountServiceTest — a model accessor does not call test fixtures.
  • app_services_billing_chargecustomerservice_chargecustomerservice_handle (.handle()) --calls--> several ChargeCustomerServiceTest test methods (e.g. .test_integration_execute_payment_failure_charge_successfully_charges_the_customer()) — production code does not call tests; the direction/target is wrong.

Repro: load the graph and list edges with context == "call" whose endpoint ids contain chargecustomerservice / balancecustomeraccountservice (probe script preserved in #37's step-through notes).

Why it matters

These edges feed the "all test noise" impression in #37's phrasing-A output and inflate every call-filtered traversal near billing. This is the PE-78803 spike's failure mode #3 (node-identity / wrong-edge territory) — kept deliberately separate from #37's seeding fix per its scope decision.

Next step

Diagnose the minting path (bare-name legacy resolution vs. member-call resolver vs. stub shadowing) before proposing a fix; this issue exists to carry the measured evidence and keep #37 unconflated.

Activity

  1. added
    needs-triage
    on Aug 6, 2026
  2. filipechagas commented on Aug 7, 2026

    @filipechagas
    CollaboratorAuthor

    Triage + diagnosis (2026-08-07)

    Diagnosed during the #46 triage sweep, probing the raw pinned graph (/tmp/api-d2d4bed/graphify-out/graph.json, 46,406 nodes / 139,497 links — the 48,529 figure in the body was the loaded graph, i.e. raw + the 2,123 dangling endpoints serve materializes, per #46). Fork code referenced @ a9adfc6.

    Correction: the evidence edges were direction-flipped by the probe

    The step-through drivers used a CLI-faithful undirected load, so both evidence items printed in arbitrary orientation. In the raw graph:

    • .handle() --calls--> test methods is actually test method --calls--> .handle() — correct edges (tests do call handle()). Not a bug.
    • .parent() --calls--> .setUp() is actually *Test.setUp() --calls--> ServiceCategory.parent() — genuinely wrong, and far bigger than the anecdote: app_servicecategory_servicecategory_parent has 1,698 inbound calls edges, one for every parent::__construct() / parent::setUp() / parent::boot() in the corpus.
    • Same mechanism, second family found during the probe: GetProviderBillingEventsTest.event() (a unit-test helper) has 848 inbound calls edges — every Laravel event(...) global-helper call in production code (e.g. ChargeCustomerService.php:76).

    Minting path (root-caused)

    1. The scoped_call_expression handler takes the scope text as the callee name (graphify/extractors/engine.py:4807-4811): parent::setUp() → callee parent. It never checks the scope against _PHP_NON_CONCRETE_TYPE_NAMES (engine.py:714 — which already contains parent/self/static), even though the (new X())->m() branch at engine.py:4858 applies exactly that refusal.
    2. Unresolved in-file, the raw call reaches the shared cross-file pass (graphify/extract.py:6092), which matches by normalized label — strip("()").lstrip("."), case-folded for PHP (extract.py:6006-6014). parent has effectively one callable candidate corpus-wide (ServiceCategory::parent(), label .parent()) → 1,698 confident wrong edges. event has 4 candidates (3 Event classes + the test's .event() method); the tie-break picked the test method → 848 wrong edges.

    Not #46 territory: every endpoint here is a real sourced node — no sourceless stubs involved. Independent bug, none of #47–#49 touches it.

    Scope for ready-for-agent

    Fix the relative-scope family: in the scoped_call_expression branch, refuse parent/self/static (and the rest of _PHP_NON_CONCRETE_TYPE_NAMES) as callee names, matching the engine.py:4858 precedent. (self::/static:: calls that should resolve within the declaring class would need inheritance context the raw-call facts don't carry — refusal over guessing, same discipline as #4/#38.)

    Acceptance:

    • Red-first: fixture with class A { function setUp() { parent::setUp(); } } + unrelated class B { function parent() {} } currently mints A.setUp --calls--> B.parent; after the fix, no such edge
    • api-scale: inbound calls on ServiceCategory::parent() drops from 1,698 to genuine callers only
    • Legit scoped calls (Helper::format() → callee Helper) unaffected

    Deliberately out of scope (needs a maintainer policy call before spec): whether a PHP function_call_expression (global helper like event()) may ever bare-match a method node cross-file — the 848-edge family. That policy interacts with legitimate global-function resolution; propose separately once the relative-scope fix lands.

  3. added
    ready-for-agent
    and removed
    needs-triage
    on Aug 7, 2026
  4. filipechagas commented on Aug 7, 2026

    @filipechagas
    CollaboratorAuthor

    Fixed on the fork feature branch fix/stub-shadowing-46 (commit 075038e, cherry-picked from fix/39-relative-scope-refusal), headed for the single PR into v8.

    What landed: the scoped_call_expression branch (graphify/extractors/engine.py) now refuses any scope whose written text is in _PHP_NON_CONCRETE_TYPE_NAMES (parent/self/static and the rest of the set) as a callee name, matching the (new X())->m() refusal precedent. No resolution attempt for self::/static:: — refusal over guessing.

    Acceptance criteria:

    • Red-first fixture (A.setUp() calling parent::setUp() + unrelated B.parent()): base minted A.setUp --calls--> B.parent (INFERRED/0.8); after the fix, no such edge. Same shape covered for self:: and static:: (tests/test_php_relative_scope_calls.py, verified red on base by an independent review session).
    • Legit scoped calls unaffected: Helper::format() and \App\Helper::format() still resolve (positive controls green on base and slice).
    • api-scale check (inbound calls on ServiceCategory::parent() drops from 1,698 to genuine callers) — deferred to Stub-shadow fix 4/4: release + acceptance grading on the pinned api corpus #50's grading rebuild, as specced.

    Out of scope, untouched as agreed: the event() global-helper family (848 edges) — function_call_expression and the cross-file matching in extract.py are unmodified; still pending a maintainer policy call.

    Adversarial review verdict: APPROVE (full trace of the refusal path, empirical probe of base vs slice, base-red verification of the new tests, full suite green: 4288 passed / 3 skipped on the integrated branch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions