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

The fleet and forge-size reads name their Server-Timing phases: graph, ops, one op, sizes #4992

Merged opened this

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

Merged

`GET /api/v1/fleet/graph`, `/fleet/ops`, `/fleet/ops/:id` and `/forges/sizes` now answer a `Server-Timing` header with their own phases. The tests for the four routes and the type check pass. I didn't run design-lint (no `src/web/` change) or the whole `bun test`, because the forge runs the whole check on this push.

shipped production is serving it deploy a9fc969

opened this

GET /api/v1/fleet/graph, /fleet/ops, /fleet/ops/:id and /forges/sizes now answer a Server-Timing header with their own phases. The tests for the four routes and the type check pass. I didn't run design-lint (no src/web/ change) or the whole bun test, because the forge runs the whole check on this push.

  • Phases: each route notes session, then the read, then render, the way …/tags does. The read phases are graph, ops, op and sizes. Bodies, status codes and access rules are unchanged.
  • Refused reads: session is noted before the auth check, so a 401, 403 or 404 still names it. The access check stays outside the read phase.
  • Sizes: the 304 (ETag match) path sits inside render.
  • Tests: test/fleet-timing.test.ts has one test per route asserting the phase names in order. The one-op test uses a missing id and asserts only the first two phases (session, op), because that read is refused and never reaches render. They fail without the change.
  • Test detail: the server prepends an app phase to every response. The helper in the new test ignores it, so the assertions cover only the route's own phases.
  • Left out: /fleet/ops still has no test for its refused (401) path.

The change is in src/http/api.ts.

Closes #4982

Approved

Clean, and does what #4982 asked. The four reads note session first, then time the read (graph, ops, op, sizes) and render with the same notePhase/timePhase pattern as …/tags. The auth check and fleetSelection stay outside the read phase, and bodies, status codes and access rules are unchanged. The 304 path on sizes keeps its ETag and cache headers.

On the preview at this head: /forges/sizes gives 200 with app, session, sizes, render; /fleet/graph and /fleet/ops as a guest give 401 with session; /fleet/ops/nope gives 404 with session, op. This is a timing header only, so nothing is added to authorization, input handling or the terminal, and there's nothing to mirror in src/tty.ts. The new tests assert the exact phase order per route and would fail without the change. The 401 path on /fleet/ops has no test, which the pull already says. That's minor and not blocking.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs