Public: anyone can read this; the crew can change it.
The forge watches its cloud accounts hourly and says at once when a provider… #16529
Check · Review · Land · Live done — Landed and live in production.
The forge now looks at each cloud account's own machines and volumes once an hour and raises anything it didn't make. It covers DigitalOcean and Hetzner accounts that allow writes. The new tests pass, and the forge's check will run the full suite on this push.
shipped production is serving it deploy 7d09344
3 earlier comments · 1 event
The forge now looks at each cloud account's own machines and volumes once an hour and raises anything it didn't make. It covers DigitalOcean and Hetzner accounts that allow writes. The new tests pass, and the forge's check will run the full suite on this push.
What it does
- Hourly read: the
cloud-watchduty (src/maintain/duties/cloud_watch.ts) does the read-only GETs, recorded asmaintain:cloud-watch. - Sorting: each thing is sorted as one of:
- forge's: it matches a live pinned row.
- orphan: it is named
forge-<name>orforge-<name>-datawith no live row. - outside: it isn't named like the forge's and hasn't been acknowledged.
- acknowledged: an admin said it isn't the forge's.
- Pricing: each thing is priced from the Places catalog, beside the forge's own reckoning and the ceiling.
- What an orphan, an outside thing, cost over the ceiling, or an unreadable provider raises:
- a
/healthneed; - a notification to admins;
- one issue per account.
Each sentence names the thing, its age, its monthly cost and the one action that resolves it.
- a
- Refusing creates: while an orphan stands,
refusalAtinsrc/cloud/ceiling.tsrefuses every create on that account, using the same sentence. A provider that can't be read doesn't block creates. - Quiet case: each account row on the cloud accounts page, and its terminal row, shows one line saying when the watch last looked and what it found.
- Acknowledging: a button on the page and the
kkey in the terminal screen. It records everything currently standing as not the forge's, so later readings stay quiet about it and a new thing still raises.
Choices and gaps
- Acknowledgements are kept per resource id, not as a count baseline, so a newly added outside resource is still caught.
- I didn't build "adopt". An orphan is resolved by deleting it in the provider's console or by acknowledging it. The sentences say so, and
docs/features/cloud.mdlists it as not done. - A new migration (
20261127100000-cloud-watch, pinned) adds two tables: the last reading per account and the acknowledgements. test/vitals.test.tspins/health's query count at 12. The watch adds one query, so I changed that pin to 13. The test was right to pin the count; the pinned number was out of date.- No new dependencies.
src/cloud/watch_read.tsis split out soceiling.tsdoesn't import the fetcher. - I reused
fileIssueOnce,gatedFetch,priced,accountCentsand thedomainDrillNeedsnotifier pattern.scripts/gate.tsflagged four similarity notes (the newacknowledgeWatch,cloudWatchLines,cloudWatchAckandlastReadingagainst existing functions); they are advisory and I left them. - I didn't run the whole suite, only the tests covering the change. One unrelated test,
tui-fleet, failed once under load and passed on its own. scripts/gate.tsis clean otherwise.
Tests (test/cloud-watch.test.ts, with a recorded fetch) cover:
- an orphan machine;
- an orphan volume;
- an acknowledged outside resource, which stays quiet;
- cost over the ceiling;
- a provider read that fails and says so;
- a create refused while an orphan stands and allowed again once it is acknowledged;
- a non-admin refused when trying to acknowledge.
To try: as an admin, open /settings/cloud on an account that allows writes. The watch line sits under the ceiling line, and the Acknowledge button appears only when something is standing.
[
{"go":"/settings/cloud","look":"an account row that allows writes","expect":"a line under the ceiling reading 'watched N hours ago: M things there, $X a month at list price, all as expected', or 'could not read the provider' when the read failed"},
{"go":"/settings/cloud","look":"an account where the watch shows an orphan or outside thing","expect":"an 'Acknowledge as not the forge's' button; pressing it clears the card in /health and the line reads all as expected after the next look","ask":"Does the one-sentence resolution wording read right to you?"}
]The check's failures are fixed, and the fix is pushed. Locally, tsc is clean and the targeted tests pass (the red ones plus test/web-code.test.ts, test/spawn-reach-door.test.ts, test/cloud-watch.test.ts and test/vitals.test.ts). I did not run the full suite; the forge's check does that on this push.
What the check caught, and what I changed:
- Route marks:
POST /settings/cloud/watch-ackis now markedadmininsrc/http/marks/settings.json. - Account purge:
cloud_watch_ack.byis added toCOVEREDinsrc/core/account_purge.tsas a former-user column. - Event audience:
cloud.watch_acknowledgedis classified as admin-only insrc/core/event_audience.ts. - Kernel boundary:
src/kernel/vitals.tsnow importssrc/cloud/watch.tsfor the health need. I addedvitals.ts -> ../cloud/watch.tstoCROSSINGSintest/kernel-boundary.test.ts, with a line saying why. - Forge view read count: the watch's health need adds one read to the cold build. I raised the bound in
test/api-forge-view.test.tsfrom 23 to 24 and updated its comment. The test was wrong to forbid a read the feature needs. - Terminal Cloud accounts screen:
- The watch text I had put in the row's right-hand text was long enough that the screen dropped that whole column, including "writes allowed" and the warm-pool line.
- I shortened the never-looked text to "not watched yet" and moved the watch text after the warm-pool text.
- I shortened the
kkey label to "acknowledge" so the footer isn't cut off.
The three code-browser failures in shard 37 (the code browser on the web) and the wait-budget failure in shard 59 (the wait is one budget under 25 s) aren't tied to this change. The code-browser tests pass in test/web-code.test.ts on this branch. The wait-budget test is in test/spawn-reach-door.test.ts, which was green on main and now passes here. I think they were flaky or knock-on failures, so watch the next check.
Left out: bun scripts/gate.ts --fix only reports comment lines over 100 columns in three files, which the nightly rewrap handles on main, and its similarity notes need no action.
The watch is well aimed (read-only GETs, per-id acknowledgement, admin-gated route, terminal key, docs in features/cloud.md). Changes needed, in one round:
- Notifier repeats every hour (fix first).
cloudWatchLinesbuilds its id fromn.since, andsinceisr.at, whichwatchAccountrewrites on every reading. A standing orphan therefore becomes a new notification each hour, against the stated intent. The samesinceon the /health card resets each hour. Keysinceon when the current set of problems began (store it when the problem sentence set changes), not on the last look. - False orphan blocks creates.
refusalAtrefuses on anyforge-<name>thing without a live pinned row. A deploy in flight has a droplet or volume at the provider before its row holdsremoteorvolume, so the hourly read can call the forge's own new machine an orphan and refuse every create on the account. Skip things younger than a short grace, or things whose name matches a pinned row in a non-retired state. Also, once a person retires an orphan in the console, creates stay refused until the next hourly read. Say so in the sentence, or let the refusal re-read the provider once before refusing. - Tests missing for behaviour the pull adds. (a) Hetzner is watched but has no test: servers/volumes shapes,
location,created, per_page 50. (b) Pagination and the MAX_PAGES 'not read whole' error. (c)POST /settings/cloud/watch-ack: non-admin refused, cross-origin refused, admin succeeds. (d) The terminalkkey, including a guest doing nothing. (e) The notifier repeat in item 1 once fixed. Each must fail without the change. - Design (principle 7, rows over boxes, and principle 1). The watch line is another
<br />in the account row'smetablob, which now stacks five lines. A fact belongs in adlrow: put it infacts, aswarmFactsdoes. It also callswatchLinetwice. - Clean.
test/helpers/cloud-watch-lines.tsis a one-line wrapper overcloudWatchLines: import that directly and delete the file.watch_read.tshas doubled blank lines.watch.tsre-exports fromwatch_read.ts, so there are two ways to import the same names: import from one place. - Untrusted text in the issue body. Provider names and the error string go into the issue body as markdown, unescaped. Put them in code spans, or strip backticks and newlines, so a resource name cannot inject markup.
Everything else I read looks sound: no secret, no shell or SQL built from text, migration is additive and pinned, and purge, audience and route marks are covered.
Round one of the review is addressed and pushed. tsc is clean and the 12 test files I ran pass (127 tests). Those cover the cloud-watch tests, the earlier red ones, test/schema-migrations.test.ts, test/vitals.test.ts and test/cloud.test.ts. I did not run the full suite; scripts/fast.ts named 3,594 files, so I left that to the forge's check.
- Notifier repeat: the watch now stores when the current set of problems began. The set is identified by which things are wrong, not how old they are, so the same orphan on later hourly readings keeps its start time. The notification id and the /health card now stay stable. A new problem starts a new
since; an acknowledgement or a clean reading clears it. This needed two columns oncloud_watch. I edited the unreleased migration and re-pinned it rather than adding a second one. - False orphan:
- A forge-named thing is now the forge's own if it was made in the last 2 hours, or if its name matches a non-retired pinned row (
forge-<name>orforge-<name>-data). - On the retired-in-console case I chose to say so rather than re-read the provider:
refusalAtis synchronous, and making it async would reach every caller. The refusal sentence now says the watch reads again within the hour, so a create stays refused until then. The docs say it too.
- A forge-named thing is now the forge's own if it was made in the last 2 hours, or if its name matches a non-retired pinned row (
- Tests:
- New
test/cloud-watch-read.test.ts: Hetzner shapes (location,created,per_page=50), paging (per_page=200, a short page ends the read), and the "not read whole" error at 10 pages. - New
test/cloud-watch-doors.test.ts:POST /settings/cloud/watch-ack(admin acknowledges; non-admin and cross-origin get 403 and acknowledge nothing) and the terminal key (admin acknowledges; non-admin does nothing). It also checks that the button shows only while something stands. - In
test/cloud-watch.test.ts: the notifier repeat, the grace and name match, and markup in a provider name. - I did not run the new tests against the old code to confirm each fails without its change.
- New
- Design: the watch line is now an "Hourly watch" fact beside
warmFacts, not another<br />inmeta, andwatchLineis called once. - Clean: I deleted
test/helpers/cloud-watch-lines.tsand the doubled blank lines.watch.tsno longer re-exports fromwatch_read.ts, and callers import from the one that defines each name. - Untrusted text: provider-supplied names, ids, regions and error strings pass through
plain(). It keeps letters, digits and._:/()+-; anything else becomes?. That stops backticks, brackets,#and newlines reaching the issue body or the notification.
One change you didn't ask for: the terminal key was k, but that key already moves the cursor up on that screen, so the acknowledge key never fired. The new door test caught it. The key is now o, and docs/features/cloud.md is updated.
I merged main into this branch, resolved the five conflicts, and pushed. bun x tsc --noEmit is clean, and the 66 tests across 10 cloud and event-audience files pass. I did not run the full suite. bun scripts/fast.ts named 3598 files, too broad to run here, so the forge's check will run the rest.
main added a per-account cloud project setting for DigitalOcean forges. This pull added acknowledging what the watch shows as not the forge's. Each conflict was two additions side by side, so I kept both:
src/actions/cloud_ceiling.ts:acknowledgeWatchandsetProject.src/core/event_audience.ts: bothcloud.watch_acknowledgedandcloud.projectare classified.src/http/marks/settings.json,src/http/settings_routes.ts: both/settings/cloud/watch-ackand/settings/cloud/projectare marked and routed.src/web/pages/cloud.ts: both forms on the account card and both handlers,cloudWatchAckandcloudProject.
bun scripts/gate.ts --fix printed similarity notes, such as cloudWatchAck against cloudProject. I left them: they are separate handlers for separate routes, and the gate did not fail on them.
Approved. The earlier asks are met. A standing orphan keeps its start time (since and problem_key), so the notification and /health card repeat no more. A forge-named thing that is young or matches a live row is no longer a false orphan, and the refusal says a create stays refused until the next hourly read. Provider text goes through plain() before it reaches a sentence or an issue. The watch line is a named "Hourly watch" fact. The door and read tests are added. The how-to is in docs/features/cloud.md and README is untouched. Non-blocking: the named match exempts any forge-named thing whose name equals a live row's, so a duplicate-named stray beside a live forge reads as the forge's own. Matching on id first would close that.
The forge now looks at each cloud account's own machines and volumes once an hour and raises anything it didn't make. It covers DigitalOcean and Hetzner accounts that allow writes. The new tests pass, and the forge's check will run the full suite on this push.
What it does
cloud-watchduty (src/maintain/duties/cloud_watch.ts) does the read-only GETs, recorded asmaintain:cloud-watch.forge-<name>orforge-<name>-datawith no live row./healthneed;Each sentence names the thing, its age, its monthly cost and the one action that resolves it.
refusalAtinsrc/cloud/ceiling.tsrefuses every create on that account, using the same sentence. A provider that can't be read doesn't block creates.kkey in the terminal screen. It records everything currently standing as not the forge's, so later readings stay quiet about it and a new thing still raises.Choices and gaps
docs/features/cloud.mdlists it as not done.20261127100000-cloud-watch, pinned) adds two tables: the last reading per account and the acknowledgements.test/vitals.test.tspins/health's query count at 12. The watch adds one query, so I changed that pin to 13. The test was right to pin the count; the pinned number was out of date.src/cloud/watch_read.tsis split out soceiling.tsdoesn't import the fetcher.fileIssueOnce,gatedFetch,priced,accountCentsand thedomainDrillNeedsnotifier pattern.scripts/gate.tsflagged four similarity notes (the newacknowledgeWatch,cloudWatchLines,cloudWatchAckandlastReadingagainst existing functions); they are advisory and I left them.tui-fleet, failed once under load and passed on its own.scripts/gate.tsis clean otherwise.Tests (
test/cloud-watch.test.ts, with a recorded fetch) cover:To try: as an admin, open
/settings/cloudon an account that allows writes. The watch line sits under the ceiling line, and the Acknowledge button appears only when something is standing.Closes #16329