Build Way Forward Item Repository
epic-structured-post-session-report-services-task-002 — Implement the Supabase-backed repository for persisting way-forward entries submitted during post-session reports. Define the data model, CRUD operations, and RLS-aware queries scoped to coordinator and peer mentor roles. This repository is a hard dependency for way-forward-task-service.
Acceptance Criteria
Technical Requirements
Implementation Notes
Define a WayForwardItem Dart class (immutable, with copyWith) and a corresponding WayForwardItemRepository abstract interface so the service layer depends on the interface, not the concrete Supabase implementation. The concrete SupabaseWayForwardItemRepository implements the interface using the supabase_flutter client. Use the repository pattern consistently: the repository is responsible only for data access; business logic (e.g. status transition rules) belongs in way-forward-task-service.
For the RLS policies, test them in the Supabase SQL editor before writing the Flutter integration tests to avoid debugging both layers simultaneously. Add a Supabase migration file for the table and RLS policies so the schema is version-controlled.
Testing Requirements
Write integration tests using flutter_test against a locally running Supabase instance (via Docker or supabase start). Tests must: (1) insert a way-forward item as a peer mentor and confirm it is readable by that peer mentor, (2) confirm a second peer mentor cannot read the first peer mentor's items, (3) insert as a peer mentor and confirm a coordinator in the same org can read, update, and delete the item, (4) confirm a coordinator in a different org cannot read the item, (5) confirm that a malformed payload (missing title) returns a typed domain exception. Also write unit tests for the repository class using a mocked Supabase client to cover error path handling without requiring a live database.
Flutter's speech_to_text package behaviour differs meaningfully between iOS and Android — microphone permission flows, locale availability, background audio session interference, and partial-result timing all vary. Inconsistent behaviour could make voice input unreliable for the primary audience (visually impaired peer mentors on iOS VoiceOver).
Mitigation & Contingency
Mitigation: Test speech-to-text-adapter on physical iOS and Android devices from the start, not just simulators. Write platform-specific test cases for permission flows and locale detection. Design the adapter's public interface to be platform-agnostic so that a native bridge could replace the package if needed.
Contingency: If speech_to_text proves unreliable on a platform, implement a native-speech-api-bridge (already identified in the component catalogue) as a drop-in replacement within the adapter, keeping the external interface unchanged so no UI code needs to change.
The coordinator task queue notification mechanism is not fully specified. If the queue system is owned by another team or uses an external service, way-forward-task-service may block on an undefined integration contract, delaying this epic.
Mitigation & Contingency
Mitigation: Define the task queue notification interface as an abstract Dart interface early in the epic. Implement a stub that writes a flag to the database so coordinator list queries can detect new tasks, deferring the real notification integration to a later epic.
Contingency: If the queue integration remains undefined at implementation time, ship way-forward-task-service with database persistence only and add a TODO-flagged notification hook. Coordinators will still see items on next page load; push notification delivery is deferred.