fix(governance): trace enum typos, surface review-due badge, retain safety-citation provenance (audit #1/#2/#9/#13)#1051
Conversation
…afety-citation provenance 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 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughGovernance metadata now logs invalid enum values, remains attached to governed safety citations, exposes review-due warnings, and appears as warning badges on clinical safety findings. Tests cover normalization, end-to-end propagation, frontend visibility, and refusal for outdated supporting sources. ChangesGovernance provenance flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Source as Source metadata
participant Normalizer as normalizeSourceMetadata
participant Governance as frontendSourceGovernanceWarnings
participant Payload as clientSafetyWarning
participant Dashboard as SafetyFindingsListContent
Source->>Normalizer: provide document and validation statuses
Normalizer->>Governance: return normalized metadata and warnings
Governance->>Payload: expose review_due and validation warnings
Payload->>Dashboard: retain citation source_metadata
Dashboard->>Dashboard: render governance warning badges
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/source-metadata.test.ts`:
- Around line 23-36: Extend the test case around normalizeSourceMetadata to spy
on logger.warn and assert it is called for each of the three invalid non-empty
enum values. Add coverage for absent and blank inputs, verifying they do not
trigger warnings while preserving the existing fallback assertions.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9cf0602b-4b82-4c9f-9420-147336e85e4f
📒 Files selected for processing (8)
src/components/clinical-dashboard/evidence-panels.tsxsrc/lib/answer-response.tssrc/lib/source-governance.tssrc/lib/source-metadata.tstests/answer-client-payload.test.tstests/provenance-flow.test.tstests/source-governance.test.tstests/source-metadata.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/branch-review-ledger.md`:
- Line 684: Update the ledger entry for claude/database-governance-audit-10b6ed
(PR `#1051`) to use the actual current review/merge date, 2026-07-21, instead of
the future date 2026-07-22. Preserve the rest of the entry unchanged.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2cee8004-9cbd-45da-8828-69153620893c
📒 Files selected for processing (1)
docs/branch-review-ledger.md
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. The branch was updated while autofix was in progress. Please try again. |
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
…nance-audit-10b6ed
…ce-metadata enums Address the CodeRabbit finding on the issue-#1 enum test: spy on logger.warn and assert it fires once per present-but-unrecognized document_status / clinical_validation_status / extraction_quality value (with field + value), while absent/blank inputs stay silent. Keeps the existing safe-fallback assertions — the return value is unchanged, so this pins the observability behaviour without altering any downstream ranking/rendering. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LRZ1EyBZW1ADXrZvMxEEsC
…nance-audit-10b6ed
Summary
Resolves the regression-safe subset of the 13-issue source-governance audit. The ranking/generation issues were deferred because they sit on the RAG-behaviour-protected surface and need a live eval-canary + approval (see below).
enumOrDefault(src/lib/source-metadata.ts) nowlogger.warns a present-but-unrecognizeddocument_status/clinical_validation_status/extraction_qualityvalue (a data-entry typo) instead of silently collapsing it into the fallback. Absent/empty stays silent. Return value unchanged — observability only.review_due_sourcetofrontendVisibleWarningCodes(src/lib/source-governance.ts) so a source past its review date shows a governance badge. Warning-severity → never forces the danger refusal. Also reconciles a real inconsistency where the render-policy copy-text already surfaced review-due language while the badge list suppressed it.clientSafetyWarning(src/lib/answer-response.ts) now retainssource_metadataon safety-finding citations (regular source citations already keep it), and the safety-findings panel (evidence-panels.tsx) renders a governance pill for outdated / review-due / unverified sources.tests/provenance-flow.test.tsasserting governance metadata survives DB-normalization → governance warnings → governed client payload (sources and safety citations) → render policy. This is the guard that would have caught Bump lucide-react from 1.16.0 to 1.17.0 #9.RAG impact: no retrieval behaviour change — governance-metadata display/observability only; no files on the ranking/eval/selection surface (verified against
ragRankingPatternsinscripts/pr-policy.mjs;check:pr-policygreen).Deferred (need a live eval-canary + approval, or architectural): #4/#5/#6/#8/#10 (RAG-protected ranking / best-source selection / LLM-context / cache), #11 & #5 (D5/D4 flag debt), #3 (
is_publicschema/RLS), #7 (conflict-detection scope), #12 (canary automation).Verification
npm run verify:pr-local— exit 0: 351 files / 3129 tests, production build, client-bundle secret scan, offline RAG fixtures (36 golden cases) all green.globals.css(unmodified by this PR;git-clean; the production build insideverify:pr-localpassed, so it is dev-Turbopack-only). The UI change is an additive, conditionally-rendered governance pill using existing primitives, covered by typecheck + lint + unit tests.eval:retrieval:qualitynot required.check:production-readinessnot run locally: it is an offline env/config validator and this PR changes no env/secret/config inputs; the worktree is secretless (demo mode) so it would only report expected missing-secret state. It runs in CI.Risk and rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy) — no env/config touchedoutdatedstill triggers the danger refusal, unchangedNotes
origin/main(was 18 behind); rebase was conflict-free (none of the 18 commits touched the 8 changed files).🤖 Generated with Claude Code
Summary by CodeRabbit