99caae76158cf55f972b4af235201705fc11dcfd
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
99caae7615 |
fix(788): gate the vocabulary on a sentinel, not on a skippable if
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>
|
||
|
|
dd9cd113c3 |
fix(788): one declarative H10 verdict vocabulary, derived by both sides
The verdict words lived in two hand-written shell copies — the `case` arms of `post-review-verdict.sh` (write: word -> commit-status state) and the `POS_RE`/`NEG_RE` regexes of `check-review-verdict.sh` (read: comment -> classification for the merge-consent hook). Nothing held them together but a comment, and that comment had already gone stale once. A word the writer treats as positive but the classifier does not sends `review-verdict/h10` green while the hook still denies. #774 tried to hold them together with a parity test that scraped both vocabularies out of shell source with regexes. Six cold-review rounds each found another construction that escaped the extractor (`SHIP*)`; an unquoted `SHIP-IT) state=success`) or reddened it on a correct tree (a `<word>) state=` in a heredoc; a column-zero `esac` in a string truncating the scoped match). It was withdrawn rather than patched a seventh time. So this removes the duplication instead of detecting it. `scripts/lib/review-verdict-vocabulary.sh` declares the two word arrays once and exposes three derived views: a membership test for the writer, an alternation body for the reader, and the operator-facing list for the "unknown verdict" message and the usage banner (both of which were themselves third copies). Neither script enumerates a word any more. Only the WORD SET moved. The grammar stays in `check-review-verdict.sh` — the column-0 anchor, the whole-word boundary, the anchored `@ <sha>` field. Every #629 false-open was in the grammar, and none of it belongs in a word list. Validation is the security property, not hygiene. The words are interpolated into an ERE, so a `.*` in the positive list would make `POS_RE` match every verdict-shaped line and classify an explicit BLOCKED as `positive`. Words are restricted to `[a-z][a-z-]*`, and a vocabulary that is missing, unreadable, duplicated across polarities or empty is fatal — exit 2 for the reader (callers fail closed on it), exit 1 for the writer, having posted nothing. The arrays are arrays rather than whitespace-separated strings because splitting a string needs an unquoted expansion, and an unquoted expansion also globs: the first draft, handed `.*`, reported on `.claude`. That makes validation depend on the cwd and fails open — a `*` expands to the filenames beside it, and `scripts`/`docs` both match `[a-z][a-z-]*` and would have entered the vocabulary as real verdict words. Caught by the negative control, not by review. The proof is behavioural, never textual: add a word to a sandbox copy of the one declaration and require it to reach both sides. Graded MUTATION, with the clause declared in `mutation_manifest.py` — the harness restores the pre-#788 hardcoded `POS_RE` on every run and requires the proof to go red, so a refactor that quietly reintroduces a second copy cannot leave the suite green. Known residual, deliberately not fixed: `pretooluse-merge-consent.sh` names the words in one operator-facing message string. It classifies nothing (it delegates to `check-review-verdict.sh`), so it is a prose copy, not a second implementation. Verification: 980 passed / 2 skipped (`pytest scripts/tests`), ruff clean, shellcheck clean, catalog regenerated. Refs: #788 Decisions-Edit: yes Co-authored-by: Timothy <timothy@noreply.gitea.tblindustries.be> |