Count ambiguous clinical tables as image evidence and attach chunk image_ids
User description
Split out of #3590 (now merged). After a full review, this PR keeps only the two picture-evidence changes. The rest was removed because it lacked evidence of benefit or carried clinical risk.
RAG impact: behaviour change — which images count as clinical evidence (isClinicalImageEvidence) also feeds image-need scoring in clinical-search.ts. The owner has chosen to use the latest green eval-canary (27ef74141f) as the baseline and run the post-merge canary themselves. That baseline predates #3590, #3591 and #3596, so a difference may come from those as well.
What changes
- Ambiguous clinical images can count as evidence (
src/lib/image-filtering.ts). An image whose classifier says "ambiguous" counts only when all of these hold: its type is clinical table, flowchart, medication chart or risk matrix; it has zero admin signal; and it has at least one clinical signal or a relevance score of 0.65 or more. Explicitclinical_evidenceandnon_clinicalclasses are unchanged. - A chunk's own
image_idsare attached during hydration (src/lib/rag/rag-hydration.ts). The pictures attached are the ones the index explicitly linked to that chunk, so attribution stays exact.
Removed in review
- Title-phrase tie-break: its test passes with or without it, so there's no evidence it changes ordering. Per
docs/rag-behaviour/refuted-approaches.md, a comparator change needs a discriminating test. - Community-admission preference: a hard-coded title/file-name match (
admissioncommunitypts) that assumed "admission" means community admission unless the question says "inpatient". - Admission/discharge side evidence in the main answer and model context: it could add back evidence that conflict-aware selection had excluded.
- Document-wide picture fallback: a picture from elsewhere in a document could appear next to text it does not support.
- Bot commits outside search scope: Qodo's operational-alert, roster-dispatch and source-row edits. The source-row edit broke the pinned test
answer-source-rail.dom.test.tsx.
Local evidence
- Lint,
npm run typecheck, Prettier andnpm run check:diff-integritypass. npm run test:focusedover the changed files: 4,058 tests passed. The one failure wasanswer-source-rail.dom.test.tsx, which passes now that the source-row edit is reverted.- No provider-backed run was made for this PR.
Clinical Governance Preflight
- If this PR changes clinical prompts, answer generation, citation logic, retrieval ranking, source policy, or clinical UI presentation, I reviewed
docs/clinical-governance.mdand recorded the clinical safety impact above. - If this PR adds or changes clinical guidance sources, I checked approval metadata and provenance requirements (
npm run check:source-governancewhere applicable). - Real patient identifiers, clinical notes, and private health information are not included in code, tests, fixtures, screenshots, or PR text.
🤖 Generated with Claude Code
CodeAnt-AI Description
Include relevant clinical charts and chunk-linked images in search evidence
What Changed
- Ambiguous clinical tables, flowcharts, medication charts, and risk matrices now count as evidence when they show clinical relevance and no administrative signals.
- Images explicitly linked to a text passage now appear with that passage, even when they are on a different page. Images from another document are not attached.
Impact
✅ Relevant clinical charts included in search evidence
✅ Chunk-linked images stay with supporting text
✅ No cross-document image attribution
💡 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.