Skip to content

test(diary): add reproducible fixture retrieval baseline - #2821

Draft
antunishdPursuit wants to merge 2 commits into
getlarge:mainfrom
antunishdPursuit:feature/552-retrieval-evaluation
Draft

antunishdPursuit wants to merge 2 commits into
getlarge:mainfrom
antunishdPursuit:feature/552-retrieval-evaluation

Conversation

@antunishdPursuit

@antunishdPursuit antunishdPursuit commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

Related to #552. Adds a reproducible baseline for measuring the existing hybrid diary search before tuning retrieval behavior.

The development corpus reuses 12 existing fixture entries and six queries, with explicit binary relevance labels and rationales. This first increment covers only the fixture baseline; the broader evaluation work remains incomplete. The larger dataset, graded labels, and threshold/fanout experiments remain follow-up work. UI work is outside this baseline PR. Whether a follow-up would extend the tool mentioned in the issue or introduce a separate interface remains to be clarified.

Changes

  • Adds precision@k, recall@k, false-positive and missed-result reporting, plus 38 metric/corpus unit tests.
  • Adds an opt-in runner using the existing search repository, cached E5-small-v2 q8 embeddings, and disposable PostgreSQL/pgvector. Four weight settings at k=1/3/5, repeated twice, produce 144 searches.
  • Freezes the database clock within each invocation, resets access metadata between searches, and records ordered results, metrics, configuration, revision and reproducibility hashes.
  • Adds dedicated Nx evaluation/typecheck targets and usage documentation. Production search code, SQL, defaults and dependency versions are unchanged.

Baseline results

The October 27 local run at c138ccd completed all 144 searches with zero ordered-result differences between repeats. Results and metrics exactly match the saved October 19 run.

Weights P@1 R@1 P@3 R@3 P@5 R@5
Relevance 1.00 0.60 0.60 1.00 0.36 1.00
+ Recency 1.00 0.60 0.467 0.80 0.28 0.80
+ Importance 0.80 0.50 0.40 0.70 0.32 0.90
+ Both 0.80 0.50 0.467 0.80 0.28 0.80

Means cover five answerable queries. The no-match query returned 1/3/5 unwanted results at k=1/3/5 under every setting. Repeats check stability; they are not independent statistical samples. This reused development corpus is not a held-out benchmark, and harness success does not establish acceptable retrieval quality.

Test plan

Local verification on October 27, 2026, using Windows, Node 24.22.1, pnpm 10.34.5 and Go 1.27.1:

  • Selected diary-service unit suite: 142 passed (104 existing + 38 new), excluding integration files.
  • Evaluation and diary-service production typechecks passed.
  • Lint passed with zero errors and two existing noop-embedding warnings.
  • Secret scanning and Nx synchronization check passed.
  • Fresh model/database evaluation: 144 searches; all trial metrics and 12 summary rows independently recomputed.
  • Diary-repository integration: 36 passed. Diary-service integration without real embeddings: 27 passed.
  • Formatting passed on the eight files' committed LF content. The Windows CRLF checkout triggers line-ending warnings under the default Prettier check.
  • All related suites green: the two existing failures below remain.
  • Runtime verification after integration with newer upstream main; hosted CI has not run for this branch.

Existing failures disclosed

  1. Embedding unit suite: 14 passed, 1 failed. The cache-path assertion expects /tmp/models/; Windows resolves it to C:\tmp\models/. A temporary test copy using a platform-native absolute path passed all 15 tests while retaining the exact-path and environment-restoration assertions. The original test remains unchanged; a portability fix is separate from this baseline.

  2. Diary integration with real embeddings: 26 passed, 1 failed. The text-search case expects one result and receives two. The relevant cryptographic entry ranks first, but the weather entry also passes the existing vector-distance cutoff (0.294 versus 0.6), despite having no full-text match. The isolated keyword-only control passes. This is an existing retrieval-quality finding relevant to feat(evals): run evals on vector search with gold dataset / RAGAS approach #552; this baseline records it while leaving threshold tuning and production fixes for follow-up evaluation.

Neither failing test nor the production code it exercises was changed by these baseline commits. Assertions, labels and thresholds have not been relaxed to obtain passing results.

Validation notes: Windows required the supported install-hook skip followed by an explicit Nx sync check, pinned pnpm for child tasks, and Windows-compatible quoting for secretlint. No tracked configuration or lockfile changes were made. Against the inspected upstream snapshot 08a2ab1, the branch is two commits ahead and 137 behind; that snapshot does not change the eight PR files, but combined runtime behavior remains unverified.

Reproduction commands and model/Docker prerequisites are documented in docs/understand/entry-search.md, under “Small retrieval evaluation baseline (#552).” No authorization/OPL changes are included.

@getlarge

Copy link
Copy Markdown
Owner

@antunishdPursuit I revisited your work in #2849 to follow the monorepo conventions.
It's now part of a dedicated internal lib, that also contains the UI for labelling - #2848 .

@legreffier

legreffier Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@antunishdPursuit following up on the earlier handoff: the real diary corpus is now available in #2848, so you can continue the retrieval experiments without waiting for access to Potato or a private dataset.

The dataset and reproduction instructions contain 276 human-approved entries and seven selected development queries. The runner is in libs/retrieval-eval; your original labelled fixture remains the separate regression baseline in #2849.

To try the real corpus:

gh pr checkout 2848
pnpm install
export NX_LOAD_DOT_ENV_FILES=false
pnpm exec nx run @moltnet/rest-api:download-model
export RETRIEVAL_MODEL_CACHE="$PWD/apps/rest-api/models"
pnpm exec nx run @moltnet/retrieval-eval:eval:corpus

Docker must be running. This requests 56 searches: seven queries × four weight configurations × two repeats, at top ten. The run retains rankings and provenance locally.

Human relevance review is underway in Potato for 80 candidate pairs. The checked-in dataset deliberately has no relevance judgments yet, so it is ready for running and inspecting retrieval, but not for claiming quality improvements. We'll add the reviewed labels as a later revision so compatible saved rankings can be rescored without rerunning search.

The library's 46 unit tests, lint, typecheck and secret scanning pass. The new full-corpus run is not yet verified end to end; local Docker storage blocked PostgreSQL startup during the smoke test.

@antunishdPursuit

Copy link
Copy Markdown
Author

Thanks for sharing the corpus! I ran it locally on Windows at d1c87924. All 56 searches completed, and repeated rankings matched exactly. I saved the results for rescoring when compatible labels are available; this confirms execution and repeatability, not retrieval quality.

The full retrieval-evaluation unit suite passed 47 of 48 tests. The remaining test failed on Windows because it expects file mode 0600, while Node reports 0666; the later concurrent-update assertions in that test were not reached.

Separately, I added tests for the two metrics coverage findings in #2849. That baseline suite passed 27/27 locally. Would you prefer a small follow-up PR against that branch or a patch?

The previously checked Nx secret-scan wrapper failed because of Windows quoting, but the equivalent direct scan passed.

Thanks again!

@antunishdPursuit

Copy link
Copy Markdown
Author

Hi there! Thanks again for incorporating the fixture baseline into #2849. I checked the updated tests, and they cover both cases I’d offered to send. I plan to close this draft as superseded in a week. Is there anything you’d like me to hand over before then?

This branch has not been deployed

No deployments
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.

2 participants