bug: devbox scripts drop -- arguments (serve --image ignored) #84

Closed
opened 2026-11-21 21:08:26 +01:00 by SirStone · 1 comment
Owner

Part of #63

What happens

devbox.json scripts are defined as command arrays ("serve": ["tools/serve.sh"]). Devbox 0.17.2 generates .devbox/gen/scripts/serve.sh as the bare command without "$@", so devbox run serve -- --image=run/map16384.png --tile-size=64 runs tools/serve.sh with no arguments. tools/serve.mjs therefore sees an empty argv, silently skips the import, and serves the default 4096 scene. /proc/<pid>/cmdline of the node process confirmed the empty argv.

The same gap affects every script documented with -- args: seed, import-scale, mutation, bench, and anything else (README, the #77 checklist comment, docs/HANDOFF-M4.md).

What to build

  • Every devbox script that accepts arguments forwards them. Devbox 0.17.2 passes -- args as positional parameters to the generated script, so the generated body must end with "$@" (append it to the last command in each script entry, and append "$@" to the final array element).
  • serve fails loudly on unknown/unused flags (unknown option, --tile-size without --image, non-numeric values) and prints serve: importing <file> … and serve: no --image given, keeping current map (<w>x<h>, tile <t>, art v<N>j) so a silent skip cannot recur.
  • A test that goes through devbox run <script> -- <args> (not the tool directly) for serve (--help / --dry-run) and seed (--help) - the seam the earlier direct-tool tests missed.
  • serve's laptop certificate-trust text: detect NixOS (/etc/NIXOS) and print security.pki.certificateFiles = [ <path> ]; + rebuild (or Chrome: tap Proceed is enough) instead of the Debian update-ca-certificates steps; keep Debian/macOS/Firefox text.
  • Remove the three UnusedImport warnings for faults in server/worldmap.nim, server/vision.nim, server/markers.nim: the import is only used inside when defined(leakfault), so guard it with when defined(leakfault): import faults (fault builds must still compile and fault tests pass).
  • Update README, docs/HANDOFF-M4.md and the #77 checklist so every documented command matches what works.

Acceptance

  • devbox run serve -- --dry-run shows the parsed options from the -- args (through devbox, not node tools/serve.mjs).
  • devbox run serve -- --bogus fails loudly and does not start a server.
  • devbox run seed -- --help prints usage; devbox run seed -- --bogus fails.
  • devbox run serve -- --image=<png> --tile-size=64 imports before serving (observable in the log line).
  • devbox run test, client-test, e2e green.

Related: #77 (blocked by this), #82, #80, #83.

Part of #63 ## What happens `devbox.json` scripts are defined as command arrays (`"serve": ["tools/serve.sh"]`). Devbox 0.17.2 generates `.devbox/gen/scripts/serve.sh` as the bare command **without `"$@"`**, so `devbox run serve -- --image=run/map16384.png --tile-size=64` runs `tools/serve.sh` with no arguments. `tools/serve.mjs` therefore sees an empty argv, silently skips the import, and serves the default 4096 scene. `/proc/<pid>/cmdline` of the node process confirmed the empty argv. The same gap affects every script documented with `-- args`: `seed`, `import-scale`, `mutation`, `bench`, and anything else (README, the #77 checklist comment, `docs/HANDOFF-M4.md`). ## What to build - Every devbox script that accepts arguments forwards them. Devbox 0.17.2 passes `--` args as positional parameters to the generated script, so the generated body must end with `"$@"` (append it to the last command in each script entry, and append `"$@"` to the final array element). - `serve` fails loudly on unknown/unused flags (unknown option, `--tile-size` without `--image`, non-numeric values) and prints `serve: importing <file> …` and `serve: no --image given, keeping current map (<w>x<h>, tile <t>, art v<N>j)` so a silent skip cannot recur. - A test that goes **through `devbox run <script> -- <args>`** (not the tool directly) for `serve` (`--help` / `--dry-run`) and `seed` (`--help`) - the seam the earlier direct-tool tests missed. - `serve`'s laptop certificate-trust text: detect NixOS (`/etc/NIXOS`) and print `security.pki.certificateFiles = [ <path> ];` + rebuild (or `Chrome: tap Proceed is enough`) instead of the Debian `update-ca-certificates` steps; keep Debian/macOS/Firefox text. - Remove the three `UnusedImport` warnings for `faults` in `server/worldmap.nim`, `server/vision.nim`, `server/markers.nim`: the import is only used inside `when defined(leakfault)`, so guard it with `when defined(leakfault): import faults` (fault builds must still compile and fault tests pass). - Update README, `docs/HANDOFF-M4.md` and the #77 checklist so every documented command matches what works. ## Acceptance - [ ] `devbox run serve -- --dry-run` shows the parsed options from the `--` args (through devbox, not `node tools/serve.mjs`). - [ ] `devbox run serve -- --bogus` fails loudly and does not start a server. - [ ] `devbox run seed -- --help` prints usage; `devbox run seed -- --bogus` fails. - [ ] `devbox run serve -- --image=<png> --tile-size=64` imports before serving (observable in the log line). - [ ] `devbox run test`, `client-test`, `e2e` green. Related: #77 (blocked by this), #82, #80, #83.
SirStone added the bugready-for-agent labels 2026-11-21 21:08:30 +01:00
SirStone added a new dependency 2026-11-21 21:08:30 +01:00
Author
Owner

Fixed in 30b3559 (pushed to main).

Root cause: devbox 0.17.2 runs .devbox/gen/scripts/<name>.sh with the -- args as positional parameters but does not append "$@"; the generated script body was the bare command, so serve/seed/bench/mutation/import-scale/fogbench saw an empty argv.

Fix: every argument-taking script body ends with "$@" in devbox.json (array entries join with newlines, so the suffix goes on the last command).

Serve hardening: --dry-run parses and prints the effective options without building; unknown options, non-numeric ports/tile sizes and --tile-size without --image exit non-zero; a no-image start prints serve: no --image given, keeping current map (16384x16384, tile 64, art vN); a bad --image import aborts before the server starts. On NixOS the cert text is security.pki.certificateFiles = [ ... ]; + rebuild (Chrome Proceed is enough), Debian/macOS/Firefox kept.

Seam test: tools/devboxargs.test.mjs runs through devbox run serve -- ... and devbox run seed -- ..., not the tools directly.

Faults warnings: the faults import in worldmap.nim, vision.nim, markers.nim is now when defined(leakfault); the normal build is warning-free and -d:leakfault still compiles.

Verified working commands:

devbox run serve -- --image=run/map16384.png --tile-size=64
devbox run serve -- --dry-run
devbox run seed -- --url=https://<lan-ip>:8443 --tokens=49 --vision=1

devbox run serve -- --image=/tmp/does-not-exist.png now prints serve: importing ... and exits 1 (server not started) instead of silently serving the default 4096 scene.

Gates: devbox run test green (evidence 20/20), client-test green, e2e green (29/29). Kernel watch clean. README, docs/HANDOFF-M4.md and the #77 checklist updated; #77 is unblocked.

Fixed in `30b3559` (pushed to `main`). **Root cause:** devbox 0.17.2 runs `.devbox/gen/scripts/<name>.sh` with the `--` args as positional parameters but does not append `"$@"`; the generated script body was the bare command, so `serve`/`seed`/`bench`/`mutation`/`import-scale`/`fogbench` saw an empty argv. **Fix:** every argument-taking script body ends with `"$@"` in `devbox.json` (array entries join with newlines, so the suffix goes on the last command). **Serve hardening:** `--dry-run` parses and prints the effective options without building; unknown options, non-numeric ports/tile sizes and `--tile-size` without `--image` exit non-zero; a no-image start prints `serve: no --image given, keeping current map (16384x16384, tile 64, art vN)`; a bad `--image` import aborts before the server starts. On NixOS the cert text is `security.pki.certificateFiles = [ ... ];` + rebuild (Chrome Proceed is enough), Debian/macOS/Firefox kept. **Seam test:** `tools/devboxargs.test.mjs` runs through `devbox run serve -- ...` and `devbox run seed -- ...`, not the tools directly. **Faults warnings:** the `faults` import in `worldmap.nim`, `vision.nim`, `markers.nim` is now `when defined(leakfault)`; the normal build is warning-free and `-d:leakfault` still compiles. **Verified working commands:** ```sh devbox run serve -- --image=run/map16384.png --tile-size=64 devbox run serve -- --dry-run devbox run seed -- --url=https://<lan-ip>:8443 --tokens=49 --vision=1 ``` `devbox run serve -- --image=/tmp/does-not-exist.png` now prints `serve: importing ...` and exits 1 (server not started) instead of silently serving the default 4096 scene. **Gates:** `devbox run test` green (evidence 20/20), `client-test` green, `e2e` green (29/29). Kernel watch clean. README, `docs/HANDOFF-M4.md` and the #77 checklist updated; #77 is unblocked.
Sign in to join this conversation.