Skip to content

Fix critical security and clinical safety issues#39

Merged
BigSimmo merged 1 commit into
mainfrom
fix/critical-security-and-safety-issues
Jun 19, 2026
Merged

Fix critical security and clinical safety issues#39
BigSimmo merged 1 commit into
mainfrom
fix/critical-security-and-safety-issues

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

This PR resolves several critical issues identified in the repository:

  1. Security: Resolved dependency vulnerabilities via npm audit fix.
  2. Medical Accuracy: Hardened numeric verification logic to prevent hallucinated dose acceptance.
  3. Safety: Increased output token limits to 4000 to eliminate risk of truncated clinical instructions.

…fety

- Fixed dependency vulnerabilities (npm audit fix)
- Hardened numeric verification regex and clinical safety logic
- Increased default token limits to 4000 to prevent clinical truncation
- Verified Supabase service role usage security
@BigSimmo
BigSimmo merged commit 06dc0ba into main Jun 19, 2026
7 of 10 checks passed
@BigSimmo
BigSimmo deleted the fix/critical-security-and-safety-issues branch June 19, 2026 05:43
BigSimmo added a commit that referenced this pull request Jun 19, 2026
…rged #38 (#41)

Re-applies the 6 blocking clinical-safety fixes (B1-B6) on top of current
main. PR #38 merged 22 RAG fixes before these blockers landed, and #39/#40
did not address them, so main still trusts wrong doses.

- B1: numeric verification now matches by exact normalized token-set
  membership instead of substring, so "2.5 mg" no longer verifies against
  "12.5 mg" (5x dose error). Fails closed.
- B2: fold unicode superscripts (×10⁹/L) to ASCII before extraction/match.
- B3: percentage branch no longer ends in \b (which could never match), so
  percentages extract and percentage mismatches are flagged.
- B4: numeric gate now scans answerSections[].body (medication_dose),
  scoped to each section's citation_chunk_ids.
- B5: safeFallbackAnswer fails closed on parse failure (ungrounded, no
  citation back-fill) and still runs the numeric gate; extractive recovery
  and strong-retry routing updated accordingly.
- B6: retry route reset is a single conditional UPDATE guarded on
  status/locked_at; 0 rows affected => 409, closing the TOCTOU race.
- N1: verifyAnswerNumbers fails closed when no cited chunk maps to a result.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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