Skip to content

Phase 5: trust and safety, Smart log accuracy, caffeine and alcohol, exercise library - #10

Merged
coderback merged 14 commits into
mainfrom
phase-5
Nov 5, 2026
Merged

coderback merged 14 commits into
mainfrom
phase-5

Conversation

@coderback

@coderback coderback commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Phase 5 of the plan in docs/PLAN_PHASES_5_TO_9.md, the first and easiest of Phases 5–9. It also carries the market research behind that plan: reports/ and research_notes/.

⚠️ Deploy notes

  • Migrations: 20261107120000_phase5_safety_library and 20261107130000_food_memory_caffeine_alcohol are already applied to Supabase (20 of 20 recorded). Both are additive.
  • Exercise library: loads itself on first start from packages/backend/data/exercises.json (free-exercise-db, public domain). It reloads when the tagging version changes. No manual step.
  • What existing users see:
    • the "Before you start" check once (age and the wellbeing question), if their profile lacks either;
    • the AI consent sheet the first time they use Smart log, the coach or plan building.
  • Account owner steps: in docs/TRUST_AND_SAFETY.md:
    • Azure: a Data Zone deployment and modified abuse monitoring (section 2);
    • store declarations (section 4);
    • a dietitian review of the calorie floors and loss cap;
    • a lawyer review of the drafts (sections 5–7).

5.1 Trust and safety

  • AI consent (Apple 5.1.2(i)):
    • a sheet names Microsoft's Azure OpenAI before the first AI use;
    • without consent the server refuses POST /food/parse, POST /ai/message and POST /workout-plan/generate with 403 { code: "ai_consent_required" }, and the nudge falls back to fixed text;
    • consent can be withdrawn in Privacy.
  • Coach:
    • labelled "AI coach" (EU AI Act disclosure);
    • instructions refuse diagnosis, medication advice and eating below target, and route crisis or eating-disorder language to help;
    • after a "yes" to the eating-disorder question, its context avoids weight-loss talk.
  • 18+:
    • the onboarding age picker starts at 18, and the server refuses younger dates of birth;
    • a ProfileGate sends users without an age or wellbeing answer to /welcome-check, which turns away under-18s and offers account deletion.
  • Calories:
    • floors of 1,500 kcal for men and 1,200 otherwise;
    • planned loss capped at 1% of body weight a week;
    • both applied in onboarding, adaptive suggestions and typed targets (server and app).
  • Wellbeing step in onboarding: "yes" hides weight-loss goals, the server refuses them, and adaptive suggestions target maintenance.
  • Names: pro-eating-disorder display and challenge names are refused. Whole-word matching means "Pro Analysis Club" passes.
  • Data permissions: four, all off by default.
  • SDK audit: no ad or analytics SDKs. Push text that reaches Expo is flagged.

5.2 Smart log accuracy

  • Per item: source plus confidence, and a "check this" flag when protein or fat is out of range for the food's category.
  • Cooking fat: the reading flags it when it's unclear instead of guessing, and the app asks "Cooked in oil or butter?" and adds the oil.

5.3 Caffeine, alcohol and search data

  • Caffeine and alcohol on food logs:
    • from Open Food Facts labels (caffeine g → mg, % vol → g) and from Smart log, and remembered with food memory;
    • drink shortcuts, the day's totals on the Food tab, and both in the coach's context.
  • POST /food/search-events: records what was picked, or nothing, with the phone's country and language.
  • Corrections: editing a log's numbers sets FoodLog.corrected. This is Phase 7's baseline.

5.4 Exercise library and coach plans

  • The library:
    • 876 exercises, each with a movement pattern and what it stresses (impact, spinal load, overhead, deep knee bend, wrists);
    • GET /exercises and GET /exercises/:id, and a library screen.
  • Coach plans:
    • the model picks exercise ids from a shortlist filtered by location, level and injuries in coach notes, enforced by an enum in the strict schema;
    • unknown ids are dropped;
    • plan exercises open their instructions.
  • Workout intensity (easy, moderate or hard) picks the MET value; moderate keeps the previous numbers.

Testing

  • Backend: 132 unit and 55 database tests. Prettier, ESLint and tsc are clean.
  • Mobile: 23 unit tests, tsc clean, no lint errors.
  • Browser (web build, live API, real model):
    • new suites: safety 19/19, food 11/11, library 11/11, onboarding 10/10;
    • Phase 4 suites: theme 16/16, sign-in 12/12, health 5/5, Smart log 18/18, coach 12/12.
  • A bug found and fixed in testing: a plan for a user with a knee note included "Barbell Step Ups", because the stress rule only matched "step-up". Step-ups and leg extensions are now tagged, with tests.
  • Not tested here: real devices, so the camera and health permissions with these changes are untested.

