Three ways the engine could strand a rider. The headroom loop spun forever
on a small gear range (maxGear is configurable down to 1) or against a
trainer that refuses to shift, so it now stops when the gear stops moving
and is capped either way. The power-target-less skip path returned before
the phase's finally, so a rider's manual ERG survived into the sweep —
pinning plateau 1 flat — and was then silently dropped by the first
shift; the check moved inside the try, and both ERG helpers now key off
the trainer's actual mode rather than only our own writes. Restores are
individually guarded: a refused gear write can no longer cost the rider
their ERG session, a refused ERG write no longer downgrades a scored run
to aborted, and run() resolves with a result whatever the harness does.
Also: a mid-test upstream dropout now aborts instead of misreporting
NO_CONTROL — prop's notifiers latch their last value, so a dead link used
to read as a trainer that ignores us.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Restoring a rider's manual ERG target right after the staircase pinned
power flat for the whole shift sweep, so every transition read "no
change" and a healthy trainer verdicted ERG_OK_VS_FAIL. The staircase now
always exits ERG before the sweep, and the rider's own ERG session is put
back at the very end — still gated on the dirty flag, so a run that never
commanded a target (noData, early abort) writes nothing at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Baseline → ERG staircase → shift sweep on a 500 ms tick, with a cadence
pause watchdog and restore-always semantics: the gear goes back to where
the rider left it and our own ERG writes are undone on pass, fail, cancel
and exception alike. Eight scenarios drive it on a virtual clock through
a fake harness, so no test waits on wall time.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>