feat(rag): record the structured generation-quality verdict on fallback (#231 phase 1) - #1899
Conversation
…ck (#231 phase 1) Quality-gate throw sites now raise GenerationQualityError carrying the specific gate reason, pipeline stage, and a provider-safe answer-shape summary (counts and lengths only, never prose). The catch path records generation_quality_gate:<reason> in answer_retry_reasons, the fallback rag_queries log gains generation_quality_gate_reason/stage/answer_shape, and eval diagnostics gain generation_quality_gate_reasons. Metadata only: the error message, the flattened generation_fallback:generation_quality_failed degraded token, cache exclusion, every gate threshold, and the conservative source-only fallback are unchanged. Offline payload-driven fixtures reproduce numeric_faithfulness_gap and provider_source_gap through the real parse->gate->fallback path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017SncTkA9eTQfRE6dL462xZ
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in:17 minutes 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 (9)
Comment |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017SncTkA9eTQfRE6dL462xZ
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:90658711b8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Uh oh!
There was an error while loading. Please reload this page.
CI triageCI failed on this PR. Automated classification of the 2 failed job(s):
Compared with main CI run #10430 (cancelled). Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger. |
…ate PR #1861 - scripts/probe-generation-quality.ts: one cache-bypassed live answer reporting the structured generation_quality_gate_reasons (provider-backed, refuses demo mode, never caches or logs the probe) - ledger: record the #1861 adjudication (superseded for phase 1, close recommended; numeric-retry half deferred to phase 2 pending probe evidence) - issues #231: operator approvals recorded; probe blocked in this container (no provider env), ready-to-run command documented Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017SncTkA9eTQfRE6dL462xZ
BigSimmo
commented
Aug 13, 2026
@copilot Fix the unresolved P2 on exact head The new diagnostics currently inspect only the terminal error in the outer generation catch. When an initial strong answer fails Required fix:
|
BigSimmo
commented
Aug 13, 2026
@copilot The P2 repair is verified on current head Resolution rules:
Run focused diagnostics/fallback tests, offline RAG fixtures, typecheck, format, ledger/docs checks and the smallest PR-local gate. Report the pushed 40-character SHA and exact outcomes. |
Resolve the current-main documentation conflicts while preserving the structured generation-quality diagnostics, provider-safe probe, and regression coverage. Keep the canonical branch-review and outstanding-issues ledgers at current main because the branch ledger mutation contains stale PR-state claims.
Resolves two content conflicts by keeping both sides' additive fallback diagnostics (structured generation-quality verdict + main's generation_failure_reason/detail and route timing diagnostics) and regenerating the scripts-index counts. Updates one test expectation: current main's sanitizeAnswerText strips the template fixture answer to empty, so the preserved strong-gate verdict is now empty_after_sanitize rather than template_like_answer (93/93 focused tests pass). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfJeqoq59y5xKmgRGHjqyA
True merge to advance the merge base: the previous conflict resolution (22fb4e6) carried main's content but was committed with a single parent, so GitHub and git kept re-reporting the same two files as conflicted. Content is unchanged from 22fb4e6, which already unioned both sides. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017SncTkA9eTQfRE6dL462xZ
…owth budget Static PR checks failed on the merge head: rag.ts reached 4396 lines against the 4362-line maintainability budget after both sides' additive fallback diagnostics merged. Moves the answerInstructions prompt constant verbatim to src/lib/rag/rag-answer-instructions.ts (pure move — prompt text, cache key and ragAnswerPromptVersion unchanged; rag.ts now 4344 lines). Focused suites 97/97, typecheck and check:rag:fixtures green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfJeqoq59y5xKmgRGHjqyA
Uh oh!
There was an error while loading. Please reload this page.
…2024) * docs: add coordination-chat handover for the RAG improvement programme Adds docs/rag-improvement/COORDINATION.md — the coordinator-side layer over the worker HANDOVER: programme history (PRs #1895/#1899/#1908), the coordinator role definition, the wave dispatch plan and per-packet model/effort/plan-mode settings, the chained worker-prompt handoff pattern, the babysit playbook learned driving #1899 to merge, the standing-approvals map, and a paste-ready coordination-chat bootstrap prompt. Links it from the docs catalogue and HANDOVER, and corrects HANDOVER's now-verifiable status rows (#1908 merged). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfJeqoq59y5xKmgRGHjqyA * docs: record review ledger entry for coordination handover PR Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfJeqoq59y5xKmgRGHjqyA * docs(ledger): record the PR #2024 coordination-handover sync review Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
Summary
#231without changing retrieval, ranking, route budgets, retry policy, quality thresholds, caching, or the conservative source-only fallback.src/lib/rag/rag-generation-quality-diagnostics.ts, including a typedGenerationQualityErrorwith the failure stage, a provider-safe gate reason, and prose-free answer-shape metadata.answer_retry_reasons, fallbackrag_queries.metadata, and eval diagnostics while keeping the existing user-visible degraded reason and error message stable.numeric_faithfulness_gapandprovider_source_gap, plus focused unit coverage of the diagnostics module.scripts/probe-generation-quality.tsoperator probe and documents the diagnostic path indocs/rag-behaviour/behaviour-map.mdanddocs/scripts-index.md.Conflict-resolution note
Current
mainwas merged ata5f03ccc3390803a2b9de1d91701cf3a9d0455a8in commitf20b898f4024cf61281c76b132f27be105378f06. The canonicaldocs/branch-review-ledger.mdanddocs/outstanding-issues.mdchanges were deliberately not replayed over current main. The branch's old#231text contained stale PR-state claims that described draft PR#1861as superseded and awaiting manual closure. The post-resolution diff therefore contains eight files and keeps the current repository ledger authoritative.RAG impact: no retrieval behaviour change. This is additive structured diagnostics around existing generation-quality gates. Retrieval, ranking, selection, ordering, thresholds, retry behaviour, caching, and fallback construction are unchanged.
Verification
npm run verify:pr-localcompleted all selected phases withfailed: (none), including lint, typecheck, full unit suite, build, client-bundle secret checks, and offline RAG validation.tests/rag-answer-fallback.test.tsandtests/rag-generation-quality-diagnostics.test.tspassed 92/92 tests.f20b898f4024cf61281c76b132f27be105378f06mergeable against currentmain.Risk and rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
This remains phase 1 of the residual
#231investigation. It makes the binding quality gate observable and reproducible offline. It does not justify a timeout increase, gate weakening, additional provider attempts, or caching a generation fallback.