An exercise library the coach builds plans from, with injury-aware
filtering; set-by-set strength logging with PRs; calorie burn from
intensity and heart rate, calibrated per person against the weight
trend; strength levels from OpenPowerlifting; and progression that
takes nutrition and sleep into account.
GRIT launches globally, so the Phase 5 food import takes the full
Open Food Facts set (needing Supabase Pro), and regional depth (local
dishes, names and units) goes where users' searches miss, measured per
country, instead of starting with West Africa.
Adds 5J, a trust and safety baseline that runs first (SDK audit, AI
consent naming Microsoft, Azure Data Zone, EU AI disclosure, 18+ gate,
calorie floors, eating-disorder safeguards, privacy notices), and a
wider health import (HRV with source, resting HR, VO2max, cycle data).

Nutrition gains dish-level regional data with local names and units,
Smart log confidence badges and a cooking-oil question, caffeine and
alcohol tracking, write-back to the phone's health app and a public
accuracy page. Fitness gains voice and offline set logging, supersets
and calculators, plans that run by session order, movement patterns
that keep history across swaps, a cycle-aware weight trend and
evidence-based deficit and protein rules in the progression engine.

Race predictions move to a later endurance package, data consent is
split into separate default-off settings, and the timeline is now
about 18 weeks for one developer or 11 for two.
5 Quick wins and safety: trust and safety baseline, Smart log accuracy
badges and checks, caffeine and alcohol, search and correction
recording, the exercise library and library-based coach plans.
6 Strength logging and health data: sets, PRs, voice and offline
logging, progression rules, wider health import, heart-rate calories
and nutrition write-back.
7 GRIT's own food database: schema, imports, local search and
barcodes, micronutrients from measured values.
8 Data quality and regional foods: contributions, quality scores,
duplicate merging, regional dishes, names and units.
9 ML and research: evaluation, name matcher, portion defaults,
micronutrient estimator, accuracy page, burn calibration, cycle-aware
trend and strength levels.

The research's later phases are renumbered 10-12.
AI features (Smart log, the coach, plan building) now ask first, in a
sheet naming Microsoft's Azure OpenAI as Apple requires; the server
refuses them without consent, and it can be withdrawn in Privacy. The
coach is labelled as an AI and its instructions refuse diagnosis,
medication advice and under-eating, and route crisis language to help.

GRIT is now 18+: onboarding starts at 18, the server refuses younger
dates of birth, and users without an age (Google or Apple sign-in) see
a short check first. Calorie targets have floors by sex (1,500 kcal
for men, 1,200 otherwise) and planned loss is capped at 1% of body
weight a week, in onboarding, adaptive suggestions and typed targets.
A new onboarding question about eating disorders turns off weight-loss
goals and steers the coach; pro-eating-disorder display and challenge
names are refused. Four separate data-use permissions, all off by
default, sit in Privacy.

docs/TRUST_AND_SAFETY.md records the SDK audit (no ad or analytics
SDKs; push text reaching Expo is flagged), the Azure steps for the
account owner, and drafts of the health privacy notice and impact
assessment for a lawyer.
Each item now shows where its numbers came from and how confident the
reading is, and items whose protein or fat is out of range for their
kind of food (grilled chicken at 2 g protein, rice at 40 g fat) are
marked "check this". Instead of guessing cooking oil, the reading now
says when it can't tell, and the app asks "Cooked in oil or butter?"
and adds the oil itself.

Readings also carry caffeine and alcohol per 100 g, which are logged
with each item and remembered with the user's foods.
Food logs now carry caffeine and alcohol, read from Open Food Facts
labels (caffeine in grams, alcohol as % vol) and from Smart log. A row
of drink shortcuts logs coffee, tea, beer, wine and spirits with
typical values, the Food tab shows the day's caffeine and alcohol, and
the coach sees them.

Food searches now record what was picked, or that nothing was, with
the phone's country and language, and editing a logged food's numbers
marks it as corrected. Together these give the baseline for GRIT's own
food database and show where searches miss.
GRIT now has an exercise library of 876 exercises from free-exercise-db
(public domain), loaded automatically on first start and reloaded when
the tagging rules change. Each exercise gets a movement pattern, so
swaps can keep progression history, and tags for what it stresses
(impact, spinal load, overhead, deep knee bend, wrists). A library
screen searches and filters it, with pictures and instructions.

Coach plans are now built only from the library: the model picks ids
from a shortlist already filtered for where the user trains, their
level and any injury in their coach notes (a sore knee keeps out
squats, lunges, step-ups and running), and the strict schema makes
anything else impossible. Plan exercises open their instructions.

Logging a workout now asks how hard it was, and calories use light,
moderate or vigorous values; moderate keeps the previous numbers.
@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
grit-demo Ready Ready Preview Nov 5, 2026 7:50pm UTC

@coderback
coderback merged commit 4911ead into main Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant