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

JSON for the home lanes, figures and slot graphs, with ETags #17923

opened this in answer to

Merged 25h 50m ago, live in production

Three read-only routes now give the home as JSON: /api/v1/home/lanes[?s=], /api/v1/home/strip and /api/v1/home/slots. The new and nearby tests pass, tsc is clean and the gate shows no failing rule. I did not run the full suite; the forge's check does that.

Notes

opened this

Three read-only routes now give the home as JSON: /api/v1/home/lanes[?s=], /api/v1/home/strip and /api/v1/home/slots. The new and nearby tests pass, tsc is clean and the gate shows no failing rule. I did not run the full suite; the forge's check does that.

What changed

  • Lanes: each lane carries key, tone, count, the health sentence, now and typical times in ms, and its tiles (key, state, kind, repo, number, issue, run, title, hint, since). run is set only in the three lanes whose tiles are runs.
  • ETag on lanes: the ETag is a header, taken from the same lane version the fragment uses. A repeat sending If-None-Match gets 304 before anything is built.
  • ?s=: a name that is not a lane is a 422 naming s. No account is a 401. A forge still reading its lanes is a 503 reading with Retry-After.
  • Strip and slots:
    • Strip: {figures, seriesStepMs, live}; shipped carries its series, landed per hour, oldest first.
    • Slots: per kind slots, busy, waiting, medianRunMs, medianWaitMs, waitEstimateMs, bucketMs and 96 buckets of {busy, waiting, full}.
    • Tagging and audience: both are tagged by their bytes. They are a forge admin's: an everyday account gets 403 and a client forge's owner gets 404, as the page draws nothing for them.
  • live: every answer lists the events that make that region due, taken from the page's own data-live strings. Slots use run.queued, run.started, run.finished; the page has no data-live for slots, so that list is mine.
  • openapi.json: all three routes are declared with full response schemas. A test checks real answers against them, which caught that the medians can be fractional, so those fields are number.
  • Terminal: the home's figures list now ends, for an admin, with one slots line per kind ("Checks: 2 of 4 slots busy · 1 waiting, oldest 3m"), sharing the page's words. The /api screen also runs the three GETs.
  • Gate waiver: the gate asked for a new terminal screen, so a commit line says No door: and why instead.
  • How-to: docs/features/home-json.md.

Reused: lanePicture, viewFor, laneTag, timesFor, healthOf, homeRow, readSlots, waitEstimate and the slotsWords text. I exported a few page constants and helpers (LANE_LIVE, STRIP_LIVE, RUN_LANES and others) and SLOT_STEP_MS; nothing was duplicated. The shaping is in src/flow/home_json.ts and the handlers are in src/http/home_json.ts. The routes are registered in src/http/home_api.ts, loaded lazily, with lazy_lists.ts and the route marks regenerated.

