critical priority low complexity database pending backend specialist Tier 0

Acceptance Criteria

An abstract Dart class named OrgPersistenceRepository exists under lib/domain/repositories/
The class declares getSelectedOrganizationId() returning Future<String?> with no implementation body
The class declares saveSelectedOrganizationId(String orgId) returning Future<void> with no implementation body
The file has no imports from infrastructure or presentation layers (pure domain layer)
The interface is exported from the domain layer barrel file (e.g., lib/domain/domain.dart)
No concrete storage logic (SharedPreferences, Hive, etc.) appears in this file
Dart analyzer reports zero errors and zero warnings on the file
A clear doc comment on the class explains its role in the domain layer

Technical Requirements

frameworks
Flutter
Dart
data models
Organization
performance requirements
Interface adds zero runtime overhead — abstract class with no fields or logic
security requirements
Interface must not expose internal storage keys or implementation details
No PII fields in the interface signature beyond the org ID string

Execution Context

Execution Tier
Tier 0

Tier 0 - 440 tasks

Implementation Notes

Place the file at lib/domain/repositories/org_persistence_repository.dart. Use Dart abstract class syntax — do NOT use the 'interface' keyword (Dart 3 interface keyword prevents mixin use; abstract class is the idiomatic contract pattern in Flutter clean architecture). Export from the domain barrel to enforce dependency inversion. This file should be the only import needed by any use case or BLoC that touches org persistence.

Testing Requirements

No direct unit tests required for a pure abstract interface. Verify via static analysis (dart analyze) that the file compiles cleanly and has no concrete implementation. Integration verification happens in task-008 when the concrete implementation is tested against this contract.

Epic Risks (2)
medium impact medium prob technical

SharedPreferences behaves differently on iOS (NSUserDefaults) vs Android (SharedPreferences) for edge cases such as first-launch cold reads, storage quota exceeded, or process kill mid-write. If the adapter does not account for these differences, the persistence layer can silently return null on one platform while returning a stale value on the other, causing incorrect routing decisions downstream.

Mitigation & Contingency

Mitigation: Write platform-specific integration tests using flutter_test device runners for both iOS and Android. Document known platform delta in the adapter's inline comments and encode defensive fallback for null returns at the repository boundary.

Contingency: If platform delta causes persistent issues, replace SharedPreferences with flutter_secure_storage for this key — the LocalStorageAdapter abstraction makes this a single-file swap with no impact on the repository or service layer.

high impact low prob dependency

The shared_preferences Flutter plugin may have a version conflict with other plugins already in the project pubspec.yaml. A conflict discovered late in the epic blocks all downstream epics.

Mitigation & Contingency

Mitigation: Resolve and pin the shared_preferences version in pubspec.yaml as the very first task of this epic before writing any implementation code. Run flutter pub get and resolve any version conflicts immediately.

Contingency: If version pinning is impossible due to transitive conflicts, implement LocalStorageAdapter using path_provider + dart:io for JSON file storage as an alternative — the interface contract remains unchanged.