An app cannot stall the forge (#12265)
The forge serves everyone on one thread, so an app that polls it on a timer must not slow people down. Nothing an app asks is refused; it only goes last, and the forge says who asks the most.
- Events before polls. To be told when something changes, open
GET $FORGE_URL/eventsonce and follow it. When a read is the right tool, sendIf-None-Matchwith the lastETagand keep your copy on a304. - Repeat reads are free (
src/http/repeat_reads.ts). An app token's last 200 tag per URL andAcceptis kept (under the token's hash, never the secret), at most 512 per forge and 30 s old. While the write clock has not moved, the same request with that tag is answered 304 without running its query. Any write ends it. - People first (
src/http/app_turn.ts). An app token's request waits while a person's request begun in the last second is open, or one was answered in the last 50 ms, for at most one second. With nobody else asking it is served at once. - Who is asking (
src/perf/asking.ts). Any one token over a fifth of the last hour's requests or of the serving thread's time is named, with the route it asks most and how often, with the choice: open the app's page, or put it to sleep, or revoke the token. It is shown on /system and in the terminal's System screen, to the owner only (canSeeMemory), and in the admin's needs-you stack. An always-on app nobody opened for a day that is still calling the forge sleeps like any idle app.
The reading is one in-process map (61 minute buckets, 64 tokens each); it is gone on restart.
Tests: test/app-turn.test.ts (the turn on a fake clock, the 304, the gate on /system), test/tui-system.test.ts.