Cold adversarial review found a fail-open in the first commit, reproduced here
before fixing: with `.*` in the positive list and the negative list written as a
scalar, `check-review-verdict.sh` classified an explicit `BLOCKED @ <head>` as
`positive`, exit 0. The merge-consent hook auto-grants on exactly that, and it
discards the classifier's stderr, so the only signal was invisible.
Root cause, measured rather than reasoned:
* `${#arr[@]}` is nounset-safe only for a DECLARED-EMPTY array. On an unset
name or a scalar it is a fatal unbound-variable error.
* Under `set -u` that error inside a FUNCTION aborts the function, not the
script — and in the `if ! validate; then exit 2; fi` form NEITHER branch is
then taken, so the gate is skipped and execution continues.
* `check-review-verdict.sh` deliberately runs without `set -e`, so the words
reached the regex unvalidated. The write side has `set -e` and did die, so
the asymmetry left the hole on precisely the side that authorizes merges.
The single-fault case needed no metacharacter and is the realistic wrong edit:
writing the list as a string degraded every negative verdict from `negative` to
`unknown` — DENY silently downgraded to ASK — with no non-zero exit anywhere.
A control-flow gate can be skipped by an abort; a value that was never assigned
cannot be read. So enforcement is now a DATA dependency: validation sets
`ETV_VERDICT_VOCABULARY_OK=1` as the last statement of its successful path, and
`etv_verdict_class`/`etv_verdict_alternation`/`etv_verdict_words_display` refuse
without it. The sentinel is reset to 0 at load time, so an inherited environment
variable cannot forge it. Array-ness is asserted with `declare -p` BEFORE any
`${#arr[@]}`, so the abort cannot occur in the first place — kept alongside the
sentinel for the accurate message, not as a second gate.
Separately, a top-level `exit` in a sourced library terminates the sourcing
script at the `source` line, so no check written after it can run: the reader
returned exit 0 with EMPTY stdout, breaking its "exactly one classification
word" contract. Both consumers now probe-source the library in a subshell and
require an end-of-file marker before sourcing it for real; that also catches a
syntax error and a truncated file.
All six failure modes now fail closed (reader exit 2, writer exit 1 having
posted nothing), and the shipped words classify exactly as before. Four of the
six new tests were witnessed RED against the unfixed predecessor 2d389a5bf; the
other two (unset array, truncated library) pin behaviour that already held and
are labelled as such rather than presented as fixes.
Also from the review: prose in the decision record, `docs/ci-cd.md` and two
in-script comments claimed validation was "run above, fatal" — the false premise
that shipped the hole. Corrected to name the sentinel as what enforces it. The
unresolved-symlink location dependency is recorded as a known limitation
(fail-closed today). De-flaked the unreadable-file test for a root runner, and
fixed a stale `check-review-verdict.sh:212` line reference plus a comment still
describing #788 as future work.
Not done, deliberately: no third guard on the both-patterns-match case. The
validator rejects a word in both lists, and test_check_review_verdict.py already
pins the dangerous direction; a third overlapping guard is the shape where
deleting any one leaves the suite green.
Verification: 987 passed / 2 skipped, ruff clean, shellcheck clean, catalog
regenerated, decisions-validate OK.
Refs: #788
Decisions-Edit: yes
Co-authored-by: Timothy <timothy@noreply.gitea.tblindustries.be>