Public: anyone can read this; the crew can change it.

Edges: snapshots as an infra kind, offered before retire (#16696) #17094

opened this

Merged 36h 45m ago, live in production

Snapshots are now an infra kind. End now on a DigitalOcean or Hetzner machine offers a snapshot first, and a snapshot can be restored or deleted from its row. The gate and bun x tsc --noEmit are clean.

Notes

opened this

Snapshots are now an infra kind. End now on a DigitalOcean or Hetzner machine offers a snapshot first, and a snapshot can be restored or deleted from its row. The gate and bun x tsc --noEmit are clean. I ran only the tests that cover this change. They pass, apart from the four apply > tests in test/infra-plan.test.ts, which also fail on main when run in the same process as the pinned-* tests. Nothing was run against a real cloud, only against recorded API calls.

What changed

  • Drivers (src/cloud/machine.ts, droplet.ts, hetzner.ts): an optional snapshots section on a driver, plus restore parameters on create.
    • DigitalOcean snapshots the data volume: 10 GiB at $0.06 a GiB a month, so $0.60.
    • Hetzner has no volume snapshots, so its snapshot is the server's own disk, billed by size at €0.0119 a GB a month converted at the day's rate. The words say which. OVHcloud keeps the plain End.
  • Rows: a new table, infra_snapshot, with src/core/snapshots.ts. A row outlives the forge's own and carries where it was and what it ran.
  • Actions (src/actions/infra_snapshot.ts, reusing withCloud, oneChange and deployPinned):
    • endWithSnapshot takes the snapshot and polls until it is complete (10 minutes at most) before it retires the machine. A snapshot that fails or times out leaves the machine running and records a failed row with the reason.
    • restoreSnapshot is one new deploy at the same place, with the volume (DigitalOcean) or server (Hetzner) made from the snapshot, so the ceiling and refusals are the deploy's own.
    • deleteSnapshot removes it at the cloud and drops the row.
  • Web: End now goes to /infra/<name>/ending where a snapshot is offered, with "Snapshot, then end" or "End without a snapshot". A Snapshots section lists each row with Restore (a name field) and Delete (through the confirm page). The snapshot-then-end action runs in the background, and a failure shows as a failed row.
  • Terminal: on the Infrastructure screen, x offers the snapshot, r restores a selected snapshot and d deletes one after a confirm.
  • API and agents: infraOf now carries snapshots, so the API and the infra tool's list show them. infraSays names them and counts them in the total.
  • Docs and events: a Snapshots section in docs/features/infra.md, and the events infra.snapshot and infra.restored.
  • Tests: test/infra-snapshot.test.ts covers:
    • the order of calls (snapshot, poll, delete the machine);
    • a refused snapshot ending nothing;
    • a snapshot that times out;
    • restore, delete, and the admin-only checks;
    • the page and the terminal;
    • Hetzner's calls and its image id check.

Tests I changed

  • test/infra-page.test.ts: End now is now a link to /infra/<name>/ending, not a confirm form.
  • test/pinned-ceiling.test.ts: its guard that every driverOf call goes through capped now also allows the snapshot calls, and the count of uses went from 8 to 13.

What I chose not to do

  • Ceiling: snapshots are not counted against the account ceiling. They cost a few cents a month and make no machine. They are counted in infraSays totals and shown on each row.
  • MCP actions: no new MCP actions, because the infra tool's slot in Talk's catalog is about 30 bytes under its ceiling. Agents read snapshots through list.
  • Plan engine: plan.ts is untouched, so snapshots are not a plan step yet.
  • Standalone snapshot: no "snapshot without ending" button.
  • Game boxes: a restore does not carry the game-box flag.
  • Hetzner restore: a restore boots a server from the image with a fresh, empty volume; the old data volume is not reattached.
  • Cloudflare DNS, firewalls and OVH: the other phase 2 edges are not part of this.

How to try it On the preview, open /infra, press End now on a DigitalOcean machine, and choose "Snapshot, then end". The Snapshots section then shows the row, with Restore and Delete.

[
  {"go": "/infra", "look": "A running DigitalOcean or Hetzner machine's End now button", "expect": "It opens /infra/<name>/ending with the offer sentence, Snapshot, then end, and End without a snapshot", "ask": "Is the offer wording clear about what is kept and what it costs?"},
  {"go": "/infra", "look": "The Snapshots section after a snapshot-then-end", "expect": "A row saying what it holds, its size, its day and its monthly cost, with a name field and Restore, and Delete via the confirm page"}
]

🤖 Generated with Claude Code

Closes #17072

5 earlier comments
commented

Snapshots are now an infra kind. End now on a DigitalOcean or Hetzner machine offers a snapshot first, and a snapshot can be restored or deleted from its row. The gate and bun x tsc --noEmit are clean. I ran only the tests that cover this change. They pass, apart from the four apply > tests in test/infra-plan.test.ts, which also fail on main when run in the same process as the pinned-* tests. Nothing was run against a real cloud, only against recorded API calls.

What changed

  • Drivers (src/cloud/machine.ts, droplet.ts, hetzner.ts): an optional snapshots section on a driver, plus restore parameters on create.
    • DigitalOcean snapshots the data volume: 10 GiB at $0.06 a GiB a month, so $0.60.
    • Hetzner has no volume snapshots, so its snapshot is the server's own disk, billed by size at €0.0119 a GB a month converted at the day's rate. The words say which. OVHcloud keeps the plain End.
  • Rows: a new table, infra_snapshot, with src/core/snapshots.ts. A row outlives the forge's own and carries where it was and what it ran.
  • Actions (src/actions/infra_snapshot.ts, reusing withCloud, oneChange and deployPinned):
    • endWithSnapshot takes the snapshot and polls until it is complete (10 minutes at most) before it retires the machine. A snapshot that fails or times out leaves the machine running and records a failed row with the reason.
    • restoreSnapshot is one new deploy at the same place, with the volume (DigitalOcean) or server (Hetzner) made from the snapshot, so the ceiling and refusals are the deploy's own.
    • deleteSnapshot removes it at the cloud and drops the row.
  • Web: End now goes to /infra/<name>/ending where a snapshot is offered, with "Snapshot, then end" or "End without a snapshot". A Snapshots section lists each row with Restore (a name field) and Delete (through the confirm page). The snapshot-then-end action runs in the background, and a failure shows as a failed row.
  • Terminal: on the Infrastructure screen, x offers the snapshot, r restores a selected snapshot and d deletes one after a confirm.
  • API and agents: infraOf now carries snapshots, so the API and the infra tool's list show them. infraSays names them and counts them in the total.
  • Docs and events: a Snapshots section in docs/features/infra.md, and the events infra.snapshot and infra.restored.
  • Tests: test/infra-snapshot.test.ts covers:
    • the order of calls (snapshot, poll, delete the machine);
    • a refused snapshot ending nothing;
    • a snapshot that times out;
    • restore, delete, and the admin-only checks;
    • the page and the terminal;
    • Hetzner's calls and its image id check.

Tests I changed

  • test/infra-page.test.ts: End now is now a link to /infra/<name>/ending, not a confirm form.
  • test/pinned-ceiling.test.ts: its guard that every driverOf call goes through capped now also allows the snapshot calls, and the count of uses went from 8 to 13.

What I chose not to do

  • Ceiling: snapshots are not counted against the account ceiling. They cost a few cents a month and make no machine. They are counted in infraSays totals and shown on each row.
  • MCP actions: no new MCP actions, because the infra tool's slot in Talk's catalog is about 30 bytes under its ceiling. Agents read snapshots through list.
  • Plan engine: plan.ts is untouched, so snapshots are not a plan step yet.
  • Standalone snapshot: no "snapshot without ending" button.
  • Game boxes: a restore does not carry the game-box flag.
  • Hetzner restore: a restore boots a server from the image with a fresh, empty volume; the old data volume is not reattached.
  • Cloudflare DNS, firewalls and OVH: the other phase 2 edges are not part of this.

How to try it On the preview, open /infra, press End now on a DigitalOcean machine, and choose "Snapshot, then end". The Snapshots section then shows the row, with Restore and Delete.

[
  {"go": "/infra", "look": "A running DigitalOcean or Hetzner machine's End now button", "expect": "It opens /infra/<name>/ending with the offer sentence, Snapshot, then end, and End without a snapshot", "ask": "Is the offer wording clear about what is kept and what it costs?"},
  {"go": "/infra", "look": "The Snapshots section after a snapshot-then-end", "expect": "A row saying what it holds, its size, its day and its monthly cost, with a name field and Restore, and Delete via the confirm page"}
]

🤖 Generated with Claude Code

commented

I fixed the failed check and pushed. The branch had a duplicate migration identifier, m446, because main added 20261201140000-scan-finding-excerpt.ts while this pull added 20261201140000-infra-snapshot.ts.

I merged main into the branch and regenerated src/generated/migrations.ts with bun scripts/own-source.ts. The snapshot migration keeps m446 and the scan-finding one is now m447.

  • Type check: bun x tsc --noEmit was clean.
  • Tests: test/own-source.test.ts and test/infra-snapshot.test.ts pass, 12 tests. I did not run the full suite.
  • Gate: bun scripts/gate.ts --fix changed nothing. It still prints the three "one implementation?" similarity notes from the check log (getSnapshot, infraSnapshot and the test Call) that I did not act on. The other gate lines (comment-wrap note, design-drift classes) are not from this change.

The pull's changes are otherwise the same as before.

commented

I fixed the failing check and pushed. src/http/infra_routes.ts imported ../actions/infra.ts twice. I merged machineOf into the first import and dropped the second line, so the duplicate-import rule should now pass.

  • Verified locally: bun x tsc --noEmit is clean, and test/dup-imports.test.ts passes (6 tests).
  • Not run: I did not run the full suite. The forge runs it on this push.
  • Gate: bun scripts/gate.ts --fix changed nothing. It still prints three "one implementation?" similarity notes about infraSnapshot/infraMachine, infraRoutes/forgesRoutes, and a test helper. I left them alone, and they were not part of the failure.

This is a one-line import cleanup, with no behaviour change.

commented

I merged main into the branch and pushed. The only conflict was src/generated/migrations.ts.

I took main's side of that file and regenerated it with bun scripts/own-source.ts. The result contains the infra-snapshot migration alongside the migrations that came in from main.

bun x tsc --noEmit is clean. test/own-source.test.ts, test/infra-snapshot.test.ts and test/dup-imports.test.ts pass (18 tests). I did not run the full suite, so the forge's check on this push is the first full run after the merge.

commented

Everything @sentinel asked for is in and pushed. bun x tsc --noEmit is clean, as are the design lint and the infra-snapshot, pinned-ceiling, dup-imports, own-source and dead-code tests. I didn't run the full suite; the forge's check does that on this push.

  1. Delete needs the forge's name typed. deleteSnapshot now takes the typed text and refuses unless it equals the snapshot's forge name, so the page and the terminal both enforce it.
    • Web: the confirm page asks "Type <name> to continue" on the red button.
    • Terminal: d confirms, then prompts for the name.
  2. Duplicate entry. The repeated DESTRUCTIVE entry in search.ts is removed.
  3. Stuck making rows. At boot, failStaleSnapshots marks any making row failed, with a reason saying the machine was left running. The detached End no longer swallows errors: a thrown error or an !ok result is logged and recorded as an infra.snapshot failed event. A test covers the boot settling.
    • Limit: the machine itself is still never ended after a restart; the row only says so. I chose not to resume the wait, since the process that held it is gone.
    • Check: the failure event goes through app.bus.append with the user id; I didn't confirm that shape against other infra.snapshot payloads. 3b. Ceiling guard. The comment in pinned-ceiling.test.ts now names the five uses, all in infra_snapshot.ts: snapshotKind twice, takeSnapshot, readSnapshot, dropSnapshot. A bare driverOf still fails the pattern.
  4. Hetzner restore. The snapshot offer, each ready machine-disk row (so the terminal too) and docs/features/infra.md now say a restore boots with a new, empty data volume and the old one is not brought back. I did not change the ending page's own "disk is kept" sentence, which is still generic.
  5. Cap. The Snapshots section on the page and the terminal list say when more than 200 exist, through a new snapshotsHidden count on the view.
commented

Follow-up after merge: this pull notes four apply > tests in test/infra-plan.test.ts fail on main when run in the same process as the pinned-* tests. That's an order-dependent failure hiding behind shard layout. If no issue tracks it, open one with the exact repro command and fix the shared state (don't skip or split the files to avoid it).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs