Keep both stages in the admission/discharge comparison answer evidence
User description
Requested by Josh ยท project thread
Summary
Before: "Compare admission and discharge requirements" is declined. Search ranks the Admission of Community Patients guideline in its top 5 (golden case passes), but answer-evidence selection fills every slot with discharge documents. The source-bound admission/discharge builder therefore has no admission source and fails closed. This is the only blocking failure in the weekly answer check (baseline run 38345051424; also run 38363682098).
After: when the selected fallback evidence has no exclusively labelled source for one stage, up to three of that stage's chunks are appended from the governed eligible set. The builder can then cite both stages.
How: withAdmissionDischargeSideEvidence (in rag-extractive-answer.ts) runs only for queries that isAdmissionDischargeRequirementsComparisonQuery matches. It is applied in rag.ts to the generation-fallback evidence. Candidates come from selectAnswerRouteEvidence's eligible set, which now also returns eligibleResults, so governance filtering still applies. A dual-title policy, such as "Referral, Admission and Discharge", does not count as a side. The builder's requirement binding and the claim-support gates are unchanged.
Areas touched: Answer engine
RAG impact: behaviour change โ canary pair 38345051424 -> post-merge dispatch (pending)
Verification
-
npm run test:focusedon the changed files: 70 files, 1669 tests passed. - Three new tests: the missing side is added and the builder cites both; the selection is unchanged when both sides are present or the query differs; a dual-title policy does not count.
- eslint and
tsc --noEmitare clean. - Live proof: one paid answer canary after merge, compared with 38345051424. A regression means a single-commit revert.
Risk and rollout
- Risk: low. This changes only the evidence passed to the fallback for this one comparison shape. Retrieval scores, ordering and the answer gates are unchanged.
- Rollback: revert this single commit.
Clinical Governance Preflight
- No clinical content is added. Appended evidence comes only from the governed eligible set. Every claim still needs a source-bound requirement sentence and claim support. If a stage has none, the answer still fails closed to the evidence-gap message.
- Sign-off: draft. Josh decides when it goes live.
๐ค Generated with Claude Code
https://claude.ai/code/session_014qdvjGwiFXsvPu5bTPL4bs
Generated by Claude Code
Summary by cubic
Fixes "Compare admission and discharge requirements" answers failing closed when answer-evidence selection fills every slot with one stage's documents, now in both the extractive-first and generation fallback paths.
- Appends up to three chunks of the missing stage from the governed eligible set when the selected evidence has no bound requirement for that stage; an unbound admission chunk or a dual-title policy such as "Referral, Admission and Discharge" does not count, and a chunk yielding several facts is added once. A single document supplying both sides also gets a second document topped up.
- The selection is unchanged when both sides are present or the query is not this comparison.
selectAnswerRouteEvidencenow returns the eligible results. Under governed context packing, top-up candidates must pass the same admission receipt the packer checks; top-ups are added to the related-document lookup so cited documents retain their metadata. The logic lives in its own modulerag-admission-discharge-side-evidence.ts.- Retrieval scoring, ordering, and the answer gates are unchanged; a side with no bound requirement still fails closed.
CodeAnt-AI Description
Include missing admission or discharge evidence in comparison answers
What Changed
- Admission/discharge requirements comparisons now include eligible evidence for a missing stage in both extractive and generated fallback answers.
- Answers still require source-backed requirements for both stages; without supporting evidence, they remain withheld rather than presenting a one-sided comparison.
Impact
โ
Both stages cited when eligible sources exist
โ
Fewer comparisons stop at an evidence gap
โ
Unsupported one-sided answers remain blocked
๐ก Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by Gitar
- Extractive-first path:
- Applies the same side-evidence top-up in
rag.tsbefore the validated extractive short-circuit
- Applies the same side-evidence top-up in
- Governed context packing:
- Top-up candidates must pass
contextPackAdmissionMatches, the admission receipt the packer requires
- Top-up candidates must pass
- Related documents:
- Top-up chunks feed the related-document lookup so cited stages keep their entries
This will update automatically on new commits.