From 985b3a7b7b2a03a4b2dd7dfa81e06701b4cfdf1f Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 7 Nov 2026 11:21:52 -0400 Subject: [PATCH] console-tui: build-static.sh marks a hash from a dirty tree and names the commit it belongs to An artifact hash is quoted in cycle hand-offs and pinned as CONSOLE_TUI_BIN, so it has to belong to a commit. A dirty tree produces one nobody else can reproduce, and not by a little: rustc embeds file:line in panic messages, so cargo fmt re-wrapping a line moved this binary by 24 bytes. That is exactly how engine#1323's body came to quote 1598144 B for a tree whose commit builds 1598120 B, and the release lane could not tell it from a real difference. The clean case now prints the hash WITH the commit ("ok (HEAD , tree clean)"). The dirty case prints "DIRTY -dirty - NOT 's artifact: N uncommitted path(s)" to stderr, still prints the binary path (it is fine to test with) and exits 1, so a hand-off or a CONSOLE_TUI_BIN pin cannot quietly carry it. Scoped to this crate: those are the only files that can change these bytes, and the engine tree is big enough that an unrelated edit elsewhere must not block a console build. Fixes #1326 --- os/v3/puppy/console-tui/README.md | 8 ++++++++ os/v3/puppy/console-tui/build-static.sh | 23 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/os/v3/puppy/console-tui/README.md b/os/v3/puppy/console-tui/README.md index 2a54a9c27..62da75f7f 100644 --- a/os/v3/puppy/console-tui/README.md +++ b/os/v3/puppy/console-tui/README.md @@ -237,6 +237,14 @@ os/v3/puppy/console-tui/build-static.sh # cargo test + musl release build CONSOLE_TUI_BIN= bash os/v3/puppy/build.sh resolute64 ``` +The last line it prints in the clean case is `build-static: ok (HEAD , tree clean)`. **That hash +names a commit, and only a clean tree produces it**: with uncommitted changes under this crate it prints +`build-static: DIRTY -dirty - NOT 's artifact …` on stderr and exits 1, while still printing the +binary path (it is fine to test with). The reason is engine#1326: `cargo fmt` re-wrapping one line moved the binary by +24 bytes - rustc embeds `file:line` in panic messages - and a hash built from the tree *before* that `cargo fmt` was +quoted as if it were the commit's, which the release lane had no way to tell from a real difference. Quote the clean +number, or rebuild from the merged tree. + `container-build.sh` installs the binary as `/usr/local/bin/1bit-console-tui`, refuses a `CONSOLE_TUI_BIN` that does not *run* (`--version` must print `1bit-console-tui ...` - a program init cannot exec is how a console becomes a dead screen), refuses a packed copy that is not executable, and merely notes the binary's absence: diff --git a/os/v3/puppy/console-tui/build-static.sh b/os/v3/puppy/console-tui/build-static.sh index 26560984a..369cc46cf 100755 --- a/os/v3/puppy/console-tui/build-static.sh +++ b/os/v3/puppy/console-tui/build-static.sh @@ -27,7 +27,9 @@ # cannot start because of a loader is a dead screen. The musl target links with the bundled rust-lld, so no # musl-gcc is needed. `--selftest` proves the binary answers without a terminal. # -# Exit: 0 built and static, 1 the toolchain or the resulting binary is not what the image needs. +# Exit: 0 built and static, 1 the toolchain or the resulting binary is not what the image needs, or the tree has +# uncommitted changes in this crate - in that last case the hash it prints is marked `-dirty`, because a hash from a +# dirty tree is not the artifact of any commit and cannot be quoted in a hand-off (engine#1326). set -eu cd "$(dirname "$0")" @@ -63,5 +65,22 @@ fi "$OUT" --version > /dev/null "$OUT" --snapshot 80x25 --fixture > /dev/null -echo "build-static: ok $(sha256sum "$OUT" | cut -c1-16) $(stat -c %s "$OUT") bytes" +# An artifact hash is quoted in cycle hand-offs and pinned as CONSOLE_TUI_BIN, so it has to belong to a COMMIT. +# A dirty tree produces a hash nobody else can reproduce - and not only by a little: rustc embeds `file:line` in +# panic messages, so `cargo fmt` re-wrapping a line moved this binary by 24 bytes (engine#1326, where the hash of a +# pre-`cargo fmt` tree was quoted as if it were #1323's head, and the release lane could not tell it apart from a +# real difference). The check is scoped to this crate: those are the only files that can change these bytes, and +# the engine tree is big enough that an unrelated edit elsewhere must not block a console build. +hash=$(sha256sum "$OUT" | cut -c1-16) +bytes=$(stat -c %s "$OUT") +head=$(git rev-parse --short HEAD 2> /dev/null || echo unknown) +dirty=$(git status --porcelain -- . 2> /dev/null || true) +if [ -n "$dirty" ]; then + echo "build-static: DIRTY $hash-dirty $bytes bytes - NOT $head's artifact: $(printf '%s\n' "$dirty" | wc -l | tr -d ' ') uncommitted path(s) under $PWD" >&2 + echo "build-static: commit them and run this again to get a hash that names a commit (the binary below is fine to test with)" >&2 + echo "$PWD/$OUT" + exit 1 +fi + +echo "build-static: ok $hash $bytes bytes (HEAD $head, tree clean)" echo "$PWD/$OUT"