high priority medium complexity infrastructure pending infrastructure specialist Tier 3

Acceptance Criteria

CognitiveAccessibilityAudit.auditScreen(ScreenConfig config) returns CognitiveAuditReport synchronously
CognitiveAuditReport exposes: violations (List<CognitiveViolation>), warnings (List<CognitiveViolation>), infos (List<CognitiveViolation>), isCompliant (bool — true only when violations is empty), summary (String plain-language overview ≤ 120 words)
Each violation in the report includes a remediation field (String) with a plain-language fix suggestion ≤ 40 words
CognitiveAccessibilityAudit.auditWidgetTree(Widget root) — async method using WidgetTester-compatible inspection or Element tree walk — detects: unlabelled Semantics nodes, touch targets < 48dp, text with contrast ratio < 4.5:1 (heuristic check against theme)
auditWidgetTree is usable only in test/debug builds; calling in release mode returns an empty report with a warning info entry
Report can be serialised to JSON via toJson() for CI pipeline consumption
CI usage: a test file can call auditScreen() with all registered ScreenConfigs and fail if any report.isCompliant == false
Utility class has no mutable state — all methods are static or instance-pure
Integration with CognitiveLoadRuleEngine: auditScreen() delegates cognitive load rules to the engine and merges results with its own structural checks
Sample CI test file is provided in test/accessibility/ demonstrating how to use the audit in a pipeline
All audit methods are covered by unit/widget tests with ≥ 90% line coverage

Technical Requirements

frameworks
Flutter
Dart
flutter_test
data models
ScreenConfig
CognitiveViolation
CognitiveAuditReport
CognitiveLoadRuleEngine
performance requirements
auditScreen() completes in < 5ms for any ScreenConfig
auditWidgetTree() is only used in test/CI context — no performance constraint in production
security requirements
Audit reports must not include user data or screen content — only structural metadata
toJson() output safe for CI log storage (no PII)

Execution Context

Execution Tier
Tier 3

Tier 3 - 413 tasks

Can start after Tier 2 completes

Implementation Notes

Keep auditScreen() as a pure synchronous function delegating to CognitiveLoadRuleEngine.instance.validateScreen() and augmenting the result list with structural checks (e.g., missing page title, no back button declared). For auditWidgetTree(), use the Flutter test framework's element tree APIs (WidgetTester.allElements or find.byType) — this is only valid inside a testWidgets() context. To make the utility usable from a standalone test file (not requiring a running widget tree), provide auditScreen() as the primary CI-facing API; auditWidgetTree() is a bonus for in-test usage. Remediation strings should be defined as a Map constant so they are easy to review and localise.

The toJson() method should produce a flat, human-readable structure (not deeply nested) so CI log parsers can grep for 'isCompliant': false. Consider adding a printReport() helper that formats the report for console output with ANSI colours (errors in red, warnings in yellow) for developer DX.

Testing Requirements

Unit tests with dart:test for auditScreen() — test compliant config returns isCompliant=true with empty violations; test each rule violation produces correct severity, message, and remediation. Widget tests with flutter_test for auditWidgetTree() — build a test widget with a known unlabelled Semantics node and verify the report flags it. Test toJson() roundtrip: serialise and deserialise a report, verify all fields preserved. Test release-mode guard on auditWidgetTree() by mocking kReleaseMode.

Test CI sample file compiles and runs against a compliant ScreenConfig set without failures. Target 90% line coverage across the audit utility classes. Include one negative test: a screen config that violates all 4 cognitive load rules simultaneously — verify report has 4 error-severity violations.

Component
Cognitive Load Rule Engine
service medium
Epic Risks (4)
high impact medium prob technical

The error message registry and help content registry both depend on bundled JSON assets loaded at startup. If asset loading fails silently (e.g. malformed JSON, missing pubspec asset declaration), the entire plain-language layer falls back to empty strings or raw error codes, breaking the accessibility guarantee app-wide.

Mitigation & Contingency

Mitigation: Implement eager validation of both assets during app initialisation with an assertion failure in debug mode and a structured error log in release mode. Add integration tests that verify asset loading in the Flutter test harness on every CI run.

Contingency: Ship a hardcoded minimum-viable fallback message set directly in Dart code so the app always has at least a safe generic message, preventing a blank or code-only error surface.

medium impact medium prob dependency

The AccessibilityDesignTokenEnforcer relies on dart_code_metrics custom lint rules. If the lint toolchain is not already configured in the project's CI pipeline, integrating a new linting plugin may cause unexpected build failures or require significant CI configuration work beyond the estimated scope.

Mitigation & Contingency

Mitigation: Audit the existing dart_code_metrics configuration in the project before starting implementation. Scope the lint rules to a separate Dart package that can be integrated incrementally, starting with the most critical rule (hard-coded colors) and adding others in subsequent iterations.

Contingency: Fall back to Flutter test-level assertions (using the cognitive-accessibility-audit utility) to catch violations in CI if the lint plugin integration is delayed, preserving enforcement coverage without blocking the epic.

medium impact low prob technical

WizardDraftRepository must choose between shared_preferences and Hive for local persistence. Choosing the wrong store for the data volume (e.g. shared_preferences for complex nested wizard state) can lead to serialisation bugs or performance degradation, particularly on lower-end Android devices used by some NHF members.

Mitigation & Contingency

Mitigation: Define a clean repository interface first and implement shared_preferences as the initial backend. Profile serialisation round-trip time with a realistic wizard state payload (≈10 fields) before committing to either store.

Contingency: Swap the persistence backend behind the repository interface without touching wizard UI code, which is possible precisely because the repository abstraction isolates the storage detail.

medium impact high prob scope

The AccessibilityDesignTokenEnforcer scope could expand significantly if a large portion of existing widgets use hard-coded values. Discovering widespread violations during this epic would force either a major refactor or a decision to exclude legacy components, potentially reducing the enforcer's coverage and value.

Mitigation & Contingency

Mitigation: Run a preliminary audit of existing widgets using a simple grep for hard-coded hex colors and raw pixel values before implementation begins. Use the results to set a realistic remediation boundary for this epic and log all out-of-scope violations as tracked tech-debt items.

Contingency: Scope the enforcer to new and modified components only (via file-path filters in dart_code_metrics config), shipping a partial but immediately valuable coverage rather than blocking the epic on full-codebase remediation.