pingqiu 994ad4e842 G5-5 script: PREBUILT_BIN_DIR Tier 2 fast-path + SRC_DIR safety guard
Architect option (a) ratified round 53. Two changes to sync_and_build:

1. PREBUILT_BIN_DIR fast-path for Tier 2 (cross-node m01+M02):
   When PREBUILT_BIN_DIR is set, skip source-tar + remote-build
   entirely. scp the 3 pre-built binaries (g5-blockmaster,
   g5-blockvolume, g5-m01verify) directly to m01:/tmp/ and onward
   to M02. Mirrors the existing LOCAL_MODE branch pattern.

   Use case: Windows workstation cross-compiles via
     CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ...
   then sets PREBUILT_BIN_DIR=/path/to/bins. No m01-side source
   tree or `go` install needed. Also works for CI artifact paths.

2. SRC_DIR safety guard (the bug QA hit round 53):
   When iterate.sh is copied away from the repo and run with
   SRC_DIR resolving to "" or "/" (e.g., bash /tmp/iterate.sh
   without overriding SRC_DIR), the prior code called
     `cd "$SRC_DIR" && tar -czf /tmp/g5-src.tgz .`
   which tarred the root filesystem. QA killed it before damage,
   but the unsafety must not exist.

   Guard sequence (refuses with named error before any tar):
     - SRC_DIR empty or "/"        → die
     - SRC_DIR/go.mod missing      → die
     - SRC_DIR/cmd/blockvolume/    → die
     - else                        → safe to tar

   Verified all 4 die paths fire with clear messages: empty, "/",
   non-repo path, PREBUILT_BIN_DIR with missing binary.

Acceptance criteria #1-#7 unaffected; only the build/sync mechanism
changes. The 4 verify_* scenario bodies are untouched.

Refs: QA Tier 2 round 53 finding (SMB-driven iterate.sh attempted
to tar root filesystem); architect option (a) binding.
2026-04-26 23:28:50 -07:00
Languages
Go 84.6%
Rust 7.8%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%