Implement TASK-015 metadata-driven exercise logging

This commit is contained in:
rob
2026-11-04 22:22:26 +00:00
parent 669bfc3910
commit 9c0e82037f
31 changed files with 1537 additions and 416 deletions
+8 -8
View File
@@ -1,15 +1,15 @@
# Initial routine data
# Exercise and routine data
`exerciseDefinitions.json` holds stable IDs, names, and categories. `initialRoutine.json` holds the versioned seven-day prescription and refers to definitions by ID. Neither file contains completed workout records or user edits.
`exerciseDefinitions.json` contains stable IDs/names/categories, definition version, equipment capabilities, measurement type and optional default dumbbell count/protocols/support notes. It contains no numeric resistance. Equipment vocabulary is bodyweight, weighted-vest, dumbbells, ez-curl-bar and straight-bar. No current exercise is assigned straight-bar. Dumbbells used as push-up handles are support equipment, not lifted load.
Each day has separate `morning` and `afternoon` sessions. An exercise's `order` is one-based within its session. A `{ "min", "max" }` pair preserves a documented range; equal bounds represent a single target. Durations use seconds unless the field says `Min`. `null` means the source does not specify a value, especially for current hanging ability, finger-hang duration, and unknown loads. A `goalDurationSec` is a goal, not an achieved duration.
`initialRoutine.json` is seed v8 with separate Morning/Afternoon prescriptions, order, ranges, optional flags, rest and historical prescription load context. All assignments follow WORKOUT_ROUTINE section 8. It preserves unknown values as null, untimed afternoon targets, Monday/Friday empty stretch headings, no walks, and the editable initial 120-second continuous daily-hang goal. Do not infer performance or overwrite local overrides from seed updates.
Loads keep vest, dumbbell, and EZ-bar components separate. The 6 kg and 10 kg values are prescribed vest settings only. The source is [`docs/WORKOUT_ROUTINE.md`](../../docs/WORKOUT_ROUTINE.md); any approved change to the initial programme must update that document and this seed together. A future broader storage adapter must copy this seed only when creating a new local routine, then preserve user edits and history.
`performanceModel.js` maps definition metadata to actual measurement/load fields. New detailed records use schemaVersion 1 and definition/prescription snapshots, independent left/right measurements and per-row completion/load. Dumbbells are kg each with actual count (1/2); vest and bars are separate, with bar totals including the bar. Draft nulls differ from explicit zero. Adding rows copies loads/count, never measurements/completion. EMOM stores ten minute rows; durations and hangs never require reps.
Strength entry fields follow each exercise's `load` keys. `dumbbellKgEach` means the mass of each of two dumbbells; `dumbbellKg` means one dumbbell. Mixed `vestKg` and dumbbell keys produce separate inputs. Actual entries do not assume the seed's prescribed weights. New records retain components and a derived total external weight; older entries with only `externalKg` remain legacy totals.
IndexedDB v3 adds performanceEntries and a compound matching-session index while retaining routineOverrides and strengthEntries unchanged. Original sets, EMOM totals, total-only/component and load-sets history remain in their original store and editor. No old totals are reclassified or distributed into detailed rows. `backupStorage.js` provides adapter JSON v2 for all three stores and a v1 legacy-envelope reader, validation and atomic non-overwriting or explicit-replacement import. TASK-009 owns backup UI; this task adds no Settings controls.
Afternoon isometric holds have no prescribed duration. The daily hang starts with a two-minute goal but no vest field. A user-changed hanging goal is stored separately in IndexedDB by `hangGoalStorage.js`; seed updates must not overwrite it.
Floor-fly definition v2 has `fixedDumbbellCount: 2`: count stays in saved load data and calculations but is hidden in the new UI. Older paired floor-fly snapshots also omit the redundant count control without being rewritten. The subsequent Captain correction hides the count input for all exercises; new rows use the defined count internally. Historical differing counts retain their original snapshot semantics.
Suitcase carries also expose their single-dumbbell load as dated weight-only set entries (`kind: load-sets`). These contain actual load and derived external kilograms, without fabricated repetitions or performed duration. The carry duration-per-side prescription remains separate. Existing repetition sets and EMOM totals are unchanged; no IndexedDB store upgrade is needed.
All dumbbell-count controls are now hidden. Counts remain in stored loads and calculations; existing non-null historical counts are preserved. If an older partial draft has a null count, an explicit Save fills only that unrecorded value from its saved definition. Reading alone never rewrites it.
Seed v7 adds vest-only support (`vestKg: null`) to front planks and side-plank hip raises without prescribing a numeric load. Front planks reuse weight-only `load-sets`; hip raises retain repetition sets. Historical bodyweight-only entries remain prior totals until the user explicitly chooses component entry. No database migration is required.
Completion has no checkbox. `preparePerformanceForSave` derives row completion from applicable values/load only when Save is requested; fully filled valid rows become complete, incomplete rows remain drafts and invalid actuals are rejected. The UI adopts derived completion only after a successful write, preserving failed-save/draft semantics and existing records on read. No schema migration is required.
+333 -30
View File
@@ -1,32 +1,335 @@
[
{"id":"pull-up","name":"Pull-ups","category":"strength"},
{"id":"ez-bar-bent-over-row","name":"EZ-bar bent-over rows","category":"strength"},
{"id":"single-arm-dumbbell-row","name":"Single-arm dumbbell rows","category":"strength"},
{"id":"suitcase-carry","name":"Suitcase carries","category":"strength"},
{"id":"weighted-deep-push-up","name":"Weighted deep push-ups using dumbbells as handles","category":"strength"},
{"id":"dumbbell-floor-fly","name":"Dumbbell floor flys","category":"strength"},
{"id":"push-up-plus","name":"Push-up plus","category":"strength"},
{"id":"feet-elevated-weighted-push-up","name":"Feet-elevated weighted push-ups","category":"strength"},
{"id":"bulgarian-split-squat","name":"Bulgarian split squats","category":"strength"},
{"id":"single-leg-romanian-deadlift","name":"Single-leg Romanian deadlifts","category":"strength"},
{"id":"squat","name":"Squats","category":"strength"},
{"id":"single-leg-calf-raise","name":"Single-leg calf raises","category":"strength"},
{"id":"front-plank","name":"Front plank","category":"strength"},
{"id":"chin-up","name":"Chin-ups","category":"strength"},
{"id":"hanging-knee-raise","name":"Hanging knee raises","category":"strength"},
{"id":"finger-hang","name":"Finger hangs","category":"strength"},
{"id":"single-arm-preacher-curl","name":"Single-arm preacher curls over a chair","category":"strength"},
{"id":"hammer-curl","name":"Hammer curls","category":"strength"},
{"id":"single-arm-shoulder-press","name":"Standing single-arm dumbbell shoulder press","category":"strength"},
{"id":"leaning-single-arm-lateral-raise","name":"Leaning single-arm lateral raises","category":"strength"},
{"id":"bent-over-rear-delt-fly","name":"Bent-over rear-delt flys","category":"strength"},
{"id":"lying-dumbbell-triceps-extension","name":"Lying dumbbell triceps extensions","category":"strength"},
{"id":"single-arm-triceps-extension","name":"Single-arm triceps extensions","category":"strength"},
{"id":"side-plank-hip-raise","name":"Side-plank hip raises","category":"strength"},
{"id":"deep-squat-hold","name":"Deep squat hold","category":"isometric"},
{"id":"ninety-ninety-hip-hold","name":"90/90 hip hold","category":"isometric"},
{"id":"bird-dog-hold","name":"Bird-dog hold","category":"isometric"},
{"id":"single-leg-balance","name":"Single-leg balance","category":"isometric"},
{"id":"prone-swimmer-iso","name":"Prone swimmer iso","category":"isometric"},
{"id":"daily-hang","name":"Daily hanging practice","category":"hang"}
{
"id": "pull-up",
"name": "Pull-ups",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "repetitions",
"protocols": [
"sets",
"emom"
]
},
{
"id": "ez-bar-bent-over-row",
"name": "EZ-bar bent-over rows",
"category": "strength",
"version": 1,
"equipment": [
"ez-curl-bar"
],
"measurement": "repetitions"
},
{
"id": "single-arm-dumbbell-row",
"name": "Single-arm dumbbell rows",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 1
},
{
"id": "suitcase-carry",
"name": "Suitcase carries",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "duration-per-side",
"dumbbellCount": 1
},
{
"id": "weighted-deep-push-up",
"name": "Weighted deep push-ups using dumbbells as handles",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "repetitions",
"supports": [
"Stable dumbbells used as handles; their weight is not lifted resistance."
]
},
{
"id": "dumbbell-floor-fly",
"name": "Dumbbell floor flys",
"category": "strength",
"version": 2,
"equipment": [
"dumbbells"
],
"measurement": "repetitions",
"dumbbellCount": 2,
"fixedDumbbellCount": 2
},
{
"id": "push-up-plus",
"name": "Push-up plus",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "repetitions"
},
{
"id": "feet-elevated-weighted-push-up",
"name": "Feet-elevated weighted push-ups",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "repetitions"
},
{
"id": "bulgarian-split-squat",
"name": "Bulgarian split squats",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest",
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 2
},
{
"id": "single-leg-romanian-deadlift",
"name": "Single-leg Romanian deadlifts",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest",
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 2
},
{
"id": "squat",
"name": "Squats",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest",
"dumbbells"
],
"measurement": "repetitions",
"dumbbellCount": 2
},
{
"id": "single-leg-calf-raise",
"name": "Single-leg calf raises",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest",
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 1
},
{
"id": "front-plank",
"name": "Front plank",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "duration"
},
{
"id": "chin-up",
"name": "Chin-ups",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "repetitions",
"protocols": [
"sets",
"emom"
]
},
{
"id": "hanging-knee-raise",
"name": "Hanging knee raises",
"category": "strength",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "repetitions"
},
{
"id": "finger-hang",
"name": "Finger hangs",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "duration"
},
{
"id": "single-arm-preacher-curl",
"name": "Single-arm preacher curls over a chair",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 1
},
{
"id": "hammer-curl",
"name": "Hammer curls",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions",
"dumbbellCount": 2
},
{
"id": "single-arm-shoulder-press",
"name": "Standing single-arm dumbbell shoulder press",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 1
},
{
"id": "leaning-single-arm-lateral-raise",
"name": "Leaning single-arm lateral raises",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 1
},
{
"id": "bent-over-rear-delt-fly",
"name": "Bent-over rear-delt flys",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions",
"dumbbellCount": 2
},
{
"id": "lying-dumbbell-triceps-extension",
"name": "Lying dumbbell triceps extensions",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions",
"dumbbellCount": 2
},
{
"id": "single-arm-triceps-extension",
"name": "Single-arm triceps extensions",
"category": "strength",
"version": 1,
"equipment": [
"dumbbells"
],
"measurement": "repetitions-per-side",
"dumbbellCount": 1
},
{
"id": "side-plank-hip-raise",
"name": "Side-plank hip raises",
"category": "strength",
"version": 1,
"equipment": [
"weighted-vest"
],
"measurement": "repetitions-per-side"
},
{
"id": "deep-squat-hold",
"name": "Deep squat hold",
"category": "isometric",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "duration"
},
{
"id": "ninety-ninety-hip-hold",
"name": "90/90 hip hold",
"category": "isometric",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "duration-per-side"
},
{
"id": "bird-dog-hold",
"name": "Bird-dog hold",
"category": "isometric",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "duration-per-side"
},
{
"id": "single-leg-balance",
"name": "Single-leg balance",
"category": "isometric",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "duration-per-side"
},
{
"id": "prone-swimmer-iso",
"name": "Prone swimmer iso",
"category": "isometric",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "duration"
},
{
"id": "daily-hang",
"name": "Daily hanging practice",
"category": "hang",
"version": 1,
"equipment": [
"bodyweight"
],
"measurement": "duration",
"protocols": [
"attempts"
]
}
]
+14 -10
View File
@@ -1,6 +1,6 @@
{
"id": "documented-baseline",
"version": 7,
"version": 8,
"source": "docs/WORKOUT_ROUTINE.md",
"days": {
"monday": {
@@ -63,7 +63,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
@@ -250,7 +250,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
@@ -348,7 +348,7 @@
}
},
"load": {
"bodyweightOnly": true
"vestKg": null
},
"notes": "Initially unweighted; focus on shoulder-blade protraction."
},
@@ -439,7 +439,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
@@ -515,6 +515,7 @@
}
},
"load": {
"vestKg": null,
"dumbbellKgEach": null
},
"notes": "Use suitable dumbbell loading and controlled balance."
@@ -659,7 +660,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
@@ -738,7 +739,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
@@ -827,7 +828,10 @@
"max": 120
}
},
"notes": "Duration not specified; distinct from the daily afternoon hang."
"notes": "Duration not specified; distinct from the daily afternoon hang.",
"load": {
"vestKg": null
}
},
{
"order": 4,
@@ -938,7 +942,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
@@ -1174,7 +1178,7 @@
"kind": "hanging-practice",
"goalDurationSec": 120,
"currentDurationSec": null,
"goalFormat": null,
"goalFormat": "continuous",
"attemptCount": null,
"breaks": null
},
+2 -2
View File
@@ -18,7 +18,7 @@ const range = (min, max = min) => ({ min, max })
describe('documented initial routine', () => {
it('is versioned, has one stable definition per used exercise, and retains every day and exercise order', () => {
expect(initialRoutine.version).toBe(7)
expect(initialRoutine.version).toBe(8)
expect(initialRoutine.source).toBe('docs/WORKOUT_ROUTINE.md')
expect(Object.keys(initialRoutine.days)).toEqual(weekdays)
@@ -91,7 +91,7 @@ describe('documented initial routine', () => {
expect(afternoon).not.toHaveProperty('restBetweenHoldsSec')
expect(afternoon.targetsAreMandatory).toBe(false)
expect(exercise(day, 'afternoon', 'daily-hang')).toMatchObject({
prescription: { goalDurationSec: 120, currentDurationSec: null, attemptCount: null, breaks: null, goalFormat: null },
prescription: { goalDurationSec: 120, currentDurationSec: null, attemptCount: null, breaks: null, goalFormat: 'continuous' },
})
expect(exercise(day, 'afternoon', 'daily-hang')).not.toHaveProperty('load')
}