Commit Graph

2 Commits

Author SHA1 Message Date
Mike Kell 51364a8f4f feat(platform,tests,ci): complete Phase 6 cross-platform hardening, integration tests, and Forgejo CI/CD
- Harden HealthGateway: kIsWeb/defaultTargetPlatform/dart:io guards, Health
  Connect SDK availability probe with graceful degradation, READ_WEIGHT/
  READ_STEPS/READ_TOTAL_CALORIES_BURNED permission validation before reads,
  HealthKit entitlement failures contained (false + debug warning), and a
  desktop/web fallback that serves locally logged biometrics through the new
  ILocalBiometricReader contract (drift-backed adapter wired in health_sync).
- Platform-safe CryptoManager vault: EncryptedSharedPreferences (Android),
  Keychain first_unlock (iOS/macOS), DPAPI-sealed file (Windows), libsecret
  (Linux); vault failures degrade to an ephemeral in-memory SQLCipher key.
- Declare the four Health Connect READ_* permissions in AndroidManifest.xml.
- Extract isAuthenticatedProvider so integration tests can simulate auth
  sessions without booting Supabase.
- Add 24 tests (99 -> 123): steady-state PK suite (Semaglutide 168h /
  Tirzepatide 120h geometric series, superposition, titration, washout),
  real-world recipe JSON-LD fixtures (BBC-style root, AllRecipes @graph),
  pantry unit-conversion group (kg/g, l/ml, dimension guard, synonyms),
  app navigation integration tests (rail + bar, authenticated + dev-bypass
  + unauthenticated), and reactive nutrition progress-bar widget tests.
- Fix NutritionScreen narrow-width overflows: Flexible protein title and
  Wrap action buttons stack cleanly on compact phones.
- Add .forgejo/workflows/ci.yml for git.kellsupport.com/mtkell/glp-companion
  (push to main + PRs, Flutter container: checkout, mock .env, pub get,
  build_runner, analyze --fatal-infos, test --coverage, build bundle + web).
- Remove dead lib/features/recipes/data/recipe_scraper.dart; rewrite
  README.md (architecture, dev setup, SQLCipher details, CI docs); add
  .env.example; allow it through .gitignore; update BUILD_STATE.md with
  Phase 6 deliverables and complete Phases 1-6 checklist.

Verified: build_runner 44 outputs, flutter analyze --fatal-infos clean,
flutter test 123/123, flutter build web and flutter build bundle succeed.
2026-10-16 14:59:15 -04:00
Mike Kell 747d917aed feat(pantry): complete Phase 5 pantry delta engine and auto-shopping generator
Domain (pure Dart):
- Add PantryItem and ShoppingListItem entities plus the PantryCategory aisle
  enum (produce/meat_seafood/dairy/dry_goods/spices/other) with a keyword
  infer() heuristic and ExpirationStatus warning buckets (expired /
  expiringSoon within 3 days)
- Add measurement_units value object (mass/volume/count dimensions with
  lb/oz/g/kg and ml/l/tsp/tbsp/cup conversion onto a shared base scale) and
  ingredient_name canonicalizer (lowercase, parenthetical stripping,
  plural folding: eggs -> egg, lbs -> lb)
- Define IPantryRepository contract covering inventory and checklist CRUD
- Add CalculateShoppingDelta use case: aggregates the active 7-day meal-plan
  slot window's recipe ingredient manifests by canonical name, computes
  deficit = totalRequired - currentPantryQuantity in base units (dominant
  recipe unit wins display, 2-decimal rounding), upserts isAutoGenerated
  rows with stable ids and source recipe titles, clears stale auto rows once
  stock covers the plan, and never modifies or removes manual rows

Data:
- Bump AppDatabase to schema v4 (migration for v1-v3 installs) with
  PantryItemsTable (UUID PK, canonical name, quantity/unit, aisle key,
  nullable expirationDate, lastUpdated) and ShoppingListItemsTable (UUID PK,
  required quantity/unit, purchased/auto flags, JSON sourceNotes for recipe
  titles) plus watch/get/upsert/delete helpers
- Implement DriftPantryRepository (record <-> entity mapping, enum keys,
  JSON recipe-title round-trip)

Presentation:
- Add PantryInventoryController (live watch stream, quick +/- stock steps
  clamped at zero, aisle-grouping vs expiration-sort modes) and
  ShoppingListController (manual add, All/To Buy/Checked filter, check-off
  with "Add to Pantry?" unit-converting stock merge or aisle-inferred row
  creation, syncWithMealPlan reading the planner's Monday-Sunday window and
  recipe catalog)
- Refactor PantryScreen: Inventory/Shopping tab header with remaining-count
  badge, Aisles/Expiration segmented control, categorized tiles with +/-
  counters and expired/expiring badges, swipe-to-delete on both lists,
  prominent "Sync with Meal Plan" banner with run summary + snackbar,
  "From: <recipe>" origin chips on auto rows, checklist filters, check-off
  -> pantry prompt, and Add Pantry Item / Add Shopping Item dialogs

Testing:
- 10 new tests in delta_calculator_test.dart: 300 g on hand vs 800 g
  requirement -> +500 g entry, sufficient stock -> no entry, manual rows
  preserved across repeated syncs, stale auto cleanup, cross-recipe
  plural/unit normalization (4 eggs + 2 egg - 2 -> +4 egg), lb/oz scale
  unification (0.75 lb), check-off -> pantry transfer (merge +
  aisle-inferred create), end-to-end syncWithMealPlan, and inventory
  canonicalization / quick-adjust clamp; full suite green (99/99)
- flutter analyze clean (No issues found!) after codegen; BUILD_STATE.md:
  mark Phase 5 complete and record all verification gates
2026-10-16 10:33:14 -04:00