fix: DEBUG-229 PHQ-9 15β19 support trigger + per-question response validation#142
Merged
Merged
Conversation
Consolidate crisis detection to one source of truth (MAINT-226 Decision E): - safety.ts detectCrisis: 15β19 now emits the support tier (phq9_moderate_severe_score, high); β₯20 the intervention tier (phq9_severe_score, critical). Fixes the zero-false-negative violation where 15β19 returned null (no support offer). - assessmentStore CrisisDetectionService delegates to the pure detectCrisis, fixing its missing phq9_severe_score at β₯20 and removing the divergence. - validation.ts: add the support-tier guard (moderate_severe valid in 15β19). Add fail-loud 0β3 response validation (TEST-08/SEC-06): answerQuestion now validates via AssessmentResponseSchema before storing/scoring; out-of-range is rejected (not stored), so a corrupt value never reaches scoring or the inline Q9 crisis check. Tests (test-first, clinical override): invert the bug-pinning assertion; boundary tests 14/15/19/20 + Q9; pure-vs-store parity test (asserts through the production store API); answerQuestion reject tests; validation support-tier tests. test:clinical (94), test:crisis-detection (82), test:unit (419) green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
β¦crisis-detection-thresholds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes DEBUG-229
Consolidates crisis detection to one source of truth per MAINT-226 Decision E: the pure
detectCrisisnow emits a distinct support tier at PHQ-9 15β19 (phq9_moderate_severe_score, high) and the intervention tier at β₯20 (phq9_severe_score, critical); the store'sCrisisDetectionServicedelegates to it (fixing its missingphq9_severe_scoreat β₯20). Adds fail-loud 0β3 validation inanswerQuestion(TEST-08/SEC-06) and a support-tier guard invalidateCrisisDetection.Test-first (clinical/safety override): inverted the bug-pinning assertion, added boundary (14/15/19/20/Q9) + pure-vs-store parity tests (through the production store API), answerQuestion reject tests, and validation-guard tests.
Verified green: typecheck Β· lint:baseline (731/731) Β· test:safety (71) Β· test:clinical (94) Β· test:unit (419) Β· test:crisis-detection (82). Phase 2.5 Maestro gate: all 4 scoped flows pass on the EAS no-dev-client e2e-sim build (crisis-button, phq9 β₯20 banner, q9 canonical alert, gad7 β₯15) β earlier per-batch failures were the documented INFRA-216 seed-timing race, green on individual launches.
π€ Generated with Claude Code