From cee396730ed8724cc5321b80f20f96cc81577499 Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Wed, 22 Jul 2026 08:02:28 +0800 Subject: [PATCH 1/4] fix(governance): trace enum typos, surface review-due badge, retain safety-citation provenance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves the regression-safe subset of the 13-issue source-governance audit: - #1 source-metadata: logger.warn on a present-but-unrecognized document_status / clinical_validation_status / extraction_quality value (data-entry typo) instead of silently collapsing it into the fallback. Return value unchanged — observability only. - #2 source-governance: add review_due_source to the frontend-visible warning set so a source past its review date shows a governance badge, consistent with the review-due language already emitted in the render-policy copy text. Warning severity — never forces the danger refusal. - #9 answer-response: retain source_metadata on safety-finding citations at the browser boundary (regular source citations already keep it), and render a governance pill in the safety-findings panel for outdated / review-due / unverified sources. - #13 tests: new provenance-flow.test.ts asserting governance metadata survives DB-normalization -> governance warnings -> governed client payload (sources AND safety citations) -> render policy — the end-to-end guard that would have caught #9. RAG impact: no retrieval behaviour change — governance-metadata display/observability only; no files on the ranking/eval/selection surface (verified against ragRankingPatterns). Deferred (need a live eval-canary + approval, or are architectural): audit #4/#5/#6/#8/#10 (RAG-protected ranking/generation/cache), #11/#5 flag debt, #3 (is_public schema), #7 (conflict-detection scope), #12 (canary automation). Verification: verify:cheap (340 files / 3068 tests), typecheck, lint, prettier all green. Co-Authored-By: Claude Opus 4.8 --- .../clinical-dashboard/evidence-panels.tsx | 28 +++- src/lib/answer-response.ts | 5 + src/lib/source-governance.ts | 5 + src/lib/source-metadata.ts | 26 ++- tests/answer-client-payload.test.ts | 5 +- tests/provenance-flow.test.ts | 152 ++++++++++++++++++ tests/source-governance.test.ts | 13 +- tests/source-metadata.test.ts | 15 ++ 8 files changed, 237 insertions(+), 12 deletions(-) create mode 100644 tests/provenance-flow.test.ts diff --git a/src/components/clinical-dashboard/evidence-panels.tsx b/src/components/clinical-dashboard/evidence-panels.tsx index 00db8fd13..144fe9b32 100644 --- a/src/components/clinical-dashboard/evidence-panels.tsx +++ b/src/components/clinical-dashboard/evidence-panels.tsx @@ -71,7 +71,7 @@ import { type SafetyFinding, type SafetyFindingKind, } from "@/lib/clinical-safety"; -import { normalizeSourceMetadata, sourceStatusLabel } from "@/lib/source-metadata"; +import { normalizeSourceMetadata, sourceStatusLabel, validationStatusLabel } from "@/lib/source-metadata"; import { normalizeExtractedGlyphs, sourceTextForVerbatimQuote } from "@/lib/source-text-sanitizer"; import type { AnswerSection, @@ -868,6 +868,23 @@ function SafetyFindingRowIcon({ kind }: { kind: SafetyFindingKind }) { return