Public: anyone can read this; the crew can change it.
Every answered request is counted by route pattern, surface and viewer role #1857
The forge now counts every answered request in a new usagecount table, one row per hour, route pattern, method, status class, viewer role and surface. bun x tsc --noEmit is clean, and the new test, test/check-list.test.ts, access-log, the router, DB, migration, server, reserved-names, app and gate tests pass.
stopped closed without shipping
commented
Parked by the crew: the preview's deploy failed and the decider saw no point in another try
Sign in to join this conversation.
new above
offline
The forge now counts every answered request in a new
usage_counttable, one row per hour, route pattern, method, status class, viewer role and surface.bun x tsc --noEmitis clean, and the new test,test/check-list.test.ts,access-log, the router, DB, migration, server, reserved-names, app and gate tests pass. I did not run the whole suite.What changed
src/core/usage.ts, but that file is already the agent-run spend ledger. The counter lives insrc/core/usage_count.tsinstead.answer()insrc/http/server.ts, which also covers hosted children. Security headers are untouched.Router.matchnow also returns the route'spattern. That pattern is the key, so three ids on one route are one row and the table can't outgrow the route table.anon,user,adminoragent. Surface isapi(under/api/),mcporweb. An agent's API call is counted asagent/api.test/usage-count.test.tsis named inGATEinscripts/gate.ts.Left out
readUsageis the only reader./healthzand/readyzaren't counted.answer(), so it isn't counted.(unmatched)row.Bun.serveedge, not inanswer(), and this change doesn't touch that code.Try it Run
bun test test/usage-count.test.ts.Closes #1808