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

The system MCP tool answers `kind: "pages"` with the same page-budget rows /system shows #16755

Merged opened this

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

Merged

The system MCP tool now answers { kind: "pages" } with the pageBudgetRows rows, one { page, pattern, budgetMs, statements, medianMs, n, over } per PAGEBUDGETS entry.

Notes

opened this

The system MCP tool now answers { kind: "pages" } with the pageBudgetRows rows, one { page, pattern, budgetMs, statements, medianMs, n, over } per PAGE_BUDGETS entry.

  • Not the same code as /system: I couldn't find anywhere on main that /system calls pageBudgetRows, so the issue's "same words /system shows" has no section to match yet. The tool uses the page strings from PAGE_BUDGETS, which that section would use too. This is the part to check.
  • Medians: they come from the watcher's 15-minute perf record, keyed by route pattern.
  • Gate: it's the same as routes, so a forge admin or telemetry:read. Anyone else gets forbidden.
  • Unknown kind: it still answers invalid, and the message now names pages.
  • Doc clause: the tool doc grew by one short clause (about 11 words). No ceiling was raised.
  • docs/MCP.md: one line where the system tool's kinds are listed.
  • Test: the new test in test/mcp-system-routes.test.ts checks that the rows' page values equal PAGE_BUDGETS' in order. It also checks that a non-admin is refused and that the unknown-kind message names pages.
  • Checks: bun test test/mcp-system-routes.test.ts test/mcp-size.test.ts passes (14 tests), and bun x tsc --noEmit and bun scripts/gate.ts --fix came back clean. I did not run scripts/similar.ts.
  • Push: the pre-push hook wanted a "Try:" commit, so the branch ends with an empty one.

I reused pageBudgetRows, summarize, telemetryReader and noteRead rather than writing new helpers.

To try it, call system with { "kind": "pages" } as an admin. An agent without the telemetry:read grant gets forbidden.

[{"go":"MCP tools/call system {\"kind\":\"pages\"} with an admin token","look":"result.content[0].text JSON","expect":"{pages:[…]} with one row per budgeted page, medianMs null where unmeasured"},{"go":"same call with a non-admin token lacking telemetry:read","look":"result.isError","expect":"true, forbidden"}]

Closes #11545

2 earlier comments
commented

The system MCP tool now answers { kind: "pages" } with the pageBudgetRows rows, one { page, pattern, budgetMs, statements, medianMs, n, over } per PAGE_BUDGETS entry.

  • Not the same code as /system: I couldn't find anywhere on main that /system calls pageBudgetRows, so the issue's "same words /system shows" has no section to match yet. The tool uses the page strings from PAGE_BUDGETS, which that section would use too. This is the part to check.
  • Medians: they come from the watcher's 15-minute perf record, keyed by route pattern.
  • Gate: it's the same as routes, so a forge admin or telemetry:read. Anyone else gets forbidden.
  • Unknown kind: it still answers invalid, and the message now names pages.
  • Doc clause: the tool doc grew by one short clause (about 11 words). No ceiling was raised.
  • docs/MCP.md: one line where the system tool's kinds are listed.
  • Test: the new test in test/mcp-system-routes.test.ts checks that the rows' page values equal PAGE_BUDGETS' in order. It also checks that a non-admin is refused and that the unknown-kind message names pages.
  • Checks: bun test test/mcp-system-routes.test.ts test/mcp-size.test.ts passes (14 tests), and bun x tsc --noEmit and bun scripts/gate.ts --fix came back clean. I did not run scripts/similar.ts.
  • Push: the pre-push hook wanted a "Try:" commit, so the branch ends with an empty one.

I reused pageBudgetRows, summarize, telemetryReader and noteRead rather than writing new helpers.

To try it, call system with { "kind": "pages" } as an admin. An agent without the telemetry:read grant gets forbidden.

[{"go":"MCP tools/call system {\"kind\":\"pages\"} with an admin token","look":"result.content[0].text JSON","expect":"{pages:[…]} with one row per budgeted page, medianMs null where unmeasured"},{"go":"same call with a non-admin token lacking telemetry:read","look":"result.isError","expect":"true, forbidden"}]
commented

I fixed the "both doors" failure with a No door: line in a new empty commit, and pushed it. I haven't seen the forge's re-run of the check yet.

The commit says the page-budget rows are not on /system or in the terminal yet, so this change only lets the MCP read the existing pageBudgetRows. I confirmed that the terminal's system screen (src/tui/screens/system.ts) doesn't use page_budget. Adding a terminal section for page budgets would be a separate change, so I didn't add one.

I left the gate's two notes alone. One is a comment over 100 columns in test/mcp-system-routes.test.ts, which the gate says the nightly rewrap handles. The other is that the test's post helper looks like call in test/roadmap.test.ts, and I didn't merge them.

commented

The system MCP tool now answers kind: pages with the page-budget rows, read from the existing pageBudgetRows. Nothing else in this push changes behaviour.

The check failed because src/perf/page_budget_read.ts is now imported from the app, so it no longer belongs in scripts/unreached-allow.json. I removed that entry. test/unreached.test.ts passes locally (4 of 4). I didn't re-run the rest of the suite or the type check after this one-line change, so the forge's re-run of the check is the full verdict.

The page-budget rows are still not shown on /system or in the terminal. I left that out on purpose; the commit says No door: for it.

To try it: as an admin, call the system tool with kind: pages and look for one row per budgeted page.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs