[Developer] #204 Phase 1 MVP — Flutter app skeleton complete

- 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>
This commit is contained in:
2026-06-12 10:33:03 +09:00
parent 29befe4d97
commit 8fe6a8f378
76 changed files with 29059 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
/// Default single-user id for local-only Phase 1.
const String kLocalDefaultUserId = 'u_local_default';
const String kSeededV1Flag = 'seeded_v1';

14
app/lib/core/id.dart Normal file
View File

@@ -0,0 +1,14 @@
import 'package:ulid/ulid.dart';
/// Typed ULID with prefix (e.g. `hb_01J9XYZ...`).
String generateUlid(String prefix) {
if (prefix.isEmpty) {
throw ArgumentError('prefix must be non-empty');
}
return '${prefix}_${Ulid().toString()}';
}
final RegExp _ulidRegex =
RegExp(r'^[A-Za-z]{1,8}_[0-9A-HJKMNP-TV-Z]{26}$');
bool isValidUlid(String s) => _ulidRegex.hasMatch(s);

16
app/lib/core/result.dart Normal file
View File

@@ -0,0 +1,16 @@
/// Minimal Result sum type. Use for domain operations that may fail.
sealed class Result<T, E> {
const Result();
bool get isOk => this is Ok<T, E>;
bool get isErr => this is Err<T, E>;
}
final class Ok<T, E> extends Result<T, E> {
final T value;
const Ok(this.value);
}
final class Err<T, E> extends Result<T, E> {
final E error;
const Err(this.error);
}

19
app/lib/core/time.dart Normal file
View File

@@ -0,0 +1,19 @@
/// Time helpers. KST default. ISO 8601 string for DB storage.
DateTime nowKst() => DateTime.now().toLocal();
/// Strip time → YYYY-MM-DD (DB date column).
String dateOnly(DateTime d) {
final local = d.toLocal();
return '${local.year.toString().padLeft(4, '0')}-'
'${local.month.toString().padLeft(2, '0')}-'
'${local.day.toString().padLeft(2, '0')}';
}
/// Monday 00:00 of the week containing [d].
DateTime weekStart(DateTime d) {
final local = d.toLocal();
final mondayOffset = (local.weekday - DateTime.monday) % 7;
final monday = DateTime(local.year, local.month, local.day)
.subtract(Duration(days: mondayOffset));
return monday;
}