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

The milestones page reuses its plan until the repository changes, so a repeat visit does not read the graph again #3643

opened this

Merged 45d 19h ago, live in production

The milestones page now keeps its plan between requests, so a repeat visit no longer calls readPlan while the repository is unchanged. I could not run the type check here, so the forge's check will be its first run. bun x tsc --noEmit and bun install both failed with "bun is unable to write files to tempdir".

Notes

opened this

The milestones page now keeps its plan between requests, so a repeat visit no longer calls readPlan while the repository is unchanged. I could not run the type check here, so the forge's check will be its first run. bun x tsc --noEmit and bun install both failed with "bun is unable to write files to tempdir". The new test and the milestones, map-cache and snappy suites pass (27 tests).

  • Cache: cachedPlan in src/web/map_cache.ts holds the plan under the repository's latest event (repoHeads), whether the viewer may see spend, and the UTC day. It lives for LANE_TTL_MS (60 s) and is cleared by clearMapCache. milestonesPage in src/web/pages/milestones.ts goes through it.
  • Access: who may read the repository, the spend decision and the seats (moverFor) are still worked out on every request. Only the plan is cached.
  • Test: test/milestones-cache.test.ts visits the golden-seed page twice and checks that planBuildCount goes up once. Opening an issue makes the next visit rebuild the plan, and so does closing it.
  • Golden test: test/milestones-golden.test.ts is unchanged and passes.
  • Timing: I did not measure the plan phase before and after, so the Server-Timing comparison the issue asks for is missing.
  • Left out: the milestone detail page and the API/MCP readPlan calls still read the graph each time. The issue only names the listing page.

Closes #3429

commented

The milestones page now keeps its plan between requests, so a repeat visit no longer calls readPlan while the repository is unchanged. I could not run the type check here, so the forge's check will be its first run. bun x tsc --noEmit and bun install both failed with "bun is unable to write files to tempdir". The new test and the milestones, map-cache and snappy suites pass (27 tests).

  • Cache: cachedPlan in src/web/map_cache.ts holds the plan under the repository's latest event (repoHeads), whether the viewer may see spend, and the UTC day. It lives for LANE_TTL_MS (60 s) and is cleared by clearMapCache. milestonesPage in src/web/pages/milestones.ts goes through it.
  • Access: who may read the repository, the spend decision and the seats (moverFor) are still worked out on every request. Only the plan is cached.
  • Test: test/milestones-cache.test.ts visits the golden-seed page twice and checks that planBuildCount goes up once. Opening an issue makes the next visit rebuild the plan, and so does closing it.
  • Golden test: test/milestones-golden.test.ts is unchanged and passes.
  • Timing: I did not measure the plan phase before and after, so the Server-Timing comparison the issue asks for is missing.
  • Left out: the milestone detail page and the API/MCP readPlan calls still read the graph each time. The issue only names the listing page.
commented

The milestones page now keeps its plan between requests, and a run starting or finishing, a change in its cost, or a limb being moved each make the next visit rebuild it.

You were right that the repository's latest event is not enough. Runs, their cost_usd and limb_place rows write no event, so the first version could show old "building" marks and old spend for up to 60 s.

  • Key: cachedPlan in src/web/map_cache.ts is now keyed on writeStamp (src/core/write_clock.ts), plus the repository, whether the viewer may see spend, and the UTC day. It replaces the repository-head key. The write clock moves on any write to the database, whichever table it touches, so I did not have to hand-pick run and place columns. The comment in write_clock.ts already says limb_place writes name no repository in the outbox.
  • Transactions: inside a transaction there is no stamp, so the plan is built and not kept.
  • Cost of the coarser key: the stamp is forge-wide, so any write anywhere, including run heartbeats, makes the next visit rebuild. The cache is therefore most useful on a quiet forge. It is never stale, and I chose that over a finer key I could not be sure was complete.
  • Limb raise/lower: this is where I disagree with the review. limb_place rows do not bump the event head, which is why the key had to change. Moving a limb is a write to the database, so the new key covers it. I checked that with a savePlaces call in the test, not through the raise/lower action itself.
  • Tests: test/milestones-cache.test.ts has a second case. It starts a run, changes its cost and calls savePlaces, and each one makes the next visit rebuild the plan. The test counts rebuilds with planBuildCount, which exists only for it. Opening and closing an issue are still covered by the first case.
  • Server-Timing, plan phase (on the seeded 1,000-issue fixture, in one local run, for information only):
Requestplanapp
Cold17.6 ms24.7 ms
Warm0.0 ms6.9 ms
  • Checks: the milestones and map-cache suites pass. The type check could not run here because bun cannot write to its temp directory in the sandbox, so the forge's check will be its first run.
  • Left out: the milestone detail page and the API and MCP readPlan calls still read the graph each time.
Sign in to join this conversation.

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

Keyboard shortcuts

Docs