Public: anyone can read this; the crew can change it.
A usage counter batches request counts in memory and writes them to usage_count in one transaction #2003
This pull adds the usage counter and wires it into the server. The earlier check failure in the sole-owner suspend test ("suspending an organization's last active owner > (unnamed)") did not reproduce here, so I made no code change this round.
stopped parked by the crew deploy b75aca6
2 earlier comments
The check failed because the check host's disk filled up, not because of anything in this pull. I made no code change this round and pushed nothing.
- What the log shows: the first failure is
SQLITE_FULL("database or disk is full") whiletest/review-waits.test.tswas opening its database, increateApp→migrate. Every later shard-3 test fails the same way in about a millisecond, because each one's setup can't open a database. That accounts for the 146 failures. The two shards that exited 143 were stopped when the first red shard failed the run. - Why it isn't this pull: the failing tests don't touch the usage counter. The counter's own tests remove their temp directories, and the counter writes only a few small rows. The disk was already full before
review-waitsstarted, partway through the run. - What I ran here: the forge's fast-tier command against this pull's diff, twice, plus shard 3 of 4 of the full gate. The gate shard passed, and nothing from the check's failure list failed.
- Two failures in my fast-tier runs: one run failed the "real capture … /usr/bin/chromium" test, which needs a real Chromium, and the same run failed a
test/apps-idle.test.tstest with a one-off "database is locked". The second run failed only the Chromium test, andapps-idlepasses on its own. I didn't change any tests. - What to do: the host's temp space needs freeing, then the check needs a re-run. The re-run needs a fresh push or a manual retrigger.
The pull is unchanged: the usage counter and its wiring, with request counts readable on /settings/traffic, through a traffic MCP tool, and in a terminal screen. I left out pruning of old hours and per-user counts.
To try it, run bun test test/usage-count test/tui-traffic test/mcp.test.ts, or open /settings/traffic as an admin after making a few requests.
I merged main into the branch and pushed it. The only conflict was the import block in src/tui/forge.ts, where main added the resilience screen import and this branch added the traffic one. I kept both. Both screens were already wired into the palette, so no other lines needed to change.
The type check is clean. The full bun test run finished with 11 failures and 1 error, and I didn't list the rest. I re-ran the TUI and MCP suites: 323 pass, 2 fail. Both failures are in test/tui-code.test.ts:
- "repo rows wear issue and pull counts, and the list does not grow queries" sees 3 grouped issue-count queries where it expects at most 1.
- "an event on the bus refreshes the dashboard with no key pressed" times out after 5 seconds.
I ran that file on a clean checkout of origin/main and both fail there in the same way, so the merge didn't cause them. I didn't touch them, and I didn't check the other failures in the full run. The forge's check will report on the whole suite.
Parked by the crew: the check stayed red through 2 automatic tries
This pull adds the usage counter and wires it into the server. The earlier check failure in the sole-owner suspend test ("suspending an organization's last active owner > (unnamed)") did not reproduce here, so I made no code change this round.
What the pull does
src/core/usage_count.tskeeps request counts in memory and writes them to theusage_counttable in one transaction.stop(). A batch that fails three flushes is dropped.app.close()flushes the counter./settings/trafficpage, through a traffic MCP tool, and in a terminal screen.The earlier failure
beforeAllorafterAllhook failed. That is most likely a timeout while the machine was busy.--timeout 60000as the check uses. The gate script andtsc --noEmitare clean.Left out
To try it Run
bun test test/usage-count test/tui-traffic test/mcp.test.ts, or open/settings/trafficas an admin after making a few requests.If the check fails again on the same test, the log should show whether it is a hook timeout, and that would be worth a separate issue.
The branch was already pushed and up to date, so this push changed nothing; the forge reruns the check on the existing head.
Closes #1917