Repository navigation
test: score the prediction on 30 hand shapes and 9 devices - #1
Merged
Merged
Conversation
The prediction was tuned against four shapes on four devices, which left most of what a hand does unwatched and made every change a question for the rig and an afternoon. This replaces that with a replay rig the fit can be iterated against on its own. `harness.ts` holds it: a hand on a known path, a modelled device reporting it in whole counts at its own rate and clock wander, a frame loop reading the lead back, and seventeen numbers scoring the run. Devices now span an 8KHz mouse to one reporting less than once a frame, including a low-DPI one whose counts are four pixels wide; displays span 30Hz to 144Hz; delivery lag is an axis of its own. Shapes: steady drags from a crawl to a whip, ramps, flicks stopping in anywhere from 40ms to 400ms, abrupt starts and stops, stop-and-go, point to point, sharp and rounded corners, circles both ways, a stir, a figure eight, a spiral, a serpentine, a zigzag, shakes, target acquisition, overshoot-and-correct, a double flick and tremor at rest and on a drag. Scored per run, and never adding overshoot to lateness: how far past the hand the guess sat and how far behind, how much the picture moved against the hand or moved at all while the hand was still, how much the size and heading of the guess jumped in a frame, and the error against the error of not guessing. `bun run bench` prints the same runs as a table, with --save/--diff so a tuning change is read as a change rather than found later on a desk. Every constant in predictor.ts was broken in turn against this and every one now fails something; two lines no modelled hand reaches are named in predictor.test.ts rather than tested for the sake of it. Two findings are pinned at their current values with the diagnosis next to them: a device whose counts are wider than a pixel gets floors written in units of one, so it spins the lead 28° a frame on a dead straight path and leads a crawl it should not; and an eased stop on a slow radio hands back up to 14px in a single frame. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T
Every noise floor in the fit is written in units of one count, and a count was assumed to be a pixel. That holds for a mouse at ordinary sensitivity and not for a low-DPI one, a page at a device pixel ratio other than 1, or an OS scaling the counts on the way through. On a mouse stepping four pixels a count, every floor sat four times too low and its staircase was believed as motion: the guess swung 28 degrees of heading a frame on a dead straight path, jumped thirty times as far in size as the same hand on a 125Hz mouse reporting just as often, ratcheted nine times as much, spun the held lead through a right angle at the tail of a stop, and led a crawl it should have refused. Deltas are the only thing that knows what a count is worth, and every delta is a whole number of them, so the grid they sit on is their greatest common divisor. Unlike sample counts or smallest deltas, that reading does not confuse a coarse device with a fast hand. Two windows of 250ms have to agree before the floors move, since a hand can hold a factor by luck for one of them but not two, and the answer is held at a pixel from below: a device finer than that is quieter than the floors assume, so following it down would mean believing more of a second derivative on the strength of an estimate. That is what makes this safe rather than a retune — the answer can only move floors up, and eight of the nine modelled devices are bit-identical to before. The speed gate takes the extra uncertainty off the measured travel rather than putting it on the threshold. Multiplying the threshold refuses an ordinary 0.35px/ms drag on such a device; four counts across a window are far too few to fit a curve to and plenty to say how fast a hand is going. On the low-DPI mouse: size step 4.69 -> 0.59, heading swing 27.9 -> 1.1 degrees a frame, ratchet 198 -> 53, crawl lead 6.3 -> 1.6, backwards lead at a stop 4.25 -> none, and error on a straight drag 0.315 -> 0.185 of not guessing. It costs the curvature, which four-pixel counts genuinely cannot carry: a second derivative there sits 1.3x its own noise, so the arc is mostly given up and circles fall back to a straight line that points half a window of turning behind the tangent. That trade is pinned in predictor-devices.test.ts with the numbers a fix would have to beat — advancing the swept heading by the turn already measured would give most of it back without believing any more curvature, and that is a change to how every device extrapolates rather than to this one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T
Reported as bad jumps on sharp turns. Traced with a frame-by-frame
trace of the fit: on the frame a right-angle corner enters the window,
the guess asks for a lead of exactly zero, from a hand that has not
slowed by a pixel per second.
Seen along the heading alone a corner and a stop are the same event —
the speed the hand had is going away — and a corner takes it away harder
and sooner than any stop does. Braking is deliberately believed on thin
evidence and acted on at once, so both readings of it fire, and the
ramp-lag subtraction then takes the whole guess with it. This is the
mistake the module header already describes for a per-axis fit at the
extremum of a circle, one level in, and it has the same answer: look at
the other axis. A hand coming to a stop pushes straight back along its
path; a hand turning pushes sideways. Measured through a right angle at
speed, a hundredth of the bend pointed back along the path and the rest
of it across.
So both brake readings are gated by how much of the bend points back
along the path. Below its own noise floor the bend has no direction
worth reading and the gate reads as one, which leaves every device too
thin to carry a curvature braking exactly as it did — that is the case
the speed trend exists for and it is worth 16px of stop overshoot on the
sparsest device.
The guess through a corner now jumps 2-3x less in size: 6.4 -> 4.5px
wired, 6.4 -> 3.0 on bluetooth, and the same on every curve. 140 cells
of the board improve against 70 that give up a little, all of them small
and on turning paths, where less braking means slightly more overshoot.
Three things measured and NOT changed, each written down where it will
be found again:
- Believing a bend sooner when it stands far above its noise. The
parabola knows the new heading the moment the corner is in the
window and the 150ms settling is what stops it being used, but
acting on it concentrates the whole catch-up into one frame: the
camera moved 102px on a frame where the hand moved 42.
- Easing the lead in polar rather than world axes, so a direction
change does not cross through a shorter vector. It moves the corner
by nothing and costs 305 cells elsewhere.
- Clamping how far the held lead may be spun in one frame. It is
currently a right angle, which looks alarming and measures as
nothing.
The corner itself turns out to be close to what a 40ms window allows:
against the same hand going straight, a right angle adds 0-11px to the
worst uneven frame, and on a mouse reporting in clumps it adds nothing
at all.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T
…over
Reported as small circular motions coming apart, and worse the higher
`leadFrames` goes. Measured, that is exactly the shape of it: a 25px
circle stirred every 110ms put the guess 14px off the circle at one
refresh of lead, 42 at two, 58 at three and 65 at four — two diameters
from anywhere the hand ever goes — and moved the picture 60px in a frame
getting there. Every extra refresh cost more than the last.
Past about a quarter turn of horizon the answer is mostly the turn rate,
which is the noisiest thing in the fit, and the chord being asked for has
stopped growing with the horizon and started coming back towards the
hand — so a wobble in the rate moves the guess around the circle rather
than along it. Worse, the arc sweep was clamped at a right angle while
the distance went on being the whole arc length, so a guess that should
have been a short chord left the circle altogether.
So the horizon is bounded by how far the path turns over it, which is the
same rule the reversal horizon already applies to a hand doubling back.
The small circles now read the same at one refresh of lead and at four:
9px off instead of 65, and 13px of uneven picture motion instead of 60.
Two things the measurements insisted on:
- The rate is settled over 100ms before it bounds anything. Bounding on
the raw reading hands the horizon the turn estimate's own wobble, and
a horizon that wobbles is a lead whose length wobbles, which is the
picture moving backwards under the hand — 2.3px of it on a tight
circle, the artefact this exists to remove rather than one to add.
- The bound is eased in rather than applied as a ceiling. A hard ceiling
has a knee, and a path whose turn sits on the knee steps across it and
back every frame; the eased shape leaves a gentle turn alone, takes a
sixth off where the bound is reached, and settles on it past that.
A quarter turn was chosen by sweeping: at a half turn the small circles
are still 23px off, and at an eighth an ordinary tight circle starts
losing lead it should have. 158 cells of the board improve against 72
that give up a little, all of the latter being more lateness on the two
tightest circles, which is the trade being made on purpose.
Wide circles keep every pixel of lead the setting asks for — they never
turn far enough to reach the bound — and a wired mouse stays within 6px
of one at four refreshes of lead. On a device reporting four or five
samples a window they still drift outside a wide circle, by up to 39px at
four refreshes; that is the turn being believed less than it is on short
chords rather than the horizon, it is unchanged by this, and it is pinned
with the numbers a fix would have to beat.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T
Reported as the marker orbiting outside a 120px circle. Measured on one
at a range of speeds, worst across the four quoted devices: 1.9px out at
300ms a lap, 19.7 at 600ms, 13.2 at 900ms. Slow circles were worse than
fast ones, which is the tell — it is not the extrapolation running away,
it is the turn not being believed.
Two gates were multiplying. The turn is read from two chords, which is a
good measurement even on a window holding four samples, and it was then
multiplied by how far the parabola was believed — a worse measurement of
the same thing, and one that sits near a half on exactly that window. Two
half-open gates left the arc bending at a quarter of the rate the hand
was turning, and a lead that lags the heading on a circle points
outwards. That is the marker sitting outside the circle.
So the turn is judged on its own evidence now. That evidence is the
average of several readings rather than one: a hand going round turns the
same way on every frame while quantisation flips sign, so averaging keeps
the turn whole, takes the noise down with the root of how many
independent windows went into it, and is more evidence rather than a
lower bar. Windows overlap, so it is windows that are counted and not
frames.
Two more things the measurements insisted on:
- A reading that contradicts a turn already worth believing is taken at
once rather than averaged in. A hand can stop going round one way and
start going round the other — a figure eight does it twice a lap —
and averaging across that says it is doing neither. The test is
against a believed turn rather than against zero, or a straight path,
whose readings flip sign every frame, would take the quick road every
time and the average would follow the noise it exists to cancel.
- The floor a turn is judged against is what quantisation typically
does to a chord's heading, not the worst it could ever do. A position
on a grid is off by a twelfth of a count in variance, which is about
four tenths of the worst case; used as the divisor of a signal to
noise ratio, the worst case asked for a five-sigma turn before
believing one, which a 120px circle at a comfortable speed does not
produce. A twentieth below the figure here is where a stalled frame's
noise starts reading as a turn, so it sits just the safe side of that.
The 120px circle now reads within 3px of itself at every speed on every
device that reports in single pixels, against 20px before. 351 cells of
the board improve against 205 that give up a little.
What it costs is what believing a turn always costs a locked pointer:
rotation is growth on both axes in turn, and a ratchet keeps growth. On
shapes whose curvature reverses that accumulation roughly triples — a
figure eight goes from 18 to 68px over three seconds. Every other shape's
is unchanged, including a plain circle and a straight drag. `kept` is now
a column of the shapes table so the next change to any of this has to
say what it did to that.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T
An arrow is a bad shape to judge alignment against: it is not centred on the position it means, so the eye compares a corner to a circle and the answer depends on which way the arrow points. A dot centred on the hotspot is the same shape as the markers chasing it, and a slow-motion frame reads as the dot being inside the ring, on its edge, or outside it. Radius 8 against the green ring's 11, so the two never touch when they agree and the gap between them stays readable. It is still the OS pointer — a cursor image handed to the window server and drawn by the compositor at the true position, exactly as the arrow was. Drawing a dot into the canvas instead would put it at the *reported* position, which is what the red square already is, and the lag this page exists to show would vanish along with the reference for it. Falls back to the ordinary arrow rather than to `none`: a rig with no pointer is worse than one with the wrong pointer, and there is already a button for hiding it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The prediction was tuned against four shapes on four devices, which left most of what a hand does unwatched and made every change a question for the rig and an afternoon. This replaces that with a replay rig the fit can be iterated against on its own.
harness.tsholds it: a hand on a known path, a modelled device reporting it in whole counts at its own rate and clock wander, a frame loop reading the lead back, and seventeen numbers scoring the run. Devices now span an 8KHz mouse to one reporting less than once a frame, including a low-DPI one whose counts are four pixels wide; displays span 30Hz to 144Hz; delivery lag is an axis of its own.Shapes: steady drags from a crawl to a whip, ramps, flicks stopping in anywhere from 40ms to 400ms, abrupt starts and stops, stop-and-go, point to point, sharp and rounded corners, circles both ways, a stir, a figure eight, a spiral, a serpentine, a zigzag, shakes, target acquisition, overshoot-and-correct, a double flick and tremor at rest and on a drag.
Scored per run, and never adding overshoot to lateness: how far past the hand the guess sat and how far behind, how much the picture moved against the hand or moved at all while the hand was still, how much the size and heading of the guess jumped in a frame, and the error against the error of not guessing.
bun run benchprints the same runs as a table, with --save/--diff so a tuning change is read as a change rather than found later on a desk.Every constant in predictor.ts was broken in turn against this and every one now fails something; two lines no modelled hand reaches are named in predictor.test.ts rather than tested for the sake of it. Two findings are pinned at their current values with the diagnosis next to them: a device whose counts are wider than a pixel gets floors written in units of one, so it spins the lead 28° a frame on a dead straight path and leads a crawl it should not; and an eased stop on a slow radio hands back up to 14px in a single frame.
Claude-Session: https://claude.ai/code/session_01HctBLnHDXwx1XURcvnEB9T