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

Each first-opened page's warm median reads beside its budget as plain rows, in one pure function with its test #11579

Merged opened this

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

Merged

This adds `pageBudgetRows(stats)`, a pure function that returns one plain row per `PAGE_BUDGETS` entry, in that order. Nothing calls it yet, so `src/perf/page_budget_read.ts` is in `scripts/unreached-allow.json` until the next issue wires it to /system. I did not call `keep_plan` on the issue.

shipped production is serving it deploy f21b126

opened this

This adds pageBudgetRows(stats), a pure function that returns one plain row per PAGE_BUDGETS entry, in that order. Nothing calls it yet, so src/perf/page_budget_read.ts is in scripts/unreached-allow.json until the next issue wires it to /system. I did not call keep_plan on the issue.

  • Row shape: each row is { page, pattern, budgetMs, statements, medianMs, n, over }. The median is the p50 of the RouteStat for that pattern.
  • Unsampled pages: a page with no stat, a null stat, or n: 0 reads medianMs: null, n: 0, over: false, never 0.
  • over: true only when the median is strictly past the budget.
  • Tests: test/page-budget-read.test.ts covers four things: rows follow the budget table one for one, the unsampled cases read null, over only past the budget, and stats for unknown patterns are ignored.
  • Left out: no page, docs or MCP change, as the issue asked.

bun x tsc --noEmit is clean. bun test on test/page-budget-read.test.ts, test/page-budget.test.ts and test/mcp-size.test.ts passes (15 tests). bun scripts/gate.ts printed nothing, so I take it as clean, but I didn't check its exit code.

To try it: bun test test/page-budget-read.test.ts.

Closes #11577

commented

This adds pageBudgetRows(stats), a pure function that returns one plain row per PAGE_BUDGETS entry, in that order. Nothing calls it yet, so src/perf/page_budget_read.ts is in scripts/unreached-allow.json until the next issue wires it to /system. I did not call keep_plan on the issue.

  • Row shape: each row is { page, pattern, budgetMs, statements, medianMs, n, over }. The median is the p50 of the RouteStat for that pattern.
  • Unsampled pages: a page with no stat, a null stat, or n: 0 reads medianMs: null, n: 0, over: false, never 0.
  • over: true only when the median is strictly past the budget.
  • Tests: test/page-budget-read.test.ts covers four things: rows follow the budget table one for one, the unsampled cases read null, over only past the budget, and stats for unknown patterns are ignored.
  • Left out: no page, docs or MCP change, as the issue asked.

bun x tsc --noEmit is clean. bun test on test/page-budget-read.test.ts, test/page-budget.test.ts and test/mcp-size.test.ts passes (15 tests). bun scripts/gate.ts printed nothing, so I take it as clean, but I didn't check its exit code.

To try it: bun test test/page-budget-read.test.ts.

Approved

Does what #11577 asked: one pure function, one row per PAGE_BUDGETS entry in order, null/0/false for unsampled, strict over, tests cover each. tsc clean, tests and gate.ts (exit 0) pass here. No user-facing surface changes, so no preview/TUI/docs obligation yet. Next two things: (1) wire it to /system and remove the unreached-allow entry in the follow-up issue, with a TUI screen alongside; (2) when wired, render null medians as "not measured" text, not a blank cell.

commented

Left #11577 open: 1 unticked item remain (new src/perf/page_budget_read.ts exports one pure function pageBudgetRows(stats) taking route stats keyed by router pattern (the RouteStat shape src/perf/record.ts already returns from summarize) and returning { page, pattern, budgetMs, statements, medianMs: number | null, n, over } for each entry of PAGE_BUDGETS (src/perf/page_budget.ts), in that order).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs