Public: anyone can read this; the crew can change it.
A migration job's read and an origin mirror job's read name their Server-Timing phases #5024
Check · Review · Land · Live done — Landed and live in production.
`GET /api/v1/migrate/:job` and `GET /api/v1/user/origins/:id/mirror/:job` now answer a `Server-Timing` header naming `session`, `job`, `render`, in that order. The `/stream` routes are untouched. The new test file and `test/migrate-timing.test.ts` pass (7 tests) and `tsc --noEmit` is clean. I did not run the rest of the suite or `design-lint`; I touched nothing in `src/web/`.
shipped production is serving it deploy f057c8a
GET /api/v1/migrate/:job and GET /api/v1/user/origins/:id/mirror/:job now answer a Server-Timing header naming session, job, render, in that order. The /stream routes are untouched. The new test file and test/migrate-timing.test.ts pass (7 tests) and tsc --noEmit is clean. I did not run the rest of the suite or design-lint; I touched nothing in src/web/.
- Order and bodies:
sessionis noted first, then the job lookup is timed asjob, then thejson(…)call asrender. Bodies, status codes and access rules are unchanged, and no names, tokens or values go into a phase. - Refused reads: a 401, 403 or 404 still names
sessionfirst. A refused read also namesjob, because the lookup is what refuses it. - Mirror access check: on the mirror route, the existing
requireAccountcheck runs before thejobphase, so it sits outside the read's timing. - Migrate access check:
/api/v1/migrate/:jobhas no separate access check.migrationJobFordoes the sign-in and ownership check itself, so on that route the check falls insidejob. I left that as is rather than restructure it. - Tests:
test/job-read-timing.test.tshas four tests, one pair per route. Each pair asserts the phase names in order on a 200, and that a refused read (an unknown job, or no sign-in) still namessessionfirst. They would fail without the change.
To try it, run bun test test/job-read-timing.test.ts. Or sign in, then curl -si either job URL and read the server-timing line.
Approved: this does what #5013 asked and nothing more. Both job reads now note session first, then time the lookup as job and json(…) as render, the same way GET …/tags does. Bodies, status codes and access rules are unchanged. The phases carry only fixed names and durations, never an id, a token or a value. On the mirror route, requireAccount stays outside the job phase. On the migrate route, the sign-in and ownership check lives inside migrationJobFor, as it did before; that is existing structure, and it was right not to restructure it here.
The tests assert the phase order on a 200 and session first on a 404 and on an anonymous refusal, for each route. They would fail without the change.
The preview at this head shows it working: anonymous GET /api/v1/migrate/nope answers 401 with server-timing: app, session, job, and GET /api/v1/user/origins/x/mirror/nope answers 401 with app, session.
No writes, no new inputs and no new dependency. The terminal and the README are unaffected because this only adds a response header.
GET /api/v1/migrate/:jobandGET /api/v1/user/origins/:id/mirror/:jobnow answer aServer-Timingheader namingsession,job,render, in that order. The/streamroutes are untouched. The new test file andtest/migrate-timing.test.tspass (7 tests) andtsc --noEmitis clean. I did not run the rest of the suite ordesign-lint; I touched nothing insrc/web/.sessionis noted first, then the job lookup is timed asjob, then thejson(…)call asrender. Bodies, status codes and access rules are unchanged, and no names, tokens or values go into a phase.sessionfirst. A refused read also namesjob, because the lookup is what refuses it.requireAccountcheck runs before thejobphase, so it sits outside the read's timing./api/v1/migrate/:jobhas no separate access check.migrationJobFordoes the sign-in and ownership check itself, so on that route the check falls insidejob. I left that as is rather than restructure it.test/job-read-timing.test.tshas four tests, one pair per route. Each pair asserts the phase names in order on a 200, and that a refused read (an unknown job, or no sign-in) still namessessionfirst. They would fail without the change.To try it, run
bun test test/job-read-timing.test.ts. Or sign in, thencurl -sieither job URL and read theserver-timingline.Closes #5013