Implement Report Schema Cache Layer
epic-structured-post-session-report-services-task-001 — Build the in-memory and persistent cache layer for organisation-specific report schemas. Implement TTL-based expiry, cache invalidation on schema updates, and a Riverpod provider exposing cached schema data to upstream services. This is the foundational data store that report-schema-service depends on.
Acceptance Criteria
Technical Requirements
Implementation Notes
Use a single ReportSchemaCacheNotifier class backed by a Map
The Riverpod provider should be scoped to the authenticated user's organisation so it is automatically disposed and re-created on org switch. Avoid using Riverpod's autoDispose on the cache provider itself — it should live for the full app session once initialised.
Testing Requirements
Write unit tests using flutter_test with a mocked Supabase client. Test matrix: (1) cache hit returns immediately without calling the network client, (2) cache miss triggers exactly one fetch and caches the result, (3) TTL expiry causes re-fetch on next read, (4) explicit invalidate() causes re-fetch, (5) two simultaneous reads during an in-flight fetch result in one network call, (6) when the network is unavailable the persistent cache is returned, (7) when both caches are empty an appropriate error/loading state is emitted. Aim for 100% branch coverage on the cache logic class.
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.