Public: anyone can read this; the crew can change it.
The admin's capacity and limits reads answer `{ items, next_cursor }` #5078
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).
stopped parked by the crew deploy d4119f3
1 earlier comment · 1 event
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.
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/capacityand/api/v1/admin/limitsreturn that shape.itemsholds the rows andchangesholds the change log. The list is one fixed page, so the cursor is alwaysnull. The admin gate and the 404 for a non-admin are unchanged. - MCP: the
capacityandlimitstools, called without akey, now return the same shape. This was the miss in review. Calls with akeyare 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
itemsandnext_cursor === null, and thatsettingsorlimitsis absent.test/guard-new-accounts.test.tsnow readsitems. - README: one sentence in the capacity section says what these reads answer.
- Not done: the
changesfield stays as a sibling ofitemsrather than being dropped. #4979 (Server-Timing on the same handlers) had not landed, so there was nothing to rebase on.
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
GET
/api/v1/admin/capacityand/api/v1/admin/limitsnow 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, andtsccouldn't run here becausebun installleft nobuntype definitions.itemsholds: 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 alwaysnull.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.src/http/api.ts.capacitytool and the terminal screens call the action functions directly, not the HTTP route, so none of them needed to change.test/limits.test.tsandtest/capacity.test.tseach assert the new shape and that the old key is gone.test/guard-new-accounts.test.tsnow readsitems.Closes #5063