Skip to content

test(rag): #019 fallback-layer reproducer for admission source drop - #1303

Closed
BigSimmo wants to merge 1 commit into
mainfrom
claude/rag-019-fallback-reproducer
Closed

test(rag): #019 fallback-layer reproducer for admission source drop#1303
BigSimmo wants to merge 1 commit into
mainfrom
claude/rag-019-fallback-reproducer

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Isolate ledger #19 ("Admission doc dropped after deterministic comparison packing") to the answer composer, not retrieval.

Root cause (src/lib/rag/rag-extractive-answer.ts): for the source-bound admission/discharge comparison query, buildFactSynthesizedAnswer (:2315) calls buildAdmissionDischargeComparisonAnswer (:2234), which needs one bound requirement fact per side from sourceBoundComparisonFacts (:2180). A side only binds when the retrieved chunk sentence matches the narrow admission/dischargeRequirementBindingPatterns (:1050/:1068). When retrieval surfaces the correct admission document but the chunk prose is phrased outside those regexes, admissionFacts is empty, the distinct-document pair is null, and the builder returns null (:2253); the caller then emits the gap answer with citationChunkIds: [] (:2320), dropping the retrieved admission source.

Adds:

  • tests/rag-admission-discharge-comparison-fallback.test.ts — drop characterization (green on current main), a control proving the binder is the discriminator (same inputs, binder-matching admission prose -> both sources cited), and an it.skip RED acceptance spec for the eventual fix.
  • docs/rag-019-admission-source-drop-reproducer.md — root cause + fix direction.
  • one-line export seam on buildAdmissionDischargeComparisonAnswer (additive).

Reproducer only. No behaviour change; the fix is canary-gated.

RAG impact: no retrieval behaviour change — test-only reproducer plus an additive export seam; zero logic, ranking, or ordering change.

Summary

Verification

  • npm run verify:pr-local

During development, use npm run verify:cheap as the faster iteration gate before the final PR-local preflight.

  • npm run verify:ui when UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changed
  • npm run verify:release before release or handoff confidence claims

For retrieval, ranking, selection, chunking, source/citation rendering, or answer-contract changes, verify:pr-local runs eval:rag:offline automatically. Run the offline command directly during iteration before spending a live eval.

  • npm run eval:retrieval:quality (must stay 36/36) when retrieval, ranking, selection, chunking, or scoring behavior changed — CI cannot run it (needs live keys), so run it locally and paste the summary. A metadata/governance-weighting change once buried correct docs (recall 1.0→0.76) and only this eval caught it.
  • npm run eval:rag -- --limit 15 + npm run eval:quality -- --rag-only when answer generation, the synthesis prompt, or answer post-processing changed (grounded-supported must not drop; citation-failure 0)
  • npm run check:production-readiness when clinical workflow, privacy, environment, Supabase, source governance, or deployment behavior changed
  • npm run check:deployment-readiness when deployment startup, hosting, or rollout behavior changed

Risk and rollout

Complete this section for clinical, data, API, auth/privacy, workflow, dependency, build, or deployment changes.

  • Risk:
  • Rollback:
  • Provider or production effects: None / describe the explicitly authorized effect

Clinical Governance Preflight

Complete this section when the change touches ingestion, answer generation, search/ranking, source rendering, document access, privacy, production env, or clinical output.

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

Isolate ledger #19 ("Admission doc dropped after deterministic comparison
packing") to the answer composer, not retrieval.
Root cause (src/lib/rag/rag-extractive-answer.ts): for the source-bound
admission/discharge comparison query, buildFactSynthesizedAnswer (:2315) calls
buildAdmissionDischargeComparisonAnswer (:2234), which needs one bound
requirement fact per side from sourceBoundComparisonFacts (:2180). A side only
binds when the retrieved chunk sentence matches the narrow
admission/dischargeRequirementBindingPatterns (:1050/:1068). When retrieval
surfaces the correct admission document but the chunk prose is phrased outside
those regexes, admissionFacts is empty, the distinct-document pair is null, and
the builder returns null (:2253); the caller then emits the gap answer with
citationChunkIds: [] (:2320), dropping the retrieved admission source.
Adds:
- tests/rag-admission-discharge-comparison-fallback.test.ts — drop
characterization (green on current main), a control proving the binder is the
discriminator (same inputs, binder-matching admission prose -> both sources
cited), and an it.skip RED acceptance spec for the eventual fix.
- docs/rag-019-admission-source-drop-reproducer.md — root cause + fix direction.
- one-line export seam on buildAdmissionDischargeComparisonAnswer (additive).
Reproducer only. No behaviour change; the fix is canary-gated.
RAG impact: no retrieval behaviour change — test-only reproducer plus an additive
export seam; zero logic, ranking, or ordering change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@supabase

supabaseBot commented Jul 28, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@BigSimmo, you've reached your PR review limit, so we couldn't start this review.

Next review available in:12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a1f6c8cd-3a6e-49c4-802f-963943fb5ba8

📥 Commits

Reviewing files that changed from the base of the PR and between 8942b8b and fa2daac.

📒 Files selected for processing (3)
  • docs/rag-019-admission-source-drop-reproducer.md
  • src/lib/rag/rag-extractive-answer.ts
  • tests/rag-admission-discharge-comparison-fallback.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/rag-019-fallback-reproducer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

Closing as invalid. #19 is already resolved on main (2026-07-27 source-bound comparison fallback + canary, per docs/outstanding-issues.md). The traced code (buildAdmissionDischargeComparisonAnswer returning null when only one side source-binds) is that fix's intended conservative evidence-gap termination, not a bug — this reproducer used synthetic admission prose that deliberately misses the requirement binders. No behaviour change; nothing to merge.

@BigSimmo
BigSimmo deleted the claude/rag-019-fallback-reproducer branch July 28, 2026 03:02
Sign up for freeto 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

@BigSimmo