From 3bb484b1f3de8536f56827c4926b8707495be1cf Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Sun, 20 Sep 2026 16:30:55 -0700 Subject: [PATCH] fix(web): the stamp guard names every missing stamp, not the first (improvise-x4wv) `stamped` exited on the first failure, so breaking two substitutions named app.js and never reached worker.js -- and the comment ("names itself when it is the one missing") read as though it did not. It fails safe, which is why it was filed rather than fixed in PR #47; the code is fixed rather than the comment because the diagnostic is paid for in wasm-pack rebuilds, the slowest loop in this repo. Each stamp is still verified on its own -- the property PR #24's finding bought -- but `stamped` records and a gate after the four calls fails the build. Proved by injection both ways: two broken sedi patterns now name both files and exit 1, and deleting the gate prints both failures while exiting 0, which is the check-that-does-not-check the comment now warns about. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01FC2jVn8Au7E9JPkw6bwXXH --- web/assemble.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/web/assemble.sh b/web/assemble.sh index 1fe1cd20..a1492d1e 100755 --- a/web/assemble.sh +++ b/web/assemble.sh @@ -73,18 +73,31 @@ sedi "s|'improvise_worker_server_bg\.wasm'|'improvise_worker_server_bg.wasm?v=${ # three failed substitutions could still produce a "successful" assembly under # `set -e` (found by Copilot on PR #24). These checks are the only guard # against the generated glue changing shape, so each stamped reference is -# verified on its own and names itself when it is the one missing. +# verified on its own and names itself when it is missing. +# +# `stamped` RECORDS rather than exits, and the gate below is what fails the +# build. Exiting on the first failure named one file and never reached the +# rest, so a shape change that broke two stamps cost two wasm-pack rebuilds to +# diagnose -- the slowest loop in this repo (improvise-x4wv). The gate is the +# whole guard: without it every failure prints and the assembly succeeds, which +# is the check-that-does-not-check this whole file is full of fixes for. +missing="" stamped() { - grep -q "$2" "$1" || { + if grep -q "$2" "$1"; then + grep -n "$2" "$1" + else echo "assemble: $1 is missing the cache-bust stamp: $2" >&2 - exit 1 - } - grep -n "$2" "$1" + missing="${missing} $1" + fi } stamped "$app/app.js" "pkg/improvise_wasm_client.js?v=${token}" stamped "$app/worker.js" "worker-pkg/improvise_worker_server.js?v=${token}" stamped "$app/pkg/improvise_wasm_client.js" "improvise_wasm_client_bg.wasm?v=${token}" stamped "$app/worker-pkg/improvise_worker_server.js" "improvise_worker_server_bg.wasm?v=${token}" +test -z "$missing" || { + echo "assemble: refusing to ship; unstamped:${missing}" >&2 + exit 1 +} # Every relative import the two entry points make must have been copied. The # cp list above is a second answer to "what ships", and a missing sibling is a