Skip to content

fix: same-named files from two repos are not one file in explain and path (#4512) - #4520

Closed
Deepjyoti-Sarmah wants to merge 2 commits into
Graphify-Labs:v8from
Deepjyoti-Sarmah:fix/4512-same-basename-repos
Closed

Deepjyoti-Sarmah wants to merge 2 commits into
Graphify-Labs:v8from
Deepjyoti-Sarmah:fix/4512-same-basename-repos

Conversation

@Deepjyoti-Sarmah

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #4512.

In a merged multi-repo graph, two nodes can share a label and a repo-relative source_file, for example web/dup.py and ml/dup.py. Both appear as dup.py. The same-file check used the bare source_file, so the two nodes counted as one file. explain and path then refused with "matches 2 nodes in dup.py", listed bare L1 lines, and gave a hint that could not tell the candidates apart.

This PR makes a file the pair (repo, source_file). The refusal names each candidate's file with its repo, and when the same path exists in more than one repo, the hint says so and asks for the full node id.

_rivals_across_files(tier)
  before: key = source_file           -> web/dup.py and ml/dup.py collapse to "dup.py"
  after:  key = (repo, source_file)   -> two files, cross-file branch

_ambiguity_message(...)
  repos differ        -> list "web/dup.py", "ml/dup.py"
  same path, 2 repos  -> hint: "the same path exists in more than one repo ..."
  otherwise           -> unchanged
  • A repo is shown in the refusal only when the candidates span more than one repo.
  • Single-repo graphs (no repo attribute) keep the old wording.
  • Same-file duplicates keep the old same-file branch.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

A same-named file from two repos is never silently merged into one file. A single-repo graph gives the same refusal text as before.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary.
  • Added regression tests that fail on the code before this change.
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

Merge Danger

Door: two-way. Only the wording of one refusal and the file key used to detect ambiguity change. No schema, cache or file-format change. Reverting restores the old wording.

Blast Radius: ambiguity refusals in merged graphs. _resolve_single_node is shared, so explain, path, and the get_node and get_neighbors tools all show the new wording. query and --seed are not changed here. Single-repo output is unchanged.

Limitations

How was this tested?

tests/test_same_basename_repos.py (5 tests). Before the fix, 3 fail: the explain message, the explain hint, and the path message. The node-id lookup and the single-repo wording pass before and after.

Repro: two repos, each with dup.py defining Config, merged with graphify merge-graphs.

before (upstream v8)
  explain Config        exit 3   Ambiguous: 'Config' matches 2 nodes in dup.py.
                                 L1 / id: web::dup_config / L1 / id: ml::dup_config
  path Config Config    exit 3   same text as explain

after
  explain Config        exit 3   Ambiguous: 'Config' matches 2 nodes in different files.
                                 web/dup.py  id: web::dup_config
                                 ml/dup.py   id: ml::dup_config
                                 Retry with the full node id: the same path exists in more than one repo ...
  path Config Config    exit 3   same text as explain
tests/test_same_basename_repos.py                                   5 passed
related files (serve, explain_same_file_tie, path_cli, lookup, http) 248 passed
full suite                                                          8397 passed, 14 skipped, 0 failed
ruff check (changed files)                                          All checks passed

Graphify-specific checklist

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched.)
  • I confirmed that AST/structural extraction remains deterministic (no ambient state dependencies like ENV variables).
  • I reviewed changes for security implications (no unsafe interpolation into shell/Python).
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages.

…th (Graphify-Labs#4512)

The tests build a merged graph where web/dup.py and ml/dup.py hold a node with the same label, and check that explain and path name both repos, give the full node id as the retry, and leave a graph with no repo attribute unchanged. Three of the five fail before the fix.
…path (Graphify-Labs#4512)

The same-file check used the bare source_file, so web/dup.py and ml/dup.py read as one file, with bare line numbers and a hint that could not tell them apart.

A file is now its repo plus source_file. A repo is shown only when the candidates span more than one repo, so a graph with no repo attribute reads as before. When the path is shared across repos, the hint says to use the full node id.
@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 17, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @Deepjyoti-Sarmah. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Not checked: tests were not run; formal verification proved 0 of 3 changed function(s) (3 sampled, not proven).

Formal verification. PR-changed functions: 3/3 verified (0 proven, 3 may-equivalent, 0 distinguished) · 0 not verified.


Graphify review — findings

Fixes ambiguity detection in merged multi-repo graphs, where two repos each holding dup.py were treated as one file and silently resolved to whichever node came first. _rivals_across_files now keys on repo plus source_file, and graphs with no repo attribute group by path alone, so single-repo wording is unchanged. Updates _ambiguity_message to prefix candidates with their repo only when they span several repos, and to tell the user to retry with the full node id when the same path appears in more than one repo. The repo-prefixed listing is a new path form that the path::symbol retry hint has to stay consistent with. Adds tests covering the two-repo refusal text, the node-id hint, full-id resolution, the graphify path CLI exit code, and the untagged-graph fallback.

Worth a look

  • Repo-prefixed paths in the refusal break the suggested path::symbol retry — graphify/serve.py:1826 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 653 functions depend on the 166 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: main() — 111 callers, 3 callees

Verification — 653 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 553 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

17 of 433 test file(s) selected (4%) via static blast radius.

  • tests/test_benchmark.py — impact
  • tests/test_benchmark_raw_graph.py — impact
  • tests/test_benchmark_real_query.py — impact
  • tests/test_explain_same_file_tie.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_mcp_graph_view_cache.py — impact
  • tests/test_path_cli.py — impact
  • tests/test_query_induced_edges.py — impact
  • tests/test_query_mcp_direction.py — impact
  • tests/test_query_names_its_graph.py — impact
  • tests/test_query_seed_order.py — impact
  • tests/test_query_seeds.py — impact
  • tests/test_same_basename_repos.py — impact, changed-test
  • tests/test_serve.py — impact
  • tests/test_serve_http.py — impact
  • tests/test_terraform.py — impact
  • tests/test_truncation_full_answer.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Docs that may be stale (advisory)

…and 10 more.

Formal verification

No difference found (not proven): No behavior difference found in \_ambiguity\_message (not a proof).

The verifier ran both versions of \_ambiguity\_message on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in \_rivals\_across\_files (not a proof).

The verifier ran both versions of \_rivals\_across\_files on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

No difference found (not proven): No behavior difference found in find\_node\_ambiguity (not a proof).

The verifier ran both versions of find\_node\_ambiguity on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

· 1 more finding(s) on lines outside this diff (see the check run).

@safishamsi

Copy link
Copy Markdown
Member

Landed in 0.9.93, cherry-picked to preserve your authorship. Two same-path files from different repos in a merged graph are kept distinct in explain and path, instead of being conflated as one file. Thanks @Deepjyoti-Sarmah. Live on PyPI: https://pypi.org/project/graphifyy/0.9.93/

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

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:merged graph — ambiguity refusal reports cross-repo same-basename nodes as being in one file

2 participants