feat(knowledge): retrieval precision metric (agents' KB #3)#228
Merged
Conversation
Closes the loop on whether retrieval is improving. Signal: of the articles a search SURFACED on a day, how many did the agent then OPEN (search -> get/context by the same api_key within a follow-through window)? That share is precision — mechanical, computed purely from article_access_events (no LLM), trends UP as dedup (#1), navigation (#5) and conflict resolution (#4) clean the corpus. - RetrievalMetrics.compute/3 (search->open correlated EXISTS + interval window), snapshot, list_snapshots. retrieval_metric_snapshots table (RLS), daily time series, upsert. - RetrievalMetricsWorker: daily all_tenants fan-out, previous full day. Cron 30 4 * * *. - GET /knowledge/analytics/retrieval-metrics (orchestrator+); MCP v2.29.0 knowledge_retrieval_metrics. Honest caveat (documented): measures search->OPEN not search->useful; consistent bias, so the TREND is what matters. Tests (+11). Full gate green (3075 tests, dialyzer, credo).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the loop on whether retrieval is actually improving.
The signal: of the articles a search surfaced on a day, how many did the agent then open (search → get/context, same api_key, within a follow-through window)? That share is
precision— a mechanical proxy computed purely fromarticle_access_events(no LLM, no labels), which should trend up as dedup (#1), navigation (#5), and conflict resolution (#4) clean the corpus and sharpen the top results.Pieces
RetrievalMetrics.compute/3— the search→open correlation (correlatedEXISTS+ interval window);compute/snapshot/list_snapshots.retrieval_metric_snapshotstable (RLS) — daily time series, upsert per tenant/day/window.RetrievalMetricsWorker— dailyall_tenantsfan-out, snapshots the previous full day. Cron30 4 * * *.GET /knowledge/analytics/retrieval-metrics(orchestrator+); MCP v2.29.0knowledge_retrieval_metrics.Honest caveat (documented in the module)
It measures search → open, not search → useful — a snippet-only use counts as a miss, so the absolute number undercounts. The bias is consistent, so the trend is the meaningful thing.
Tests (+11): precision math (window / api_key / context / empty), snapshot idempotency + tenant isolation, worker fan-out (skips suspended) + per-day, controller series + role gate. Full gate green: format, credo, dialyzer, 3075 tests.