feat(query): --min-confidence filter on trace/impact (#112)#200
Conversation
Exploit the edge `confidence` field: a `--min-confidence` flag on the `trace` and `impact` commands hides low-confidence edges (e.g. unresolved `raw_call:` calls at 0.1) so the output shows only trustworthy paths. - QueryEngine.get_flow_graph / get_impact_graph / _bfs_traverse gain a `min_confidence` param; the BFS prunes sub-threshold edges so the traversal never crosses them (low-confidence neighbours stay out of the result). - CLI `trace` / `impact` gain `--min-confidence` (0.0–1.0), threaded through both the mermaid (engine) and text-tree (build_*_tree) render paths. This is the confidence-filtering slice of #112. Deferred follow-ups: resolution rate in `cgis validate` (resolved_calls / total_calls), and a per-edge-type resolution-rate table in the `cgis ingest` summary. TDD: engine-level tests (flow + impact prune the 0.1 edge) and a CLI test (`trace --min-confidence 0.9` hides the unresolved `print` call). 813 tests, mypy strict, ruff, doc 99.5%. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
/guardian review |
There was a problem hiding this comment.
Code Review
This pull request introduces a --min-confidence option to the CLI's trace and impact commands, allowing users to filter out low-confidence edges (such as unresolved raw calls) during traversal. The underlying BFS traversal and tree-building logic in src/cgis/query/engine.py and src/cgis/cli.py have been updated to support this filtering, and corresponding unit tests have been added to verify the behavior. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
LGTM — no defects found in this diff.
Reviewed diff for logic correctness, type safety, ontology compliance, and test coverage. All changes are properly typed, tested, and consistent with the project's standards. The min_confidence filtering is correctly implemented across CLI, QueryEngine, and tests.
🤖 mistral-medium-latest · 8,133 prompt + 61 completion = 8,194 tokens · graph 2/4 files (50%)
…lexity Sonar S3776: the added min_confidence guard pushed _bfs_traverse cognitive complexity to 16 (>15). Extract the two filter checks (type allow-list + confidence floor) into `_edge_accepted`; behavior identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|



Summary
Exploits the per-edge
confidencefield (issue #112, part 2). A--min-confidenceflag ontraceandimpacthides low-confidence edges — chiefly unresolvedraw_call:calls (confidence 0.1) — so the output shows only trustworthy paths.cgis trace mymod.handler --min-confidence 0.5 # drop unresolved/guessed calls cgis impact mymod.Service --min-confidence 0.5Changes
QueryEngine.get_flow_graph/get_impact_graph/_bfs_traversegain amin_confidenceparam. The BFS prunes sub-threshold edges during traversal, so it never crosses them — nodes reachable only via a low-confidence edge stay out of the result (matches the "hide unresolved edges" intent).trace/impactgain--min-confidence(0.0–1.0), threaded through both render paths: the mermaid path (engine) and the text-tree path (build_trace_tree/build_impact_tree, alongside their existingallowed_edge_typesfilter).Scope
This is the confidence-filtering slice of #112. The other two acceptance items are deferred to a focused follow-up (they touch the storage stats query + the ingest summary, and warrant their own tests):
cgis validate(resolved_calls / total_calls, CALLS-specific)cgis ingestsummarystructureis intentionally not wired — its edges are structural (CONTAINS/DECLARES) at confidence 1.0, so the filter would be a no-op there.Tests
TDD — engine tests (flow + impact each prune the 0.1 edge, assert the low-confidence neighbour is unreachable) and a CLI test (
trace --min-confidence 0.9hides the unresolvedprintcall that--show-externalotherwise shows). Full suite 813 passing, mypy strict, ruff, doc 99.5%.🤖 Generated with Claude Code