Repository navigation
Closed
Description
Follow-ups from the reviews of #6 (patient consent, data rights and retention). None blocks the merge; all were reported as non-blocking advisories.
Correctness
- ACEPTO takes no per-sender lock.
recordSenderConsentis a plain insert intoconsent_events, whilerevoke_sender_consentanderase_sender_datatake a per-sender advisory lock (migration 008). If ELIMINAR and ACEPTO from the same sender interleave, agrantedevent can land after the erasure. Fix: move the grant into a SQL function that takes the same lock and checks the prompt was shown. - Crisis exchange on a failed consent read.
persistCrisisExchangeskips storing the redacted crisis marker when the consent read fails (lookupFailed), even for a consented sender. The helpline is always sent. Decide whether this fail-closed behavior is intended, and pin it with a test. - Bare "pánico" overmatches. The clinical keyword was widened from "ataque de pánico" to "pánico", so administrative questions that mention it get the clinical referral and are stored as a marker.
- Clinical keyword coverage. "estoy deprimida", "tomo sertralina", "no puedo dormir" are not detected as clinical, so for consented senders they reach Claude and storage as written.
Maintainability
- Command words are duplicated. Reply texts (
OPT_IN_CONFIRMED_NOTICE,REVOKED_NOTICE,NOTHING_TO_REVOKE_NOTICE,consentReminder) and the seeded policy text spell out ACEPTO, BAJA and ELIMINAR instead of usingOPT_IN_TOKENS,REVOKE_TOKENandERASE_TOKEN. -
isClinicalRefusalis coupled to a substring. It checks for "atención directa", an unstated fragment ofCLINICAL_REFERRAL_RESPONSE. Derive the check from the constant. - Retention and window literals. The 90 days appear in the purge default, the cron script, the preview query, the consent text and the docs. The 2-hour counter retention in
erase_sender_datasilently depends onRATE_LIMIT_WINDOW_MSbeing one hour. - Naming. The gate's
erasedvariable holds "a consent was also withdrawn", not "data was erased". - Purge SQL test asserts exact counts, so it only passes on a fresh database.
Accepted by design (no action unless it changes)
- BAJA and ELIMINAR are handled before the rate limit: exercising a right must not depend on message count. Cost is indexed queries and one reply, no Claude call.
- After BAJA, the record that the policy was shown is kept, so a later ACEPTO counts without showing the text again.
References: odd/tasks/patient-consent-and-data-rights.md (Log L11-L16), docs/09-privacidad-y-consentimiento.md.
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(privacy): do not let an everyday 'me da pánico' hide another pani…
docs(privacy): list every place the 90-day retention is written