Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions docs/verification/skill-curator-promote-digest-test-path.md
Original file line number Diff line number Diff line change
@@ -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 <pre-change test-promote-digest.sh>
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.
10 changes: 8 additions & 2 deletions lib/skill-curator/tests/test-promote-digest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,22 @@ 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" <<EOF
#!/usr/bin/env bash
if [ ! -e "$TMP/fired-hash" ]; then
: > "$TMP/fired-hash"
mkdir -p "$SKILL_CURATOR_PROPOSALS_DIR/race-mid"
printf -- '---\nname: race-mid\ndescription: v2 newer\n---\nV2-MID-NEWER\n' > "$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 ]] \
Expand Down
Loading