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

One button moves a browser forge to a shared server forge by copying its files #17312

opened this

Merged 29h 31m ago, live in production

A browser forge's SQLite file and git data can now be copied to a shared forge on the server, and the shared forge shows the same issues. The in-browser forge isn't in this repo yet, so there is no button on its own page. /forges/move-in is the form that button would post.

Notes

opened this

A browser forge's SQLite file and git data can now be copied to a shared forge on the server, and the shared forge shows the same issues. The in-browser forge isn't in this repo yet, so there is no button on its own page. /forges/move-in is the form that button would post.

The tests I ran pass: test/move-in.test.ts plus the neighbouring forges, route, body-cap, unused-export, feature-orphans, own-source and hollow suites. bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean. I did not run the full suite. The forge's check runs it on this push.

What changed

  • Page: /forges/move-in is linked from /forges and is open to admins who are people. Before any file is chosen it says what the move costs and does:
    • the shared plan's price a month;
    • the 50 MiB of disk it holds;
    • that it sleeps and wakes on the next visit;
    • that its address is new;
    • that the browser's copy stays.

    Then you choose a name, forge.db, and optionally a repos.tar.gz. Check reads the files and reports what they hold and cost without keeping anything. Move does the copy.

  • Core, src/spawn/move_in.ts:
    • The copy is checked first. The name must be free and the files within the shared forge's disk share. The database must be a SQLite file that passes its integrity check, and the tar must hold only plain files and folders with relative names. A file that fails keeps nothing and says why.
    • The files go under children/<bodyId> unchanged. The shared forge's own reader must then report the same issue, pull, repo and people counts as the file, or everything is removed.
    • The forge is recorded as hosted on the shared plan, and one forge.moved_in event keeps the byte counts, the SHA-256 of each file and the counts as the receipt.
  • Terminal: key i on the Forges screen shows the same cost rows. The upload itself stays a browser form.
  • Tests: test/move-in.test.ts builds a real browser forge with three issues and a repo, moves its files, and checks the shared forge reads three issues from the same bytes. It also covers the page (same-origin check, check-only, receipt), the refusals, and the terminal.
  • Reused: tar from archive.ts, childCounts, forgeNameVerdict, quotaRefusal, densityOf, putEntitlement and tellPlan. I added recordMovedIn to src/actions/spawn.ts to write the ledger.
  • Wiring: a moveIn body cap, the event registered, the route marked admin, and a how-to at docs/features/browser-forge-move.md.

Left out

  • The move does not start the shared forge's process. The first visit wakes it, as with any shared forge.
  • Files over 32 MiB together are refused. The form is read whole to check it, so the cap is the same as a Drop form's; a streamed upload would lift it toward the shared forge's 50 MiB.
  • There is no API or MCP route, because a file doesn't fit a tool call.
  • The browser forge's sign-in sessions aren't carried over, since the address is new.
  • The database must be checkpointed (no -wal file beside it) before it's sent.

Try it: open /forges/move-in on the preview as an admin and read the cost. Then choose a forge.db, press Check, then Move it to a shared forge.

[
  {"go": "/forges", "look": "The line under the heading, 'Move in a forge that runs in a browser'", "expect": "It links to /forges/move-in"},
  {"go": "/forges/move-in", "look": "The cost sentence and rows above the form", "expect": "The shared plan's price, 50 MiB of disk, 'nothing is converted', 'nothing is charged before you press the button'"},
  {"go": "/forges/move-in", "look": "Choose a name and a forge.db, press 'Check what it would hold and cost'", "expect": "The page lists the issue, pull, repository and people counts and the size; no forge is created"},
  {"go": "/forges/move-in", "look": "Press 'Move it to a shared forge' with a valid forge.db", "expect": "A receipt line with the same issue count, a new address, and the forge appears on /forges as shared"}
]

Closes #16862

7 earlier comments
commented

A browser forge's SQLite file and git data can now be copied to a shared forge on the server, and the shared forge shows the same issues. The in-browser forge isn't in this repo yet, so there is no button on its own page. /forges/move-in is the form that button would post.

The tests I ran pass: test/move-in.test.ts plus the neighbouring forges, route, body-cap, unused-export, feature-orphans, own-source and hollow suites. bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean. I did not run the full suite. The forge's check runs it on this push.

What changed

  • Page: /forges/move-in is linked from /forges and is open to admins who are people. Before any file is chosen it says what the move costs and does:
    • the shared plan's price a month;
    • the 50 MiB of disk it holds;
    • that it sleeps and wakes on the next visit;
    • that its address is new;
    • that the browser's copy stays.

    Then you choose a name, forge.db, and optionally a repos.tar.gz. Check reads the files and reports what they hold and cost without keeping anything. Move does the copy.

  • Core, src/spawn/move_in.ts:
    • The copy is checked first. The name must be free and the files within the shared forge's disk share. The database must be a SQLite file that passes its integrity check, and the tar must hold only plain files and folders with relative names. A file that fails keeps nothing and says why.
    • The files go under children/<bodyId> unchanged. The shared forge's own reader must then report the same issue, pull, repo and people counts as the file, or everything is removed.
    • The forge is recorded as hosted on the shared plan, and one forge.moved_in event keeps the byte counts, the SHA-256 of each file and the counts as the receipt.
  • Terminal: key i on the Forges screen shows the same cost rows. The upload itself stays a browser form.
  • Tests: test/move-in.test.ts builds a real browser forge with three issues and a repo, moves its files, and checks the shared forge reads three issues from the same bytes. It also covers the page (same-origin check, check-only, receipt), the refusals, and the terminal.
  • Reused: tar from archive.ts, childCounts, forgeNameVerdict, quotaRefusal, densityOf, putEntitlement and tellPlan. I added recordMovedIn to src/actions/spawn.ts to write the ledger.
  • Wiring: a moveIn body cap, the event registered, the route marked admin, and a how-to at docs/features/browser-forge-move.md.

Left out

  • The move does not start the shared forge's process. The first visit wakes it, as with any shared forge.
  • Files over 32 MiB together are refused. The form is read whole to check it, so the cap is the same as a Drop form's; a streamed upload would lift it toward the shared forge's 50 MiB.
  • There is no API or MCP route, because a file doesn't fit a tool call.
  • The browser forge's sign-in sessions aren't carried over, since the address is new.
  • The database must be checkpointed (no -wal file beside it) before it's sent.

Try it: open /forges/move-in on the preview as an admin and read the cost. Then choose a forge.db, press Check, then Move it to a shared forge.

[
  {"go": "/forges", "look": "The line under the heading, 'Move in a forge that runs in a browser'", "expect": "It links to /forges/move-in"},
  {"go": "/forges/move-in", "look": "The cost sentence and rows above the form", "expect": "The shared plan's price, 50 MiB of disk, 'nothing is converted', 'nothing is charged before you press the button'"},
  {"go": "/forges/move-in", "look": "Choose a name and a forge.db, press 'Check what it would hold and cost'", "expect": "The page lists the issue, pull, repository and people counts and the size; no forge is created"},
  {"go": "/forges/move-in", "look": "Press 'Move it to a shared forge' with a valid forge.db", "expect": "A receipt line with the same issue count, a new address, and the forge appears on /forges as shared"}
]
commented

I merged main into the branch and pushed it. The only conflict was the key list in src/tui/screens/forges.ts.

  • What conflicted: main moved "move to a machine" from g to M, and this branch had added i for "move in a browser forge".
  • How I resolved it: I kept both changes, so M moves to a machine and i moves in a browser forge. The g key still shows a hint pointing people to M.
  • Checks: bun x tsc --noEmit printed nothing. I ran 125 tests across 24 forge-related files: 123 passed, 2 were skipped and none failed, including test/move-in.test.ts and test/tui-forges.test.ts. I did not run the full suite. The sandbox blocked some network connections to *.localhost hosts during the run, and the tests still passed.
  • Gate: bun scripts/gate.ts --fix left nothing to commit.
commented

The three failing checks passed in my run after the fix, and I've pushed it. I ran only those three test files, not the full suite. The new files from this pull weren't registered in three places that the repo's rule tests read.

  • Design audit: I added /forges/move-in to docs/design/audit.md. The test counts the page routes against the audit's entries, and that page had none.
  • Worker database opens: I listed src/spawn/move_in.ts in test/worker-database-opens.test.ts. It opens one database read-only to count rows, on the serving thread. The Worker src/engine/worker.ts imports it, but no Worker calls it.
  • Module state: I added src/spawn/move_in.ts:busy to test/module-state.baseline.txt. That set stops the same forge being moved in twice at once. It is a module-level Set, which the rule flags.

bun scripts/gate.ts --fix left nothing to commit.

commented

This pull lets an admin move a browser forge onto this forge by copying its SQLite file and git data. The last check failed because the forges page went over its first-view budget, and that is now fixed.

What changed

  • A browser forge now moves to a shared forge from /forges/move-in. The page states the cost first, the copy runs on one button, and a receipt follows. It is built in src/spawn/move_in.ts and src/web/pages/forge_move_in.ts, with its terminal screen under src/tui/screens/forges.ts and its how-to in docs/features/browser-forge-move.md.
  • The fix: my extra "Move in a forge that runs in a browser" line pushed the /forges page to 39 words and 6 blocks, against budgets of 30 and 5. The link is now a small "Move in" button beside "New forge", and the page subtitle is shortened to "Each forge you sent, and what runs there." Both attention-budget widths for /forges now pass.

What I did not do

  • I did not raise the budget.
  • I did not put the link on the new-forge form. That form is large and would risk its own budget.

Checks run

  • bun test on the attention, move-in, forges, TUI-forges, design and unused-exports tests passes, 200 tests in the forges, TUI and design set, 0 failures.
  • bun x tsc --noEmit is clean.
  • scripts/design-lint.ts is clean.
  • scripts/gate.ts --fix ran and left nothing to commit.
  • The commit line names the issue (#16862).
  • Some sandbox network denials appeared during the test run (hosts like moved--forge.test). They did not fail anything.

To try it Sign in as an admin, open /forges, click "Move in", and send a name, a database and optionally a repos/ .tar.gz.

[{"go":"/forges","look":"the header actions","expect":"a small 'Move in' button sits beside 'New forge'; no extra line under the header"},{"go":"/forges/move-in","look":"the page","expect":"the cost is stated before the one button that copies the files"}]

🤖 Generated with Claude Code

commented

Still red on current main: a repeat on the same two heads does not run the comparison again. Fix it and push.

commented

The one failure this pull caused is fixed and pushed. tsc is clean, and gate.ts --fix printed nothing and left nothing to commit. I did not run gate.ts --explain. The pinned-forge, retention and upstream-counts tests passed for me, so I didn't change anything for them. I haven't seen the forge's check on the new push.

The fix. The new GET /forges/move-in page didn't report session and render in its Server-Timing header. test/server-timing-sweep.test.ts caught it. forgeMoveInForm in src/web/pages/forge_move_in.ts now notes both phases, the same way allFlowsPage does. The test passes.

The other nine failures. The rest of the check's failures didn't reproduce:

  • The pinned-forge tests (test/pinned-forge.test.ts), the retention-samples test and the upstream-counts test all passed when I ran those files.
  • The check's own log said test/upstream-counts.test.ts was green on main in 3 runs. That reads like a problem with the full run under load, not with this change, but I haven't shown that.
  • If they fail again on this push, send me the log.

I left everything else in the move-in change as it was.

commented

This round meets all seven findings, except that the terminal still can't move a forge and the browser button and immediate start still aren't built. I ran test/move-in.test.ts and test/tui-forges.test.ts (26 pass) and tsc --noEmit (clean). gate --fix and design-lint found nothing to change. I did not run the full suite; the forge's check does that.

  • Gzip bomb (1, HIGH): plainTar now sums the expanded sizes from the tar -tvzf listing. It refuses when they pass SHARE_BYTES minus the database size, before anything is written. A new test packs 60 MiB of zeros into a gzip under 1 MiB and checks it is refused with "expands past".
  • Name validation (5): moveIn checks CHILD_NAME before it builds bodyId or dir. The test passes ../x and it is refused.
  • Limits (4): the Disk row now says 50 MiB for the shared forge and that the form takes 32 MiB together. I removed the separate "Up to N MiB" line.
  • Design (6): the page no longer repeats the cost sentence above the rows. The price and "nothing is charged before the button" are folded into the Plan row. The two file inputs use field with type: "file".
  • Docs (7): I fixed the capital and noted the 32 MiB form limit and the expanded-size check.

Two points where I did not do what was asked:

  • Terminal (3): I took the "say it plainly" option. The terminal screen and the how-to now say it is read-only for this feature, because the upload is a browser's file form. The terminal screen also drops the cost sentence and shows the rows only. I did not add a server-path import, since that is a new input surface and I'd want its own review.
  • Browser side (2): the in-browser forge is not in this repository, so its button (checkpoint, tar repos/, post to /forges/move-in) and an immediate start of the shared process are not built. The server still wakes the process on the first visit. I filed that as #17377. Box 1 of the issue stays open until it lands.

I did not touch the move_in baseline or design-audit lists. The test for exports with no caller is untested here, but I added no new exports.

[
  {"go": "/forges/move-in", "look": "the rows (Plan, Disk, Copied, Then, Stays) and two file fields styled like the Name field", "expect": "no repeated cost sentence; Disk says 50 MiB for the shared forge and 32 MiB for this form"},
  {"go": "/forges/move-in (submit a gzip of a large zero file with a valid database)", "look": "the result page", "expect": "refused: the git data expands past what a shared forge holds; nothing kept"}
]
commented

Left #16862 open: 1 unticked item remain (The browser forge's page has one button that uploads its SQLite file and git data and starts it as a shared forge; nothing is exported to another format.).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs