- Drift 21 tables (8 catalog + 11 user + habit_dose_variants + meta_kv) with R1~R10 CHECK constraints and 19 indexes - 8 hand-crafted seed JSON catalogs in app/assets/seed/ (refs 84, protocols 34, methodologies 21, frame_patterns 30, reward_menu_items 30, break_protocols 8, common_frames 5, diet_patterns 5) - 6 domain functions: recommend_variant, compute_streak, validate_frame_level, active_habit_quota, weekly_minimum_ratio, seed_importer (transactional, idempotent) - 4 vertical-slice Riverpod screens: HabitList, HabitCreate, CheckIn, Streak - 31 unit tests passing; flutter analyze clean - OQ-5 streak semantics: missing entry ≠ explicit blank (missing = end of history; only TrackerValue.blank triggers Never-miss-twice) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
21 lines
605 B
Dart
21 lines
605 B
Dart
import '../models/habit.dart';
|
|
|
|
/// XOR: build → protocol_id (only); break → break_protocol_id (only).
|
|
void assertXorProtocol({
|
|
required HabitType type,
|
|
required String? protocolId,
|
|
required String? breakProtocolId,
|
|
}) {
|
|
if (type == HabitType.build) {
|
|
if (protocolId == null || breakProtocolId != null) {
|
|
throw ArgumentError(
|
|
'build habit requires protocol_id and no break_protocol_id');
|
|
}
|
|
} else {
|
|
if (breakProtocolId == null || protocolId != null) {
|
|
throw ArgumentError(
|
|
'break habit requires break_protocol_id and no protocol_id');
|
|
}
|
|
}
|
|
}
|