Repository navigation
feat(stats): golden-record facts for the Query Results breakdown (slice 67E, backend) - #270
Merged
Merged
Conversation
Expose result_runs, golden_queries (+source) and partial_runs so the dashboard can explain total_results as runs x golden queries instead of implying top_k drives the row count. The golden count is persisted lazily by the orchestrator from the same load_queries the pipeline uses; older experiments infer it from the largest per-run result count.
Derive per-run result counts from the run breakdown the single-experiment paths already build (no extra results scan), fold them into the existing Mongo grouped pipeline, and degrade the Postgres grouped per-run query to an empty result with a logged warning so an optional breakdown cannot take the stats endpoints down. Memoise the lazy golden-count write per process, log persistence failures with the traceback, and document partial_runs, write-once golden_queries and the grouped-view limitation. Add a real-run seam test and live-Postgres assertions.
A failed optional per-run query now yields None (unknown) for result_runs, partial_runs and the golden facts instead of a misleading 0, and group totals skip it. Log the persistence traceback only on the first failure, apply the same >0 run filter in the SQLite adapter, and add a live Mongo test of the grouped results pipeline plus stricter seam and edge-case tests.
…cision 313, progress Records the owner decisions on the golden count, the verified one-row-per-query fact, the failure isolation and what is still open for the frontend half.
Resolves the four documentation conflicts (CHANGELOG, DECISIONS, GROWTH, PROGRESS) by keeping both slices' entries; 67D first, then 67E.
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.
What and why
Slice 67E, backend half. The stats tile for "Query Results" shows a 6-7 digit number with no way to see what it is made of. This adds the backend facts needed to break it down by golden-dataset record; the tile that displays it is the frontend half (separate branch, after this).
total_resultsis the sum over runs of queries answered (runs × golden querieswhen every run finished).top_konly changes how many chunks each row holds.unique_queriesis not the golden count: it equalstotal_resultsbecause a fresh id is generated for every query in every run.result_runs,golden_queries,golden_queries_source(configormax_per_run),partial_runs. New group totals:total_result_runs,golden_queries_min,golden_queries_max. All are assembled once inserver/db/ports/stats_common.py(golden_query_facts) for Mongo, Postgres and SQLite; adapters only supply per-run row counts they already build, so the single-experiment paths issue no extra query.load_queriesand saved assweep_summary.golden_queriesthe first time a run loads the queries (once per process, best effort, idempotent). Older experiments are inferred from stored results and taggedmax_per_run.Verification
./scripts/ci/quality-gates.sh: all gates passed (1015 backend tests, coverage 79.31 / 66.48 / 79.31 against the 72/59/72 floors, ruff, mypy, xenon, bandit, audits)._run_singleagainst a real SQLite store with a 3-record, two-persona, duplicate-text queries file and readssweep_summary.golden_queries == 3and exactly 3 result rows back; deleting the persist call or passing a wrong length makes it fail.Notes for the reviewer
total_resultshas);partial_runsalso counts runs still in flight; the stored count is write-once and goes stale ifqueries_filechanges between pause and resume; the Mongo and Postgres live tests do not run in PR CI.sweep_summary(the SQLite read-modify-write can lose a concurrent update; a lost count self-heals through the fallback); merge the two Postgres grouped scans; the Mongo per-experimentquery_idsdocument-size ceiling; a Mongo index onresults(experiment_id, run_id).Complexity
Automatically refreshed by CI for product-code changes.
Functions above the JavaScript threshold
ExperimentDetailScreen.tsx:53— CC 118SearchExplorerScreen.tsx:35— CC 38ExplorePanels.tsx:415— CC 29LoadingFeedbackPanel.tsx:41— CC 28labels.ts:36— CC 25ExperimentsScreen.tsx:64— CC 21VectorDbStatsPanel.tsx:84— CC 18ExperimentControlButtons.tsx:54— CC 14loadWalkthruResults.ts:37— CC 14ExperimentsScreen.tsx:465— CC 13Functions above the cognitive-complexity threshold
ExperimentDetailScreen.tsx:53— cognitive 60LoadingFeedbackPanel.tsx:41— cognitive 27labels.ts:36— cognitive 25ExplorePanels.tsx:415— cognitive 23markdown.ts:59— cognitive 20SearchExplorerScreen.tsx:35— cognitive 17steps.ts:63— cognitive 16