Skip to content

feat(query): --min-confidence filter on trace/impact (#112)#200

Merged
zaebee merged 2 commits into
mainfrom
worktree-issue-112-confidence-metrics
Jun 12, 2026
Merged

feat(query): --min-confidence filter on trace/impact (#112)#200
zaebee merged 2 commits into
mainfrom
worktree-issue-112-confidence-metrics

Conversation

@zaebee

@zaebee zaebee commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Exploits the per-edge confidence field (issue #112, part 2). A --min-confidence flag on trace and impact hides low-confidence edges — chiefly unresolved raw_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.5

Changes

  • QueryEngine.get_flow_graph / get_impact_graph / _bfs_traverse gain a min_confidence param. 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).
  • CLI trace / impact gain --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 existing allowed_edge_types filter).

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):

  • resolution rate in cgis validate (resolved_calls / total_calls, CALLS-specific)
  • per-edge-type resolution-rate table in the cgis ingest summary

structure is 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.9 hides the unresolved print call that --show-external otherwise shows). Full suite 813 passing, mypy strict, ruff, doc 99.5%.

🤖 Generated with Claude Code

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>
@zaebee

zaebee commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

/guardian review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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%)

github-actions Bot added a commit that referenced this pull request Jun 12, 2026
…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>
@sonarqubecloud

Copy link
Copy Markdown

@zaebee zaebee merged commit 9bc20e3 into main Jun 12, 2026
2 checks passed
@zaebee zaebee deleted the worktree-issue-112-confidence-metrics branch June 12, 2026 13:54
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.

1 participant