Expose ScenarioRuleEngine and managers via Riverpod providers
epic-scenario-based-follow-up-prompts-core-logic-task-013 — Wire all three services into the Riverpod provider graph: scenarioRuleEngineProvider (depends on scenarioRuleRepositoryProvider and promptHistoryRepositoryProvider), scenarioConfigurationManagerProvider (depends on scenarioRuleRepositoryProvider), and scenarioDeepLinkHandlerProvider (depends on promptHistoryRepositoryProvider and go_router). Ensure providers are scoped correctly for multi-chapter support using family providers keyed by chapterId where appropriate.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Use Riverpod's Provider (not StateNotifierProvider or FutureProvider) for these service objects since ScenarioRuleEngine, ScenarioConfigurationManager, and ScenarioDeepLinkHandler are stateless service classes. Use .family modifier on scenarioConfigurationManagerProvider keyed by chapterId (String). Mark family providers as .autoDispose to avoid memory leaks when switching chapters. For go_router injection into scenarioDeepLinkHandlerProvider: if using the riverpod_go_router package, use routerProvider; otherwise pass a GoRouter reference through a dedicated goRouterProvider.
Define all three providers in lib/features/scenario/providers/scenario_providers.dart and export from a barrel file. Avoid putting provider definitions inside service class files — keep them in a dedicated providers layer.
Testing Requirements
Write provider graph tests using flutter_test with ProviderContainer. Test: (1) scenarioRuleEngineProvider resolves correctly with a ProviderContainer that overrides repository providers with fakes; (2) scenarioConfigurationManagerProvider.family('ch-A') and .family('ch-B') are distinct instances; (3) autoDispose behavior — after container.dispose(), no lingering references; (4) scenarioDeepLinkHandlerProvider resolves without requiring a real GoRouter (override with a fake RouterDelegate). Place provider tests in test/unit/scenario_providers_test.dart.
The Rule Engine must support a flexible JSON rule schema that can express compound conditions (e.g., contact_type AND wellbeing_flag AND delay_days). Underestimating schema expressiveness may require breaking changes to the rule format after coordinators have already configured rules.
Mitigation & Contingency
Mitigation: Define and freeze the rule JSON schema (trigger_type enum, metadata_conditions structure, delay logic) before any implementation begins; validate schema against all known HLF scenarios documented in the feature spec.
Contingency: If schema changes are needed after deployment, implement a schema version field and a migration utility that upgrades stored rules to the new format without coordinator intervention.
Deep-link navigation to the activity wizard with pre-filled arguments may fail if the user's session has expired or if the wizard route is not yet mounted in the navigator stack, causing unhandled navigation exceptions.
Mitigation & Contingency
Mitigation: Implement session state check before navigation; if session is expired, redirect to biometric/login screen and store the pending deep-link URI for post-auth redirect using go_router's redirect mechanism.
Contingency: If post-auth redirect proves unreliable, fall back to navigating to the home screen with a visible action banner that re-triggers the wizard with pre-filled arguments.