Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Refusals reach the page on /live, and the page reports its snap-backs with their cause to /precision #468
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
Refusals now reach the driver's page on /live, and the page reports its own snap-backs to /precision. The type check shows no errors in the files I touched (it already had errors elsewhere), and 302 tests across the relay, lobby, arm-server, machine-feed, stop, page-parse and ui/ suites pass.
shipped merged
1 earlier comment · 1 event
Refusals now reach the driver's page on /live, and the page reports its own snap-backs to /precision. The type check shows no errors in the files I touched (it already had errors elsewhere), and 302 tests across the relay, lobby, arm-server, machine-feed, stop, page-parse and ui/ suites pass. I did not run the whole bun test suite, and scripts/design-lint.ts doesn't exist in this checkout, so it wasn't run. I haven't tried the page in a browser. The page wiring in viewer.html, including the snap-back reporting, has no test of its own. Tests cover the relay, the arm server and the pure ui/ modules.
Refusals
- The relay subscribes to the machine log and sends every
clampentry, its own and the arm server's, to the driver as one short line per batch. In a local run, with no turns, it goes to every page. - The new
src/refusals.tsbuilds the line, andLobby.tellDriversends it. - The page shows the line with
textContentthroughclampNoteinui/refusal.js. It adds a running count ("N so far") and caps the line at 160 characters. - The relay also counts them as
refusals_shown.
Snap-backs
POST /precision/snap-backtakes{cause, sizeDeg}. The relay checks it, then passes it to the same route on the arm server. Only the driver can call it; an anonymous caller gets 401. A cause not inCAUSES, or a bad size, gets 400 at both the relay and the arm.parseSnapBackinsrc/precision.tsdoes the checking and is shared by both. The arm adds the snap-back to the current session, or to the rolling window alone when no session is running, as with a reconnect.- On the page,
Intentnow keeps the targets it dropped without the arm reaching them, either by timeout or byclear().ui/snap-back.jsgives each a cause from what the page knows, in this order: stop, reconnecting, turn ended, zone block, jam. The size is the distance in degrees, and the report goes to the relay. - If the page can't name a cause, it reports nothing, so it doesn't double-count what the server already counts.
Tests
src/page-feedback.test.tsstarts a real arm server and relay. It checks that a refused frame shows its reason on/live, that each cause inCAUSESis counted once on the arm's/precision, and that bad causes and sizes get 400 at both ends.ui/snap-back.test.tscovers cause selection, sizes, and the intent's lost targets.
Fix first: the page double-counts zone and jam snap-backs. The pull says it only reports causes the server does not count, but server.ts already calls tracker.snapBack("zone") (line ~1271) and tracker.snapBack("jam") (line ~1160). snapCause in ui/snap-back.js also returns "zone" and "jam", so one event lands in /precision twice and the scorecard's by-cause numbers inflate. Drop "zone" and "jam" from snapCause, leaving the causes only the page can see (STOP, reconnect, turn-end). Check that the server does not count those three itself, and add a test that fails if the page reports a cause the server also counts.
Also needed:
- The README (or its usage docs) says nothing about the refusal line on /live or POST /precision/snap-back. Only code header comments changed. Add a short usage note.
- The terminal door is missing. The driver's refusals reach web viewers, but src/tty.ts neither shows them nor offers anything equivalent. Say how a terminal user sees a refusal, or add it.
- precision.ts has a typo,
export type Kind ="error", and the line looks edited by accident. Restore it toKind =. - The viewer.html wiring (reportLost, streamRefused) has no test, and the pull says it was never tried in a browser. Cover reportLost with a test, or move its logic into a ui/ module that you can test.
What is fine: parseSnapBack is shared and validated at both the relay and the arm. On the preview, an anonymous POST to /precision/snap-back gets 401. The refusal text goes in through textContent and is bounded. Bodies are capped by readBody.
The page now reports only reconnect, so zone and jam are no longer counted twice. The new and changed tests (ui/snap-back.test.ts, ui/intent.test.ts, terminal.test.ts, page-feedback.test.ts) pass. I did not re-run the wider suites, and I still haven't tried the page in a browser.
Double counting. I went further than you asked. The arm server counts STOP and turn-end too: stopCause.set(client, "STOP" | "turn-end") feeds tracker.snapBack at server.ts ~1365, whenever a stream is open. So the page would have double-counted those as well. snapCause in ui/snap-back.js now returns reconnect or null.
New test in ui/snap-back.test.ts: it scans server.ts for every cause the server counts, via snapBack("…") and stopCause.set. It fails if the page can return any of them. It also asserts the scan still finds jam, zone, STOP and turn-end, so a refactor can't empty it silently.
Your other points
- README:
Software/README.mdhas a short paragraph in the Precision section. It covers therefusedpush, the line on the page,POST /precision/snap-backwith its 400s, and why onlyreconnectis reported. I also replaced the stale "#457 is still to come" sentence. - Terminal:
hear()insrc/terminal.tsnow handlesrefusedand printsblocked: <line>as plain text. A run of the same line prints once, so a stream of identical refusals doesn't flood it. This is tested interminal.test.ts. - Typo:
Kind = "error"is restored inprecision.ts. - Page logic:
reportLostnow lives inui/snap-back.js.viewer.htmlkeeps a thin wrapper that calls it. The test drains anIntentagainst a status, postsreconnectwith the right sizes only when reconnecting, and posts each once.streamRefusedis just theclampNotecall plustextContent, andclampNotehas its own tests.
Intent.lost is now capped at 50 entries, since a non-relayed page never drains it.
Approved. Refusals reach the driver (/live push, tellDriver, terminal line as plain text, escaped), POST /precision/snap-back is validated at relay and arm (400s) and sits behind the relay mutation gate (preview answers 401 to an anonymous POST). Tests cover relay+arm end to end and the ui modules. Two things next: (1) viewer.html wiring (streamRefused, reportLost wrapper) has no test; add a page-parse test so a refactor cannot unplug it. (2) The refusal line is a plain text node; give it role=status/aria-live=polite so screen-reader users hear a blocked move, and check it wraps at 360px.
Refusals now reach the driver's page on
/live, and the page reports its own snap-backs to/precision. The type check shows no errors in the files I touched (it already had errors elsewhere), and 302 tests across the relay, lobby, arm-server, machine-feed, stop, page-parse andui/suites pass. I did not run the wholebun testsuite, andscripts/design-lint.tsdoesn't exist in this checkout, so it wasn't run. I haven't tried the page in a browser. The page wiring inviewer.html, including the snap-back reporting, has no test of its own. Tests cover the relay, the arm server and the pureui/modules.Refusals
clampentry, its own and the arm server's, to the driver as one short line per batch. In a local run, with no turns, it goes to every page.src/refusals.tsbuilds the line, andLobby.tellDriversends it.textContentthroughclampNoteinui/refusal.js. It adds a running count ("N so far") and caps the line at 160 characters.refusals_shown.Snap-backs
POST /precision/snap-backtakes{cause, sizeDeg}. The relay checks it, then passes it to the same route on the arm server. Only the driver can call it; an anonymous caller gets 401. A cause not inCAUSES, or a bad size, gets 400 at both the relay and the arm.parseSnapBackinsrc/precision.tsdoes the checking and is shared by both. The arm adds the snap-back to the current session, or to the rolling window alone when no session is running, as with a reconnect.Intentnow keeps the targets it dropped without the arm reaching them, either by timeout or byclear().ui/snap-back.jsgives each a cause from what the page knows, in this order: stop, reconnecting, turn ended, zone block, jam. The size is the distance in degrees, and the report goes to the relay.Tests
src/page-feedback.test.tsstarts a real arm server and relay. It checks that a refused frame shows its reason on/live, that each cause inCAUSESis counted once on the arm's/precision, and that bad causes and sizes get 400 at both ends.ui/snap-back.test.tscovers cause selection, sizes, and the intent's lost targets.Closes #457