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

GET a repository's milestones answers under 50 ms: trevato/forge's `read` phase is 1,365 ms today #16735

Merged opened this

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

Merged

GET /api/v1/repos/:owner/:name/milestones now builds its answer from the same kept plan the milestones page uses, instead of rebuilding the plan on every request. In the new test, read stays under 50 ms on a 2,300-issue fixture, cold and warm.

Notes

opened this

GET /api/v1/repos/:owner/:name/milestones now builds its answer from the same kept plan the milestones page uses, instead of rebuilding the plan on every request. In the new test, read stays under 50 ms on a 2,300-issue fixture, cold and warm. I didn't time it against the old code, so I can't say whether the new test would have failed before this change. The 1,365 ms figure on trevato/forge is not re-measured here.

  • Which fix: the shared plan, not a batched read. milestonesJson in src/web/pages/milestones.ts now calls planFor, the cached plan the page already builds. It is also the function behind the MCP milestones tool, so that tool gets the same speed-up. I didn't wait for #6182 or build a second plan.
  • Server-Timing: read now comes with its stretches listed before it: plan-graph, plan-crew, plan-week, plan-spend, plan-limbs, read-ask and read-waves. The plan-* stretches appear only on a cold plan.
  • Test of the answer: test/api-milestones-speed.test.ts uses the 10-pillar fixture and checks the items against a fresh, uncached readPlan run through limbJson. It checks that each limb's own fields (via limbJson) match. It doesn't compare the ask-to-live or last-wave fields, which come from separate code that I didn't change.
  • Test of the speed: the same file seeds 2,000 closed and 300 open issues across the 10 pillars. It asserts read under 50 ms, cold and warm, and that the stretches are named.
  • One existing test changed: test/api-milestones-timing.test.ts expected exactly session, read, render. It was right for the old route and wrong for this change, so it now ignores the new stretch names and checks that read-ask is present.

I ran the milestones tests and tsc --noEmit, and both pass. The gate output wasn't checked. The first push was refused by a pre-push hook that asks for a "Try:" commit, so I added an empty commit carrying it.

I didn't touch the MCP tool or the page.

To try it: curl -si .../api/v1/repos/trevato/forge/milestones | grep -i server-timing.

🤖 Generated with Claude Code

Closes #6199

3 earlier comments
commented

GET /api/v1/repos/:owner/:name/milestones now builds its answer from the same kept plan the milestones page uses, instead of rebuilding the plan on every request. In the new test, read stays under 50 ms on a 2,300-issue fixture, cold and warm. I didn't time it against the old code, so I can't say whether the new test would have failed before this change. The 1,365 ms figure on trevato/forge is not re-measured here.

  • Which fix: the shared plan, not a batched read. milestonesJson in src/web/pages/milestones.ts now calls planFor, the cached plan the page already builds. It is also the function behind the MCP milestones tool, so that tool gets the same speed-up. I didn't wait for #6182 or build a second plan.
  • Server-Timing: read now comes with its stretches listed before it: plan-graph, plan-crew, plan-week, plan-spend, plan-limbs, read-ask and read-waves. The plan-* stretches appear only on a cold plan.
  • Test of the answer: test/api-milestones-speed.test.ts uses the 10-pillar fixture and checks the items against a fresh, uncached readPlan run through limbJson. It checks that each limb's own fields (via limbJson) match. It doesn't compare the ask-to-live or last-wave fields, which come from separate code that I didn't change.
  • Test of the speed: the same file seeds 2,000 closed and 300 open issues across the 10 pillars. It asserts read under 50 ms, cold and warm, and that the stretches are named.
  • One existing test changed: test/api-milestones-timing.test.ts expected exactly session, read, render. It was right for the old route and wrong for this change, so it now ignores the new stretch names and checks that read-ask is present.

I ran the milestones tests and tsc --noEmit, and both pass. The gate output wasn't checked. The first push was refused by a pre-push hook that asks for a "Try:" commit, so I added an empty commit carrying it.

I didn't touch the MCP tool or the page.

To try it: curl -si .../api/v1/repos/trevato/forge/milestones | grep -i server-timing.

🤖 Generated with Claude Code

commented

<!-- look-pages bd2122bb6c5a --> Look pages for bd2122b, from the gate:

  • look pages (inferred): this pull changes src/web/pages/milestones.ts; the forge pictures / (src/web/pages/milestones.ts), /docs (src/web/pages/milestones.ts), /explore (src/web/pages/milestones.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

GET /api/v1/repos/:owner/:name/milestones now builds its answer from the same kept plan the milestones page uses, instead of rebuilding the plan on every request. The 50 ms read bound is asserted only on the 2,300-issue fixture. I never timed the old code, so I can't say whether the new test would have failed before. The 1,365 ms from the issue is not re-measured.

I used the shared plan, not a batched read. milestonesJson in src/web/pages/milestones.ts now calls planFor, the cached plan the page already builds. The MCP milestones tool calls the same function, so it gets the same speed-up. I didn't wait for #6182 or build a second plan.

read now lists its stretches in Server-Timing: plan-graph, plan-crew, plan-week, plan-spend, plan-limbs, read-ask and read-waves. The plan-* ones appear only when the plan is built cold.

test/api-milestones-speed.test.ts has two tests, on a fixture of 10 pillars with 2,000 closed and 300 open issues:

  • Same answer: each of the 10 limbs matches a fresh, uncached readPlan run through limbJson. It doesn't compare the ask-to-live or last-wave fields, which come from code I didn't change.
  • Under 50 ms: read stays under 50 ms cold and warm, and the named stretches are present.

I also changed test/api-milestones-timing.test.ts. It expected exactly session, read, render, which was right for the old route. It now ignores the new stretch names and checks that read-ask appears.

The check's gate refused the first push for two reasons, both fixed:

  • as never cast: the speed test cast its user. It now passes the real user record.
  • Both doors: the commit message now carries No door: and No look: lines. The edit changes only how the JSON route and the MCP tool read the plan, and the page and terminal show what they showed before.

I re-ran tsc --noEmit and the speed test locally and both pass. scripts/gate.ts --fix still shows the two refusals locally, because they read the commit message that was written afterwards. The 100-column comment note it also prints is not something I touched. I haven't seen the forge's check pass on this push yet.

To try it: curl -si .../api/v1/repos/trevato/forge/milestones | grep -i server-timing.

🤖 Generated with Claude Code

commented

Both review points are fixed in test/api-milestones-speed.test.ts, and the file now passes. bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. I did not re-measure the 1,365 ms figure, and I could not check the real Server-Timing on trevato/forge, because the preview has no such repository.

  • Answer unchanged (box 2): the test now builds the expected items the old way and compares them whole with toEqual. That means a fresh readPlan plus the same pillarView/askToLiveFor and lastWaves calls the route makes. So askToLive and lastWave are compared along with the limbJson fields, over the 10-limb, 2,300-issue fixture. The fixture has no waves, so lastWave is absent from every item; that equality is only checked as absence. askToLive is asserted present on every item.
  • Flaky timing bound: the cold read still has to name the plan-graph, read-ask and read-waves stretches. Its bound is now under 1000 ms, which still catches a return to the old 1.4 s without going red on a busy runner. The warm read keeps the strict 50 ms bound, taken as the best of three reads.

The gate also notes one comment line over 100 columns in src/web/pages/milestones.ts. I left it, since it asks for nothing and the nightly rewrap wraps it on main.

No page markup changed, so there is no review block.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs