Skip to content

serve: query/shortest_path endpoint resolution lacks the sourced-beats-sourceless rule that explain/affected now enforce (#49 gap) #54

Closed

Description

@filipechagas

Surfaced during #49's review (fork PR #51). _score_nodes / _pick_scored_endpoint did not learn #49's sourced-preference rule, so graphify query and shortest_path can still land on a sourceless stub while explain and affected agree on the sourced declaration.

Measured by the reviewer: graph [{id: aaa_stub, label: FooRepository, source_file: ""}, {id: zzz_src, label: FooRepository, source_file: app/bindings.php}] → both score identically (5619.08), _pick_scored_endpoint returns aaa_stub, while _find_node()[0] and resolve_seed return zzz_src. The comment at graphify/serve.py:515-520 states the design intent that path/query resolve the same node explain does — this widens a gap that comment names.

Post-0.9.38 blast radius is small (1,031 residual stubs, all vendor externals, per the #46 grading) but the inconsistency is structural. Candidate fix: apply the same sourced-preference (or a scoring penalty for source_file == "") in the scored-endpoint path, with the same lone-stub carve-out #49 pinned with tests.

Activity

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

    @filipechagas
    CollaboratorAuthor

    Triage decision (2026-08-07): accepted for the current fix cycle

    Spec: apply #49's sourced-beats-sourceless rule to the scored-endpoint path so query/shortest_path resolve the same node explain/affected do (the design intent stated at graphify/serve.py:515-520).

    Acceptance criteria (red-first):

    1. The reviewer's two-node repro: _pick_scored_endpoint returns the sourced node (currently the stub — red first).
    2. Lone-stub carve-out: same query with only the sourceless node present still returns it.
    3. query and shortest_path endpoint resolution agree with explain's _find_node pick on the repro graph.
    4. Tests mirror Stub-shadow fix 3/4: find_node_ambiguity must not collapse sourceless rivals into one group (RC3 of #46) #49's style/coverage; full suite green: uv run --frozen pytest tests/ -q --tb=short.
  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 cycle branch fix/resolution-gaps-52-53-54 (integrated as the cherry-pick of slice commit a72956c), shipping in 0.9.39 via the cycle PR into v8.

    Acceptance criteria, all verified locally (serve-side, synthetic graphs — no api corpus needed):

    1. ✅ The reviewer's two-node repro (identical scores 5619.081861425897) — _pick_scored_endpoint now returns the sourced zzz_src; was aaa_stub. Test red on base (14/20 of the new file fail on 18c17d8:graphify/serve.py), green after.
    2. ✅ Lone-stub carve-out holds by construction and is pinned (source_file: "" and missing-key variants; N=2,18 all-sourceless fields; query-over-stubs traversal).
    3. ✅ query/shortest_path agree with explain's _find_node on the repro shapes (incl. a false "No directed path found" on base that is now a 1-hop path).
    4. ✅ 20 tests mirroring Stub-shadow fix 3/4: find_node_ambiguity must not collapse sourceless rivals into one group (RC3 of #46) #49's style (tests/test_scored_endpoint_sourced_preference.py); full suite green on the slice (4391 passed / 3 skipped) and on the integration branch after cherry-pick (4399 passed / 3 skipped).

    Mechanism: a tie-break, not a scoring penalty — a sourceless node can never out-score an identical sourced one (the only source-derived term is additive), so the shadowing case always arrives as an exact tie; the sourced flag sits directly under the score in both tie-break keys (combined sort + per-term singleton winner). No live score changes, all score-sensitive baselines hold unedited. _find_node untouched per scope.

    Adversarial review: APPROVE (fresh session; base-red verified in a detached worktree, half-patch experiment proved both keys live, 10-case probe: scored-vs-_find_node agreement 4/10 → 8/10). One deliberate asymmetry documented in the CHANGELOG bullet: the scored path demotes stubs on any score tie while _find_node does so in its exact tier only — closing that would mean changing _find_node, out of scope here.

  5. added 2 commits that reference this issue on Aug 7, 2026
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