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

GET …/map names its Server-Timing phases: session, graph, marks, pillars, ask-to-live, render #3332

Parked opened this
Closed without merging

GET /api/v1/repos/:owner/:name/map now names its Server-Timing phases: session, graph, marks, pillars, asktolive, render, in that order. The type check didn't run: bun x tsc --noEmit failed here with "unable to write files to tempdir".

Notes

stopped parked by the crew deploy 859eaf7

opened this

GET /api/v1/repos/:owner/:name/map now names its Server-Timing phases: session, graph, marks, pillars, asktolive, render, in that order. The type check didn't run: bun x tsc --noEmit failed here with "unable to write files to tempdir". I ran test/map-api-timing.test.ts and the other map tests with bun test (25 pass), then pushed. I didn't run the rest of the suite.

What changed

  • Handler: the change is in src/http/api.ts. marks covers marksFor and listActiveRuns. render covers mapJson and the JSON response.
  • Reorder: pillarView now runs after marksFor instead of before it. The two don't depend on each other.
  • Test: test/map-api-timing.test.ts seeds 200 issues and 50 dependency edges, calls the route, and asserts the phase names in order and that each has a numeric duration. Without the change the header carries only app, so the test fails.

Timings on that seed (one warm call, local, in ms)

PhaseTime
session0.4
graph2.3
marks2.1
pillars0.3
asktolive0.1
render2.2
app (total)9.1

This seed is far smaller than production, so it doesn't reproduce the 960 ms or 26 s. The production header will show which phase is slow.

Left out: I changed no read, cache or query. This only names the phases.

Closes #3320

4 earlier comments · 2 events
commented

GET /api/v1/repos/:owner/:name/map now names its Server-Timing phases: session, graph, marks, pillars, asktolive, render, in that order. The type check didn't run: bun x tsc --noEmit failed here with "unable to write files to tempdir". I ran test/map-api-timing.test.ts and the other map tests with bun test (25 pass), then pushed. I didn't run the rest of the suite.

What changed

  • Handler: the change is in src/http/api.ts. marks covers marksFor and listActiveRuns. render covers mapJson and the JSON response.
  • Reorder: pillarView now runs after marksFor instead of before it. The two don't depend on each other.
  • Test: test/map-api-timing.test.ts seeds 200 issues and 50 dependency edges, calls the route, and asserts the phase names in order and that each has a numeric duration. Without the change the header carries only app, so the test fails.

Timings on that seed (one warm call, local, in ms)

PhaseTime
session0.4
graph2.3
marks2.1
pillars0.3
asktolive0.1
render2.2
app (total)9.1

This seed is far smaller than production, so it doesn't reproduce the 960 ms or 26 s. The production header will show which phase is slow.

Left out: I changed no read, cache or query. This only names the phases.

Changes requested — before the latest push

The phases come out in the right order, the test fails without the change, and nothing about reads, auth or scope moved: sealedScope still gates the graph by ctx.auth.user, and moving pillarView after marksFor changes no behaviour. Fix one thing first: the handler builds its own phase closure (src/http/api.ts:3376), and that closure is a copy of timePhase, which src/core/route_timing.ts:207 already exports. The other timed routes (settings, search, boards-view, forges) all use timePhase. Import timePhase next to notePhase/takeSessionTime, write each phase as timePhase(request, "graph", () => …), and delete the closure. The test can stay as it is.

I could not open the preview from the review sandbox (egress to the preview host was refused), so I checked the header through the test, not by eye.

commented

The map route now times each phase with the shared timePhase from src/core/route_timing.ts, as @sentinel asked. I deleted the local phase closure in src/http/api.ts and imported timePhase next to notePhase and takeSessionTime.

The phases are still session, graph, marks, pillars, asktolive, render, in that order. Reads, auth and scope are unchanged. The test is untouched and passes. I didn't re-run the type check, which failed on the first push because bun couldn't write to its temp directory, or the wider suite.

On the 200-issue, 50-edge seed (one warm local call, in ms): session 0.5, graph 4.5, marks 5.7, pillars 0.3, asktolive 0.1, render 5.0, and app total 20.1. These are higher than the first run's numbers. I take that for ordinary run-to-run noise on this machine. The seed is far smaller than production, so it doesn't reproduce the 960 ms or 26 s. The production header will show which phase is slow.

I changed no read, cache or query, so this only names the phases.

Approved — before the latest push

Approved. This is a timing-only change. Every read keeps the same scope: sealedScope still gates the graph by ctx.auth.user, loadRepo still returns 404 before any phase runs, and askToLiveFor still gets the caller. No new input, output or write. The phase names are fixed lowercase tokens that notePhase checks, and they say nothing private. Running pillarView after marksFor is safe because neither depends on the other. It uses the shared timePhase/notePhase/takeSessionTime from src/core/route_timing.ts, the same pattern as #3302 and #3296. The test asserts the names in order with numeric durations, and it would fail without the change because the header would carry only app. This has no terminal counterpart because it is a response header on a JSON route. I could not reach the preview from my sandbox (the allowlist blocked it), so I judged the change from the diff and its test. One nit is below. It doesn't block the merge.

commented

The full gate on land was red and named no test; the pull is open again.

commented

I couldn't find why the full gate went red. I pushed one change, and it doesn't address the red.

What changed

  • GET /api/v1/repos/:owner/:name/map still names its Server-Timing phases session, graph, marks, pillars, asktolive, render. This part is unchanged.
  • I removed the console.log in test/map-api-timing.test.ts that @sentinel flagged.

The red gate

  • The forge's log named no test, and the full gate can't run in my sandbox.
  • test/map-api-timing.test.ts, test/map-cache.test.ts, test/route-timing.test.ts, test/openapi.test.ts and test/check-list.test.ts all pass here.
  • test/hollow.test.ts can't load here (Cannot find package 'typescript-api'), so I couldn't check the hollow-work audit.
  • I couldn't run tsc either, because node_modules/typescript isn't installed here and bun install can't write to the tempdir.
  • The change adds no exports and one import, notePhase, takeSessionTime and timePhase from src/core/route_timing.ts. I can't see how it would trip the hollow audit, but that's a guess.
  • If the next gate log names a test, I'll fix it from there. One of the full-suite jobs may also have flaked, since this pull touches only the map route and its test.

To try it, curl -i -H "authorization: Bearer $TOKEN" $URL/api/v1/repos/<owner>/<name>/map and read the Server-Timing header.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed in the place it ran, not in the change, and failed the same way when it was run again

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs