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

A hosted forge's database and git stream to its snapshot bucket every five minutes, and a restore from the stream boots and matches #16983

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Each hosted forge's SQLite and git now stream to its snapshot bucket every five minutes, and a restore from that stream boots and matches. This is #16887's stream work with its System screen change left out. No file under src/web/ changes.

Notes

opened this

Each hosted forge's SQLite and git now stream to its snapshot bucket every five minutes, and a restore from that stream boots and matches. This is #16887's stream work with its System screen change left out. No file under src/web/ changes.

I ran tsc, snapshot-stream, unused-exports, job-slices and the docs tests; all pass. I did not run the whole suite.

What changed

  • Stream pass: takeSnapshot takes a stream option. Its manifest goes to stream/<name>/manifest.json and replaces the last one, so it doesn't count against the 14 nightly snapshots. startSnapshots runs a pass every five minutes (streamEveryMs), and streamNow() runs one on request. Passes and snapshots run one after another.
  • Chunk sweep: sweepChunks keeps every chunk a stream manifest names. A test fails without that.
  • Lag: src/snapshot/stream.ts keeps each forge's last whole pass and last failure in snapshot/stream.json. streamLag(dataDir) is the one function a page can read.
  • Restore: bun run src/snapshot/restore.ts stream <dir> --forge <name>. test/snapshot-stream.test.ts restores a streamed forge into another directory, opens it, and compares its users, repositories and commits.
  • Egress: unchanged. The stream uses the existing snapshot destination, so there is no new host.

What I dropped from #16887

  • The System page section, the terminal System screen, the MCP system stream kind, and the words and summary helpers that only they called. No page, screen or tool shows the stream yet.
  • Because nothing calls streamLag yet, I added it to scripts/unused-exports-allow.json. The commit carries No door: for the same reason.
  • docs/features/hosted-stream.md now says no page shows the stream yet.

Reused: takeSnapshot, copyHosted, hostedSources, the chunk store and restoreHosted. I didn't run similar.ts. gate.ts flags keepJson as 0.56 like writeServing; it's advisory, exits 0, and the two use different path layouts.

Not done: the off-box mirror still copies nightly snapshots only. The stream covers hosted forges, not the parent forge.

Try it: set the S3_* or FORGE_SNAPSHOT_DIR variables as in docs/RESTORE.md, then run bun test test/snapshot-stream.test.ts. To restore one forge by hand, run the restore command above into an empty directory.

Closes #16977

3 earlier comments
commented

Each hosted forge's SQLite and git now stream to its snapshot bucket every five minutes, and a restore from that stream boots and matches. This is #16887's stream work with its System screen change left out. No file under src/web/ changes.

I ran tsc, snapshot-stream, unused-exports, job-slices and the docs tests; all pass. I did not run the whole suite.

What changed

  • Stream pass: takeSnapshot takes a stream option. Its manifest goes to stream/<name>/manifest.json and replaces the last one, so it doesn't count against the 14 nightly snapshots. startSnapshots runs a pass every five minutes (streamEveryMs), and streamNow() runs one on request. Passes and snapshots run one after another.
  • Chunk sweep: sweepChunks keeps every chunk a stream manifest names. A test fails without that.
  • Lag: src/snapshot/stream.ts keeps each forge's last whole pass and last failure in snapshot/stream.json. streamLag(dataDir) is the one function a page can read.
  • Restore: bun run src/snapshot/restore.ts stream <dir> --forge <name>. test/snapshot-stream.test.ts restores a streamed forge into another directory, opens it, and compares its users, repositories and commits.
  • Egress: unchanged. The stream uses the existing snapshot destination, so there is no new host.

What I dropped from #16887

  • The System page section, the terminal System screen, the MCP system stream kind, and the words and summary helpers that only they called. No page, screen or tool shows the stream yet.
  • Because nothing calls streamLag yet, I added it to scripts/unused-exports-allow.json. The commit carries No door: for the same reason.
  • docs/features/hosted-stream.md now says no page shows the stream yet.

Reused: takeSnapshot, copyHosted, hostedSources, the chunk store and restoreHosted. I didn't run similar.ts. gate.ts flags keepJson as 0.56 like writeServing; it's advisory, exits 0, and the two use different path layouts.

Not done: the off-box mirror still copies nightly snapshots only. The stream covers hosted forges, not the parent forge.

Try it: set the S3_* or FORGE_SNAPSHOT_DIR variables as in docs/RESTORE.md, then run bun test test/snapshot-stream.test.ts. To restore one forge by hand, run the restore command above into an empty directory.

commented

The check failed because test/snapshot-stream.test.ts ran over the 2 s per-test budget (3.10 s under full-suite load). I added that file to SLOW in scripts/gate.ts and pushed.

  • Cause: the failing test, "the service streams on its own timer and on request, never beside a snapshot", takes a real stream pass and a real snapshot of a forge that has a database. Each takes about 1 s, so it can't fit in 2 s under load. It came from #16858, not from this pull's change.
  • Fix: the SLOW entry gives that reason and cites #16977, as the gate requires. I didn't speed the test up, because the work it does is the point of the test.
  • Not changed: test/spawn-archive-dash-id.test.ts was also named in the check summary, at 2.03 s, just over the budget. It isn't in this change and I left it alone. If it fails again it will need its own SLOW entry or a faster test.
  • Local checks: bun x tsc --noEmit is clean, and the gate tests (test/gate*.test.ts, 93 tests) pass. The stream test file passes alone (6 tests, 17 s). I didn't run the full suite; the forge's check does that on this push.
commented

A forge the copy refuses no longer replaces the last good stream manifest, and the stream now reports it as a failure. bun test test/snapshot-stream.test.ts passes (7 tests) and tsc is clean. I did not run the whole suite, since the forge runs the full check on push.

  • Refused copy (src/snapshot/snapshot.ts). In stream mode, takeSnapshot now throws before the manifest put if a hosted entry carries why. The previous stream/<name>/manifest.json stays as it was.
  • Pass result (src/snapshot/stream.ts). streamPass also treats hosted[0].why on a take's result as a failure, so any take that returns a refused forge instead of throwing is caught. The forge keeps its old at, and error is set. streamLag therefore shows the forge as late, not fresh.
  • Restore message (src/snapshot/restore.ts). The "holds no hosted forges" message now reads "the stream of <forge>" when restoring from the stream.
  • New test. It first takes a good pass. It then runs a second pass through the hostedCopy seam with the copy refused, and shows three things:
    • the manifest is byte-identical to the good one;
    • streamLag shows the old at plus the error;
    • a restore from the stream still boots with its repo.

Nothing under src/web/, the terminal or MCP changed, so the commit line says No door: the stream has no page, terminal or MCP change.

gate --explain still prints one similarity note, keepJson vs writeServing. I did not touch either, so I left it.

commented

I merged main into the branch and pushed it; the only conflict was in scripts/unused-exports-allow.json.

Both sides had added entries at the end of the allow list. I kept all of them: this branch's streamLag and the three that came in from main (forgetMachines, registerMachine, forgetRoutes). The file still parses as JSON.

bun x tsc --noEmit is clean. I ran test/unused-exports.test.ts, test/job-slices.test.ts and test/snapshot-stream.test.ts, and all 13 tests pass. scripts/fast.ts named 3,805 test files, which is too broad to run here. The forge's full check on the push is the verdict for the rest.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs