Support double progression: gate on the top of the rep range and require all sets to qualify
Use case
Double progression is one of the most common progression schemes in hypertrophy training: you work inside a rep range (say 3 sets of 8-12) at a fixed weight, add reps from workout to workout, and only increase the weight once you reach the top of the range - typically once ALL prescribed sets hit the top. After the weight increase you drop back to the bottom of the range and start climbing again.
The current requirements mechanism can't express this. The available rules (weight, repetitions, rir, rest) gate against the displayed prescription of the base config, which for a rep range is the bottom. With 3x8-12, a WeightConfig gated on {"rules": ["repetitions"]} already fires when the lifter logs 8 reps, i.e. immediately on re-entering the range, so the weight ratchets up every workout and the "fill the range first" phase never happens. There is no way to reference the top of the range (the MaxRepetitionsConfig value), and no way to require that every prescribed set qualifies rather than any single one.
Proposal
Two additive extensions to the existing requirements JSON, no schema or migration changes:
New rules max_repetitions and max_weight. They read the same log field as their base rule (repetitions, weight) but gate against the top of the prescribed range, i.e. the value walked for the maxrepetitions / maxweight config. A weight progression for classic double progression becomes: {"rules": ["max_repetitions"]}.
New optional boolean all_sets. When set, the gating iteration only qualifies if at least the prescribed number of sets was logged and every logged set meets all rules, instead of a single qualifying set being enough. Strict double progression is then: {"rules": ["max_repetitions"], "all_sets": true}.
This slots into the walk-based engine from #2465's follow-up rework quite naturally: the thresholds map gains entries for the max fields (rounded like their base field), and _requirements_met gets the all-sets branch with the prescribed set count floored at 1 so empty or under-logged iterations never qualify vacuously.
I have a working implementation on top of the current engine, including validator support (unknown keys rejected, all_sets type-checked), about 20 regression tests for the new rules and flag, and a CHANGELOG entry. All of wger.manager passes. Happy to open a PR if this direction sounds good to you, and to adjust naming or semantics to whatever you prefer.
Additional Context
- I have been running this in production (self-hosted) since June for a 6-day routine where every exercise uses {"rules": ["max_repetitions"], "all_sets": true} together with per-gym weight rounding, so the semantics have seen a few hundred real workouts. The backfill fix (#2464) originally fell out of this work.
- Purely backward compatible: existing requirements keep their meaning, the API surface is unchanged apart from accepting the new keys, and clients that don't know the new rules are unaffected.
- The web and Flutter UIs would eventually want a way to toggle this in the routine editor; I kept the scope server-side here since the JSON can already be set through the API today.
Source: wger-project/wger