Skip to content

fix(governance): trace enum typos, surface review-due badge, retain safety-citation provenance (audit #1/#2/#9/#13)#1051

Merged
BigSimmo merged 7 commits into
mainfrom
claude/database-governance-audit-10b6ed
Jul 22, 2026
Merged

fix(governance): trace enum typos, surface review-due badge, retain safety-citation provenance (audit #1/#2/#9/#13)#1051
BigSimmo merged 7 commits into
mainfrom
claude/database-governance-audit-10b6ed

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 22, 2026

Copy link
Copy Markdown
Owner

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).

  • Bump actions/checkout from 4 to 6 #1 Silent enum normalizationenumOrDefault (src/lib/source-metadata.ts) now logger.warns a present-but-unrecognized document_status / clinical_validation_status / extraction_quality value (a data-entry typo) instead of silently collapsing it into the fallback. Absent/empty stays silent. Return value unchanged — observability only.
  • Bump actions/setup-node from 4 to 6 #2 Review-due badge — added review_due_source to frontendVisibleWarningCodes (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.
  • Bump lucide-react from 1.16.0 to 1.17.0 #9 Safety-citation provenanceclientSafetyWarning (src/lib/answer-response.ts) now retains source_metadata on 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.
  • [codex] Clinical KB cleanup readiness #13 End-to-end provenance test — new tests/provenance-flow.test.ts asserting 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 ragRankingPatterns in scripts/pr-policy.mjs; check:pr-policy green).

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_public schema/RLS), #7 (conflict-detection scope), #12 (canary automation).

Verification

  • npm run verify:pr-localexit 0: 351 files / 3129 tests, production build, client-bundle secret scan, offline RAG fixtures (36 golden cases) all green.
  • UI verification not run: the dev server is blocked by a pre-existing Tailwind/Turbopack dev-compile error in globals.css (unmodified by this PR; git-clean; the production build inside verify:pr-local passed, 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.
  • Retrieval/ranking/selection/scoring unchanged — no files on the ranking surface; eval:retrieval:quality not required.
  • check:production-readiness not 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

  • Risk: Low. Additive governance surfacing + observability; no ranking, retrieval, generation, schema, auth, or privacy logic changed. Two contract tests were updated to reflect the intended new behaviour (review-due now visible; safety-citation metadata retained).
  • Rollback: single-commit revert; no data or config migration.
  • Provider or production effects: None.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — no env/config touched
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative — this PR makes governance more visible (review-due badge, retained provenance, typo tracing); outdated still triggers the danger refusal, unchanged
  • Deployment classification/TGA SaMD impact checked — display/observability of existing governance metadata only; no clinical decision-support / answer-generation / ranking behaviour changed

Notes

  • Branch was rebased onto current 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

  • New Features
    • Safety findings now display extra badge pills for governance signals (e.g., outdated/review-due and unverified) alongside citations.
    • Review-due source governance warnings are now surfaced in the interface.
    • Governed payloads preserve source metadata so badges/citations remain consistent across the experience.
  • Bug Fixes
    • Invalid enum-like source metadata values now safely normalize to defaults, with warning logs for unrecognized non-empty inputs.
  • Tests
    • Added end-to-end provenance flow coverage and updated governance metadata expectations.
  • Documentation
    • Updated the branch review ledger with the latest review record.

…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>
@supabase

supabase Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e44cb1b1-b53e-4eed-b544-732177ce2165

📥 Commits

Reviewing files that changed from the base of the PR and between 5f3a9ed and b1f2aa5.

📒 Files selected for processing (2)
  • docs/branch-review-ledger.md
  • tests/source-metadata.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/source-metadata.test.ts

📝 Walkthrough

Walkthrough

Governance 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.

Changes

Governance provenance flow

Layer / File(s) Summary
Normalize governed source metadata
src/lib/source-metadata.ts, tests/source-metadata.test.ts
Invalid non-empty enum values trigger warnings and fall back to unknown or unverified defaults.
Propagate and expose governance signals
src/lib/source-governance.ts, src/lib/answer-response.ts, tests/answer-client-payload.test.ts, tests/provenance-flow.test.ts, tests/source-governance.test.ts, docs/branch-review-ledger.md
Review-due warnings become frontend-visible, safety-warning citations retain source metadata, and tests cover metadata preservation and refusal for outdated sources. The review ledger records the governance audit and verification status.
Render governance badges
src/components/clinical-dashboard/evidence-panels.tsx
Safety finding citations produce labels for outdated, review-due, and unverified states, rendered as warning-tone badges.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main governance changes: enum typo tracing, review-due badge surfacing, and safety-citation provenance retention.
Description check ✅ Passed The description follows the template with Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes, with only minor non-blocking gaps.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/database-governance-audit-10b6ed

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce32fe1 and cee3967.

📒 Files selected for processing (8)
  • src/components/clinical-dashboard/evidence-panels.tsx
  • src/lib/answer-response.ts
  • src/lib/source-governance.ts
  • src/lib/source-metadata.ts
  • tests/answer-client-payload.test.ts
  • tests/provenance-flow.test.ts
  • tests/source-governance.test.ts
  • tests/source-metadata.test.ts

Comment thread tests/source-metadata.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between cee3967 and 5f3a9ed.

📒 Files selected for processing (1)
  • docs/branch-review-ledger.md

Comment thread docs/branch-review-ledger.md Outdated
@BigSimmo
BigSimmo enabled auto-merge (squash) July 22, 2026 01:19
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • docs/branch-review-ledger.md

Commit: 8f2afd9bfb9a13183551a8ea3f5ad02a49100337

The changes have been pushed to the claude/database-governance-audit-10b6ed branch.

Time taken: 59s

coderabbitai Bot and others added 4 commits July 22, 2026 01:25
Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
…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
@BigSimmo
BigSimmo merged commit 2f69e2b into main Jul 22, 2026
17 checks passed
@BigSimmo
BigSimmo deleted the claude/database-governance-audit-10b6ed branch July 22, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants