Repository navigation
refactor(hosts): run the host update worker as one Bun bundle - #31
Conversation
The daemon bundled nothing: copyHostWorkerSources copied update-worker.ts and every module it imports as rewritten .mts files, and workerRuntime picked the lifecycle modules at runtime. Every tau process runs on Bun now, so the daemon builds one self-contained worker.mjs with Bun.build (buildHostUpdateWorker), as self-update.ts does for the server worker, and the worker imports its lifecycle modules statically. Tests that swapped a lifecycle module beside the copy now swap it in the bundle through a build plugin. Closes #23
- Bun.build throws a bare "Bundle failed" by default; build with throw: false so the failure names its cause (host and server workers). - The worker calls its lifecycle functions directly: the RUNTIME object and its parameters only served the runtime module choice. - Tests: the health-window stand-in proves it ran, and the bundle check also refuses require() and any path into the checkout.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Closes #23.
The daemon no longer copies the host update worker's sources. Before,
copyHostWorkerSourcescopiedupdate-worker.tsand every module it imports into the attempt directory as rewritten.mtsfiles, andworkerRuntimechose at runtime which copy of the lifecycle modules to load. Every tau process runs on Bun now, so:buildHostUpdateWorker(lib/hosts/updates.ts) builds one self-contained<attempt>/worker.mjswithBun.build({ target: "bun" }), mode 0600. This is howself-update.tsalready builds the server worker. It imports only builtins, which a test checks. A compiled binary still runs its own copy ashost-update-workerand never builds.upgrade-processandprocess-identitydirectly. The runtime module choice, theRUNTIMEobject and its parameters are gone.throw: false, so a build failure names its cause instead of Bun's bare "Bundle failed".worker.mjswith the copied runtime..mtstrick did, includingupgrade-process's own./process-identity.Review
Review round 1 (full): adversarial
Scope:
09c36b6..439cb6c(whole change). Tool: adversarial-review.lib/hosts/updates.ts:286Bun.buildthrowsAggregateError("Bundle failed")by default, so the branch that formats the build logs never runs (alsoself-update.ts:413).throw: falsein both (test: a worker that cannot be bundled fails with the bundler's reason; red without the fix)lib/hosts/update-worker.test.mjs:1121lib/hosts/update-worker.test.mjs:1006process-identitystand-in to reachupgrade-process's own import..mtscopies; the plugin does reach that import (probe), and only the worker's calls drive these scenarioslib/hosts/updates.ts:285lib/hosts/update-worker.ts:62RUNTIME,WorkerRuntimeand theruntimeparameters are leftover indirection.lib/hosts/update-worker.test.mjs:731file:URL)Not checked: Windows and macOS; a real npm-installed package end to end; Bun versions other than 1.4.4.
Review round 1 (full): code review
Scope:
09c36b6..439cb6c(whole change). Tool: /code-review.lib/hosts/updates.ts:286lib/self-update.ts:414lib/hosts/update-worker.ts:675.mtscopies an older daemon left in a retained attempt.lib/hosts/updates.ts:289lib/hosts/update-worker.test.mjs:731require("x").__requiretoo)Not checked: Windows.
Review round 1 (full): simplification
Scope:
09c36b6..439cb6c(whole change). Tool: code-simplification.lib/hosts/update-worker.ts:12RUNTIMEand threeruntimeparameters.lib/hosts/updates.ts:281buildHostUpdateWorkeras written (thepluginstest seam, the chmod).lib/self-update.ts:413lib/hosts/update-worker.ts:675Review round 2 (light): code review
Scope:
439cb6c..d952223(since the last reviewed head). Tool: /code-review.lib/hosts/update-worker.test.mjs:732\brequirenever matches__require.lib/hosts/update-worker.test.mjs:734file:URL.lib/self-update.ts:413Round head d952223; 1 of 3 rounds after the first full review used. e1efa43 changes only a test, so no next round is due.
Summary by CodeRabbit