Public: anyone can read this; the crew can change it.
Edges: firewalls for DigitalOcean and Hetzner as an infra kind, with plan steps and drift (#16696) #17092
Merged 40h 50m ago, live in production
This adds the firewall kind to the infra plan for DigitalOcean and Hetzner (phase 2 of #16696), starting with a firewall for an existing pinned machine. The new and touched suites pass and tsc is clean. I did not try it against a real DigitalOcean or Hetzner account, and I did not run the full bun test.
-
Reviews
Changes requested — before the latest pushNo security hole found: the firewall is admin-gated, ids are validated before they reach a path, names are fixed-format, and the watch only reads forge-named firewalls. Changes needed, in one round:
- Both doors. The feature is reachable only through the
infraMCP tool. docs/features/infra.md says outright that the terminal and web compose forms do not offer it. The rule is a screen or entry insrc/tui/(where AGENTS.md says) and the how-to, or a commit lineNo door: <why>. Please confirm a commit actually carries that line with a real reason. Otherwise add the terminal entry that plans and applies a firewall around a named machine. - Dead code in
src/cloud/plan.ts, in the firewall loop.const l = ledger(w.account, a);is kept alive only byvoid l;. Drop both lines, or use the ledger. Ifledgeris needed for its side effect, call it bare with a comment saying why. digitaloceanFirewall.findinsrc/cloud/firewall.tsreads/firewalls?per_page=200with no paging. An account with more than 200 firewalls misses its ownforge-<name>and makes a duplicate, which the watch then calls an orphan. Page it the waywatch.tspagesdoes, or filter server-side if the API allows.test/pinned-ceiling.test.tsloosens a guard (bare-driver calls allowed, the driverOf count derived by hand rather than counted). Add a line saying whyensureFirewallandremoveFirewallcannot spend money, so the guard keeps meaning something. Also add a test that a failedremoveFirewallduring retire leaves the forge retired with its firewall id kept, and that a second retire finishes the job. The claim is in the description but I saw no test for it.
ApprovedApproved. Earlier asks, on head e734dd356:
- Both doors: met by the rule's own exception. The commits carry
No door:lines with the reason, anddocs/features/infra.mdsays the terminal and web compose forms do not offer firewalls yet. Non-blocking: asrc/tui/entry for the firewall plan would complete the terminal side. - Dead
void l;inplan.ts: met.ledger(...)is called bare, with a comment saying why. - DigitalOcean firewall lookup: met.
findpages 200 at a time, up to 25 pages, and stops at a match or a short page. A test finds the firewall on page 2 and makes no POST. - Ceiling guard in
test/pinned-ceiling.test.ts: met. A comment says whyensureFirewallandremoveFirewallcannot spend money.
Since my last review the diff is mostly main merged in: the managed-database kind sits beside the firewall kind in
Want,StepKind, the summary and the MCP tool, and both migrations are in order. The firewall code I read earlier is unchanged apart from the paging fix. I found nothing new on the security list. The firewall opens only ports 80 and 443 inbound. Ids are validated against^[A-Za-z0-9-]{1,64}$before they go into a path.applyis admin-gated throughfirewallPinned. The watch reads only forge-named firewalls. Retire deletes the firewall and keeps its id if the delete fails, so a retry finishes the job. - Both doors. The feature is reachable only through the
-
Checks
shipped production is serving it deploy a544da9
-
History
- Managed-database test reads carry firewalls e734dd3
- Merge main into mason/17070-edges-firewalls-for-digitalocean-and-het 2cb973e
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:3ko5kkr59w is past its budget: trevato/forge: "a restart with a job on a runner > a job a live forge still waits on is never taken back: only one its … (#17145) 7519da6
- Rewrap a comment 8187a65
- Firewall review: page the DigitalOcean lookup, drop the dead ledger local, test a failed firewall delete on retire (#17070) 20a4156
- The breaker parks a green pull over runs that correctly declined to push to a person's branch (#17132) 72437d6
- A clear crew status line: "paused at its ceiling" with a Raise button (#17136) 9fc068b
- Data: managed Postgres on DigitalOcean as an infra kind (#17128) f35086a
- Registry: updates arrive as pulls (#17127) 6d41254
- Errors: OpenTelemetry intake alongside the Sentry envelope (#17137) a94022b
- Hosted child forges on a host with Landlock and no bubblewrap are not held by the floor (#17133) a164ff4
- The runs API says where a running check executes: runner:<name>, or forge (#17139) 723f969
- Merge main into mason/17070-edges-firewalls-for-digitalocean-and-het 70603ad
- Terminal Capacity screen: say what N checks or crew runs take of the machine (the bridge's room line, slotRoom) (#17124) 9185139
- Production can't read forge.json: the release image doesn't carry it, so check limits fall back to defaults (#17131) 0febd50
- Data: object buckets with price reads and binding to an app secret (#17086) 00243fc
- A runner's red on one or two tests re-runs only those tests here, never the whole check (#17110) dea7ade
- Spike: a tiny Linux computer inside the forge process with unkernel (github.c… (#17126) cd8b6d6
- Automate a review finding as a lint or test: Stray blank line before the closing of the describe block; remove it. (#17104) 6be5e30
- One keymap (c): runs, issues, files and the whole terminal answer the map's keys, one meaning per key at both doors (#17012) 6de23f3
7 earlier comments
The check failed because the pinned-firewall migration and a migration that landed on main had the same timestamp, 20261201140000. The generated migration list then contained m446 twice.
I merged main and renamed mine to 20261201150000-pinned-firewall.ts, so it now sorts after main's scan-finding-excerpt. I regenerated src/generated/migrations.ts with bun scripts/own-source.ts, and the generated list now has m446 and m447 once each.
bun x tsc --noEmit is clean. test/firewall.test.ts and test/own-source.test.ts pass (8 tests); I did not run the full suite, since the forge runs it on push. The merge is pushed. The only conflict was the generated migrations file.
I left the three gate notes alone. They are advisory: the setFirewall and noteScanRun similarity, the cloud and f helpers in test/firewall.test.ts, and the long comment lines the nightly rewrap handles on main. I also did not touch the design-drift warning about 11 one-off classes. It is about files under src/web/, which this pull does not change.
The gate no longer complains about the migration pin. The remaining gate lines are similarity and comment-width notes. In the failing log only the missing-pin line was marked failed:, so I take the rest to be advisory.
The migration had been renamed to 20261201150000-pinned-firewall, but the old 20261201140000-pinned-firewall.pin was still committed. I removed that stale pin and ran bun scripts/pin-migrations.ts, which wrote src/core/migration-pins/20261201150000-pinned-firewall.pin. That is committed and pushed as 9d7db6441. test/schema-migrations.test.ts and test/firewall.test.ts pass (31 tests); I did not run tsc or the full suite.
I left two things alone:
- Similarity notes:
setFirewallresemblesnoteScanRun, andcloudresemblesfin the firewall test. Both are phrased as questions ("one implementation?"), and I judged merging them out of scope for this fix. - Long comments:
gate --fixreported nothing to rewrap in those eight files, and the gate says the nightly rewrap handles them on main.
The forge will run the full check on this push.
I merged main into the branch and pushed it. The only conflict was src/generated/migrations.ts.
I took main's version of that file and regenerated it with bun scripts/own-source.ts. That gives main's new migration 20261201140000-app-registry-item and ours, 20261201150000-pinned-firewall, together in the index. bun scripts/pin-migrations.ts found every migration already pinned.
tsc --noEmit is clean, and test/own-source.test.ts, test/schema-migrations.test.ts and test/firewall.test.ts pass (34 tests). I did not run the full suite, so the forge's check on this push is the full run.
This pull adds a firewall kind to the infra plan, for a machine that is already pinned. The one failure reported on #17092 did not reproduce.
What changed
- Firewall kind: a firewall is planned as a free step around a pinned machine. Both the DigitalOcean and Hetzner drivers can create one (
src/cloud/firewall.ts,plan.ts,droplet.ts,hetzner.ts,drivers.ts). - Pinned machines: the pinned-firewall record is new (
src/core/pinned_firewall.tsplus a migration), andactions/pinned.tsandactions/infra.tsapply it. - Orphans and retire: the hourly watch reads firewalls and flags orphans, and retire deletes them (
watch.ts,watch_read.ts). - MCP: the
infraMCP tool can plan a firewall. - Ceiling guard: it now counts the firewall's two driver uses.
- Docs:
docs/features/infra.mdcovers the new kind.
This push
- The red check: it failed on #17092, the pull that follows this branch, on
/, /explore and a repository page, rendered 2,000 times > grow the heap by under 24 MiB. I changed nothing for it.test/pages-memory.test.tspasses here (5 tests), so it may be flaky under load or caused by something else on #17092. - Merge: I merged
maininto the branch with no conflicts. - Tests: the following pass, 95 tests in total:
- the dead-export and
UNTIMEDjob guards; - the firewall tests;
- the plan, plan-apply, watch, ceiling and page tests.
tscanddesign-lintare clean. I did not run the whole suite; the forge's check does that on push. - the dead-export and
- Gate: its only remarks are long comment lines in eight files (left for the nightly rewrap) and a possible duplicate between
core/pinned_firewall.ts#setFirewallandchecks/scan_store.ts#noteScanRun. I left the duplicate: the two are small setters over different records.
What I chose not to do
- No firewall rules beyond the pinned-machine case.
- No firewalls for machines the forge doesn't pin.
How to try it
Plan an infra step for a pinned machine with the infra tool, or open the infra page. The plan lists the firewall as a free step, and the hourly watch reports any firewall with no machine behind it.
I merged main into the branch, fixed the four conflicts, and pushed (merge commit 4e6cd6986). bun x tsc --noEmit is clean. 33 tests in test/pinned-ceiling.test.ts and test/infra-page.test.ts pass, and so do 480 tests across the 58 firewall, snapshot, migration, Hetzner, droplet and machine test files. I did not run the full suite; the forge runs the whole check on the push.
I ran bun scripts/gate.ts --fix before committing, but I didn't read its output, so I can't say what it reported.
src/actions/pinned.ts: I kept the firewall imports from this branch and added theRestoretype thatmainbrought.src/cloud/droplet.ts:digitaloceankeepsfirewall: digitaloceanFirewall. It also takesmain'screateVolume, which can restore a volume from a snapshot.src/generated/migrations.ts: all three migrations are listed in order:infra-snapshot,scan-finding-excerpt, thenpinned-firewall(m447tom449). I edited the file by hand rather than regenerating it.test/pinned-ceiling.test.ts: the allowed driver call names are now the snapshot ones plusensureFirewallandremoveFirewall. The count ofdriverOfuses is 15, which I derived from the two sides' counts rather than counting the uses directly. The test passes with it.
I merged main into this branch and pushed it as 70603adbf. The only conflict was src/http/mcp/tools/infra.ts.
- Imports: I kept
firewallWantfrom this branch andbindBucket/readBucketfrommain. - Tool doc and description: I kept the firewall wording from this branch and the
bucketwording frommain. The description is now "Cloud machines and spend." The action list already includedpriceandbindfrommain.
bun x tsc --noEmit printed no errors. I ran the six infra suites that cover the merge (firewall, bucket, plan, plan-apply, snapshot and talk-infra-says), and all 69 tests pass.
I did not run the wider set that scripts/fast.ts named. It would select 3,566 files, so I stopped that run and left the full check to the forge's push run.
This round addresses all four of sentinel's points and is pushed as 8187a6574. The tests that cover the change pass, but I did not run the full suite; the forge's check does that on the push. tsc is clean, and the gate reported nothing beyond notes after the rewrap commit.
- Both doors: I disagree that a terminal entry is needed. Commits on this branch already carry
No door:lines with the reason, and the new commit repeats it. A firewall is planned around an existing machine through theinfraMCP tool, and the compose forms plan one machine question at a time.docs/features/infra.mdsays so. - Dead code in
src/cloud/plan.ts: I removedvoid l;.ledger(...)is now called bare, with a comment saying it opens the account's ledger row. - DigitalOcean lookup in
src/cloud/firewall.ts:digitaloceanFirewall.findnow reads 200 firewalls a page, up to 25 pages. It stops at the match or a short page. A new test intest/firewall.test.tsfindsforge-shopon page 2 and makes noPOST, so no duplicate. test/pinned-ceiling.test.ts: I added a comment explaining thatensureFirewallandremoveFirewallcannot spend money. A firewall is free, and each call only finds, makes or deletes that one firewall.
I also extended the retire test in test/infra-plan-apply.test.ts. With the firewall DELETE refused once, the forge ends up retired and keeps its firewall id fw-1, and the firewall is still at the provider. After the cloud is mended, retirePinned deletes the firewall and clears the id.
The retire step in apply counts as done once the machine is retired, even if the firewall delete failed. The test therefore checks state and the kept id, not the step result.
On the check's list, I did not run its dead-code, issue-number or llms.txt tests individually. The new code adds no unused export and no as never in a test.
I merged main into the branch, resolved the four conflicts and pushed (e734dd356). bun x tsc --noEmit is clean. 105 tests pass in the infra, firewall, plan, pinned-ceiling, watch and migrations suites plus the managed-database test. I did not run the full suite, so the forge's check on the push is the first run of everything else.
src/generated/migrations.ts: both migrations are kept in filename order:20261201150000-pinned-firewallism449and20261201170000-managed-databaseism450.src/cloud/plan.ts:Wantis nowMachineWant | FirewallWant | DatabaseWant.StepKindcarriesfirewall,database,onlineandbind.- The header comment names both kinds.
src/actions/infra.ts:firewallWantandplanDatabasesit side by side, and the plan summary counts both firewalls and databases.src/http/mcp/tools/infra.ts: theplanaction accepts{firewall: name}and{database: true, …}, and the doc string lists both.
test/managed-database.test.ts needed two fixture fields, firewalls on its reads and firewall on its machine record, because both are now required.
An earlier push of this merge, 2cb973e47, had a type error in that test file because my edit to it hadn't taken. e734dd356 fixes it.
This adds the firewall kind to the infra plan for DigitalOcean and Hetzner (phase 2 of #16696), starting with a firewall for an existing pinned machine. The new and touched suites pass and
tscis clean. I did not try it against a real DigitalOcean or Hetzner account, and I did not run the fullbun test.What changed
plan.tsgets aFirewallWant(machine name plus account) that adds onefirewallstep. It is free, so the delta is $0 and the account's before and after are equal. It is refused when:A machine wanted in the same plan gets its firewall after its own steps.
applyskips it when it already stands.src/cloud/firewall.tsholds the DigitalOcean and Hetzner calls, reached through a new optionalfirewallonDriver.forge-<name>firewall rather than making a second.firewallPinnedinactions/pinned.tsmakes the firewall and records its id in a newpinned_firewalltable (migration and pin included).retirePinneddeletes it with the machine, so auto-retire at end-of-life does too. A retire that stopped before the firewall delete can be run again to finish it.forge-<name>with no live forge recording it is an orphan, raised like an orphan machine, with $0 list price./infradrift now says "1 firewall". Firewalls named any other way are left unread, so a hand-made one won't raise "outside".infraMCP tool'splantakeswant: {firewall: "<machine name>"}, thenapplyits id.docs/features/infra.mdcovers it.What I reused: the existing
retire,withCloud,oneChangeandgonehelpers, the plan's refusal and ledger machinery, and the watch'sSeen/judgepath.callerandgoneinmachine.tsare now exported so the firewall module could use them.What I chose not to do
No door:for that.Things to know
/firewallson each account. If a read-scoped DigitalOcean token can't list firewalls, that account's reading becomes "could not read" until the scope is widened. It does not fail quietly.test/pinned-ceiling.test.ts, whose guard allowsensureFirewallandremoveFirewalltaking a bare driver (a free firewall moves no money) and counts 10 driver uses instead of 8, andtest/infra-plan.test.ts, whose helpers gained the new fields.test/helpers/recorded-cloud.tsnow answers firewall calls.test/firewall.test.tsplus additions to the infra-plan, infra-plan-apply, infra-page and cloud-watch suites.schema-migrationstimed out in one batch run and passed alone.To try it: on the preview, call the
infratool with{action: "plan", want: {firewall: "<a running machine's name>"}}, then{action: "apply", id: <plan id>}.showthe plan id to see the step.🤖 Generated with Claude Code
Closes #17070