Skip to content

feat(health): surface mentionRate on the health snapshot#710

Merged
arberx merged 1 commit into
mainfrom
feat/health-mention-rate
Jun 17, 2026
Merged

feat(health): surface mentionRate on the health snapshot#710
arberx merged 1 commit into
mainfrom
feat/health-mention-rate

Conversation

@arberx

@arberx arberx commented Jun 17, 2026

Copy link
Copy Markdown
Member

What

Add mentionRate (answer-text mention signal) to the health snapshot path so cnry health leads with mention rate alongside cited rate. cnry health was the last citation-only read surface; mention is already live on overview/report/analytics.

Scope: overallMentionRate + mentionedPairs + per-provider mentionRate, added beside the untouched cited fields.

Why

So health/dashboard/overviews can lead with mention while still showing cited. The two signals are independent and must never be derived from one another.

How

  • A pair counts as mentioned only when answer_mentioned === true. The field is tri-state (true / false / null); null means "not checked" and is never coerced to false in logic. Legacy persisted rows (no mention columns) coalesce NULL→0 on read.
  • buildRunData now threads query_snapshots.answer_mentioned (previously dropped) into computeHealth, which emits the mention metrics.
  • New nullable columns overall_mention_rate / mentioned_pairs on health_snapshots, added by an idempotent migration (v80, guarded by table + column existence checks).
  • HealthSnapshotDto gains the mention fields (additive only — no rename of overallCitedRate).
  • API read/aggregate/empty mappers surface the new fields and coalesce legacy NULL→0.
  • CLI renders mention first, cited second, on both the single-health view and the --history table.

Additive contract, idempotent migration, legacy rows read back as 0. Minor version bump (4.83.0 → 4.84.0) per the Versioning rule (additive, multi-package, >100 lines).

Tests

  • intelligence/health.test.ts: explicit mention math (numerator/denominator/rounded), plus a null/undefined case proving null is not counted as mentioned.
  • api-routes/health-latest.test.ts: ready-snapshot mention fields, aggregate summing mentionedPairs + merging per-provider mentionRate, and a legacy NULL-column row coalescing to 0 without crashing.
  • canonry: health JSONL + human-render tests (mention leads), and an analyzeAndPersist round-trip threading answerMentioned through to the persisted columns.
  • db: round-trip of the new columns + a legacy NULL-column row.

🤖 Generated with Claude Code

cnry health was the last citation-only read surface; mention is already
live on overview/report/analytics. Add mentionRate alongside citedRate so
health/dashboard/overviews can lead with mention while keeping cited.

The two signals stay independent: mention counts a (query x provider) pair
only when answer_mentioned === true (tri-state; null = "not checked" and is
never coerced to false). buildRunData now threads query_snapshots.answer_
mentioned through computeHealth, which emits overallMentionRate + mentioned
Pairs + per-provider mentionRate beside the untouched cited fields.

- intelligence: Snapshot.answerMentioned + HealthScore mention fields; compute
- canonry: buildRunData SELECT + persist the new columns; CLI renders mention first
- db: nullable overall_mention_rate / mentioned_pairs columns; idempotent
  migration v80 (guarded run, table+column existence checks)
- contracts: additive HealthSnapshotDto fields (public SDK contract)
- api-routes: map/aggregate/empty health rows; coalesce legacy NULL -> 0

Additive contract, idempotent migration, legacy rows read back as 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@arberx arberx merged commit d8118b3 into main Jun 17, 2026
12 checks passed
@arberx arberx deleted the feat/health-mention-rate branch June 17, 2026 21:44
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