fix(rag): restore the strict source_metadata presence pin on retrieval rows - #2121
Conversation
…l rows PR #2107 loosened sourceMetadataSchema from .nullable() to .nullish() inside a mixed-scope ledger/runbook PR. That reverses the tranche-1 decision (PR #1946, "throw on mismatch") on the one field the retrieval row contract pins stricter than the rest, precisely so an RPC that drops the source_metadata column fails loudly as RetrievalRowShapeError instead of silently degrading every citation to "unknown" governance defaults. Present-and-null stays accepted; absent is again rejected. Adds the discriminating test the loosening lacked. Ranking, scoring and citation output are unchanged: this restores the exact contract the last green canary (run 32111839806) measured. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in:37 minutes Limit details: You’ve used all 1 included review currently available under your plan. You completed 101 included PR reviews in the past 7 days; at that activity level, included reviews refill at 1 review per hour. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Summary
sourceMetadataSchemainsrc/lib/rag/rag-row-contracts.tsfrom.nullish()back to.nullable(). PR feat(ledger): record 15 delivered resolutions, harden operator runbooks, and relax source metadata schema #2107 loosened it inside a mixed-scope ledger/runbook PR; its own RAG-impact text conceded the effect: a retrieval row with thesource_metadatakey absent (RPC column drift) is now silently accepted instead of raisingRetrievalRowShapeError. That reverses the tranche-1 decision recorded with the owner (PR harden(rag): validate retrieval RPC rows against a Zod shape contract #1946, "throw on mismatch") on the one field pinned stricter than the rest for exactly that reason, and it landed with no fixture proving the case.nullremains accepted (unchanged); absent is again rejected. Adds the discriminating test feat(ledger): record 15 delivered resolutions, harden operator runbooks, and relax source metadata schema #2107 lacked (rejects a row whose source_metadata key is absent). Comment on the schema explains the pin and points at Retrieval correctness: repair #325 golden regression, corpus-grounded finding #11 fix, RC9 confidence hardening #343 for the constraint-backing follow-up.RAG impact: no retrieval behaviour change — restores the exact row-contract the last green canary (run 32111839806 on
84aa667ad) measured; ranking, scoring and citation output unchanged; only the validation boundary is re-tightened to fail loudly on drift.Verification
npx vitest run tests/rag-retrieval-row-contract.test.ts—Tests 26 passed (26)(25 existing + the new absent-key rejection).npm run eval:rag:offline—Tests 623 passed (623);Offline RAG fixture and production-contract checks passed.npm run check:rag:fixtures—Offline RAG fixture and manifest validation passed (36 golden cases, 26 suites).npx tsc --noEmitclean; Prettier applied.Risk and rollout
source_metadata, retrieval fails loudly (the intended behaviour) rather than degrading citations silently. Rollback: revert this commit. Provider or production effects: none.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.
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
check (jsonb_typeof(metadata) = 'object')ondocuments, or decide to loosen it deliberately with a fixture and a canary — not silently.c5effece6underdocs/branch-review-records/.Opened by the RAG programme coordinator chat (Claude Code).