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

Every answered request is counted once, in the server's answer, by pattern, role and surface #1918

shipped production is serving it opened this has it
opened this

Part 3 of #1808: wire the counter (from the usage counter issue) and the matched pattern (from the router issue) into the server.

Done looks like:

  • [ ] The count is taken in one place in src/http/server.ts (the function every response passes through, hosted children included), after the security headers are set; every response keeps them.
  • [ ] Role comes from the request's viewer (an agent token is agent), surface from the path (/api/ is api, the MCP route is mcp, else web). An unmatched path is counted under one pattern, (unmatched), so the table cannot grow with what strangers type.
  • [ ] The server stops by flushing the counter. The common request adds no query and stays under 50 ms.
  • [ ] A test (in test/usage-count.test.ts or a new file named in GATE) shows three ids on one route land on one row, and an agent's API call is counted as agent/api.

Files: src/http/server.ts, the test, scripts/gate.ts if a file is added. No new page, so no reserved name. Run bun x tsc --noEmit, the usage, server and access-log tests and test/check-list.test.ts before pushing.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs