Skip to content

fix(tree): support src and file aliases to prevent empty tree viewer - #5030

Closed
Adityakk9031 wants to merge 1 commit into
Graphify-Labs:v8from
Adityakk9031:fix/tree-html-source-file-aliases
Closed

Adityakk9031 wants to merge 1 commit into
Graphify-Labs:v8from
Adityakk9031:fix/tree-html-source-file-aliases

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Summary

In graphify/build.py, _fold_node_aliases normalized ("file", "path", "filepath") onto source_file, but did not include "src". In addition, graphify.tree_html.build_tree filtered strictly on n.get("source_file") without normalizing alias fields, causing graphs whose nodes carry src or other file aliases to discard all nodes and return (empty graph).

Changes

  • In graphify/build.py (_fold_node_aliases): added "src" to the alias list so that build_from_json folds src onto source_file.
  • In graphify/tree_html.py (build_tree): normalize node aliases (src, file, path, filepath) onto source_file before filtering file_nodes.
  • In tests/test_alias_folding.py: added test_node_src_folds_to_source_file.
  • In tests/test_tree_html.py: added test_build_tree_accepts_src_and_file_aliases.

Test Plan

  • pytest tests/test_alias_folding.py tests/test_tree_html.py -> 47 passed.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Thanks for the pull request, @Adityakk9031. 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.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

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

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


Graphify review — findings

Adds src to the file-path aliases that _fold_node_aliases folds into source_file, so nodes carrying src keep their file association when a graph is built. Teaches build_tree to resolve a path from src, file, path or filepath when source_file is missing, so alias-only graphs render a populated tree instead of "(empty graph)". It runs its own alias loop with src checked first, while the build-time fold checks src last. New tests cover src folding and alias-only tree rendering.

No blocking issues surfaced. 4 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2160 functions depend on the 211 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: build_tree() — 22 callers, 5 callees

Verification — 2160 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: 1502 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

150 of 526 test file(s) selected (29%) via static blast radius.

  • tests/test_4874_jvm_resolution.py — impact
  • tests/test_4978_reconcile_cost.py — impact
  • tests/test_affected_cli.py — impact
  • tests/test_affected_path_file_node.py — impact
  • tests/test_affected_seed_reference_forms.py — impact
  • tests/test_alias_folding.py — impact, changed-test
  • tests/test_analyze.py — impact
  • tests/test_atomic_canvas_export.py — impact
  • tests/test_atomic_writes.py — impact
  • tests/test_backend_opt_in.py — impact
  • tests/test_benchmark.py — impact
  • tests/test_benchmark_raw_graph.py — impact
  • tests/test_benchmark_real_query.py — impact
  • tests/test_build.py — impact
  • tests/test_build_located_semantic_identity.py — impact
  • tests/test_build_merge_dedup_scope.py — impact
  • tests/test_build_merge_ghost_fold_4955.py — impact
  • tests/test_build_merge_hyperedges_and_prune.py — impact
  • tests/test_build_merge_shrink_guard.py — impact
  • tests/test_c_include_resolution.py — impact
  • tests/test_carried_hyperedge_remap.py — impact
  • tests/test_charmap_encoding.py — impact
  • tests/test_chunking.py — impact
  • tests/test_claude_cli_backend.py — impact
  • tests/test_cli_export.py — impact
  • tests/test_cluster.py — impact
  • tests/test_community_labels_skill.py — impact
  • tests/test_compact_graph_json.py — impact
  • tests/test_confidence.py — impact
  • tests/test_confidence_score_output.py — impact
  • tests/test_corrupt_graph_json.py — impact
  • tests/test_cpp_objc_cross_file_calls.py — impact
  • tests/test_cross_extension_reexport_self_cycle.py — impact
  • tests/test_cross_repo_external_call_guards.py — impact
  • tests/test_csharp_method_owner_labels.py — impact
  • tests/test_csharp_object_creation.py — impact
  • tests/test_dedup.py — impact
  • tests/test_dedup_remaps_hyperedges.py — impact
  • tests/test_dedup_shrink_refuses_force_write.py — impact
  • tests/test_dedup_survivor_richness.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_duplicate_annotation_edges.py — impact
  • tests/test_edge_also_seen.py — impact
  • tests/test_evidence_binding.py — impact
  • tests/test_export.py — impact
  • tests/test_export_control_characters.py — impact
  • tests/test_export_direction.py — impact
  • tests/test_export_idempotent_writes.py — impact
  • tests/test_export_path_length.py — impact
  • tests/test_ext_tagged_id_clash.py — impact
  • … and 100 more

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.

Formal verification

No difference found (not proven): No behavior difference found in \_fold\_node\_aliases (not a proof).

The verifier ran both versions of \_fold\_node\_aliases 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 build\_tree (not a proof).

The verifier ran both versions of build\_tree 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 added a commit that referenced this pull request Nov 8, 2026
…llow-up)

tree_html.build_tree folded aliases in a different order (src first) than
build._fold_node_aliases (src last), so a node carrying two conflicting file
aliases could key on different paths in the viewer vs the built graph. Use the
same order and pop the consumed alias, as the build-side fold does.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Landed on v8 and shipped in 0.9.104 (now on PyPI), cherry-picked with -x. Follow-up: I aligned the alias precedence so tree_html.build_tree folds in the same order as build._fold_node_aliases (src last), so a node carrying two conflicting file aliases resolves identically in the built graph and the viewer. Thanks @Adityakk9031.

@safishamsi safishamsi closed this Nov 8, 2026
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.

2 participants