Skip to content

fix(metrics): use per-domain matching for knowledge miss/gap rates#145

Merged
decko merged 1 commit into
release/v0.7.1from
fix/130-knowledge-miss-rate
Apr 21, 2026
Merged

fix(metrics): use per-domain matching for knowledge miss/gap rates#145
decko merged 1 commit into
release/v0.7.1from
fix/130-knowledge-miss-rate

Conversation

@decko
Copy link
Copy Markdown
Owner

@decko decko commented Apr 21, 2026

Summary

All doc chunk texts were merged into one blob, causing every finding's
issue words to overlap and knowledge_miss_rate to always return 1.00.
Now doc chunks are grouped by domain for per-domain word-set matching.

A finding is only "covered" when its significant words overlap with a
specific domain's doc chunk words, not the entire merged corpus.

Fixes #130

Changes

  • src/raki/metrics/protocol.py: Added doc_chunks field to MetricConfig
  • src/raki/metrics/knowledge/_common.py: Added build_domain_word_sets() and is_finding_covered_by_chunks()
  • src/raki/metrics/knowledge/miss_rate.py: Domain-aware path with legacy fallback
  • src/raki/metrics/knowledge/gap_rate.py: Same structure as miss_rate
  • src/raki/cli.py: Passes doc_chunks to MetricConfig
  • tests/test_metrics_knowledge.py: 8 new tests

Review

  • Python Specialist: 2 IMPORTANT (pre-existing legacy path, list[Any] typing) — not regressions
  • Security Specialist: not applicable
  • RAG Specialist: 1 CRITICAL (pre-existing legacy word filtering) — not a regression; 2 MINOR

Assisted-by: Claude Opus 4.6 (1M context) noreply@anthropic.com
Assigned-by: decko

All doc chunk texts were merged into one blob, causing every finding to
overlap and knowledge_miss_rate to always return 1.00. Now doc chunks
are grouped by domain for per-domain word-set matching, so a finding is
only "covered" when its words overlap with a specific domain's docs.

Fixes #130

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assigned-by: decko
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