Repository navigation
feat(path): report path confidence as the weakest hop (#4885) - #4892
SyedFahad7 wants to merge 3 commits into
Conversation
…phify-Labs#4881) A same-relation collision keeps the higher-confidence edge (Graphify-Labs#3711), and the other copy was discarded, so an AMBIGUOUS or INFERRED duplicate (typically a semantic-pass edge over an AST edge) left no trace in graph.json. The winner now lists each other copy's confidence, confidence_score, source_file and source_location in `also_seen`, weakest first, deduplicated against the winner and each other so re-feeding graph.json through an update is idempotent. A malformed `also_seen` read back from disk is sanitized. When the incoming edge wins, fields only the loser carried are removed from the stored edge: add_edge merges attribute dicts, so the displaced edge's confidence_score used to stay on an EXTRACTED winner that had none. `graphify path` (CLI and MCP shortest_path) unions the also_seen tags into the hop label, as it already does for parallel edges: [AMBIGUOUS/INFERRED]. Fixes Graphify-Labs#4881 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Syed Fahad <sfahad2904@gmail.com>
…4885) `graphify path` and the MCP `shortest_path` tool labelled each hop on its own, so one INFERRED or AMBIGUOUS hop among EXTRACTED ones read as a list of independent tags rather than marking the whole path. Both now end with one summary line: Path confidence: INFERRED (weakest hop 2: dispatches_to, score 0.75) A hop's strength is the weakest evidence it carries, its parallel edges and also_seen entries included; hops are ranked by _CONFIDENCE_RANK, then by the lowest confidence_score (a missing score never counts as weaker than a present one), and ties name the first such hop. A hop with no recognised tag makes the path "unknown" rather than letting the other hops vouch for it. The helper lives in serve.py and the CLI calls it, so both entry points stay identical. Fixes Graphify-Labs#4885 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Syed Fahad <sfahad2904@gmail.com>
|
Thanks for the pull request, @SyedFahad7. 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. |
There was a problem hiding this comment.
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 4 changed function(s) (4 not verified).
Formal verification. PR-changed functions: 0/4 verified (0 proven, 0 may-equivalent, 0 distinguished) · 4 not verified (4 vacuous).
Not verified on this run: build\_from\_json (vacuous: never exercised), dispatch\_command (vacuous: never exercised), \_build\_server (vacuous: never exercised), \_shortest\_path\_text (vacuous: never exercised).
Graphify review — findings
Adds an overall confidence line to graphify path and the shortest_path MCP tool, reporting the path's weakest hop (e.g. Path confidence: INFERRED (weakest hop 2: calls, score 0.7)). A hop with no recognised confidence tag makes the whole path report as unknown. When two edges with the same relation between the same nodes collapse, the lower-confidence copy is no longer thrown away: the winner keeps the best one and records the others in a new also_seen list (confidence, score, source file and location, weakest first). Re-feeding a written graph.json through the build is idempotent, and graphify path now shows the tags of every copy on a hop, such as [AMBIGUOUS/INFERRED]. README and docs/how-it-works.md describe the new line and the also_seen edge field.
No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 2342 functions depend on the 427 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
build_from_json()— 283 callers, 21 callees - worse:
dispatch_command()— 5 callers, 137 callees - worse:
main()— 117 callers, 3 callees - worse:
_shortest_path_text()— 17 callers, 5 callees
Verification — 2342 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: 2128 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
471 of 471 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_affected_cli.py— impact, full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— full-run-safetytests/test_affected_path_file_node.py— impact, full-run-safetytests/test_agents_platform.py— impact, full-run-safetytests/test_alias_folding.py— impact, full-run-safetytests/test_analyze.py— impact, full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— full-run-safetytests/test_astro_import_ids.py— full-run-safetytests/test_atomic_canvas_export.py— impact, full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— impact, full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_backend_opt_in.py— impact, full-run-safetytests/test_benchmark.py— impact, full-run-safetytests/test_benchmark_raw_graph.py— impact, full-run-safetytests/test_benchmark_real_query.py— impact, full-run-safetytests/test_binary_media_words.py— full-run-safetytests/test_blade_extractor.py— full-run-safetytests/test_build.py— impact, full-run-safetytests/test_build_located_semantic_identity.py— impact, full-run-safetytests/test_build_merge_dedup_scope.py— impact, full-run-safetytests/test_build_merge_hyperedges_and_prune.py— impact, full-run-safetytests/test_build_merge_shrink_guard.py— impact, full-run-safetytests/test_builtin_global_type_refs.py— full-run-safetytests/test_c_include_resolution.py— impact, full-run-safetytests/test_cache.py— full-run-safetytests/test_cache_long_paths.py— full-run-safetytests/test_cache_stale_import_target.py— full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— impact, full-run-safetytests/test_case_sensitive_resolution.py— full-run-safetytests/test_charmap_encoding.py— impact, full-run-safetytests/test_chunking.py— impact, full-run-safetytests/test_cjs_module_extension.py— full-run-safetytests/test_claude_cli_backend.py— impact, full-run-safetytests/test_claude_md.py— full-run-safetytests/test_cli_broken_pipe.py— full-run-safetytests/test_cli_export.py— impact, full-run-safetytests/test_cli_help.py— full-run-safetytests/test_cloud_cta.py— impact, full-run-safety- … and 421 more
non-code file(s) changed (
README.md,docs/how-it-works.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)
changed code file(s) with no mapped test (
README.md,docs/how-it-works.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests
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 11 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous
Could not verify: Could not verify dispatch\_command.
The verifier did not have enough to check dispatch\_command, 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 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly SystemExit — names the real obstacle, not a sampling gap)
Could not verify: Could not verify \_build\_server.
The verifier did not have enough to check \_build\_server, 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 40 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly ValueError — names the real obstacle, not a sampling gap)
Could not verify: Could not verify \_shortest\_path\_text.
The verifier did not have enough to check \_shortest\_path\_text, 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 35 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly KeyError — names the real obstacle, not a sampling gap)
· 1 grounded finding(s) anchored inline below; 3 more finding(s) on lines outside this diff (see the check run).
| return f"Path confidence: {conf} (weakest hop {hop}: {rel}{score_str})" | ||
|
|
||
|
|
||
| def _shortest_path_text(G: nx.Graph, arguments: dict) -> str: |
There was a problem hiding this comment.
_shortest_path_text()
17 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
…bs#4885) EXTRACTED is 1.0 by definition, and the hop tags (Graphify-Labs#4882) print it bare, but the path summary printed "score 1" when an EXTRACTED hop carried a stored confidence_score. Its score is now ignored both when printing and when ranking, so an all-EXTRACTED path names its first hop instead of whichever hop happened to store 1.0. A non-finite score is treated as missing, as in the hop tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Syed Fahad <sfahad2904@gmail.com>
…els, path weakest-hop confidence, Type.Member path endpoints Covers the SyedFahad7 batch: #4891 and #4889 merged on GitHub; #4892 and #4893 landed via authorship-preserving cherry-pick (their CI matrix was gated pending first-contributor approval, so brought in through the local gate instead). Credit by GitHub PR-author login @SyedFahad7. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Landed in v0.9.98, now on PyPI (pip install graphifyy==0.9.98). Landed via cherry-pick (your CI matrix was gated). path reports the overall confidence as the weakest hop. Thanks for the fix, @SyedFahad7. |
What does this PR do?
Fixes #4885.
graphify pathand the MCPshortest_pathtool label each hop separately. A path with one INFERRED or AMBIGUOUS hop among EXTRACTED hops therefore reads as a list of independent tags, and nothing marks the path as a whole as uncertain. Both now end with one summary line.Repro from the issue (
Report.cs:IReport.Build(),PdfReport/CsvReportimplementing it,Exporter.Run()calling_report.Build();graphify update .):The MCP
shortest_pathresult ends with the same line.How the summary is computed (
_path_confidence_lineingraphify/serve.py, also called by the CLI path ingraphify/cli.py):also_seenentries._CONFIDENCE_RANK(graphify/build.py) first, then by the lowestconfidence_score. A missing score never counts as weaker than a present one. On a tie, the first such hop is named., score Xis printed only when the weakest evidence has a score.Path confidence: unknown (hop N: <relation> has no confidence tag). The other hops cannot vouch for it.shortest_pathtool description and the README sentence aboutgraphify pathmention the new line.Type of change
Verification & Invariants
Invariant: a path is never reported as more certain than its least certain hop (CONTRIBUTING, "Keep inference visibly separate from extracted fact"). The existing hop segments are byte-identical. The only output change is one extra line after them, so anything matching
Shortest path (N hops):or hop substrings is unaffected. Nothing is persisted, so no graph or cache state changes.Limitations:
pathreturns. Comparing several routes to the same target is not attempted.pathandexplain#4882 (PR fix(serve): print confidence_score in path, explain and neighbors output #4888, scores printed in hop tags) edits the sameconfs = sorted(...)hop-tag line inserve.pyandcli.py. Whichever lands second has a trivial one-line merge per file. This PR's own additions (hop_datas, the summary line, the helper) are outside those lines.How was this tested?
tests/test_path_confidence.py(7 tests) covers:_shortest_path_text;also_seencounting toward their hop;On PR A's commit, without this change, the module fails (
_path_confidence_linedoes not exist), and the repro output has no summary line.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No fragments touched.)Stacked on #4891 — review/merge that first; this PR includes its commit.
Update (follow-up commit 659e7db)
6e6e68a2(this change) and659e7db9(follow-up), on top of fix(build): keep a collapsed edge's weaker evidence in also_seen (#4881) #4891.tests/test_path_confidence.py(was 7); targeted run 218 passed; full suite 8986 passed, 17 skipped, 1 xfailed.