diff --git a/docs/verification/skill-curator-promote-digest-test-path.md b/docs/verification/skill-curator-promote-digest-test-path.md new file mode 100644 index 00000000..036ad277 --- /dev/null +++ b/docs/verification/skill-curator-promote-digest-test-path.md @@ -0,0 +1,68 @@ +# Verification: skill-curator-promote-digest-test-path + +Test-only change to `lib/skill-curator/tests/test-promote-digest.sh`, case [6]. No product code touched. + +Cause: case [6] writes a `sha256sum` PATH stub that execs `${REAL_SHA256:-/usr/bin/sha256sum}`. On a PATH with no real `sha256sum` (the Mini nightly job sets `PATH=$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin`, no `/sbin`), `promote.sh` would fall back to `shasum -a 256`, but the stub shadows it and execs a missing binary. The digest comes back empty and promote refuses with rc=4. The fix creates the `sha256sum` stub only when a real one exists. + +## Negative control + +The same command on the test script from before this change (`HEAD~1`), same PATH. It fails with the nightly assertion: + +```text +Command: env -i HOME=$HOME PATH=$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin bash +Exit: 1 +Output: +[1] list prints 12-hex digest; added file and symlink target change it +[2] re-stage between list and promote is refused (rc=4), nothing moves +[3] no digest, --force in digest slot, and wrong digest all refuse (rc=4) +[4] right digest promotes exact reviewed draft including extra files and symlinks +[5] --force after digest replaces live skill and backs up previous live copy +[6] re-stage during promotion (PATH stub) publishes reviewed copy, newer draft stays visible + FAIL: mid-digest re-stage failed (rc=4, list='beta 2a0ad9d2324c tampered +[7] late re-stage during promote (mkdir stub, Fault 2) does not hide newer draft +[8] re-stage during refused promotion preserves BOTH old and new drafts +[9] inherited temp variable does not recursively delete unrelated folder (Fault 1) +[10] auto mode promotes eligible draft from private copy and preserves concurrent newer draft +[11] curate_restore refuses over a live skill (rc=5), no nesting, manifest unchanged +[12] normal curate_restore moves archive back and removes only its manifest row +[13] file with newline in name added after list is refused (rc=4), not installed +[14] fifo added after list is refused (rc=4), not installed +[15] chmod +x after list changes digest and is refused (rc=4), not installed +[16] absolute symlink target swap after list is refused (rc=4), not installed +[17] curate_restore refuses traversal, slash, empty, and leading-dash slugs +test-promote-digest: 16 passed, 1 FAILED +Result: RED as expected, proves the check bites +``` + +Verdict: RED + +## Green run (nightly PATH, after the fix) + +```text +Command: env -i HOME=$HOME PATH=$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin bash lib/skill-curator/tests/test-promote-digest.sh +Exit: 0 +Output: +[1] list prints 12-hex digest; added file and symlink target change it +[2] re-stage between list and promote is refused (rc=4), nothing moves +[3] no digest, --force in digest slot, and wrong digest all refuse (rc=4) +[4] right digest promotes exact reviewed draft including extra files and symlinks +[5] --force after digest replaces live skill and backs up previous live copy +[6] re-stage during promotion (PATH stub) publishes reviewed copy, newer draft stays visible +[7] late re-stage during promote (mkdir stub, Fault 2) does not hide newer draft +[8] re-stage during refused promotion preserves BOTH old and new drafts +[9] inherited temp variable does not recursively delete unrelated folder (Fault 1) +[10] auto mode promotes eligible draft from private copy and preserves concurrent newer draft +[11] curate_restore refuses over a live skill (rc=5), no nesting, manifest unchanged +[12] normal curate_restore moves archive back and removes only its manifest row +[13] file with newline in name added after list is refused (rc=4), not installed +[14] fifo added after list is refused (rc=4), not installed +[15] chmod +x after list changes digest and is refused (rc=4), not installed +[16] absolute symlink target swap after list is refused (rc=4), not installed +[17] curate_restore refuses traversal, slash, empty, and leading-dash slugs +test-promote-digest: all 17 passed +Verdict: PASS +``` + +## Not covered + +The full nightly run was not repeated; only this suite. With `/sbin` on PATH and in a login shell the suite also passed 17 of 17. diff --git a/lib/skill-curator/tests/test-promote-digest.sh b/lib/skill-curator/tests/test-promote-digest.sh index 7da889fa..96261c99 100755 --- a/lib/skill-curator/tests/test-promote-digest.sh +++ b/lib/skill-curator/tests/test-promote-digest.sh @@ -114,6 +114,11 @@ if [ ! -e "$TMP/fired-hash" ]; then fi exec "${REAL_SHASUM:-/usr/bin/shasum}" "\$@" EOF +STUB_HASHES=("$STUB1/shasum") +# A sha256sum stub is only valid where a real one exists; otherwise it would shadow +# the shasum fallback in promote.sh and exec a missing binary (nightly PATH has no /sbin). +if [[ -n "$REAL_SHA256" ]]; then +STUB_HASHES+=("$STUB1/sha256sum") cat > "$STUB1/sha256sum" < "$SKILL_CURATOR_PROPOSALS_DIR/race-mid/SKILL.md" fi -exec "${REAL_SHA256:-/usr/bin/sha256sum}" "\$@" +exec "$REAL_SHA256" "\$@" EOF -chmod +x "$STUB1/shasum" "$STUB1/sha256sum" +fi +chmod +x "${STUB_HASHES[@]}" PATH="$STUB1:$PATH" "$CLI" promote race-mid "$d_mid" >/dev/null 2>&1; rc_mid=$? lst_mid="$("$CLI" list)" if [[ $rc_mid -eq 0 ]] \