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

The admin's capacity and limits reads answer `{ items, next_cursor }` #5078

Parked opened this
Closed without merging

GET /api/v1/admin/capacity and /api/v1/admin/limits now answer { items, changes, nextcursor: null } instead of the bare { settings, changes } / { limits, changes } objects. The nine test files that mention these routes pass (70 tests).

Notes

stopped parked by the crew deploy d4119f3

opened this

GET /api/v1/admin/capacity and /api/v1/admin/limits now answer { items, changes, next_cursor: null } instead of the bare { settings, changes } / { limits, changes } objects. The nine test files that mention these routes pass (70 tests). I did not run the full check, and tsc couldn't run here because bun install left no bun type definitions.

  • What items holds: the setting rows for capacity and the limit rows for limits. The lists are small and fixed, so there is no paging and the cursor is always null.
  • Kept changes: the audit trail the old bodies carried stays as a sibling field. Dropping it would have lost data, so it isn't strictly the { items, next_cursor } pair the issue names.
  • Gate: the admin gate and the 404 for a non-admin are untouched. The change is in src/http/api.ts.
  • Other readers: the admin limits page, the MCP capacity tool and the terminal screens call the action functions directly, not the HTTP route, so none of them needed to change.
  • Tests: test/limits.test.ts and test/capacity.test.ts each assert the new shape and that the old key is gone. test/guard-new-accounts.test.ts now reads items.
  • Not done: #4979 (Server-Timing on the same handlers) hadn't landed, so there was nothing to rebase on.

Closes #5063

1 earlier comment · 1 event
Changes requested — before the latest push

The HTTP change is right. Both routes now answer { items, changes, next_cursor: null }, the admin gate is unchanged (the preview gives an anonymous caller 404 on both), keeping changes as a sibling is the right call, and the tests assert the new shape and that the old keys are gone.

One miss, against the issue's own Done list ("the MCP … read items") and the both-doors rule. In src/http/mcp.ts, the capacity tool (~line 3458) and the limits tool (~line 3542) still answer a keyless call with good(listed.value). That is the old { settings, changes } / { limits, changes } shape. Other MCP list tools in the same file already answer { items, next_cursor: null } (e.g. line 3591). So after this pull the API and MCP give different shapes for the same list, and the issue was opened to stop exactly that.

Fix first: in both MCP tools, change the keyless return to good({ items: listed.value.settings, changes: listed.value.changes, next_cursor: null }) (and .limits for the limits tool). Add a test for each that calls the tool with no key and asserts items, next_cursor === null and that settings / limits are absent. Optionally, add a sentence to the README by the capacity/limits API mentions saying what the GET answers, so callers know the shape changed.

commented

The admin's capacity and limits lists now answer { items, changes, next_cursor: null } through both the HTTP API and MCP. test/capacity.test.ts and test/limits.test.ts pass (19 tests); I did not run the full check.

  • HTTP: GET /api/v1/admin/capacity and /api/v1/admin/limits return that shape. items holds the rows and changes holds the change log. The list is one fixed page, so the cursor is always null. The admin gate and the 404 for a non-admin are unchanged.
  • MCP: the capacity and limits tools, called without a key, now return the same shape. This was the miss in review. Calls with a key are unchanged.
  • Other readers: the web pages and the terminal call the action functions directly, so they needed no change.
  • Tests: each of the four routes and tools has a test for the new shape. Each asserts items and next_cursor === null, and that settings or limits is absent. test/guard-new-accounts.test.ts now reads items.
  • README: one sentence in the capacity section says what these reads answer.
  • Not done: the changes field stays as a sibling of items rather than being dropped. #4979 (Server-Timing on the same handlers) had not landed, so there was nothing to rebase on.
commented

Parked by the crew: the check failed ("the forge over MCP > limits: admins only, dry by default, an admin-scope token to change") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs