feat: add verified evidence chains and source highlighting - #72
Draft
CognitiveCodeAI wants to merge 1 commit into
Draft
feat: add verified evidence chains and source highlighting#72CognitiveCodeAI wants to merge 1 commit into
CognitiveCodeAI wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This update makes answer evidence auditable in the original source document and adds HyCE-RAG-inspired, query-aware evidence chains for multi-hop questions.
Why
The previous source-review path could show context without proving that the displayed location was the exact text used for the answer. That is insufficient for legal and clinical review. A verified evidence label now requires an independently checked node, document version, content hash, page, exact quote, and source locator. Approximate or unresolved evidence is never promoted to verified.
Evidence-chain scores rank relevance only. They do not represent truth, medical confidence, legal confidence, or private model reasoning.
Safety and rollout
This change is suitable for a controlled pilot, not broad production default-on. Production promotion still requires representative legal/clinical domain review, full infrastructure validation, and production-like load/concurrency testing.
Validation
The chain computation measured 0.94 ms at p95, but total provider request p95 was 31.29% higher in the small 12-case configured-model run. This is explicitly documented as an observational result requiring representative load testing before default-on.
Review guide
Start with:
backend/docs/EVIDENCE_HIGHLIGHTING_V2.mdbackend/docs/HYCE_EVIDENCE_CHAINS_ADOPTION.mdbackend/docs/HYCE_EVIDENCE_CHAINS_VERIFICATION.mdbackend/app/qa/evidence_chain.pybackend/app/llm/openai_client.pybackend/app/services/highlighting.pyfrontend/src/app/(app)/chat/chat-client.tsxRepository hygiene
Local research-paper files, browser session state, screenshots, and workspace instructions were intentionally excluded from this commit.