Implement CertificationRecordRepository with HLF null-safe branching
epic-peer-mentor-detail-screen-data-layer-task-005 — Implement fetchCertificationHistory(String mentorId, String organizationId) in CertificationRecordRepository. The method MUST return null (not an empty list) for NHF and Blindeforbundet organizations to signal that certifications are not applicable to those orgs. For HLF organizations, fetch from the certification_records table and map to List<CertificationRecord>. Org branching must be based on organizationId, not hardcoded org names.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
The null vs empty list distinction is the most important aspect of this method — document it clearly with a doc comment on the method signature: /// Returns null if certifications are not applicable for the given organization. /// Returns an empty list if applicable but no records exist. The org branching should consult an injected ICertificationConfigProvider (or equivalent) that returns a Set
The UI consuming this method should render a 'Certifications not available for this organization' message when null is returned, and 'No certifications yet' when an empty list is returned — these are two distinct UI states. Order results by issued_at descending so the most recent certification appears first.
Testing Requirements
Unit tests using flutter_test with mocked SupabaseClient and mocked certification config provider. Test file: test/features/peer_mentor/data/repositories/certification_record_repository_test.dart. Required cases: (1) returns null without calling Supabase when organizationId maps to non-certification org, (2) returns empty List
Supabase RLS policies for peer mentor data may block coordinator queries if the RLS rules are written for peer-mentor-self access only, requiring policy updates that affect other features sharing the same tables.
Mitigation & Contingency
Mitigation: Review existing RLS policies on peer_mentors, certification_records, and activity_log tables before writing repository queries. Coordinate with the database team to add coordinator-role predicates without weakening existing mentor-self policies.
Contingency: If policy changes are blocked, implement a Supabase Edge Function as a secure query proxy that enforces authorization server-side, avoiding direct RLS policy modification.
The activity log table schema may not have a mentor_id foreign key column or may require a JOIN through an intermediate table, making the aggregation query significantly more complex than anticipated.
Mitigation & Contingency
Mitigation: Inspect the actual Supabase activity_log table schema before starting the MentorActivityLogRepository implementation. Document the exact JOIN path needed and validate it returns correct results for a known mentor.
Contingency: If schema requires complex multi-table aggregation, implement a Supabase database function (RPC) and expose it via the repository's fetchSummary method to keep Dart code clean.
The Blindeforbundet assignment table may not yet exist in the shared Supabase schema or may have a different structure than assumed, blocking the AssignmentHistoryRepository implementation.
Mitigation & Contingency
Mitigation: Verify the assignments table exists and confirm its column structure with the Contact Detail & Edit Screen team which also depends on assignment data (assignment-repository in that feature).
Contingency: If the assignments table is not yet available, implement the AssignmentHistoryRepository with a stub returning empty list and a TODO marker, unblocking the aggregation service while the schema is finalized.