Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

A Data view to explore the arm: people, precision, latency and health, over time, on any screen #519

Parked opened this in answer to
Closed without merging

Adds the Data view at `/admin/data` for the owner and moderators. It's linked from `/admin` and from the Room card in the app's Admin tab. Behind it are a 90-day facts store and one read API, `GET /data`.

stopped parked by the crew deploy 74967da

opened this

Adds the Data view at /admin/data for the owner and moderators. It's linked from /admin and from the Room card in the app's Admin tab. Behind it are a 90-day facts store and one read API, GET /data.

What changed

  • src/facts.ts stores three tables in facts.sqlite under FORGE_APP_DATA, each row tagged with the app's commit:

- turns: one row per turn — who, start, length, why it ended, wait in line. When the arm answers /precision just after the turn, the row also gets releases, snap-backs by cause, jams, p95 arrive and tracking, and p50/p95 per hop and per joint. - events: visits, names set, joining the line, chat (counted, never the text), STOP, jams and zone blocks as they start (src/arm-edges.ts), link reconnects, app starts (deploy when the commit changed, otherwise restart) and the Pi's commit when it changes. - samples: once a minute — watchers, drivers, queue length, whether the arm link is live, and fps per camera. - "Who" is a user id or a 16-hex hash of an anonymous browser's id, never a name or address. precision-history now also exposes the last whole session with the time it ended.

  • src/data-series.ts cuts those rows into steps. How each number is made is written at the top of the file: sums are added before dividing; a step's p95 is the p95 of its turns' p95s, so one bad turn still shows; uptime is live minutes over minutes passed.
  • src/data-api.ts serves GET /data?from&to&step[&compare=1] and ?turn=<id>. Anonymous visitors and plain users get 403; bad parameters get a 400 that says what to send.
  • src/data-page.ts and src/ui/data-view.js are the page, with hand-drawn SVG and no new dependency:

- Controls: Hour, Day, Week or All; drag on any chart to zoom them all; "compare to the period before"; exact values on hover, tap or arrow keys; version marks on every time axis. - Content: the overview strip, the precision, latency, people and health charts, and a worst-sessions table that opens a session's detail. - Delivery: it's a page of its own, so nothing loads with the camera. The only style and script are inline, pinned by hash in a default-src 'none' CSP. - Layout: one column with swipeable cards on a phone in portrait, two columns in landscape and on a tablet, three on a desktop. Both colour schemes; motion only under prefers-reduced-motion: no-preference.

Tests

  • New: data-series.test.ts (the aggregation math), facts.test.ts (store, retention, card parsing, jam/block edges), data-api.test.ts (403 for anonymous and plain users, 200 for owner and moderator, 400s, CSP) and data-layout.test.ts.
  • The layout test reads the CSS at 390×844, 844×390, 820×1180 and 1440×900 rather than rendering it, because there is no browser here. It checks the column count, that nothing overflows, nothing is 0 px, and nothing is fixed over the camera.
  • The new suites and the related existing ones (relay, lobby, admin, precision history, page parsing, README) pass. The full check is the forge's run. Locally the app boots: /admin/data answered in 4 ms and /data in 6 ms.

Not done

  • Pi temperature and under-voltage: the arm server doesn't serve its health log yet. Split into #520.
  • A session's joint traces (intent against actual): the arm keeps only each session's summary. Split into #521.
  • #508 now waits on both.
  • There's no separate "Data" entry in the dock; the view is reached through the Admin tab and /admin.

To try it: open /admin/data as the owner on the preview. Drive a turn, press STOP, then choose Hour and drag across a chart.

🤖 Generated with Claude Code

Closes #508

commented

Adds the Data view at /admin/data for the owner and moderators. It's linked from /admin and from the Room card in the app's Admin tab. Behind it are a 90-day facts store and one read API, GET /data.

What changed

  • src/facts.ts stores three tables in facts.sqlite under FORGE_APP_DATA, each row tagged with the app's commit:

- turns: one row per turn — who, start, length, why it ended, wait in line. When the arm answers /precision just after the turn, the row also gets releases, snap-backs by cause, jams, p95 arrive and tracking, and p50/p95 per hop and per joint. - events: visits, names set, joining the line, chat (counted, never the text), STOP, jams and zone blocks as they start (src/arm-edges.ts), link reconnects, app starts (deploy when the commit changed, otherwise restart) and the Pi's commit when it changes. - samples: once a minute — watchers, drivers, queue length, whether the arm link is live, and fps per camera. - "Who" is a user id or a 16-hex hash of an anonymous browser's id, never a name or address. precision-history now also exposes the last whole session with the time it ended.

  • src/data-series.ts cuts those rows into steps. How each number is made is written at the top of the file: sums are added before dividing; a step's p95 is the p95 of its turns' p95s, so one bad turn still shows; uptime is live minutes over minutes passed.
  • src/data-api.ts serves GET /data?from&to&step[&compare=1] and ?turn=<id>. Anonymous visitors and plain users get 403; bad parameters get a 400 that says what to send.
  • src/data-page.ts and src/ui/data-view.js are the page, with hand-drawn SVG and no new dependency:

- Controls: Hour, Day, Week or All; drag on any chart to zoom them all; "compare to the period before"; exact values on hover, tap or arrow keys; version marks on every time axis. - Content: the overview strip, the precision, latency, people and health charts, and a worst-sessions table that opens a session's detail. - Delivery: it's a page of its own, so nothing loads with the camera. The only style and script are inline, pinned by hash in a default-src 'none' CSP. - Layout: one column with swipeable cards on a phone in portrait, two columns in landscape and on a tablet, three on a desktop. Both colour schemes; motion only under prefers-reduced-motion: no-preference.

Tests

  • New: data-series.test.ts (the aggregation math), facts.test.ts (store, retention, card parsing, jam/block edges), data-api.test.ts (403 for anonymous and plain users, 200 for owner and moderator, 400s, CSP) and data-layout.test.ts.
  • The layout test reads the CSS at 390×844, 844×390, 820×1180 and 1440×900 rather than rendering it, because there is no browser here. It checks the column count, that nothing overflows, nothing is 0 px, and nothing is fixed over the camera.
  • The new suites and the related existing ones (relay, lobby, admin, precision history, page parsing, README) pass. The full check is the forge's run. Locally the app boots: /admin/data answered in 4 ms and /data in 6 ms.

Not done

  • Pi temperature and under-voltage: the arm server doesn't serve its health log yet. Split into #520.
  • A session's joint traces (intent against actual): the arm keeps only each session's summary. Split into #521.
  • #508 now waits on both.
  • There's no separate "Data" entry in the dock; the view is reached through the Admin tab and /admin.

To try it: open /admin/data as the owner on the preview. Drive a turn, press STOP, then choose Hour and drag across a chart.

🤖 Generated with Claude Code

commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs