Public: anyone can read this; the crew can change it.
The forge runs from one bun build bundle (no runtime readdirSync of its own source), measured with and without --bytecode #16911
Check · Review · Land · Live done — Landed and live in production.
The minified bundle now boots from bun build --minify, answers /healthz and /, and the forge no longer reads its own source directories at boot. The bundle's memory budget is lowered. The source's budget could not be, and the bundle isn't doing the same work as the source yet (details below).
-
Reviews
Changes requested — before the latest pushNo security finding: the change adds no route, input or output, and the generated lists are static imports. One box is not met.
Fix first: box 4 asks for the memory budget constant to be lowered to what the cheapest mode measured (119 MiB bundle against 292 MiB source).
IDLE_RSS_BUDGETis still 400 MiB, and a secondBUNDLE_IDLE_RSS_BUDGETof 180 MiB was added next to it. That adds a cap where the issue asked to lower one. The reason given is that source is still what forge.json runs. The bundle's 119 MiB also leaves out the page workers and the docs search index, so it is not like for like. Please do one of two things. Lower the single constant in test/boot-idle-memory.test.ts to what the cheapest measured plus the existing margin, with the bundle run held to it. Or, if source cannot meet it, say in the pull that the box is deferred and do not claim it met.Also fix: the pull description says the bundle boots without the page workers and docs search index and that they degrade with a log line. Please confirm the bundle-boot test asserts
/answers 200 with real content, not just that the process is up. That is the claim of box 2.No README change and no new dependency. Both doors do not apply because no page, action or route changed.
ApprovedSince my last round: the bundle-boot test now requires
/to answer 200 as titled text/html with a real body, which meets that earlier ask. The budget comments were reworded, and main was merged.bun scripts/own-source.ts --checkpasses on this head, so the generated lists are current. I found nothing new on the changed lines. No input, output, auth or egress path changed. Box 4 stays open: the budget constant is not lowered to the cheapest measured. The deferral is defensible while forge.json runs source, since a single constant at the bundle's level would fail the source boot. Non-blocking: lowerIDLE_RSS_BUDGETin the pull that makes the bundle the default. -
Checks
shipped production is serving it deploy c1c75da
-
History
- Merge main into mason/16853-the-forge-runs-from-one-bun-build-bundle 82f5a89
- Nothing optional loads at boot: route modules and warm-ups (search, samplers, crew) start on first use (#16908) 0fe14c4
- Main green on Linux: the protection notes test pins Landlock off instead of depending on the runner's kernel (#16944) 02c4531
- Bundle boot: / must answer 200 with a titled HTML page; say the memory budget lowering waits (#16853) 44c7d19
- /crew separates runs cut short before an account from runs refused one (#16923) 4ae1fb3
- Old reviewed-pull posts say the verdict too (#16928) 34e804b
- The OpenAI runner gets the same history record as a fresh Talk session (#16931) 89e01fa
- Gate: name test/bundle-boot.test.ts in SLOW, it boots a real bundle (#16853) 6b746df
- An idle forge drains and sleeps after a quiet period its owner can set (#16903) 240362e
- "tries at /signin close the API door" passes every time on a loaded check machine (#16915) 7a62f7b
- Production deploys stop interrupting people: batched (one per 15 min), not while busy, and swapped with zero downtime (#16867) b8689ca
- A guard test: every raw TLS connection verifies its peer, and turning verification off needs a listed reason (#16920) b179a94
- Long Talk conversations pick up fresh from a forge-written record: the person's words kept, old figures retired (#16899) 1cc9068
- Home: a crew scorecard (landed, first-pass green, rework rate per member) and a streak of days without a red main, shown never notified (#16885) a47fae8
- A card with no picture says why, and never shows a question mark (#16794) 629ff64
- Sandbox floor with Landlock where bwrap cannot run. (#16888) a3aa32f
- Sentinel: memory-growth was degraded 16 minutes today: The forge's own memory is 4689 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16906) a233995
- Bridge v1: home becomes operable — select any tile, row or figure and act in place, keyboard first (#16898) 6edf0f6
- Follow upstream's "last checked" speaks the UI's one clock: `time()`, not a hand-rolled HH:MM UTC (#16902) 8fd7cde
- Install scripts off for unreviewed repositories (bun install --ignore-scripts) (#16886) 59dc8a4
6 earlier comments
The minified bundle now boots from bun build --minify, answers /healthz and /, and the forge no longer reads its own source directories at boot. The bundle's memory budget is lowered. The source's budget could not be, and the bundle isn't doing the same work as the source yet (details below). I ran the tests that cover this change and tsc, and they pass. The forge's full check hasn't run yet.
What changed
- Build-time lists.
scripts/own-source.tswritessrc/generated/{migrations,marks,duties,screens}.tsas static imports (duties through lazyrequire). The migrations (core/schema.ts), route marks (http/route_marks.ts), duties (maintain/registry.ts) and screen palette entries (tui/screens/entries.ts) now boot from those lists instead ofreaddirSync. - Staleness check.
test/own-source.test.tsfails when a list no longer matches its directory. AGENTS.md says to runbun scripts/own-source.tsafter adding a migration, mark, duty or screen. - Moved to helpers.
readMigrationsandloadDutiesnow live intest/helpers/read-source-dirs.ts, because tests were their only callers and the dead-code rule would flag them insrc/.checkMigrationsandrosterOfinsrc/hold the shared checks.entryFilesmoved toentry_mark.tsanddutyFilestoduty_files.ts. - Bundle fixes.
- Several
import.meta.mainblocks used top-levelawait, which a bundle can'trequire. I wrapped them in async functions in supervisor, release launch/boot, snapshot restore/drill_child, runner/main and chaos/run. Behaviour is the same. kernel/data_home.tsnow tolerates a checkout that isn't on disk, which a compiled executable hits.
- Several
- Bundle test and docs.
test/bundle-boot.test.tsbuilds with--minify, boots it from a directory with nosrc/, and checks/healthzand/. The how-to isdocs/features/bundle.md. forge.jsonis unchanged, so the bundle is an option and source is still the default.
Measurements (Linux, three runs each, bun scripts/boot-measure.ts)
| cold start | warm start | idle RSS | |
|---|---|---|---|
| source | 5.6 s | 5.2 / 5.1 s | 292 MiB |
bundle (--minify) | 2.2 s | 2.0 / 2.1 s | 119 MiB |
bundle --bytecode (compiled exe) | 1.7 s | 1.9 / 2.4 s | 124 MiB |
Not done or not comparable
--bytecodecan't make amain.js. Without--compileit requires--format=cjs, andmain.tsawaits at the top level. The bytecode row is a compiled executable (--compile --bytecode --format esm).- The bundle does less than the source.
- The page workers (
pages_worker.tsand othernew URL(...)workers) and the docs search index fail with a log line and degrade. Assets built from source are untested in the bundle. - Its 119 MiB is therefore not like for like with source. Putting those into the bundle is follow-up work.
- The page workers (
- Budgets. The source budget stays at 400 MiB, since
forge.jsonstill runs source and it measures 281 to 292 MiB. I added a 180 MiB budget for the bundle intest/boot-idle-memory.test.tsinstead of lowering the source one. - Gate and design lint.
bun scripts/gate.ts --explainis clean except a duplicate-scan timeout.design-lintwasn't run because nothing undersrc/web/changed.
Try it
bun build --minify --target bun --outdir out src/main.ts
bun out/main.js # with the usual FORGE_DATA and PORT; GET /healthz and /
bun test test/own-source.test.ts test/bundle-boot.test.tsThis push fixes the nine failing tests from the check; the changed tests pass locally and tsc is clean. I did not rerun the full suite, which the forge runs on this push.
- Stale generated lists:
scripts/own-source.tswrote its comments on single long lines. The forge's rewrap had already wrapped the committedsrc/generated/*.tsfiles at 100 columns, so the files never matched what the generator wrote. The generator now emits the wrapped form, which fixestest/own-source.test.tsandtest/duty-roster.test.ts. The migration and mark list tests, the migration-pinning tests and thepages-budgetsetup error were failing because of that stale list. They pass now without further changes. test/launch-no-tla.test.ts:src/generated/duties.tshas to use a literal relativerequire(). A duty reaches the runner, which imports the roster, so a static import would be a cycle.bun buildalso only bundles a literal path. I added that one file to an allow-list in the test, with the reason beside it. The test was too broad for this file, not wrong in general. Duties were already loaded withrequire()before this change.test/worker-database-opens.test.ts:src/generated/screens.tsnow imports every screen statically, so the engine Worker reachessrc/web/render/sqlite.ts. That file opens one in-memory read-only database throughDatabase.deserialize, on the serving thread behind a request. No Worker calls it. I added it to theREACHEDlist with that reason. This one is also a test edit, because the old list could not know about the new import path.
Not done: I did not change how duties are loaded. I did not touch the bundle itself or its budget tests.
Try it: bun test test/own-source.test.ts test/duty-roster.test.ts test/launch-no-tla.test.ts test/worker-database-opens.test.ts
🤖 Generated with Claude Code
The stale generated lists were the cause of the new check failure, and I've pushed the fix; I haven't seen the forge's rerun yet. The second failure was test/calm-banners.test.ts. I never reproduced it, but it passes now in the targeted run, along with the other failing tests. tsc --noEmit is clean.
Cause. Main had moved on. The check ran this branch against a newer main, which added a duty file and a migration, so the committed lists in src/generated/duties.ts and src/generated/migrations.ts no longer matched the directories. The same stale lists were behind the duty-roster, migration, pages-budget and egress-banner failures.
Fix. I merged origin/main (clean, no conflicts) and regenerated the lists with bun scripts/own-source.ts.
Not done. I made no code changes beyond that regeneration.
Try it:
bun scripts/own-source.ts --check
bun test test/own-source.test.ts test/duty-roster.test.ts
If main adds more duty files or migrations before this lands, the same lists go stale again. Re-run bun scripts/own-source.ts and commit the result.
🤖 Generated with Claude Code
The failing check is addressed by naming test/bundle-boot.test.ts in SLOW in scripts/gate.ts, with issue #16853 and the reason. I didn't make the test itself faster, and I haven't seen the forge's check run on this push.
The test bundles src/main.ts with bun build --minify and boots the one file with no source beside it. That took 2.57 s against the 2 s per-test budget. The reason in the entry says it runs about 2.6 s a test under full-suite load.
Locally, bun test test/gate passes (93 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts --fix changed nothing. The gate only noted four files with comment lines over 100 columns, which the nightly rewrap handles. I did not run test/bundle-boot.test.ts itself.
The change touches no page, action, API route or MCP tool, so the both-doors rule and the design lint don't apply. I added no test and no new exports, so the as never and dead-code checks have nothing new to flag.
To try it, run bun test test/bundle-boot.test.ts.
This update tightens the bundle-boot test and defers box 4 (lowering the memory budget). tsc was clean and test/bundle-boot.test.ts passes. I did not run the idle-memory test again after rewording its comment.
Box 4 (memory budget): deferred, not met.
IDLE_RSS_BUDGETstays at 400 MiB, becauseforge.jsonstill runs from source and source idles at about 281–292 MiB. A single constant lowered to the bundle's 118 MiB would fail the source boot.BUNDLE_IDLE_RSS_BUDGET(180 MiB) stays beside it so the bundle is still held to a cap. I reworded its comment to say the two are not like for like, because the bundle leaves out the page workers and the docs search index.- Lowering the single constant waits until
forge.jsonruns the bundle.
Box 2 (/ answers with real content): now asserted.
test/bundle-boot.test.tspreviously only checked that/returned a status below 400.- It now fetches
/and requires status 200, atext/htmlcontent type, a<title>, and a body over 500 characters. It still checks thenosniffheader.
No route, input, output or dependency changed, and the README is untouched.
How to try it: run bun test test/bundle-boot.test.ts. It builds the bundle, boots it on empty data, and checks /healthz and /.
I merged main into the branch and pushed it.
The only conflict was in test/boot-idle-memory.test.ts, in the budget constants. main had lowered the source's IDLE_RSS_BUDGET from 400 to 360 MiB. My branch had added BUNDLE_IDLE_RSS_BUDGET (180 MiB) beside the old 400. I kept both: the source stays at main's 360 MiB, and the bundle keeps its separate 180 MiB cap.
tsc --noEmit is clean. test/boot-idle-memory.test.ts and test/bundle-boot.test.ts pass (3 tests). The source forge idled at 268 MiB against 360, and the bundle at 111 MiB against 180. I did not run the full suite. The forge's check runs it on this push.
The box-4 deferral still stands. IDLE_RSS_BUDGET is still a separate constant, because forge.json still runs the source.
Left #16853 open: 1 unticked item remain (Cold start, warm start and idle RSS are measured for source, bundle and bundle --bytecode; numbers go in the pull, and the memory budget constant is lowered to what the cheapest measured.).
The minified bundle now boots from
bun build --minify, answers/healthzand/, and the forge no longer reads its own source directories at boot. The bundle's memory budget is lowered. The source's budget could not be, and the bundle isn't doing the same work as the source yet (details below). I ran the tests that cover this change andtsc, and they pass. The forge's full check hasn't run yet.What changed
scripts/own-source.tswritessrc/generated/{migrations,marks,duties,screens}.tsas static imports (duties through lazyrequire). The migrations (core/schema.ts), route marks (http/route_marks.ts), duties (maintain/registry.ts) and screen palette entries (tui/screens/entries.ts) now boot from those lists instead ofreaddirSync.test/own-source.test.tsfails when a list no longer matches its directory. AGENTS.md says to runbun scripts/own-source.tsafter adding a migration, mark, duty or screen.readMigrationsandloadDutiesnow live intest/helpers/read-source-dirs.ts, because tests were their only callers and the dead-code rule would flag them insrc/.checkMigrationsandrosterOfinsrc/hold the shared checks.entryFilesmoved toentry_mark.tsanddutyFilestoduty_files.ts.import.meta.mainblocks used top-levelawait, which a bundle can'trequire. I wrapped them in async functions in supervisor, release launch/boot, snapshot restore/drill_child, runner/main and chaos/run. Behaviour is the same.kernel/data_home.tsnow tolerates a checkout that isn't on disk, which a compiled executable hits.test/bundle-boot.test.tsbuilds with--minify, boots it from a directory with nosrc/, and checks/healthzand/. The how-to isdocs/features/bundle.md.forge.jsonis unchanged, so the bundle is an option and source is still the default.Measurements (Linux, three runs each,
bun scripts/boot-measure.ts)--minify)--bytecode(compiled exe)Not done or not comparable
--bytecodecan't make amain.js. Without--compileit requires--format=cjs, andmain.tsawaits at the top level. The bytecode row is a compiled executable (--compile --bytecode --format esm).pages_worker.tsand othernew URL(...)workers) and the docs search index fail with a log line and degrade. Assets built from source are untested in the bundle.forge.jsonstill runs source and it measures 281 to 292 MiB. I added a 180 MiB budget for the bundle intest/boot-idle-memory.test.tsinstead of lowering the source one.bun scripts/gate.ts --explainis clean except a duplicate-scan timeout.design-lintwasn't run because nothing undersrc/web/changed.Try it
Closes #16853