Status (2026-05-21):
packages/runtime/src/currently contains 1,289 Zig source files. Of the audited 1,193-file Bun baseline, 552 files are integrated into Home (~46.3%): Home-import-rewritten, Zig 0.17-clean, build-wired, and tested. Phase 12.2 (JSC bring-up) has reached the M6 milestone — JSON + Promise
- Iterator + Global helpers across 128 files. Phase 12.7 round-15 has top-level
node:*substrate modules forbuffer,stream,fs,events,util,assert,os,url,querystring, andcrypto,process,string_decoder, andtty. End-to-endhome run app.tswaits on the JS-callable JSC bridge to wire up. Detailed per-area status:docs/PARITY-BUN.mdanddocs/PARITY-NODE.md. Live recount:scripts/measure-parity.sh --values.
This package is Home's JavaScript / TypeScript runtime, equivalent to Bun in surface area. Once complete, home run app.ts, home test, home x <pkg>, home build src/index.ts --target=native, home add <pkg>, etc. all work natively, with package management deferring to Pantry (~/Code/Tools/pantry).
- Zig 0.17 dev compatibility is non-negotiable. Every copied file must compile under Pantry-managed
0.17.0-dev.263+0add2dfc4. Bun upstream targets a more recent Zig; some files use APIs that moved between 0.16 → 0.17 (e.g.std.array_list.Managed(T)is 0.17+,std.heap.stackFallbackwas relocated,std.io.fixedBufferStreamwas removed in favor ofstd.Io.Writer.fixed,Child.initwas replaced byprocess.spawn). Files that don't compile under 0.17 must be tracked as integration blockers with a// Zig 0.17 compat: ...note near the blocked import or adapter; they do not count as integrated until the adapter lands and the file is build-wired. - Verify
git -C ~/Code/bun rev-parse HEADmatchesUPSTREAM_SHA.txtbefore copying. If they diverge, rewind Bun or update the SHA in a separate commit. - Rewrite
@import("bun")→@import("home_rt")and everybun.X→home_rt.Xat copy time. No semantic edits in the same commit. - Drop JSC-bridge re-exports (
.toJS,.fromJS,Bun__Xexterns) with a// JSC-bridge X omitted — re-lands in Phase 12.2note. - Every copied file must add at least one inline
test "..."that exercises a method or invariant. - After integrating: run
./pantry/.bin/zig build test --summary allANDhome testin~/Code/Apps/settlers-iii. Both must stay green; commit only if so.
The 2026-05-21 bulk import is deliberately different: it staged the
remaining filtered Bun Zig source in src/ without overwriting
integrated Home ports. Those files are tracked in
DORMANT_BUN_ZIG_IMPORT_2026-05-21.txt as an integration backlog only:
they do not count as ported until they go through the rules above and
are exported, build-wired, and tested.
UPSTREAM_SHA.txt holds the exact Bun commit our copy is anchored against. Today: fd0b6f1a271fca0b8124b69f230b100f4d636af6 (http: port fetch TCP keepalive to on_open in lib.rs).
Per user direction: "build it natively as if it was ours, bc bun is MIT code." Bun is MIT-licensed, so we can copy. The flattening convention:
- Copied subsystem directories live directly under
src/(e.g.src/cli/,src/install/,src/jsc/,src/event_loop/,src/web/,src/home/,src/node/). - The aggregator
src/home_rt.zigre-exports everything so subsystems can@import("home_rt")without coupling to Bun's namespace. - JS-visible APIs go under
Home.*(Bun'sBun.*namespace becomesHome.*for runtime callers); the Zig aggregator stayshome_rtto avoid colliding withhome.runtimewhich is reserved for native Home callers.
bun install is not copied. home add <pkg> / home install / home remove / home update route through the Pantry CLI at ~/Code/Tools/pantry, which is Home's package manager and registry. The Pantry CLI is independently maintained; Home talks to it via a thin Zig shim.
Per user direction (2026-05-17): once the runtime copy is feature-complete, Home must pass the entire Bun test suite, no exceptions. Concretely:
- Copy
~/Code/bun/test/intopackages/runtime/test/bun-corpus/at the pinned SHA. home test packages/runtime/test/bun-corpus/must produce zero failures on macOS, Linux, and the WASM target.- The corpus stays verbatim on disk.
Bun.*APIs are provided by Home's Bun-compat runtime surface at test-runtime, not rewritten at copy time. - Any test that the corpus marks as
bun-only(e.g. macOS Bonjour specifics) is preserved verbatim and must pass — no skipping. - CI gate is
home test packages/runtime/test/bun-corpus/ --bail=0 --reporter=junit --reporter-outfile zig-out/bun-corpus.junit.xml. A regression on any case blocks merge.
This is the hard release gate for Phase 12. Substrate is in place today; the
gate becomes enforceable after Phase 12.2 (JSC bring-up) and Phase 12.8 (test
runner copy). Until then, home test packages/runtime/test/bun-corpus/ must
fail as a native Home gate, not silently delegate to system Bun.
The gate's corpus discovery and test-file classification live in
packages/home_test/src/corpus.zig, which keeps this path inside Home's Zig
packages while the execution engine is still blocked.
src/home_rt.zig— aggregator that re-exports every ported subsystem.src/jsc/— 128 files; Phase 12.2 milestones M1-M6 plus the first nativeJSEvaluateScripthelper and the publicJSObjectMakeDeferredPromisedeferred-promise constructor bridge. Default tests compile the surface; run./pantry/.bin/zig build test -Dfilter=home_rt -Denable_jsc=truefor a live1 + 2evaluation through JavaScriptCore.src/node/— 28 files; Phase 12.7 round-15 (top-levelassert.zig,buffer.zig,crypto.zig,events.zig,fs.zig,os.zig,path.zig,process.zig,querystring.zig,stream.zig,string_decoder.zig,tty.zig,url.zig,util.zig, plus binding/helper files:Stat,StatFS,dir_iterator,fs_events,os_constants,nodejs_error_code,node_fs_constant,node_net_binding,node_error_binding,uv_signal_handle_windows,types,time_like,util/parse_args_utils,assert/myers_diff).src/cli/— destination for Bun'ssrc/cli/command dispatch (Phase 12.10 scaffold landed).src/runtime/bake/— Bake DevServer/HmrSocket lifetime carrier copied from Bun and made Zig 0.17-clean. This covers the deinit counter, active route viewer release, source-map ref release, and active websocket snapshot-before-close invariants; the JS-visibleBun.serve/Bake API is still pending.src/runtime/server/server.zig— server lifecycle carrier for the Bun.serve/Bake teardown gate: pending requests, listener state, and active websockets must all clear before a DevServer is detached and deinitialized.src/install/—home <-> pantryshim. Pantry replacesbun installentirely.src/event_loop/,src/io/,src/async/,src/web/,src/http/,src/runtime/,src/string/,src/threading/,src/css/,src/sql/,src/uws_sys/, … — 85 subsystem directories undersrc/, most populated by wave-19+ grinder rounds (Tier-0 / Tier-1 leaves, no JSC dependency yet).
| Sub-phase | Source under ~/Code/bun/src/ |
Destination | Status |
|---|---|---|---|
| 12.1 | cli/ |
src/cli/ |
🟡 scaffold landed |
| 12.2 | jsc/, bun.js.zig, jsc_stub.zig |
src/jsc/ |
🟡 M6 milestone landed (128 files; JS-callable bridge pending) |
| 12.3 | event_loop/, io/, async/ |
src/event_loop/ |
🟡 substrate landing (~30+ leaves via wave-19+ grinders) |
| 12.4 | resolver/, module_loader.zig |
src/module_loader/ |
🔴 blocked on 12.2 |
| 12.5 | web/, http/, csrf/, dns/ |
src/web/ |
🔴 blocked on 12.3 |
| 12.6 | bun.zig (Home.* surface) |
src/home/ |
🔴 blocked on 12.2 |
| 12.7 | node/ namespace shims |
src/node/ |
🟡 round-15 landed (28 files) |
| 12.8 | test/ runner |
src/test/ |
🔴 blocked on 12.2 |
| 12.9 | Pantry CLI integration | src/install/pantry.zig |
🟡 scaffold in progress |
| 12.10 | CLI surface | src/cli/ |
🟡 scaffold landed |
| 12.11 | Cross-compile + single-file builds | src/build/ |
🔴 not started |
While the JS-callable JSC bridge isn't wired up yet, the Home CLI surface (home run, home test, home add, home x) is exposed today via a delegation shim that calls into pantry / the system Bun runtime. This is intentional scaffolding — every delegation site has a TODO(phase-12-N) marker in src/main.zig so progressive replacement is mechanical.
The runtime package is wired into the Home build. Substrate + JSC milestones M1-M6 currently compile and pass their inline tests; the runtime won't actually run JS / TS until the JS-callable JSC bridge is wired up. Verification today:
./pantry/.bin/zig build --summary all # Pantry Zig 0.17.0-dev.263+0add2dfc4
./pantry/.bin/zig build test --summary all # substrate + JSC inline testsTo recount the port progress in one shot:
scripts/measure-parity.sh --values # raw counts (RUNTIME_FILES, JSC_FILES, NODE_FILES, …)
scripts/measure-parity.sh --markdown # README headline-numbers table block
scripts/measure-parity.sh --diff # exits non-zero if README has gone stale