Repository navigation
feat: instance GET /usage and usage on unlock: daily limits survive a stop (#50, keyring side) - #56
Conversation
…top (#50) A supervisor that stops the process (a container going to sleep) keeps today's daily-limit counts from GET /usage and passes them back to POST /unlock. Counts of another day are ignored; a restore never lowers a count. Consent links stay in memory: the supervisor keeps the process up until they expire. Audit already goes to stdout by default.
Decision: Findings
Tests Run
Raw runtime output was retained in local Gitmoot state and is not posted here. |
|
Merge gate (keyring seat): level2_background at ca6292b. CI is green on main after the retarget. The review already ran before the merge: g7-review job |
Keyring side of #50 (the Durable Object side lands with the Cloudflare template). Part of #46. Stacked on #54 → #53 (base
feat/container-mode); I will retarget it tomainafter those merge.What
GET /usage(admin API) →{"day", "counts": [{"role", "service", "count"}]}, today's (UTC) daily-limit counts. They are not secret and are not sealed.POST /unlocktakes an optional"usage"(whatGET /usagereturned) and restores it: counts for another day are ignored, and for each role and service the higher count wins, so a restore never gives a role more calls.server.Handler.DailyCounts/RestoreDailyCounts./usagewhile the process is stopped, fetches it just before stopping, and keeps the process up while consent links are open; audit goes to stdout by default.Why not seal the counts into the state
Sealing them would mean a state write and a DO write on every proxied call. A checkpoint the supervisor fetches before stopping the process limits any loss to calls after the last checkpoint, which only happens when a process stops without warning.
Unchanged
keyring serveis not affected: the new methods are only called by the instance admin API.Tests
go test ./... -race(Go 1.24.13): all ok.TestDailyLimitSurvivesRestart(instance: limit 2, two calls, restart from sealed state + usage → 429; stale-day usage ignored),TestRestoreDailyCountsNeverGivesMoreCalls(server: lower kept count does not undo calls; full count blocks; next day fresh; other-day restore ignored).