Automatic Removal from Active Roster When Certificate Expires
This story captures the automated suppression behavior triggered at certification expiry. The mentor visibility suppressor updates the peer mentor's active status flag in the database when the expiry check confirms the certificate is expired. This update propagates through Supabase RLS policies so that public-facing queries exclude the expired mentor. The mentor receives an in-app notification explaining that their visibility has been suppressed. The coordinator also receives a separate notification (covered in coordinator stories). The mentor's app experience changes: they can still log activities but cannot appear in public contact directories or be assigned new contacts until recertified. The RLS policy ensures data isolation is enforced at the database level.
User Story
Acceptance Criteria
- Given a peer mentor's certification expired at midnight, When the expiry check edge function runs, Then the mentor's active status is set to false and the visibility suppressor updates the record
- Given the mentor's active status is set to false, When a public query is made for active peer mentors in their chapter, Then the expired mentor is excluded from results due to RLS policy enforcement
- Given the mentor's active status has been suppressed, When the mentor opens their own profile in the app, Then they see a clear status banner: 'Your certification has expired. You are currently not visible to the public.'
- Given the mentor's certification is renewed and confirmed, When the certification management service updates the record, Then the visibility suppressor re-enables the active status and the mentor reappears in public listings
- Given a mentor whose certificate expired while they were on pause, When the nightly scheduler runs, Then both the pause status and the expired certification are reflected correctly without conflict
- Given the RLS policy is active, When an unauthenticated query attempts to retrieve an expired peer mentor's profile, Then the record is not returned and no error is thrown
Business Value
HLF's workshop confirmed that when a peer mentor's certificate expires, they must automatically disappear from the organization's public website. Manually managing this across potentially hundreds of mentors is error-prone and creates compliance risk. Automating suppression via RLS at the database level ensures the organization's public-facing information is always accurate without requiring any administrative action, directly addressing a core HLF requirement.
Components
- Peer Mentor Visibility Suppressor service
- Certificate Expiry Check Edge Function infrastructure
- Certificate Expiry RLS Visibility Policy infrastructure
- Certification Management Service service
- Certification Repository data
- Certification Status Derivation Service service
- Nightly Job Scheduler infrastructure
- Certification Expiry Nightly Cron Job infrastructure
- HLF Dynamics Sync Service service