Repository navigation
fix(consent): lock ACEPTO, tighten log grants and widen clinical detection - #10
Merged
Merged
Conversation
…t rate window on ELIMINAR ACEPTO now goes through record_sender_consent, which takes the same advisory lock as BAJA and ELIMINAR and refuses the grant when the consent text is no longer recorded as shown. The service role loses direct INSERT on consent_events, erase_sender_data receives the current rate-limit window from the Edge Function, client roles lose the sequence grant, and a published policy must name ACEPTO, BAJA and ELIMINAR. Refs #7
…e 'pánico' Clinical matching is now accent-insensitive and covers 'deprimido/a', 'no puedo dormir', insomnia and common psychiatric medication, while 'pánico' alone no longer counts. The clinical refusal check is derived from the referral text, and the fail-closed crisis storage on an unreadable consent is documented and pinned by a test. Refs #7
…etention in one place Reply texts take ACEPTO, BAJA and ELIMINAR from the gate constants, the purge job uses the function's default retention, and 'siento pánico', 'tengo pánico' and 'trastorno de pánico' are clinical again. Tests restore the injected Claude client in finally and check that publishing the draft publishes it. Refs #7
…day 'me da pánico' Also pin the purge's 90-day default in the SQL test, compare the clinical referral marker case-insensitively, and correct the retention notes. Refs #7
1 task done
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 #7
Summary
Follow-ups from the #6 reviews, plus one permission found while verifying production.
record_sender_consent. It takes the same advisory lock asBAJAandELIMINAR, and refuses the grant when the consent text is no longer recorded as shown. A grant can no longer land after an erasure. The bot then shows the full text again.service_roleloses directINSERTonconsent_events.anonandauthenticatedlose the default grant onconsent_events_id_seq.erasedis renamed toconsentWithdrawn.Before deploying
009, then deploywebhookright away. Until then,ACEPTOandELIMINARreply that they could not be processed and confirm nothing. With the policy still unpublished, onlyELIMINARis exposed.interval '90 days'explicitly, which is equivalent. Re-runningsupabase/scripts/schedule_retention_purge.sqlmakes it follow the default.Test plan
deno test supabase/functions/_shared/phase1.test.ts, type-checked)npx tsc --noEmitclean; Node tests: 13 passedrecord_sender_consentwith and without a prompt, and afterELIMINARINSERTrefused forservice_roleELIMINARkeepsconsent_eventsunchanged (same count and md5).record_sender_consentblocks on the advisory lock held byerase_sender_dataand then returns false.main.mainonly for the requested phrases.