Document rule engine API and default rule templates
epic-scenario-based-follow-up-prompts-core-logic-task-014 — Write developer documentation for the ScenarioRuleEngine public API including: evaluate() parameter contracts and return type, EvaluationResult reason code enum with descriptions, ScenarioRule JSON schema with annotated examples for the five most common HLF follow-up scenarios (post-initial-contact, post-long-session, wellbeing-flag-raised, no-contact-after-10-days, post-group-activity), and configuration manager seeding behaviour. Store as inline Dart doc comments and a markdown reference in the docs/ folder.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 6 - 158 tasks
Can start after Tier 5 completes
Implementation Notes
Write Dart doc comments using the /// triple-slash style, not /** */ blocks, to align with Dart conventions. For the markdown file, use a structure with sections: Overview, evaluate() API Reference, EvaluationResult Codes, ScenarioRule JSON Schema, Default Rule Templates (5 examples), and Seeding Behaviour. The five HLF scenarios map to the real use cases described in the workshop summary: post-initial-contact (first contact completed, prompt to follow up within 3 days), post-long-session (session > 60 min, check-in prompt), wellbeing-flag-raised (coordinator flagged concern during activity), no-contact-after-10-days (Blindeforbundet 10-day reminder — adapt for HLF context), post-group-activity (group session completed, individual follow-up prompt). Keep examples realistic but use placeholder IDs like 'chapter-hlf-demo'.
Testing Requirements
No automated tests required for documentation. However, verify that: (1) dart doc generates without warnings for the documented classes (run dart doc --dry-run); (2) all 5 JSON examples in the markdown are valid JSON (validate with a JSON linter); (3) cross-references in the markdown to EvaluationResult enum values match the actual enum value names in code.
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.