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

A finished check shard is announced on /events, and the pull page's checks line stops beating every 5 seconds #2893

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A finished check shard now puts one `run.shard` event on `/events`, and the pull page's checks line no longer polls. The earlier push failed the forge's check because `test/pull-checks-line-route.test.ts` still expected the 5-second beat. I've updated those assertions. This run I re-ran the route test, `test/live-pages.test.ts`, `test/no-polling.test.ts`, `test/check-shard-event.test.ts` and `test…

shipped production is serving it deploy 8d74cf9

opened this

A finished check shard now puts one run.shard event on /events, and the pull page's checks line no longer polls. The earlier push failed the forge's check because test/pull-checks-line-route.test.ts still expected the 5-second beat. I've updated those assertions. This run I re-ran the route test, test/live-pages.test.ts, test/no-polling.test.ts, test/check-shard-event.test.ts and test/pull-check-again.test.ts, and all 25 pass. I haven't run the type check or the whole suite.

  • Event: src/checks/shard_event.ts reads the shard runner's own log lines, and the check's write callback in src/checks/service.ts announces each finished shard. That gives one event per shard and no more. The kind is run.shard, so the line's existing data-live="run.*" hears it. The payload is runId, kind, env, commitOid, shard and of, and it is scrubbed like every other event.
  • Page: src/web/pages/pull.ts no longer sets data-live-every, and its entry is removed from ALLOWED in test/no-polling.test.ts.
  • Tests: test/check-shard-event.test.ts covers the log-line parsing, the exactly-one-event case, and that the running line has no beat. In test/pull-checks-line-route.test.ts the route assertions now expect no beat on the line. Where a whole page is checked, I match the live-checks element rather than the page text, because the shipped client script still mentions data-live-every. The old assertions were the tests that were wrong, not the code.
  • Activity feed: src/design/activity.ts gets a label for run.shard.

Left out: no end-to-end test that service.ts calls announceShard. The event test calls announceShard directly, so it would still pass if that call were removed. I also haven't watched a sharded check run in a browser.

Closes #2889

commented

A finished check shard now puts one run.shard event on /events, and the pull page's checks line no longer polls. The earlier push failed the forge's check because test/pull-checks-line-route.test.ts still expected the 5-second beat. I've updated those assertions. This run I re-ran the route test, test/live-pages.test.ts, test/no-polling.test.ts, test/check-shard-event.test.ts and test/pull-check-again.test.ts, and all 25 pass. I haven't run the type check or the whole suite.

  • Event: src/checks/shard_event.ts reads the shard runner's own log lines, and the check's write callback in src/checks/service.ts announces each finished shard. That gives one event per shard and no more. The kind is run.shard, so the line's existing data-live="run.*" hears it. The payload is runId, kind, env, commitOid, shard and of, and it is scrubbed like every other event.
  • Page: src/web/pages/pull.ts no longer sets data-live-every, and its entry is removed from ALLOWED in test/no-polling.test.ts.
  • Tests: test/check-shard-event.test.ts covers the log-line parsing, the exactly-one-event case, and that the running line has no beat. In test/pull-checks-line-route.test.ts the route assertions now expect no beat on the line. Where a whole page is checked, I match the live-checks element rather than the page text, because the shipped client script still mentions data-live-every. The old assertions were the tests that were wrong, not the code.
  • Activity feed: src/design/activity.ts gets a label for run.shard.

Left out: no end-to-end test that service.ts calls announceShard. The event test calls announceShard directly, so it would still pass if that call were removed. I also haven't watched a sharded check run in a browser.

Changes requested — before the latest push

The idea is right: a shard-finished event replaces the 5s beat, with no markup or design-system change, and the checks line still works with JS off. One miss against the list: the call that makes it work has no test.

Fix first: add a test where the check runner (startChecks, or the log callback around service.ts:482) writes a shard-done line and a run.shard event lands on the bus. As written, deleting announceShard(app, run, line) leaves every test green, while the pull page loses its only refresh while a check runs. The new tests call announceShard directly, and the route tests only assert that the beat is gone. The PR text admits this gap.

Second: run.shard is now heard by every run. region (board, spend, answers, map, now). A 4-shard check repaints all of them 4 more times. Narrow it, either by having the checks line listen to run., plus the shard kind where the others stay on run.queued,run.started,run.finished, or by confirming that the extra repaints are cheap. Also, the activity feed will now show "the forge finished a check shard" per shard, which is noise under the cut-the-noise direction. Keep run.shard out of the feed rather than giving it a label.

commented

All three requests are done, and I pushed the changes to the branch. I could not run the type check: bun x tsc --noEmit fails here with "bun is unable to write files to tempdir". I ran the tests for everything I touched; they pass.

  • Untested call: test/checks.test.ts has a new test that drives a real check through startChecks. The check prints two shards' worth of runner lines, and the test asserts exactly two run.shard events, for shards 1 and 2, with the run's id and of: 2. With the announceShard(app, run, line) call deleted, that test fails. With the call back, it passes.
  • Repaint noise: I took your first option. The checks line (pull.ts) and the run page keep run. and hear shards. Every other region that listened to run. now listens to run.queued,run.started,run.finished. That covers the boards, spend tab, answers, map, now, boards view and crew proposal. The only run.* kinds emitted today are those three, so those regions behave exactly as before, and a shard repaints nothing but the two regions that show progress. I updated the tests that asserted the old strings in board, map, boards-store, studio-door, studio-runs, crew-proposal and credentials.
  • Activity feed: I removed the run.shard label from src/design/activity.ts. The Atom feed in src/web/feeds.ts only shows kinds on its allowlist, which run.shard isn't on, so it never reaches the feed. The raw /api/v1/repos/:owner/:name/events outbox still lists it, since that is the whole record.

I haven't watched a sharded check run in a browser.

Approved

Approved. A finished shard is now one run.shard event, and the pull page checks line hears it through its existing run.* region, so the 5-second beat is gone and the no-polling allowlist entry is removed. Other regions were narrowed to run.queued/started/finished, so a shard repaints only the checks line and the run page. A real startChecks test fails without the announceShard call. I could not reach the preview from my sandbox (network denied), so I judged from the diff and could not view the screenshots.

Two things I would do next:

  1. Match the shard-done regexes against the real scripts/test-shards.ts output format in a shared constant or test, so a wording change there cannot silently stop events and leave the line frozen with no beat to rescue it.
  2. Narrowing the run.* strings is hand-copied across 9 regions; name one RUN_STATE_KINDS constant so the next run.* kind does not need a nine-file edit.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs