Skip to content

fix(build): preserve higher confidence on same-relation edge collisio… - #3711

Closed
shobhitagnihotri69 wants to merge 1 commit into
Graphify-Labs:v8from
shobhitagnihotri69:fix/3703-same-relation-confidence-precedence
Closed

shobhitagnihotri69 wants to merge 1 commit into
Graphify-Labs:v8from
shobhitagnihotri69:fix/3703-same-relation-confidence-precedence

Conversation

@shobhitagnihotri69

Copy link
Copy Markdown
Contributor

Summary

Fixes #3703.

When an existing edge and an incoming edge share the same node pair and same relation name, build.py previously overwrote the existing edge with the incoming edge unconditionally. This inadvertently downgraded deterministic EXTRACTED AST edges to INFERRED semantic edges.

Changes

  • Implemented confidence precedence comparison (EXTRACTED > INFERRED > AMBIGUOUS) for same-relation collisions in graphify/build.py.
  • Preserved existing edge attributes (including source_location) when an existing higher-confidence edge encounters an incoming lower-confidence edge with the same relation.
  • Added regression test test_same_relation_collision_preserves_extracted_over_inferred in tests/test_relation_collapse_precedence.py.

Validation

  • pytest tests/test_relation_collapse_precedence.py: 68 passed.
  • pytest tests/test_build.py: 92 passed.

@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 3 advisory finding(s) below merit a look before merge.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Makes same-relation edge collisions resolve by confidence instead of edge order: when two edges share src, tgt, and relation, build_from_json keeps the one ranked higher under _CONFIDENCE_RANK (EXTRACTED > INFERRED > AMBIGUOUS), and on ties prefers the edge that has a source_location and, failing that, the higher confidence_score. This stops a later INFERRED edge from downgrading an already-recorded EXTRACTED AST edge regardless of arrival order; the existing generic-vs-specific collapse is unchanged.

Worth a look

  • Malformed confidence_score can abort JSON graph build — graphify/build.py:1439 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Duplicate edge collapse can now raise on incomparable confidence_score values — graphify/build.py:1434 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
  • Null confidence_score can overwrite a scored same-relation edge — graphify/build.py:1438 · 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 — 1288 functions depend on the 118 functions this change touches.

Health — this change adds coupling hotspots:

  • new: _rebuild_code() — 142 callers, 54 callees
  • new: build_from_json() — 219 callers, 20 callees
  • new: build_merge() — 76 callers, 14 callees
  • new: to_obsidian() — 38 callers, 14 callees
  • new: extract_files_direct() — 17 callers, 20 callees
  • new: build() — 52 callers, 6 callees
  • new: _call_claude_cli() — 33 callers, 9 callees
  • new: to_wiki() — 41 callers, 7 callees
  • …and 40 more — each is listed as a finding

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

Test selection

Test selection

92 of 290 test file(s) selected (32%) via static blast radius.

  • tests/test_analyze.py — impact
  • tests/test_atomic_canvas_export.py — impact
  • tests/test_benchmark.py — impact
  • tests/test_benchmark_raw_graph.py — impact
  • tests/test_build.py — impact
  • tests/test_build_merge_dedup_scope.py — impact
  • tests/test_build_merge_hyperedges_and_prune.py — impact
  • tests/test_build_merge_shrink_guard.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_confidence.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_dedup.py — impact
  • tests/test_dedup_remaps_hyperedges.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_duplicate_annotation_edges.py — impact
  • tests/test_evidence_binding.py — impact
  • tests/test_export.py — impact
  • tests/test_export_control_characters.py — impact
  • tests/test_export_path_length.py — impact
  • tests/test_external_stub_endpoints.py — impact
  • tests/test_extract.py — impact
  • tests/test_falkordb_integration.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_global_add_tag_inference.py — impact
  • tests/test_global_graph.py — impact
  • tests/test_go_qualified_resolution.py — impact
  • tests/test_god_nodes_exclude_hubs.py — impact
  • tests/test_hyperedge_member_shapes.py — impact
  • tests/test_hyperedge_roundtrip.py — impact
  • tests/test_hypergraph.py — impact
  • tests/test_image_vision.py — impact
  • tests/test_import_self_loops.py — impact
  • tests/test_issue_3472_source_file_collision.py — impact
  • tests/test_java_type_resolution.py — impact
  • tests/test_languages.py — impact
  • tests/test_llm_backends.py — impact
  • tests/test_llm_parser.py — impact
  • tests/test_llm_parser_reasoning.py — impact
  • tests/test_loose_sibling_import_resolution.py — impact
  • tests/test_lua_import.py — impact
  • tests/test_manifest_ingest.py — impact
  • tests/test_merge_chunks_validation.py — impact
  • … and 42 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

Could not verify: Could not verify build\_from\_json.

The verifier did not have enough to check build\_from\_json, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 6 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly NameError — names the real obstacle, not a sampling gap)

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

@safishamsi

Copy link
Copy Markdown
Collaborator

Shipped in v0.9.66 (on PyPI). Cherry-picked with authorship preserved so it shows under your GitHub contributions. Thanks @shobhitagnihotri69!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Same-pair same-relation collision downgrades an EXTRACTED edge to INFERRED and rewrites its provenance

2 participants