Skip to content

test(theoracle): public synthetic retrieval and evidence-gate eval for CI - #25

Merged
gaffercode merged 2 commits into
mainfrom
claude/project-thread-cg01id
Nov 26, 2026
Merged

gaffercode merged 2 commits into
mainfrom
claude/project-thread-cg01id

Conversation

@gaffercode

Copy link
Copy Markdown
Owner

Requested by Gafferness · project thread

Why

CI skipped every retrieval-quality check because the TheOracle knowledge base is private. This adds a public, synthetic eval that runs on every PR.

What

  • tests/fixtures/theoracle-eval/corpus.json: 31 invented passages in 16 SINTETIS documents, including an off-topic document and a privacy trap (phone number). It is not clinically reviewed and is not guidance.
  • tests/fixtures/theoracle-eval/cases.json: 23 retrieval cases (15 clinical, 8 lay wording), 12 therapy-retrieval cases, 11 evidence-gate cases, and thresholds.
  • tests/theoracle-eval.test.ts:
    • Layer 1 (no model): gateTherapy runs on each case's declared evidence.
    • Layer 2 (pinned EmbeddingGemma): the production builder embeds the corpus into a temp folder. The production retriever answers each case. The test asserts recall@6/MRR, therapy dose recall and the privacy filter, then gates the drafts on the evidence actually retrieved. It also records on-topic vs off-topic top similarity as data for a future similarity floor. The report goes to node_modules/.cache/theoracle-eval/report.json and to the job summary.
  • scripts/build-theoracle-index.mjs --index-dir <folder> lets the eval reuse the real builder. A stub test was added in scripts.node-test.mjs.
  • ci.yml: SENTRAPEDIA_ORACLE_EVAL=required makes a missing model fail the run instead of skipping it.
  • docs/testing.md: new section with the acceptance criteria.

Acceptance criteria

Check Criterion
Clinical-wording retrieval recall@6 = 1, MRR ≥ 0.8
Lay-wording retrieval recall@6 ≥ 0.75
Therapy retrieval dose passage reached for all 12 diagnoses
Privacy trap passage never returned
Evidence gate expected status for every case, in both layers

Thresholds are provisional until this PR's first CI run.

Known gap found (not fixed here, by owner decision)

Case g08 runs as it.fails. The tablet rule reads a weight band as BB 60 kg, but not as a range like BB 41-59 kg. A clause with a range band therefore verifies its tablet count for any weight. In a local probe, 4 tablets of DHP for a 45 kg patient came out verified when the bands were written 41-59 / 60-80. The fix goes in a separate PR with clinical review.

Verification

  • Run in a cloud container: Vitest gave 837 passed, 1 expected fail and 0 failed. The related node system tests passed (48 passed, 6 skipped). Lint, typecheck, secret-scan (staged) and leak-guard were clean.
  • Layer 2 has NOT been run yet. The container could not reach huggingface.co, so this PR's CI is its first run.

Notes

  • The public repo is normally filled by export-split, so this change also needs porting back to the monorepo.
  • This couples with the pending similarity-floor branch (THEORACLE_MIN_SIMILARITY): any eval case below the floor would throw THEORACLE_NO_MATCH.

Generated by Claude Code

…r CI

CI skipped every retrieval-quality test because the knowledge base is private.
Add a synthetic corpus (31 passages, 16 documents) and case set (23 retrieval,
12 therapy-retrieval, 11 gate cases) under tests/fixtures/theoracle-eval/.

Layer 1 runs the gate on each case's declared evidence, with no model.
Layer 2 builds a temporary index with the production builder and the pinned
EmbeddingGemma model, then scores recall@6/MRR, therapy dose recall, the privacy
filter and the gate on what was actually retrieved. CI sets
SENTRAPEDIA_ORACLE_EVAL=required so a missing model fails instead of skipping.

build-theoracle-index.mjs gains --index-dir so the eval reuses the real builder.

Known gap found by layer 1 (g08, it.fails): the tablet rule does not read a
weight band written as a range ("BB 41-59 kg"), so that clause verifies a
tablet count for any patient weight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ta9C6s513KoCTM6zpyNXH
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentrapedia Ready Ready Preview Nov 26, 2026 6:25pm UTC

Request Review

@gaffercode gaffercode self-assigned this Nov 26, 2026
Run 45874985015: clinical recall@6 1 / MRR 1, lay recall@6 1 / MRR 0.938,
therapy dose recall 1. Lay recall floor 0.75 -> 1, clinical MRR 0.8 -> 0.9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ta9C6s513KoCTM6zpyNXH
@gaffercode
gaffercode marked this pull request as ready for review November 26, 2026 20:09
@gaffercode
gaffercode merged commit a9c2b21 into main Nov 26, 2026
4 checks passed
@gaffercode
gaffercode deleted the claude/project-thread-cg01id branch November 26, 2026 20:09
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