Left out

  • Lanes have no app= or waits=me filter; the issue asked only for s.
  • No Your games link or crew queue line in the lane JSON.
  • No new event-region route; live rides on each answer.
  • now in the lane JSON is read per request, but the ETag changes only with the lane picture and once a minute (as the page's does), so a 304 can show times up to a minute old.

Try it: on the preview, signed in as an admin, GET /api/v1/home/lanes and repeat it with If-None-Match set to the returned ETag for a 304. Then GET /api/v1/home/strip and /api/v1/home/slots. The tests are in test/home-json.test.ts.

🤖 Generated with Claude Code

Closes #17919

4 earlier comments
commented

Three read-only routes now give the home as JSON: /api/v1/home/lanes[?s=], /api/v1/home/strip and /api/v1/home/slots. The new and nearby tests pass, tsc is clean and the gate shows no failing rule. I did not run the full suite; the forge's check does that.

What changed

  • Lanes: each lane carries key, tone, count, the health sentence, now and typical times in ms, and its tiles (key, state, kind, repo, number, issue, run, title, hint, since). run is set only in the three lanes whose tiles are runs.
  • ETag on lanes: the ETag is a header, taken from the same lane version the fragment uses. A repeat sending If-None-Match gets 304 before anything is built.
  • ?s=: a name that is not a lane is a 422 naming s. No account is a 401. A forge still reading its lanes is a 503 reading with Retry-After.
  • Strip and slots:
    • Strip: {figures, seriesStepMs, live}; shipped carries its series, landed per hour, oldest first.
    • Slots: per kind slots, busy, waiting, medianRunMs, medianWaitMs, waitEstimateMs, bucketMs and 96 buckets of {busy, waiting, full}.
    • Tagging and audience: both are tagged by their bytes. They are a forge admin's: an everyday account gets 403 and a client forge's owner gets 404, as the page draws nothing for them.
  • live: every answer lists the events that make that region due, taken from the page's own data-live strings. Slots use run.queued, run.started, run.finished; the page has no data-live for slots, so that list is mine.
  • openapi.json: all three routes are declared with full response schemas. A test checks real answers against them, which caught that the medians can be fractional, so those fields are number.
  • Terminal: the home's figures list now ends, for an admin, with one slots line per kind ("Checks: 2 of 4 slots busy · 1 waiting, oldest 3m"), sharing the page's words. The /api screen also runs the three GETs.
  • Gate waiver: the gate asked for a new terminal screen, so a commit line says No door: and why instead.
  • How-to: docs/features/home-json.md.

Reused: lanePicture, viewFor, laneTag, timesFor, healthOf, homeRow, readSlots, waitEstimate and the slotsWords text. I exported a few page constants and helpers (LANE_LIVE, STRIP_LIVE, RUN_LANES and others) and SLOT_STEP_MS; nothing was duplicated. The shaping is in src/flow/home_json.ts and the handlers are in src/http/home_json.ts. The routes are registered in src/http/home_api.ts, loaded lazily, with lazy_lists.ts and the route marks regenerated.

Left out

  • Lanes have no app= or waits=me filter; the issue asked only for s.
  • No Your games link or crew queue line in the lane JSON.
  • No new event-region route; live rides on each answer.
  • now in the lane JSON is read per request, but the ETag changes only with the lane picture and once a minute (as the page's does), so a 304 can show times up to a minute old.

Try it: on the preview, signed in as an admin, GET /api/v1/home/lanes and repeat it with If-None-Match set to the returned ETag for a 304. Then GET /api/v1/home/strip and /api/v1/home/slots. The tests are in test/home-json.test.ts.

🤖 Generated with Claude Code

commented

The check failed because test/openapi.test.ts reads a fixed list of route files, and the new src/http/home_api.ts wasn't on it. The test was wrong, not the route, so I added the file to the list. test/openapi.test.ts and test/openapi-drift.test.ts pass (37 tests) and the fix is pushed. I did not rerun the full suite.

The pull is otherwise as described before. /api/v1/home/lanes[?s=], /strip and /slots give the home as JSON.

  • Lanes: each lane has its tone, count, health sentence, times and tiles. The ETag comes back as a header and a repeat sending it gets 304.
  • Strip and slots: admin-only, with the strip's series and the slots' 24-hour buckets.
  • live: each answer lists the events that make it due.
  • Terminal: the home prints one slots line per kind.
  • Left out: app= and waits=me filters, and a separate events route.

Try it: on the preview, signed in as an admin, GET /api/v1/home/lanes. Repeat it with If-None-Match set to the returned ETag for a 304. Then GET /api/v1/home/strip and /api/v1/home/slots.

🤖 Generated with Claude Code

commented

The failing check is fixed and pushed. I ran test/contract-openapi-tags.test.ts and test/openapi.test.ts (37 pass) and bun x tsc --noEmit (clean). I did not re-run the full suite; the forge runs it on this push.

The new /api/v1/home/* routes (lanes, slots, strip) produced a home tag that TAG_WORDS has no line for. The test requires a line for every tag the document lists, so it failed. I added home: "meta" to the path-to-tag aliases in src/contract/tags.ts, so these routes sit under meta, next to here and health. I chose an alias over a new home tag to avoid adding a tag to the document for three routes.

bun scripts/gate.ts --fix rewrapped nothing. It left two notes: two files have comment lines over 100 columns, which the nightly rewrap handles on main, and home_api.ts#homeApiRoutes is flagged as identical to forges_routes.ts#forgesRoutes. I did not act on either.

commented

This round covers all five of sentinel's points. tsc, the gate, the unused-exports, feature-doors and route-marks rules and the home tests all pass locally.

  • Terminal door (1): test/home-json.test.ts now renders dashboardScreen for each reader. An admin's screen has the Checks: and Crew runs: lines. A non-admin's has neither, and neither does a client forge's owner's (built with claimedForge). The old test that called slotLines directly and had the loose regex is gone.
  • ETag (2): the test now moves a card (a run finishes, a check starts, the bus is told). It then asserts that the old If-None-Match gets 200 with a different tag and the six lanes.
  • Docs (3): I reworded the how-to to say /api lists the three routes from the OpenAPI document. The diff changes nothing in src/tui/, so I had no test to show for the original claim.
  • Agent admin tag (4): the lanes tag is now keyed on the same wide flag that timesFor gets. An agent admin's tag is keyed on <id>|admin, so it differs from a human admin's. I did not add a test for this one.
  • Clean-ups (5):
    • slotLines moved to src/tui/slot_lines.ts, and NAME and slotsWords are now exported from src/web/flow_slots.ts so both doors share the same words.
    • stripData uses HOUR_MS, now exported from src/flow/kpis.ts.
    • answer(ctx, etag, data) now handles the 304 for all three routes, and the lane body is only shaped when the tag doesn't match.

The commit says No door: <why>, because only tests, docs and a moved helper changed, and the terminal line already existed.

The gate's duplicate-implementation note for homeApiRoutes against forgesRoutes is advisory, so I left it.

[{"go":"/api/v1/home/lanes","look":"response headers","expect":"an ETag; repeating the request with it as If-None-Match gets 304"},{"go":"/api/v1/home/slots","look":"as a non-admin","expect":"403"},{"go":"ssh terminal home as an admin","look":"the end of the figures list","expect":"Checks: and Crew runs: lines"}]
commented

The check failed on a duplicate import in test/home-json.test.ts: ../src/core/users.ts was imported twice, on lines 13 and 19. I merged the two into one import on line 13 and pushed.

tsc, test/dup-imports.test.ts and test/home-json.test.ts pass locally. I did not re-run the rest of the suite, since nothing else changed.

The pull is otherwise as described in my previous message:

  • The terminal door is tested for admin, non-admin and client-forge owner.
  • The lanes ETag test now moves a card and checks the tag changes.
  • The lanes tag is keyed on wide.
  • slotLines moved to src/tui/slot_lines.ts.
  • stripData reuses HOUR_MS instead of its own hour constant.
  • The three routes share one 304 helper.
  • The how-to now says /api lists the three routes from the OpenAPI document.
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs