open-standards/scripts/check-comparative-prose.sh
Transaction Science 348a2d9259 wai: restate the ranking phrases the retrofit left in research and extensions
The retrofit's commit says the research notes, extensions and source
comments make no comparisons. These lines still ranked or promoted:

- research/cargo-roadmap.md: the sequencing rationale and the phase
  reasons now say what each phase reuses or carries, and the status note
  points to content-taxonomy.md for each class's status.
- research/content-taxonomy.md: the "white space" table is now the
  cargo-roadmap phase table, with each phase marked shipped and its
  capability named, so it no longer contradicts the taxonomy rows above
  it; the closing clause of the spatial-audio row and "That's the whole
  map" are removed.
- extensions/spatial-audio.md and research/spatial-audio-draft.md: the
  appendix says why spatial audio was first without ranking it.
- SPEC.md §5, extensions/ternary-tt.md and the CAP_TERNARY_TT comment:
  wai.ternary.tt is stated by its own measured operating point (13.3 dB
  SNR at 3.8x with six residual layers, the extension's table) and its
  Lossy tier.
- research/2030-transport-landscape.md: three lines restated as what WAI
  specifies; the CHANGELOG entry now says comparative framing in dated
  records is restated in place, as names are redacted.
- wai-rs/src/lib.rs: the quantum_qec comment ends at the metric it carries.

scripts/check-comparative-prose.sh gains five phrases (commercial wedge,
unclaimed, fast win, differentiator, rate-competitive), each with a case
in scripts/test-public-text-checks.sh.

REGISTRY.md and vocab/README.md say that the v2 SHACL shape checks the
capability and fallback against this revision's registry and only the
form of media, and that a violation for an unregistered string means it
is not registered in this revision, not that the envelope fails to
conform or cannot be dispatched (SPEC §4, §8).

The CHANGELOG's candidate-capability bullet states the MINOR rule as a
full sentence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-01 08:38:05 -04:00

125 lines
3.8 KiB
Shell
Executable file

#!/usr/bin/env bash
#
# check-comparative-prose.sh
#
# Holds WAI's public text to its writing rule: it states what WAI does,
# plainly, and does not rank WAI against anything else. The phrases below are
# the comparative and promotional forms the tree has had to remove; each is a
# POSIX extended regular expression, matched case-sensitively.
#
# Scope: the same files as scripts/check-public-names.sh — the tracked files
# under wai/ with the extensions .md .rs .toml .py .sh .mjs .js .json .html
# .css .ttl .h .c .txt and wai/'s .gitignore files, except the settled OER/2
# documents and corpus, and except wai/CHANGELOG.md: its history is a record,
# and only names are redacted from it. Files given as arguments replace that
# list (the self-test, scripts/test-public-text-checks.sh, uses this).
#
# Opt-out, for a functional identifier or a quotation only (an environment
# variable or file name that contains a listed word, a phrase quoted from a
# cited document): put `allow-phrase: <reason>` on the same line, in a comment
# of the file's own syntax. The reason is required: it must contain a letter or
# a digit.
#
# Exit status: 0 clean; 1 a hit; 2 a pattern grep cannot compile, or any other
# grep error. The check never reads an error as "clean".
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"
PHRASES=(
'\bSOTA\b'
'\bwin vs\b'
'\b[Mm]oat\b'
'[Nn]obody signs'
'[Nn]ot one signs'
'[Nn]one signs'
'[Bb]est[- ]in[- ]class'
'\b[Bb]eats\b [A-Z]'
'\b[Ss]uperior(ity)?\b'
'% better'
'\b[Tt]he opposite\b'
'[Ss]trictly worse'
'[Tt]oll[- ]road'
'\b[Pp]arity \+'
'[Ff]eature[- ]parity'
'\bparity with\b'
'\b[Uu]nderperforms\b'
'\b[Oo]utperforms\b'
'royalty trap'
'well below [A-Z]'
'well above [A-Z]'
'among the (lowest|best|highest|fastest|smallest)'
'nothing else .* offers?'
'\b[Nn]o other .* (offers?|signs?|provides?)'
'[Cc]ommercial wedge'
'\b[Uu]nclaimed\b'
'\b[Ff]ast win\b'
'\b[Dd]ifferentiator\b'
'[Rr]ate-competitive'
)
args=()
for p in "${PHRASES[@]}"; do args+=(-e "$p"); done
# Compile every phrase once before scanning: grep exits 1 when nothing matches
# and 2 on an error, and only 0 and 1 mean the list is usable.
set +e
grep -E "${args[@]}" /dev/null >/dev/null
rc=$?
set -e
if [ $rc -gt 1 ]; then
echo "::error::a phrase in $0 does not compile (grep exit $rc); nothing was checked" >&2
exit 2
fi
files=()
if [ $# -gt 0 ]; then
files=("$@")
else
while IFS= read -r f; do
case "$f" in
wai/extensions/oer-receipts.md|wai/wai-rs/src/oer.rs|wai/oer-conformance/*) continue ;;
wai/CHANGELOG.md) continue ;;
esac
files+=("$f")
done < <(git ls-files 'wai/*.md' 'wai/*.rs' 'wai/*.toml' 'wai/*.py' 'wai/*.sh' 'wai/*.mjs' 'wai/*.js' \
'wai/*.json' 'wai/*.html' 'wai/*.css' 'wai/*.ttl' 'wai/*.h' 'wai/*.c' 'wai/*.txt' \
'wai/*.gitignore')
fi
if [ ${#files[@]} -eq 0 ]; then
echo "::error::no file to check" >&2
exit 2
fi
out="$(mktemp)"
trap 'rm -f "$out"' EXIT
set +e
grep -HnE "${args[@]}" -- "${files[@]}" > "$out"
rc=$?
set -e
if [ $rc -gt 1 ]; then
echo "::error::grep failed (exit $rc) while scanning; nothing was checked" >&2
exit 2
fi
hits=0
while IFS= read -r line; do
content="${line#*:}"
content="${content#*:}"
if printf '%s' "$content" | grep -qE 'allow-phrase:[[:space:]]*[[:alnum:]]'; then
continue
fi
if [ $hits -eq 0 ]; then
echo "::error::comparative or promotional phrasing in public text (scripts/check-comparative-prose.sh)"
fi
echo "$line"
hits=$((hits + 1))
done < "$out"
if [ $hits -gt 0 ]; then
echo "Fix: state what WAI does, measured where a figure is given, without ranking it against"
echo "anything else; for an identifier or a quotation, mark the line with allow-phrase: <reason>."
exit 1
fi
echo "comparative-prose check: clean (${#files[@]} files)"