Skip to content

Stub-shadow fix 2/4: resolve imports edges from their own target_fqn metadata (RC2 of #46) #48

Closed

Description

@filipechagas

Parent

#46 — implements RC2 (independent root cause).

What to build

An imports edge whose target never got a stub node becomes resolvable: _resolve_php_type_references resolves imports edges from the edge's own target_fqn metadata (stamped by _import_php since #19) instead of requiring a stub node to read a label from. Today _import_php (graphify/extract.py:810-822) mints no node, and the repoint pass skips the edge when stub_label.get(tgt) misses (graphify/extractors/resolution.py:2770-2773) — so the dangling bare target survives into graph.json and serve materializes an attributeless degree-1 node at load.

Acceptance criteria

Blocked by

None — independent of RC1 (#47): it resolves from edge metadata, not from node existence. Note the interplay: imports of interfaces/traits/enums additionally need #47's nodes to exist before they can land.

Activity

  1. added
    ready-for-agent
    on Aug 7, 2026
  2. filipechagas commented on Aug 7, 2026

    @filipechagas
    CollaboratorAuthor

    Fixed on the fork feature branch fix/stub-shadowing-46 (commit 258d8e3, cherry-picked from fix/48-imports-target-fqn), headed for the single PR into v8.

    What landed: the repoint pass in _resolve_php_type_references resolves class imports edges from their own target_fqn metadata (stamped by _import_php since #19) instead of requiring a stub node to read a label from — an import used only via ::class no longer dangles. Unresolvable FQNs park on FQN-labeled external stubs (deduped by FQN, never bare-matched to a same-short-name type). use function/use const are excluded from the type map.

    Acceptance criteria:

    • Red-first OnlyImport.php case: use App\Repo\DbFooRepository; used only as ::class — the edge lands on the real class node (was dangling on base; verified red by review).
    • No new false merges: an FQN resolving to nothing parks on a labeled external stub; the FQN label keys distinctly under _node_label_key, so the bare-label rewire cannot collapse it onto a same-short-name type (explicit test, mutation-verified by review).
    • Existing resolution tests green; the modified capture-layer test was split, not weakened (review verified the original invariant still passes on base via the extract_php seam).
    • Q2 shape (ChargeCustomerCancellationFee resolves without disambiguation retry) and the 19,303-dangling-imports drop — deferred to Stub-shadow fix 4/4: release + acceptance grading on the pinned api corpus #50's grading rebuild, as specced.

    Bonus deltas (intended, tested): aliased imports (use A\B\C as D;) now resolve to the written FQN instead of a namespace guess; class imports in namespace-less files repoint too (the use FQN is itself the namespace fact).

    Review history worth recording: the first round found a major — repointing could add arbitrary short-name ids to the orphan-prune set, silently deleting an unrelated real node whose id collided with an imported short name (e.g. a Page.md doc node vanishing when any file gained use Vendor\Pkg\Page;). Fixed with a stub-only guard plus a regression test; the re-review mutation-tested the guard (dropping it fails exactly that test) and confirmed the repro now keeps the real node. Final verdict: APPROVE, no findings. Full suite on the integrated branch: 4321 passed / 3 skipped.

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