test(coach): pin the workout launch's tenancy, closure and snapshot-once

Four suites, each mutation-checked against a reverted protection:

- route-workout-scope: the workout row is read exactly once across a ten-turn
  conversation that keeps sending the id, the where clause always names
  userId, another user's id resolves to nothing and the chat proceeds, and
  the section sits inside the health-data fence.
- workout-evidence: the numbers-only closure. An instruction-shaped
  sport_type — reachable through the restore path, which types the column as
  free text — folds to "other" and never reaches the block; a free-text leaf
  at any depth throws.
- page-launch-params: an unknown ?scope= is ignored silently, and ?workout=
  yields to both ?c= and the fenced ?doc= path.
- composite-score-anatomy-coach: every score sheet carries an opener, a
  scope narrowed to the composite's inputs, and auto-send.

resolveLaunchState's shape assertion gains the workoutId field.
This commit is contained in:
Marc-André Bombeck committed 2026-07-19 14:19:33 +02:00
1 parent 096c8c799b
commit 2bf450cf17
11 files changed
+829 -7

No files matched your search

+2 -2
View File
@@ -16,9 +16,9 @@ import { prisma } from "@/lib/db";
import { pickCanonicalWorkoutRows } from "@/lib/measurements/pick-canonical-workout-rows";
/** Own-history lookback for the sport-average comparison line. */
export const SPORT_CONTEXT_LOOKBACK_DAYS = 180;
const SPORT_CONTEXT_LOOKBACK_DAYS = 180;
/** Slim-row cap for the sport-average read. */
export const SPORT_CONTEXT_MAX_ROWS = 500;
const SPORT_CONTEXT_MAX_ROWS = 500;
export interface WorkoutSportContext {
count: number;