Repository navigation
fix(serve): print confidence_score in path, explain and neighbors output - #4888
SyedFahad7 wants to merge 2 commits into
Conversation
graph.json stores a confidence_score next to every INFERRED edge (C# interface dispatch writes 0.85 / 0.75 / 0.65 by implementer count), but `path`, `explain` and the MCP shortest_path / get_neighbors renderers only printed the bare tag, so `[INFERRED]` hid whether an edge was a strong or a weak inference. A shared _confidence_tag() now renders a scored non-EXTRACTED edge as `[INFERRED 0.75]` at all four sites. EXTRACTED stays bare (it is 1.0 by definition), and a missing, non-numeric, boolean or non-finite score keeps the bare tag instead of printing a guess. Tests: tests/test_confidence_score_output.py runs the issue's Report.cs repro through extract/build and checks CLI explain, CLI path, MCP path and MCP neighbors; the four output tests fail without the fix. Fixes Graphify-Labs#4882 Co-Authored-By: Claude <[email protected]> Co-authored-by: Syed Fahad <[email protected]>
|
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 3 changed function(s) (3 not verified).
Formal verification. PR-changed functions: 0/3 verified (0 proven, 0 may-equivalent, 0 distinguished) · 3 not verified (3 vacuous).
Not verified on this run: dispatch\_command (vacuous: never exercised), \_neighbor\_lines (vacuous: never exercised), \_shortest\_path\_text (vacuous: never exercised).
Graphify review — findings
Adds the stored confidence_score to edge output in path, explain, and the MCP shortest_path and neighbor listings, so a scored non-EXTRACTED edge now reads [INFERRED 0.75] instead of a bare [INFERRED]. A new _confidence_tag helper in serve.py builds the label and is shared by the CLI and MCP renderers. EXTRACTED edges stay bare since their score is 1.0 by definition. Edges with a missing, boolean, string, or non-finite score fall back to the bare label rather than printing a guess. New tests cover the helper's edge cases and check the output end to end on a C# interface-dispatch graph.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 818 functions depend on the 254 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
dispatch_command()— 5 callers, 136 callees - worse:
main()— 116 callers, 3 callees - worse:
_shortest_path_text()— 15 callers, 4 callees - worse:
_neighbor_lines()— 6 callers, 4 callees
Verification — 818 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: 771 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
49 of 470 test file(s) selected (10%) via static blast radius.
tests/test_affected_cli.py— impacttests/test_agents_platform.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_cli_export.py— impacttests/test_cloud_cta.py— impacttests/test_codebuddy.py— impacttests/test_compact_graph_json.py— impacttests/test_confidence_score_output.py— impact, changed-testtests/test_dedup_shrink_refuses_force_write.py— impacttests/test_devin.py— impacttests/test_explain_cli.py— impacttests/test_explain_same_file_tie.py— impacttests/test_extract.py— impacttests/test_extract_cli.py— impacttests/test_extract_cost_ledger.py— impacttests/test_file_label_disambiguation.py— impacttests/test_global_add_tag_inference.py— impacttests/test_god_nodes_cli.py— impacttests/test_hollow_chunks_arm_shrink_guard.py— impacttests/test_hook_guard_token_match.py— impacttests/test_hook_nudge_wording.py— impacttests/test_hook_out_of_project_paths.py— impacttests/test_hook_strict.py— impacttests/test_incomplete_build_guard.py— impacttests/test_install.py— impacttests/test_install_references.py— impacttests/test_lookup_exit_codes.py— impacttests/test_mcp_graph_view_cache.py— impacttests/test_merge_chunks_validation.py— impacttests/test_multigraph_diagnostics.py— impacttests/test_no_dedup_flag.py— impacttests/test_opencode_plugin_refresh.py— impacttests/test_partial_cache.py— impacttests/test_path_cli.py— impacttests/test_query_cli.py— impacttests/test_query_induced_edges.py— impacttests/test_query_mcp_direction.py— impacttests/test_query_names_its_graph.py— impacttests/test_query_seed_order.py— impacttests/test_query_seeds.py— impacttests/test_serve.py— impacttests/test_serve_http.py— impacttests/test_skill_auto_refresh.py— impacttests/test_stale_prune.py— impacttests/test_terraform.py— impacttests/test_truncation_full_answer.py— impacttests/test_unverified_semantic_shrink.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.
Formal verification
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 \_neighbor\_lines.
The verifier did not have enough to check \_neighbor\_lines, 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 153 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — 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 conf | ||
|
|
||
|
|
||
| def _shortest_path_text(G: nx.Graph, arguments: dict) -> str: |
There was a problem hiding this comment.
_shortest_path_text()
15 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
Keep v8 path behavior (also_seen evidence, weakest-hop confidence, Type.Member endpoints, and C# owner labels) and print confidence_score on non-EXTRACTED hops in path, explain, and neighbor output. EXTRACTED hops stay bare. Update expected path and explain strings for the owner-qualified C# labels. Co-authored-by: Syed Fahad <[email protected]>
…4888) #4888 was built on 0.9.97, before #4881 (path weakest-hop refactor), #4889 (qualified C# method labels) and #4891 (also_seen) landed. Its cherry-pick dropped the merge commit that reconciled expectations. Update the per-hop confidence assertions to carry scores ([INFERRED 0.85]) and the C# path/explain/neighbor labels to their owner-qualified form (Exporter.Run, IReport.Build) - the correct composed output of all four features. Resolved the serve.py conflict by keeping #4881's _path_weakest/ _path_confidence_line and adding only #4888's _confidence_tag, applied over edge_evidence so parallel/also_seen evidence keeps its scores. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…4888) Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.99, now on PyPI (pip install graphifyy==0.9.99). path, explain and neighbors now print an edge's confidence_score alongside its tag; EXTRACTED stays bare. Thanks for the fix, @SyedFahad7. |
What does this PR do?
graph.jsonstores aconfidence_scoreon INFERRED edges. For example, C# interface dispatch (interface_dispatch.py,_dispatch_confidence) writes 0.85, 0.75 or 0.65 depending on how many implementers there are. The text renderers printed only the bare tag, though, so[INFERRED]didn't tell you whether an edge was a strong or a weak inference.This adds one shared helper,
_confidence_tag()inserve.py. Wherever an edge's confidence is printed inpath,explainand neighbors output, it now shows[INFERRED 0.75]when the edge has a score:path(cli.py)explain(cli.py)shortest_path(serve.py_shortest_path_text)get_neighbors(serve.py_neighbor_lines)Repro from the issue (
Report.cs, thengraphify update .):I've since merged v8 (0.9.98) into this branch. The score now sits alongside what landed there: the weaker
also_seenevidence shows as[AMBIGUOUS 0.40/INFERRED 0.75], and the weakest-hopPath confidence:line gets the score too. EXTRACTED hops still print no score. The test expectations now use the new C# owner labels, likePdfReport.Build(). ThequeryEDGE lines andaffected(#2352) are out of scope and unchanged.Fixes #4882
Type of change
Verification & Invariants
Invariant: inference stays visibly separate from extracted fact, and the output never shows more precision than
graph.jsonactually stores.A score is printed only for a non-EXTRACTED edge whose stored
confidence_scoreis a finite int or float. EXTRACTED edges stay[EXTRACTED]because they are 1.0 by definition, and showing that everywhere would only add noise.A missing,
None, string, boolean or NaN score leaves the bare tag. The fallback is the old output, not a guessed number.Scores are formatted as
{:.2f}, which matches the two-decimal tiers in the extraction rubric.Display only: no persisted graph or cache state changes, and no AST cache schema bump is needed.
Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
Limitation: a score stored as a numeric string (for example
"0.75") is not coerced and renders bare.How was this tested?
tests/test_confidence_score_output.pyruns the issue'sReport.csrepro throughextract→build_from_json→to_json. It asserts the stored scores (0.85 and 0.75), then checks CLIexplain, CLIpath, MCPshortest_pathand MCPget_neighbors. It also has parametrized boundary cases for_confidence_tag. On v8 without the fix, the four output tests fail.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched)