Skip to content

fix(tests): resolve SC2015 in mktemp guards - #3

Merged
adbarc92 merged 1 commit into
mainfrom
fix/shellcheck-sc2015
Aug 10, 2026
Merged

fix(tests): resolve SC2015 in mktemp guards#3
adbarc92 merged 1 commit into
mainfrom
fix/shellcheck-sc2015

Conversation

@adbarc92

Copy link
Copy Markdown
Owner

Fixes the ShellCheck job, red on main since 2026-07-25. It was the only failing job — all four test jobs pass.

The finding

Four files carried the same guard, validating mktemp output before installing a rm -rf trap:

[ -n "$WORK" ] && [ -d "$WORK" ] || { echo "FATAL: bad WORK" >&2; exit 1; }

ShellCheck raises SC2015 (A && B || C is not if-then-else). Here it is arguably a false positive — both operands are tests, so C running when B fails is the intent. I did not suppress it: the guard protects a rm -rf, and it should say what it means.

if [ -z "$WORK" ] || [ ! -d "$WORK" ]; then echo "FATAL: bad WORK" >&2; exit 1; fi

Identical semantics, no shellcheck disable anywhere. Files: tests/simple-test.sh, tests/mutate.sh, tests/spec-map.sh, tests/oracle-gate.sh.

Evidence nothing was weakened

  • bash tests/simple-test.sh202 passed, 0 failed — identical to before
  • oracle.lock.json's tests[] array is byte-identical, 202 entries
  • bash -n clean on all four
  • Guard behavior re-verified: fires on empty, fires on a missing directory, silent on a good one

⚠️ The freeze gate will fail R7, and that is correct

Three of these files are content-hashed by the oracle. The gate now reports:

GATE FAIL [R7] NEEDS_HUMAN: tests/simple-test.sh changed
GATE FAIL [R7] NEEDS_HUMAN: tests/oracle-gate.sh changed
GATE FAIL [R7] NEEDS_HUMAN: tests/spec-map.sh changed

oracle-gate.sh states that --accept is "a deliberate human act", so this PR does not re-lock itself. An agent that edits the tests and then re-arms the gate over its own change is the exact tamper path this repo is built to stop.

To land: review the diff above, then:

bash tests/oracle-gate.sh --accept
git commit -am "chore(tests): re-lock oracle after SC2015 guard fix"

CI goes green after that.

Four identical guards validated mktemp output with A && B || C before
installing a 'rm -rf' trap. ShellCheck flagged SC2015 on each. Rewritten
as explicit if-statements: same semantics, unambiguous intent.

No test assertion is touched; the suite is 202 passing before and after
and oracle.lock.json's tests[] array is byte-identical. Three of the four
files are hashed by the freeze gate, so R7 will fail until a human
reviews this diff and re-locks with --accept. That is deliberate.
@adbarc92
adbarc92 merged commit 607b132 into main Aug 10, 2026
5 of 6 checks passed
@adbarc92
adbarc92 deleted the fix/shellcheck-sc2015 branch August 10, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant