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

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

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.

Notes

shipped merged

opened this

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 clamp entry, 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.ts builds the line, and Lobby.tellDriver sends it.
  • The page shows the line with textContent through clampNote in ui/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-back takes {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 in CAUSES, or a bad size, gets 400 at both the relay and the arm.
  • parseSnapBack in src/precision.ts does 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, Intent now keeps the targets it dropped without the arm reaching them, either by timeout or by clear(). ui/snap-back.js gives 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.ts starts a real arm server and relay. It checks that a refused frame shows its reason on /live, that each cause in CAUSES is counted once on the arm's /precision, and that bad causes and sizes get 400 at both ends.
  • ui/snap-back.test.ts covers cause selection, sizes, and the intent's lost targets.

Closes #457

1 earlier comment · 1 event
commented

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 clamp entry, 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.ts builds the line, and Lobby.tellDriver sends it.
  • The page shows the line with textContent through clampNote in ui/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-back takes {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 in CAUSES, or a bad size, gets 400 at both the relay and the arm.
  • parseSnapBack in src/precision.ts does 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, Intent now keeps the targets it dropped without the arm reaching them, either by timeout or by clear(). ui/snap-back.js gives 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.ts starts a real arm server and relay. It checks that a refused frame shows its reason on /live, that each cause in CAUSES is counted once on the arm's /precision, and that bad causes and sizes get 400 at both ends.
  • ui/snap-back.test.ts covers cause selection, sizes, and the intent's lost targets.
Changes requested — before the latest push

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:

  1. 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.
  2. 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.
  3. precision.ts has a typo, export type Kind ="error", and the line looks edited by accident. Restore it to Kind = .
  4. 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.

commented

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

  1. README: Software/README.md has a short paragraph in the Precision section. It covers the refused push, the line on the page, POST /precision/snap-back with its 400s, and why only reconnect is reported. I also replaced the stale "#457 is still to come" sentence.
  2. Terminal: hear() in src/terminal.ts now handles refused and prints blocked: <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 in terminal.test.ts.
  3. Typo: Kind = "error" is restored in precision.ts.
  4. Page logic: reportLost now lives in ui/snap-back.js. viewer.html keeps a thin wrapper that calls it. The test drains an Intent against a status, posts reconnect with the right sizes only when reconnecting, and posts each once. streamRefused is just the clampNote call plus textContent, and clampNote has its own tests.

Intent.lost is now capped at 50 entries, since a non-relayed page never drains it.

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs