Skip to content

fix(calculators): enforce clinical safety and evidence governance - #2491

Merged
BigSimmo merged 9 commits into
mainfrom
codex/calculators-clinical-safety-governance
Sep 1, 2026
Merged

fix(calculators): enforce clinical safety and evidence governance#2491
BigSimmo merged 9 commits into
mainfrom
codex/calculators-clinical-safety-governance

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • add the binding clinical-safety specification and implementation plan for Psychiatry Calculators
  • add failing regression tests for unsafe catalogue exposure, incomplete-score interpretation, MDQ missing-data handling, claim/source provenance and safer mode copy
  • implement the production changes in follow-up commits on this draft PR

Verification

  • npm run verify:pr-local

During development, use npm run verify:cheap as the faster iteration gate before the final PR-local preflight.

  • npm run verify:ui when UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changed
  • npm run verify:release before release or handoff confidence claims

Verification not run yet: this draft is intentionally at the TDD red stage. The new test imports the evidence-governed fixture contract and asserts safer behavior that the current implementation does not yet provide. Hosted PR checks are expected to fail until the production commits land.

  • npm run eval:retrieval:quality (must stay 36/36) when retrieval, ranking, selection, chunking, or scoring behavior changed — not applicable; no retrieval/ranking behavior changes.
  • npm run eval:rag -- --limit 15 + npm run eval:quality -- --rag-only when answer generation changed — not applicable.
  • npm run check:production-readiness when clinical workflow, privacy, environment, Supabase, source governance, or deployment behavior changed — will be selected by the final verification plan if required.
  • npm run check:deployment-readiness when deployment startup, hosting, or rollout behavior changed — not applicable.

Risk and rollout

  • Risk: high clinical-content correctness, low infrastructure risk. The PR removes or quarantines unsafe/unverified tools and changes incomplete-result behavior.
  • Rollback: revert the PR; no migration, persistent data, provider or environment change.
  • Provider or production effects: None. No live provider, Supabase, Railway, Sentry or production mutation is used.
  • RAG impact: no retrieval behaviour change — calculator fixtures, scoring, presentation, evidence metadata and tests only.

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)
  • 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
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

  • Base frozen at d3074946a917cac378de64284c67cbc1d4dc58fa.
  • Branch: codex/calculators-clinical-safety-governance.
  • This draft must not be merged until the TDD red/green cycle, focused clinical proof and final PR-local verification are complete.

Note

High Risk
Changes clinician-facing scoring, catalogue exposure, and suicide-risk messaging—areas where incorrect partial results or management-adjacent copy could mislead care decisions.

Overview
Introduces a binding clinical-safety spec and an evidence registry (data/calculators/evidence.json) so interpretations, safety flags, and considerations carry claim/source IDs and review metadata.

The live catalogue is narrowed to PHQ-9, GAD-7, K10, CAGE, and AUDIT-C; MDQ, SAD PERSONS, and Y-BOCS are quarantined (fail-closed on rights/evidence). Score bands drop deterministic treatment/disposition wording in favor of context-only interpretation; “Score-linked actions” and KB related-content panels are removed in favor of source-linked clinical considerations shown only after completion.

Scoring/UI behavior changes: every item must be answered before bands, copy-to-clipboard, or considerations appear (incomplete is not negative); PHQ-9 item 9 still alerts early; progress copy distinguishes answered vs endorsed. Home, about, and privacy text no longer imply all tools are validated or that nothing is stored app-wide.

Regression coverage adds tests/calculators-clinical-safety.dom.test.tsx and updates scoring/mode copy tests.

Reviewed by Cursor Bugbot for commit 42e9eeb. Configure here.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: f19458b8-9dda-4e24-8b80-da8eba0aeba8


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@supabase

supabase Bot commented Sep 1, 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 ↗︎.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Static PR checksneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #14635 (failure).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

@BigSimmo
BigSimmo marked this pull request as ready for review September 1, 2026 08:18
@cursor

cursor Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_deb1fcb0-0159-4d94-934b-ec7710c6fb7d)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T08:22:18.263767Z 79dd00f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BigSimmo
BigSimmo enabled auto-merge (squash) September 1, 2026 08:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79dd00f904

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/calculators-clinical-safety.dom.test.tsx
Comment thread tests/calculators-clinical-safety.dom.test.tsx
Comment thread tests/calculators-clinical-safety.test.tsx Outdated
@cursor

cursor Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f491d452-9b77-4d99-a1f6-e38afbc2a679)

@BigSimmo
BigSimmo merged commit 00c2c12 into main Sep 1, 2026
29 checks passed
@BigSimmo
BigSimmo deleted the codex/calculators-clinical-safety-governance branch September 1, 2026 09:45

BigSimmo commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

Final PR summary

  • Verified head: 9fee1b757ddc15b1f9543cd764873537ac2a3559; pre-merge base: a633eb6e3dd0ac40891b81310947bbb872bd0efa.
  • Implemented the clinical-safety catalogue/evidence governance, strict completion behavior, PHQ-9 item-9 safety prompt, privacy copy, source-linked considerations, and regression coverage; refreshed the repository-awareness snapshot.
  • All 3 actionable review threads are resolved.
  • Focused local verification passed: 137 tests, lint, typecheck, changed-file formatting, and the direct repository-awareness check.
  • Exact-head CI passed: Static PR checks, Unit coverage, Build, Safety/config, Caring Contacts, all Production UI shards, and PR required. Lighthouse passed; advisory/non-applicable jobs were skipped with no advisory failures.
  • Local sandbox limitation: the wrapper commands that invoke tsx IPC could not run here; the direct snapshot check and hosted required CI provided the decisive verification.

GitHub's pre-existing squash auto-merge completed at 2026-09-01T09:45:28Z after the required gate passed. I did not merge the PR or alter auto-merge.

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.

1 participant