Define section data model with validation badge metadata
epic-bufdir-report-preview-ui-components-task-004 — Define BufdirReportSectionData model containing section title, semantic heading level, list of BufdirFieldRowData items, and a section-level validationSummary (error count, warning count). This model feeds BufdirReportSectionWidget and is produced by BufdirPreviewService from the decorated preview model.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
The fromFields factory should compute validationSummary by iterating fields: errorCount = fields.where((f) => f.validationState == BufdirValidationState.anomaly).length; warningCount = fields.where((f) => f.validationState == BufdirValidationState.warning).length. This is the canonical source for the validation badge displayed in BufdirReportSectionWidget — BufdirPreviewService should use this factory when constructing sections so counts are always consistent with actual field states. Use UnmodifiableListView for the fields list in the model to enforce immutability. When implementing Equatable, include listEquals-compatible props: override get props => [sectionId, title, headingLevel, fields, validationSummary].
This model is a direct dependency for task-005.
Testing Requirements
Write unit tests in test/features/bufdir/models/bufdir_report_section_data_test.dart. Cover: (1) fromFields with zero warnings produces validationSummary(0,0); (2) fromFields with 2 warnings and 1 anomaly produces validationSummary(1,2) — note anomaly maps to errorCount; (3) equality for two sections with same fields list; (4) copyWith replaces only specified fields; (5) JSON round-trip preserves all nested BufdirFieldRowData items and their validationState; (6) headingLevel serializes to/from 'h2'/'h3' strings. No widget tests needed.
Implementing the tap-to-scroll-and-focus behavior from the validation banner to a specific field row in a long scrollable list is complex in Flutter. If focus management is incorrectly implemented, VoiceOver users who navigate to the banner and select an issue will not be moved to the relevant field row, breaking the accessibility workflow and violating WCAG 2.4.3 (Focus Order).
Mitigation & Contingency
Mitigation: Use BufdirAccessibilityUtils focus management utilities (built in the foundation epic) with explicit GlobalKey-based scroll anchors on each field row. Test with a real iOS device running VoiceOver during widget development, not only in the Flutter accessibility inspector.
Contingency: If programmatic scroll-to-focus cannot be reliably achieved before the TestFlight deadline, fall back to a navigation approach where tapping a banner issue opens a modal detail sheet for that field row rather than scrolling in place, and file a follow-up ticket for the inline scroll implementation.
The validation summary banner must reactively update its issue count as underlying aggregated data changes (e.g., if the coordinator has navigated away and data was refreshed). If the banner's Riverpod provider is not correctly scoped, it may display stale issue counts or fail to disappear when all issues are resolved, eroding coordinator trust in the validation system.
Mitigation & Contingency
Mitigation: Drive the banner exclusively from the same Riverpod provider that powers the full preview model — do not maintain a separate local state for issue counts. Write a widget test that simulates a data refresh mid-review and asserts the banner updates within one frame.
Contingency: If stale state reaches production, add a manual refresh button to the banner as a short-term workaround while the provider scoping is corrected in the next release cycle.