Skip to content

fix: DEBUG-229 PHQ-9 15–19 support trigger + per-question response validation#142

Merged
MP2EZ merged 2 commits into
developmentfrom
fix/debug-229-crisis-detection-thresholds
Jun 6, 2026
Merged

fix: DEBUG-229 PHQ-9 15–19 support trigger + per-question response validation#142
MP2EZ merged 2 commits into
developmentfrom
fix/debug-229-crisis-detection-thresholds

Conversation

@MP2EZ
Copy link
Copy Markdown
Owner

@MP2EZ MP2EZ commented Jun 6, 2026

Closes DEBUG-229

Consolidates crisis detection to one source of truth per MAINT-226 Decision E: the pure detectCrisis now 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's CrisisDetectionService delegates to it (fixing its missing phq9_severe_score at β‰₯20). Adds fail-loud 0–3 validation in answerQuestion (TEST-08/SEC-06) and a support-tier guard in validateCrisisDetection.

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

MP2EZ and others added 2 commits June 6, 2026 13:49
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>
@MP2EZ MP2EZ merged commit 83a522d into development Jun 6, 2026
22 checks passed
@MP2EZ MP2EZ deleted the fix/debug-229-crisis-detection-thresholds branch June 6, 2026 21:45
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