founding: private-path stand-up fails — the helper is spawned with an empty environment #255

Closed
opened 2026-08-02 00:00:57 +00:00 by ben · 1 comment
Owner

What happened

During the #183 Phase A rehearsal (unpackaged production build, launched via the sanctioned dev script that exports the single-artifact overrides — guest image + QEMU paths), founding a private community and clicking Create landed on a fail-loud callout:

founding: stand up the local VM guest: vm: the private-path payload is not carried — missing NixOS guest base image ("")

The guest base image was in place on disk and the launch environment pointed at it, but the helper resolved an empty image path.

What I expected

The private-path stand-up creates the local VM: the helper resolves the bundled QEMU + guest base image from the carried payload (packaged) or from the dev single-artifact environment overrides (unpackaged, ADR 0110 resolution order), and Create proceeds through create VM → pair → deploy access role.

Steps to reproduce

  1. Build the production helper + shell and launch unpackaged with the dev environment overrides set (guest image, qemu-img, qemu-system) — the Phase A launch script does exactly this.
  2. Found a community, choose Private — just testing, and click Create on Review & create.
  3. The stand-up fails immediately with the payload-not-carried error, image path ("").

Additional context

Root cause (diagnosed during the rehearsal): the production renderer build bakes the process environment away — the bundle compiles the environment object to an empty literal, so the helper bridge spawns every helper with only the two variables it sets explicitly (state dir, payload dir). Everything else the shell was launched with is lost: the ADR 0110 dev overrides, and even PATH/HOME. Consequences beyond this rehearsal: even a packaged install would spawn helpers without PATH, so the stand-up's systemctl/qemu-img invocations would fail too. The fix should make the spawned helper inherit the app's real runtime environment (and a guard test should pin that the production bundle preserves it — the same shape as the #233 file:// boot guard).

Found in the #183 Phase A rehearsal; blocks the private-path leg of the rehearsal.

## What happened During the #183 Phase A rehearsal (unpackaged production build, launched via the sanctioned dev script that exports the single-artifact overrides — guest image + QEMU paths), founding a **private** community and clicking Create landed on a fail-loud callout: > founding: stand up the local VM guest: vm: the private-path payload is not carried — missing NixOS guest base image ("") The guest base image was in place on disk and the launch environment pointed at it, but the helper resolved an **empty** image path. ## What I expected The private-path stand-up creates the local VM: the helper resolves the bundled QEMU + guest base image from the carried payload (packaged) or from the dev single-artifact environment overrides (unpackaged, ADR 0110 resolution order), and Create proceeds through create VM → pair → deploy access role. ## Steps to reproduce 1. Build the production helper + shell and launch unpackaged with the dev environment overrides set (guest image, qemu-img, qemu-system) — the Phase A launch script does exactly this. 2. Found a community, choose **Private — just testing**, and click Create on Review & create. 3. The stand-up fails immediately with the payload-not-carried error, image path `("")`. ## Additional context Root cause (diagnosed during the rehearsal): the **production renderer build bakes the process environment away** — the bundle compiles the environment object to an empty literal, so the helper bridge spawns every helper with only the two variables it sets explicitly (state dir, payload dir). Everything else the shell was launched with is lost: the ADR 0110 dev overrides, and even `PATH`/`HOME`. Consequences beyond this rehearsal: even a packaged install would spawn helpers without `PATH`, so the stand-up's `systemctl`/`qemu-img` invocations would fail too. The fix should make the spawned helper inherit the app's real runtime environment (and a guard test should pin that the production bundle preserves it — the same shape as the #233 file:// boot guard). Found in the #183 Phase A rehearsal; blocks the private-path leg of the rehearsal.
Author
Owner

Done in b26ff4c (on origin/main).

Root cause confirmed as diagnosed: the production renderer build (Vite) statically compiles a bare process.env to an empty object literal {} (verified in the built bundle: var s5={}; ... {...s5}). So stdioBridge's spawn(..., { env: { ...process.env } }) handed every spawned helper an env carrying only the two vars it sets explicitly (OURCLOUD_STATE_DIR, OURCLOUD_PAYLOAD_DIR) — the ADR 0110 dev single-artifact overrides, and even PATH/HOME, were all lost. The boot seam test runs in Node (real process.env), so it structurally could not catch this.

Fix: app/src/lib/stdioBridge.ts now reads the live environment off the node:process builtin ({ ...nodeProcess.env }) instead of the bare process.env global. The #233 electron-builtins plugin bridges the builtin to the node-integrated renderer's runtime require, so it resolves to the real environment at spawn time and the bundle keeps it. Verified: the shipped bundle now spreads {...require("node:process").env} before layering OURCLOUD_STATE_DIR/OURCLOUD_PAYLOAD_DIR on top.

Guard (the #233 file:// boot-guard shape): app/tests/unit/rendererBuild.test.ts builds the shipped renderer and asserts the helper spawn env is spread off require("node:process").env, never an empty literal — so the class of defect (and even a plain PATH-less packaged spawn) cannot regress.

This unblocks the private-path leg of the #183 Phase A rehearsal. (boot.test.ts needs go on PATH — an unrelated sandbox env limitation; all other app tests pass.)

Done in b26ff4c (on origin/main). **Root cause confirmed as diagnosed:** the production renderer build (Vite) statically compiles a bare `process.env` to an empty object literal `{}` (verified in the built bundle: `var s5={}; ... {...s5}`). So `stdioBridge`'s `spawn(..., { env: { ...process.env } })` handed every spawned helper an env carrying only the two vars it sets explicitly (`OURCLOUD_STATE_DIR`, `OURCLOUD_PAYLOAD_DIR`) — the ADR 0110 dev single-artifact overrides, and even `PATH`/`HOME`, were all lost. The boot seam test runs in Node (real `process.env`), so it structurally could not catch this. **Fix:** `app/src/lib/stdioBridge.ts` now reads the live environment off the `node:process` builtin (`{ ...nodeProcess.env }`) instead of the bare `process.env` global. The #233 electron-builtins plugin bridges the builtin to the node-integrated renderer's runtime `require`, so it resolves to the real environment at spawn time and the bundle keeps it. Verified: the shipped bundle now spreads `{...require("node:process").env}` before layering `OURCLOUD_STATE_DIR`/`OURCLOUD_PAYLOAD_DIR` on top. **Guard (the #233 file:// boot-guard shape):** `app/tests/unit/rendererBuild.test.ts` builds the shipped renderer and asserts the helper spawn env is spread off `require("node:process").env`, never an empty literal — so the class of defect (and even a plain `PATH`-less packaged spawn) cannot regress. This unblocks the private-path leg of the #183 Phase A rehearsal. (`boot.test.ts` needs `go` on PATH — an unrelated sandbox env limitation; all other app tests pass.)
ben closed this issue 2026-08-02 01:29:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#255
No description provided.