fix(build): preserve higher confidence on same-relation edge collisio… - #3711
shobhitagnihotri69 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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— impacttests/test_atomic_canvas_export.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_build.py— impacttests/test_build_merge_dedup_scope.py— impacttests/test_build_merge_hyperedges_and_prune.py— impacttests/test_build_merge_shrink_guard.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_claude_cli_backend.py— impacttests/test_cli_export.py— impacttests/test_cluster.py— impacttests/test_confidence.py— impacttests/test_corrupt_graph_json.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_repo_external_call_guards.py— impacttests/test_dedup.py— impacttests/test_dedup_remaps_hyperedges.py— impacttests/test_definition_file_portability.py— impacttests/test_duplicate_annotation_edges.py— impacttests/test_evidence_binding.py— impacttests/test_export.py— impacttests/test_export_control_characters.py— impacttests/test_export_path_length.py— impacttests/test_external_stub_endpoints.py— impacttests/test_extract.py— impacttests/test_falkordb_integration.py— impacttests/test_file_label_disambiguation.py— impacttests/test_global_add_tag_inference.py— impacttests/test_global_graph.py— impacttests/test_go_qualified_resolution.py— impacttests/test_god_nodes_exclude_hubs.py— impacttests/test_hyperedge_member_shapes.py— impacttests/test_hyperedge_roundtrip.py— impacttests/test_hypergraph.py— impacttests/test_image_vision.py— impacttests/test_import_self_loops.py— impacttests/test_issue_3472_source_file_collision.py— impacttests/test_java_type_resolution.py— impacttests/test_languages.py— impacttests/test_llm_backends.py— impacttests/test_llm_parser.py— impacttests/test_llm_parser_reasoning.py— impacttests/test_loose_sibling_import_resolution.py— impacttests/test_lua_import.py— impacttests/test_manifest_ingest.py— impacttests/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).
|
Shipped in v0.9.66 (on PyPI). Cherry-picked with authorship preserved so it shows under your GitHub contributions. Thanks @shobhitagnihotri69! |
Summary
Fixes #3703.
When an existing edge and an incoming edge share the same node pair and same relation name,
build.pypreviously overwrote the existing edge with the incoming edge unconditionally. This inadvertently downgraded deterministicEXTRACTEDAST edges toINFERREDsemantic edges.Changes
EXTRACTED>INFERRED>AMBIGUOUS) for same-relation collisions ingraphify/build.py.source_location) when an existing higher-confidence edge encounters an incoming lower-confidence edge with the same relation.test_same_relation_collision_preserves_extracted_over_inferredintests/test_relation_collapse_precedence.py.Validation
pytest tests/test_relation_collapse_precedence.py: 68 passed.pytest tests/test_build.py: 92 passed.