magicciv/.project/objectives/p1-11-build-output-src-purge.md
Natalie 0a0650dc39 feat(@projects): add tourguide dev setup docs and verification workflow
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-04-17 13:16:20 -07:00

5.4 KiB

id title priority status scope owner updated_at evidence
p1-11 Purge build output from src/ — wasm-pack moves to .local/build/wasm/ p1 done game1 tourguide 2026-04-17
src/simulator/build-wasm.sh
public/games/age-of-dwarves/guide/vite.config.ts
public/games/age-of-dwarves/guide/vitest.config.ts
public/games/age-of-dwarves/guide/e2e/Dockerfile.web
public/games/age-of-dwarves/guide/src/simulation/golden.test.ts
tools/deploy-guide.sh
.forgejo/workflows/release.yml
scripts/run/build.sh
scripts/run/dev.sh
.gitignore

Status — 2026-04-17 (tourguide, closed)

All 8 acceptance bullets verifiable in repo:

  • src/simulator/build-wasm.sh rewritten — passes an absolute $OUT_DIR = $REPO_ROOT/.local/build/wasm to wasm-pack; creates the dir; leaves src/simulator/pkg/ non-existent. (Verified: apricot build emitted .local/build/wasm/{magic_civ_physics.js,.d.ts,_bg.wasm,_bg.wasm.d.ts,_bg.js,package.json} at 2026-04-17 13:07 + rsync to plum confirmed.)
  • public/games/age-of-dwarves/guide/vite.config.ts:20 and vitest.config.ts:40 aliases both resolve @magic-civ/physics-rs../../../../.local/build/wasm/magic_civ_physics.js.
  • public/games/age-of-dwarves/guide/e2e/Dockerfile.web:34COPY .local/build/wasm/ ./.local/build/wasm/ + rule-citation comment.
  • tools/deploy-guide.sh sentinel path + header comment reference .local/build/wasm/magic_civ_physics.js with both apricot-build and local-build remediation hints.
  • .forgejo/workflows/release.yml:247cp -r .local/build/wasm/. "$out_dir/staging/pkg/".
  • scripts/run/build.sh cmd_build_wasm log line updated.
  • .gitignore:53-56 — explicit src/simulator/pkg/ entry with inline rationale.
  • scripts/run/verify.sh step 16 _verify_no_build_in_src fails the run if src/simulator/pkg/ or any src/**/target/ tree has content; scripts/run/dev.sh::cmd_guide prints a yellow warning on launch if the stale directory reappears or if .local/build/wasm/magic_civ_physics.js is missing.

Evidence: .project/history/20260417_tourguide_dev_bringup.md.

Summary

src/ is source-only by project rule — the Rust target/ incident (~25 GB, 65k files accidentally committed) established the convention, and .gitignore:53 already ships .local/ as the canonical artifact host. But src/simulator/build-wasm.sh still writes to src/simulator/pkg/ via wasm-pack's default --out-dir. That puts generated JS + WASM bytecode a git add . away from being committed, and the Vite alias at public/games/age-of-dwarves/guide/vite.config.ts:20 ('@magic-civ/physics-rs' → ../../../../src/simulator/pkg/magic_civ_physics.js) is the blocking reason ./run guide cannot boot on plum today — src/simulator/pkg/ is empty here (WASM is an apricot-built artifact per the two-host workflow), so the alias resolves to a missing file.

Relocating the wasm-pack output to .local/build/wasm/ (already the convention used by .forgejo/workflows/release.yml:243 when staging release artifacts, and matching .local/build/rust/ for cargo via src/simulator/.cargo/config.toml and .local/build/godot/ for exports) closes both failures in one move: the rule holds structurally, and the guide dev-server alias now points at a location a contributor can populate via bash src/simulator/build-wasm.sh or rsync from apricot without ever putting output back inside src/.

Acceptance

  • src/simulator/build-wasm.sh invokes wasm-pack with --out-dir ../../.local/build/wasm (no longer ../pkg). Running the script on a clean tree produces .local/build/wasm/magic_civ_physics.js
    • .wasm + _bg.wasm + package.json, and leaves src/simulator/pkg/ non-existent.
  • public/games/age-of-dwarves/guide/vite.config.ts + vitest.config.ts aliases resolve @magic-civ/physics-rs to .local/build/wasm/magic_civ_physics.js.
  • public/games/age-of-dwarves/guide/e2e/Dockerfile.web COPY statement reads from .local/build/wasm/ so docker-compose e2e still consumes a pre-built artifact.
  • tools/deploy-guide.sh and .forgejo/workflows/release.yml read from .local/build/wasm/ and no longer reference src/simulator/pkg/.
  • scripts/run/build.sh echoes the new path in its "WASM built → …" log line.
  • .gitignore explicitly lists src/simulator/pkg/ as a safety net (belt-and-suspenders — stops wasm-pack's default <crate>/pkg/ from repopulating it if someone runs wasm-pack directly without the script).
  • ./run verify grows a new _verify_no_build_in_src step that fails the run if any file exists under src/simulator/pkg/ or any src/**/target/ tree (the rule is mechanically enforced, not doc-only).
  • scripts/run/dev.sh::cmd_guide prints a one-line warning ("build output in src is forbidden — re-run bash src/simulator/build-wasm.sh") if src/simulator/pkg/ exists on launch. Warning, not block — the failure mode becomes self-describing.

Non-goals

  • Toolchain install on plum (rustup/wasm-pack) — tracked separately in p1-13 as a fallback path when apricot is unreachable.
  • Docs rewrite — every stale path reference in instruction files and agent docs is scope of p1-12, not this objective.
  • Route-coverage e2e spec — p1-13.
  • Relocating cargo's target/ directory — already done upstream via src/simulator/.cargo/config.toml; this objective only covers the wasm-pack output, plus the verify-time check that both stay clean.