@soleur/opencode 3.393.2 → 3.393.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/ci-head-verdict.sh +1 -1
- package/scripts/monitor-pr-checks.sh +2 -2
- package/scripts/required-set-report.sh +150 -0
- package/scripts/required-set-report.test.sh +583 -0
- package/skills/agent-browser/test/playwright-mcp-redact-proxy.test.sh +3 -3
- package/skills/compound/scripts/token-efficiency-report.sh +1 -1
- package/skills/constraint-scaffold/scripts/constraint-scaffold.sh +1 -1
- package/skills/linear-fetch/scripts/assert-no-linear-telemetry.sh +2 -2
- package/skills/linear-fetch/scripts/redact-linear-urls.sh +1 -1
- package/skills/merge-pr/SKILL.md +35 -2
- package/skills/model-launch-review/scripts/audit-models.sh +1 -1
- package/skills/operator-bootstrap/template.sh +2 -1
- package/skills/postmerge/SKILL.md +2 -2
- package/skills/postmerge/references/phase4-false-alarm-history.md +5 -0
- package/skills/product-roadmap/scripts/roadmap-reconcile.sh +1 -1
- package/skills/provision-cloudflare/scripts/provision-cloudflare.sh +1 -1
- package/skills/provision-doppler/scripts/provision-doppler.sh +1 -1
- package/skills/provision-github/scripts/provision-github.sh +3 -3
- package/skills/review/references/risk-tier-and-fix-rounds.md +1 -0
- package/skills/seo-aeo/scripts/validate-seo.sh +1 -1
- package/skills/ship/SKILL.md +47 -14
- package/skills/ship/references/adr-ordinal-collision.md +6 -0
- package/skills/ship/references/monitor-hygiene.md +11 -0
- package/skills/ship/references/ready-run-wait.md +9 -5
- package/skills/skill-security-scan/scripts/check-telemetry-surface.sh +2 -2
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Unit suite for plugins/soleur/scripts/required-set-report.sh (#11544, inline half).
|
|
3
|
+
#
|
|
4
|
+
# The resolver (`ci-head-verdict.sh required`) is a STUB that replays the REAL contract (hints first, the marker as the LAST stdout line,
|
|
5
|
+
# exit 0 for decided states, 3 for state=error, 2 and no marker for usage); a stub that echoed what the script expects would grade the
|
|
6
|
+
# script against itself. No `gh` is called and no `git` is spawned. Every row runs with a private TMPDIR that must be empty afterwards
|
|
7
|
+
# (no leaked temp file is a property of every row, not a row of its own). All scratch lives under ONE root owned by ONE EXIT trap.
|
|
8
|
+
# shellcheck disable=SC2012,SC2016,SC2094 # ls -A emptiness probes, literal $ in single-quoted fixtures, one-way byte compare
|
|
9
|
+
set -uo pipefail
|
|
10
|
+
export TMPDIR="${TMPDIR:-/var/tmp}"
|
|
11
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
+
SUT="$DIR/required-set-report.sh"
|
|
13
|
+
[[ -r "$SUT" ]] || { printf 'FATAL: SUT not found at %s\n' "$SUT" >&2; exit 1; }
|
|
14
|
+
REAL_BASH="$(command -v bash)"; REAL_TOUCH="$(command -v touch)"
|
|
15
|
+
|
|
16
|
+
CASES_RUN=0; passes=0; fails=0; FAILED=()
|
|
17
|
+
pass() { passes=$((passes + 1)); printf ' [ok] %s\n' "$1"; }
|
|
18
|
+
fail() { fails=$((fails + 1)); FAILED+=("$1"); printf ' [FAIL] %s\n' "$1" >&2; [[ -n "${2:-}" ]] && printf ' %s\n' "$2" >&2; return 0; }
|
|
19
|
+
# chk <status> <label> <detail>: the status is the FIRST argument so that a command substitution in the label or detail cannot clobber
|
|
20
|
+
# its $?. The case counter moves at the CALL SITE, independent of the verdict.
|
|
21
|
+
chk() { CASES_RUN=$((CASES_RUN + 1)); if [[ "${1:-1}" -eq 0 ]]; then pass "$2"; else fail "$2" "${3:-}"; fi; }
|
|
22
|
+
|
|
23
|
+
# INSTRUMENT SELF-TEST (ADR-193): drive both helpers once, then roll back, so a suite whose pass()/fail() were neutered cannot report green.
|
|
24
|
+
_p=$passes; _f=$fails; _fl=${#FAILED[@]}
|
|
25
|
+
pass "selftest" >/dev/null; fail "selftest" >/dev/null 2>&1
|
|
26
|
+
if [[ "$passes" -eq $((_p + 1)) && "$fails" -eq $((_f + 1)) ]]; then
|
|
27
|
+
passes=$_p; fails=$_f; FAILED=("${FAILED[@]:0:$_fl}"); chk 0 "INSTRUMENT: pass() and fail() each move their own counter" ""
|
|
28
|
+
else
|
|
29
|
+
passes=$_p; fails=$_f; FAILED=("${FAILED[@]:0:$_fl}"); chk 1 "INSTRUMENT: helpers do not discriminate; every assertion below is decorative" ""
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# chk() decides every assertion below, so it gets its own control: status 0 must move passes, non-zero must move fails, and the case
|
|
33
|
+
# counter must move by one per call (a chk that always passes, or that routes by the wrong status, is caught here).
|
|
34
|
+
_p=$passes; _f=$fails; _fl=${#FAILED[@]}; _c=$CASES_RUN
|
|
35
|
+
chk 0 "selftest-ok" "" >/dev/null; _p1=$passes; _f1=$fails
|
|
36
|
+
chk 1 "selftest-bad" "" >/dev/null 2>&1
|
|
37
|
+
if [[ "$_p1" -eq $((_p + 1)) && "$_f1" -eq "$_f" && "$passes" -eq $((_p + 1)) && "$fails" -eq $((_f + 1)) && "$CASES_RUN" -eq $((_c + 2)) ]]; then
|
|
38
|
+
_v=0
|
|
39
|
+
else
|
|
40
|
+
_v=1
|
|
41
|
+
fi
|
|
42
|
+
passes=$_p; fails=$_f; FAILED=("${FAILED[@]:0:$_fl}"); CASES_RUN=$_c
|
|
43
|
+
# The verdict on chk() must NOT be delivered through chk() (a chk that always passes would pass its own check): count the case and call
|
|
44
|
+
# pass/fail directly.
|
|
45
|
+
CASES_RUN=$((CASES_RUN + 1))
|
|
46
|
+
if [[ "$_v" -eq 0 ]]; then pass "INSTRUMENT: chk() routes status 0 to pass, non-zero to fail, one case per call"
|
|
47
|
+
else fail "INSTRUMENT: chk() does not discriminate on its status; every assertion below is decorative"; fi
|
|
48
|
+
|
|
49
|
+
# ONE root, ONE owning EXIT trap (ADR-129). The reaper also runs there, so an aborted row cannot leave a detached holder behind.
|
|
50
|
+
assert_fixture_dir() { # refuse an empty, relative, root-ish or synthetic-fs scratch dir before anything is armed to rm -rf it
|
|
51
|
+
case "${1-}" in
|
|
52
|
+
"") printf 'FATAL: fixture dir is EMPTY; git -C "" would operate on %s\n' "$PWD" >&2; exit 2 ;;
|
|
53
|
+
*/../*|*/..) printf 'FATAL: fixture dir %s contains ..; refusing\n' "$1" >&2; exit 2 ;;
|
|
54
|
+
/proc/*|/sys/*|/dev/*) printf 'FATAL: fixture dir %s is a synthetic-fs path; refusing\n' "$1" >&2; exit 2 ;;
|
|
55
|
+
/|//|/.) printf 'FATAL: fixture dir resolves to the filesystem root; refusing\n' >&2; exit 2 ;;
|
|
56
|
+
/*) : ;;
|
|
57
|
+
*) printf 'FATAL: fixture dir %s is RELATIVE; refusing\n' "$1" >&2; exit 2 ;;
|
|
58
|
+
esac
|
|
59
|
+
}
|
|
60
|
+
ROOT="$(mktemp -d)"; assert_fixture_dir "$ROOT"
|
|
61
|
+
HOLDER_PIDS="$ROOT/pids"; : > "$HOLDER_PIDS"
|
|
62
|
+
reap() { # kill every pid the stubs recorded (the detached holder, the trapping stub's sleep)
|
|
63
|
+
local p
|
|
64
|
+
while read -r p; do [[ "$p" =~ ^[0-9]+$ ]] && kill -KILL "$p" 2>/dev/null; done < "$HOLDER_PIDS"
|
|
65
|
+
: > "$HOLDER_PIDS"
|
|
66
|
+
}
|
|
67
|
+
trap 'reap; rm -rf "$ROOT"' EXIT
|
|
68
|
+
gone() { # 0 once the pid is gone (polls $2 times, default 20); a killed orphan may linger as a zombie for a moment (read -t is the sleep-free wait)
|
|
69
|
+
local n
|
|
70
|
+
for n in $(seq 1 "${2:-20}"); do
|
|
71
|
+
kill -0 "$1" 2>/dev/null || return 0
|
|
72
|
+
read -r -t 0.2 <> <(:) || true
|
|
73
|
+
done
|
|
74
|
+
return 1
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
PRN=4387
|
|
78
|
+
SHA=0123456789abcdef0123456789abcdef01234567
|
|
79
|
+
mk() { # mk <state> [pr]: a marker line in the resolver's real shape
|
|
80
|
+
case "$1" in
|
|
81
|
+
complete) printf 'SOLEUR_CI_REQUIRED_SET state=complete pr=%s sha=%s required=3 reason=all-green absent=[] pending=[] failed=[]\n' "${2:-$PRN}" "$SHA" ;;
|
|
82
|
+
absent) printf 'SOLEUR_CI_REQUIRED_SET state=absent pr=%s sha=%s required=3 reason=context-absent absent=["cla-evidence"] pending=[] failed=[]\n' "${2:-$PRN}" "$SHA" ;;
|
|
83
|
+
pending) printf 'SOLEUR_CI_REQUIRED_SET state=pending pr=%s sha=%s required=3 reason=context-pending absent=[] pending=["cla-evidence"] failed=[]\n' "${2:-$PRN}" "$SHA" ;;
|
|
84
|
+
failed) printf 'SOLEUR_CI_REQUIRED_SET state=failed pr=%s sha=%s required=3 reason=context-failed absent=[] pending=[] failed=["CLA check"]\n' "${2:-$PRN}" "$SHA" ;;
|
|
85
|
+
error) printf 'SOLEUR_CI_REQUIRED_SET state=error pr=%s sha=- required=- reason=api-error absent=- pending=- failed=-\n' "${2:-$PRN}" ;;
|
|
86
|
+
esac
|
|
87
|
+
}
|
|
88
|
+
M_ABS="$(mk absent)"; M_ERR="$(mk error)"
|
|
89
|
+
R_HINT='RECOVERY rerun run=4242 basis=workflow ctx="cla-evidence" wf="CLA": gh run rerun 4242'
|
|
90
|
+
|
|
91
|
+
# The stub resolver. State lives in files beside it: body, rc, err, pre (an executable run first), trap (marker file: TERM-trapping variant).
|
|
92
|
+
STUBD="$ROOT/stub"; mkdir -p "$STUBD"
|
|
93
|
+
cat > "$STUBD/req.sh" <<'EOF'
|
|
94
|
+
#!/usr/bin/env bash
|
|
95
|
+
d="$(cd "$(dirname "$0")" && pwd)"
|
|
96
|
+
printf '%s\n' "$*" >> "$d/calls"
|
|
97
|
+
case "${1:-}" in
|
|
98
|
+
required)
|
|
99
|
+
[[ -x "$d/pre" ]] && "$d/pre"
|
|
100
|
+
# like the real resolver: TERM prints the body (an error marker) and exits 3 instead of dying silently
|
|
101
|
+
if [[ -f "$d/trap" ]]; then trap 'cat "$d/body"; exit 3' TERM; sleep 30 & echo $! >> "$d/pids"; wait $!; fi
|
|
102
|
+
[[ -f "$d/err" ]] && cat "$d/err" >&2
|
|
103
|
+
cat "$d/body" 2>/dev/null
|
|
104
|
+
exit "$(cat "$d/rc" 2>/dev/null || echo 0)" ;;
|
|
105
|
+
*) echo "stub-miss: $*" >&2; exit 64 ;;
|
|
106
|
+
esac
|
|
107
|
+
EOF
|
|
108
|
+
sed -i "s|\$d/pids|$HOLDER_PIDS|" "$STUBD/req.sh" # the stub records into the suite's reaper list
|
|
109
|
+
newrow() { # reset the stub's state for the next row
|
|
110
|
+
rm -f "$STUBD/body" "$STUBD/rc" "$STUBD/err" "$STUBD/pre" "$STUBD/trap" "$STUBD/calls" "$STUBD/targv"
|
|
111
|
+
ENVV=(); SUT_OVERRIDE=""; TMPDIR_OVERRIDE=""
|
|
112
|
+
}
|
|
113
|
+
calls() { local c; c="$(grep -c -- "$1" "$STUBD/calls" 2>/dev/null)" || true; printf '%s' "${c:-0}"; }
|
|
114
|
+
cnt() { local c; c="$(grep -c -- "$1" "$2" 2>/dev/null)" || true; printf '%s' "${c:-0}"; } # lines of file $2 matching $1; 0 for a missing file
|
|
115
|
+
|
|
116
|
+
ROWN=0
|
|
117
|
+
ENVV=(); SUT_OVERRIDE=""; TMPDIR_OVERRIDE=""
|
|
118
|
+
# sut <label> [args...]: runs the script with a private TMPDIR; sets OUT (stdout text), OUTF (stdout file, byte-exact), RC, ERRTXT.
|
|
119
|
+
# The private TMPDIR must be empty afterwards; with TMPDIR_OVERRIDE (a nonexistent path) it must still not exist.
|
|
120
|
+
sut() {
|
|
121
|
+
local label="$1"; shift
|
|
122
|
+
ROWN=$((ROWN + 1)); ROWTMP="$ROOT/row$ROWN"; mkdir -p "$ROWTMP"
|
|
123
|
+
OUTF="$ROOT/row$ROWN.out"; local errf="$ROOT/row$ROWN.err"
|
|
124
|
+
env -u REQUIRED_SET_TIMEOUT_S -u REQUIRED_SET_TIMEOUT_BIN CI_HEAD_VERDICT_BIN="$STUBD/req.sh" TMPDIR="${TMPDIR_OVERRIDE:-$ROWTMP}" "${ENVV[@]}" \
|
|
125
|
+
"$REAL_BASH" "${SUT_OVERRIDE:-$SUT}" "$@" >"$OUTF" 2>"$errf" </dev/null
|
|
126
|
+
RC=$?
|
|
127
|
+
OUT="$(cat "$OUTF")"; ERRTXT="$(cat "$errf")"
|
|
128
|
+
if [[ -n "$TMPDIR_OVERRIDE" ]]; then
|
|
129
|
+
[[ ! -e "$TMPDIR_OVERRIDE" ]] && _v=0 || _v=1; chk "$_v" "$label: the nonexistent TMPDIR was not created" "exists=$(ls -d "$TMPDIR_OVERRIDE" 2>&1)"
|
|
130
|
+
else
|
|
131
|
+
[[ -z "$(ls -A "$ROWTMP")" ]] && _v=0 || _v=1; chk "$_v" "$label: no temp file left in the private TMPDIR" "left=[$(ls -A "$ROWTMP" | tr '\n' ' ')]"
|
|
132
|
+
fi
|
|
133
|
+
[[ "$RC" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "$label: exit 0 (always)" "rc=$RC"
|
|
134
|
+
[[ -z "$ERRTXT" ]] && _v=0 || _v=1; chk "$_v" "$label: nothing on stderr" "stderr=[$ERRTXT]"
|
|
135
|
+
}
|
|
136
|
+
nlines() { grep -c '' "$OUTF" 2>/dev/null || true; }
|
|
137
|
+
last_line() { tail -n 1 "$OUTF"; }
|
|
138
|
+
nmarkers() { cnt '^SOLEUR_CI_REQUIRED_SET' "$OUTF"; }
|
|
139
|
+
no_ctrl() { LC_ALL=C tr -d '\000-\010\013-\037\177' < "$1" | cmp -s - "$1"; } # no byte in \000-\010\013-\037\177
|
|
140
|
+
# Positive controls for the helpers that decide many verdicts: each must answer BOTH ways once, or a helper that always says "fine" is invisible.
|
|
141
|
+
printf 'clean text\n' > "$ROOT/ctl-clean"; printf 'esc\033[0m\n' > "$ROOT/ctl-esc"
|
|
142
|
+
no_ctrl "$ROOT/ctl-clean" && ! no_ctrl "$ROOT/ctl-esc" && _v=0 || _v=1; chk "$_v" "CONTROL no_ctrl() accepts clean text and rejects a file holding an ESC byte" ""
|
|
143
|
+
sleep 30 & _lp=$!; echo "$_lp" >> "$HOLDER_PIDS"
|
|
144
|
+
! gone "$_lp" 2 && _v=0 || _v=1; chk "$_v" "CONTROL gone() reports a live pid as NOT gone" "pid=$_lp"
|
|
145
|
+
kill -KILL "$_lp" 2>/dev/null; gone "$_lp" && _v=0 || _v=1; chk "$_v" "CONTROL gone() reports a killed pid as gone" "pid=$_lp"
|
|
146
|
+
: > "$HOLDER_PIDS" # S4a reads the FIRST recorded pid as its holder: the control's pid must not stay on the list
|
|
147
|
+
printf 'required 1\nrequired 2\nother\n' > "$STUBD/calls"
|
|
148
|
+
[[ "$(calls '^required 1$')" -eq 1 && "$(calls '^required')" -eq 2 && "$(calls 'zzz')" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "CONTROL calls() counts matching lines (1, 2 and 0 on a known file)" "got=$(calls '^required 1$'),$(calls '^required'),$(calls zzz)"
|
|
149
|
+
rm -f "$STUBD/calls"
|
|
150
|
+
|
|
151
|
+
# ── S1 happy path: running line, read-only note, hint, marker LAST; argv shapes. The same evaluator drives the anti-vacuity row below. ──
|
|
152
|
+
cat > "$STUBD/tbin" <<'EOF'
|
|
153
|
+
#!/usr/bin/env bash
|
|
154
|
+
d="$(cd "$(dirname "$0")" && pwd)"
|
|
155
|
+
printf '%s\n' "$*" > "$d/targv"
|
|
156
|
+
shift 3
|
|
157
|
+
exec "$@"
|
|
158
|
+
EOF
|
|
159
|
+
chmod +x "$STUBD/tbin"
|
|
160
|
+
s1_eval() { # 0 when the S1 clauses all hold for the current OUT/OUTF
|
|
161
|
+
local ok=0
|
|
162
|
+
[[ "$(nlines)" -eq 4 ]] || ok=1
|
|
163
|
+
[[ "$(sed -n 1p "$OUTF")" == "REQUIRED-SET READ — running (up to 125s):"* ]] || ok=1
|
|
164
|
+
[[ "$(sed -n 2p "$OUTF")" == "REQUIRED-SET READ — read-only"* ]] || ok=1
|
|
165
|
+
[[ "$(sed -n 3p "$OUTF")" == "$R_HINT" ]] || ok=1
|
|
166
|
+
[[ "$(last_line)" == "$M_ABS" && "$(nmarkers)" -eq 1 ]] || ok=1
|
|
167
|
+
return $ok
|
|
168
|
+
}
|
|
169
|
+
newrow; printf '%s\n%s\n' "$R_HINT" "$M_ABS" > "$STUBD/body"; ENVV=(REQUIRED_SET_TIMEOUT_BIN="$STUBD/tbin")
|
|
170
|
+
sut S1 "$PRN"
|
|
171
|
+
s1_eval && _v=0 || _v=1; chk "$_v" "S1 order: running line, read-only note, hint, marker LAST (and only)" "out=[$OUT]"
|
|
172
|
+
[[ "$(calls '^required 4387$')" -eq 1 && "$(wc -l < "$STUBD/calls")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S1 the resolver is called exactly once, with argv 'required 4387'" "calls=[$(cat "$STUBD/calls" 2>/dev/null)]"
|
|
173
|
+
[[ "$(cat "$STUBD/targv" 2>/dev/null)" == "-k 5 120 bash $STUBD/req.sh required 4387" ]] && _v=0 || _v=1; chk "$_v" "S1 the read runs as: timeout -k 5 120 bash <resolver> required <PR>" "argv=[$(cat "$STUBD/targv" 2>/dev/null)]"
|
|
174
|
+
# anti-vacuity (guard 2 harness row): point S1 at a no-op script; its 'marker printed LAST' clause must FAIL.
|
|
175
|
+
printf '#!/usr/bin/env bash\nexit 0\n' > "$ROOT/noop.sh"
|
|
176
|
+
newrow; printf '%s\n%s\n' "$R_HINT" "$M_ABS" > "$STUBD/body"; SUT_OVERRIDE="$ROOT/noop.sh"
|
|
177
|
+
sut "S1-vacuity" "$PRN"
|
|
178
|
+
s1_eval && _v=1 || _v=0; chk "$_v" "S1-vacuity a no-op script fails the S1 evaluator (the marker-LAST clause is not decorative)" "out=[$OUT]"
|
|
179
|
+
|
|
180
|
+
# ── S2 each of the five states ──
|
|
181
|
+
for st in complete absent pending failed error; do
|
|
182
|
+
newrow; { [[ "$st" != error ]] && printf '%s\n' "$R_HINT"; printf 'RECOVERY owner not determined, read the run before re-running ctx="cla-evidence"\n'; mk "$st"; } > "$STUBD/body"
|
|
183
|
+
[[ "$st" == error ]] && printf '3' > "$STUBD/rc"
|
|
184
|
+
sut "S2 state=$st" "$PRN"
|
|
185
|
+
[[ "$(last_line)" == "$(mk "$st")" && "$(nmarkers)" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S2 state=$st: the marker is printed verbatim, last, and unique" "out=[$OUT]"
|
|
186
|
+
if [[ "$st" == complete ]]; then
|
|
187
|
+
[[ "$OUT" == *"NOT that the PR is mergeable"* ]] && _v=0 || _v=1; chk "$_v" "S2 state=complete carries the 'NOT that the PR is mergeable' note" "out=[$OUT]"
|
|
188
|
+
else
|
|
189
|
+
[[ "$OUT" != *"NOT that the PR is mergeable"* ]] && _v=0 || _v=1; chk "$_v" "S2 state=$st carries no 'mergeable' note" "out=[$OUT]"
|
|
190
|
+
fi
|
|
191
|
+
if [[ "$st" == error ]]; then
|
|
192
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "S2 state=error prints no RECOVERY line even though the body has some" "out=[$OUT]"
|
|
193
|
+
else
|
|
194
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 2 ]] && _v=0 || _v=1; chk "$_v" "S2 state=$st prints both RECOVERY lines in the resolver's order" "out=[$OUT]"
|
|
195
|
+
fi
|
|
196
|
+
[[ "$OUT" != *"exits after the read"* && "$OUT" != *"counts as the first of the 3"* ]] && _v=0 || _v=1; chk "$_v" "S2 state=$st: no 'exits after the read' / 'counts as the first of the 3' (monitor wording, wrong for a poll)" "out=[$OUT]"
|
|
197
|
+
done
|
|
198
|
+
|
|
199
|
+
# ── S3 no marker and always 0: one degraded line, never marker-shaped ──
|
|
200
|
+
for rcv in 2 0 64 137; do
|
|
201
|
+
newrow; : > "$STUBD/body"; printf '%s' "$rcv" > "$STUBD/rc"
|
|
202
|
+
sut "S3 empty body rc=$rcv" "$PRN"
|
|
203
|
+
[[ "$(cnt 'no marker (' "$OUTF")" -eq 1 && "$(nmarkers)" -eq 0 && "$(last_line)" == "REQUIRED-SET READ — no marker ("* ]] && _v=0 || _v=1; chk "$_v" "S3 empty body, resolver rc $rcv: exactly one 'no marker (...)' line, last, zero marker lines" "out=[$OUT]"
|
|
204
|
+
_v=1
|
|
205
|
+
if [[ "$rcv" -eq 137 ]]; then [[ "$OUT" == *"no marker (timed out after 120s)"* ]] && _v=0; else [[ "$OUT" == *"no marker (exit $rcv)"* ]] && _v=0; fi
|
|
206
|
+
chk "$_v" "S3 resolver rc $rcv: the cause names the exit (137 reads as a kill by the timeout)" "out=[$OUT]"
|
|
207
|
+
done
|
|
208
|
+
newrow; : > "$STUBD/body"; printf '2' > "$STUBD/rc"; printf 'usage: bad\tinput\033[0m\n' > "$STUBD/err"
|
|
209
|
+
sut "S3 stderr" "$PRN"
|
|
210
|
+
[[ "$OUT" == *"no marker (exit 2; stderr: usage: bad input"* && "$(nlines)" -eq 2 ]] && no_ctrl "$OUTF" && _v=0 || _v=1; chk "$_v" "S3 the resolver's stderr rides on the degraded line with control characters turned into spaces" "out=[$OUT]"
|
|
211
|
+
# the stderr tail is cut at 160 bytes (400 in, 160 out) and goes through the shared sanitizer (NEL, LS, PS and a marker-shaped fragment)
|
|
212
|
+
newrow; : > "$STUBD/body"; printf '2' > "$STUBD/rc"; printf 'E%.0s' $(seq 1 400) > "$STUBD/err"
|
|
213
|
+
sut "S3 long stderr" "$PRN"
|
|
214
|
+
_e160="$(printf 'E%.0s' $(seq 1 160))"
|
|
215
|
+
[[ "$OUT" == *"stderr: ${_e160}): treat as state=error" ]] && _v=0 || _v=1; chk "$_v" "S3 a 400-byte stderr is cut to its first 160 bytes on the degraded line" "out=[$OUT]"
|
|
216
|
+
newrow; : > "$STUBD/body"; printf '2' > "$STUBD/rc"
|
|
217
|
+
printf 'x\xc2\x85SOLEUR_CI_REQUIRED_SET state=complete pr=%s sha=a required=3 reason=forged absent=[] pending=[] failed=[]\xe2\x80\xa8y\xe2\x80\xa9z\033[31m\n' "$PRN" > "$STUBD/err"
|
|
218
|
+
sut "S3 NEL stderr" "$PRN"
|
|
219
|
+
[[ "$(LC_ALL=C grep -cF -e $'\xc2\x85' -e $'\xe2\x80\xa8' -e $'\xe2\x80\xa9' "$OUTF")" -eq 0 && "$(nlines)" -eq 2 && "$(nmarkers)" -eq 0 ]] && no_ctrl "$OUTF" && _v=0 || _v=1; chk "$_v" "S3 NEL / LS / PS and ESC in the resolver's stderr do not reach the degraded line (two lines, zero marker lines)" "out=[$(printf '%q' "$OUT")]"
|
|
220
|
+
# nested sequences re-form after one removal (c2 c2 85 85 leaves c2 85): the stderr tail is cleaned to a fixpoint, and so is an absurd nesting
|
|
221
|
+
# depth (40 > the 32-pass cap) through the lead-byte fallback.
|
|
222
|
+
_deep="$(printf '\xc2%.0s' $(seq 1 40); printf '\x85%.0s' $(seq 1 40))"
|
|
223
|
+
newrow; : > "$STUBD/body"; printf '2' > "$STUBD/rc"
|
|
224
|
+
{ printf 'x\xc2\xc2\x85\x85y\xe2\x80\xe2\x80\xa8\xa8z\xe2\x80\xe2\x80\xa9\xa9w'; printf '%s\n' "$_deep"; } > "$STUBD/err"
|
|
225
|
+
sut "S3 nested stderr" "$PRN"
|
|
226
|
+
[[ "$(LC_ALL=C grep -cF -e $'\xc2\x85' -e $'\xe2\x80\xa8' -e $'\xe2\x80\xa9' "$OUTF")" -eq 0 && "$OUT" == *"stderr: xyzw"* && "$(nlines)" -eq 2 ]] && _v=0 || _v=1; chk "$_v" "S3 nested NEL / LS / PS (and 40-deep nesting) in the resolver's stderr do not re-form on the degraded line" "out=[$(printf '%q' "$OUT")]"
|
|
227
|
+
for badarg in "" "abc" "1 2" "-1" "12x"; do
|
|
228
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"
|
|
229
|
+
sut "S3 arg [$badarg]" "$badarg"
|
|
230
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && "$(nmarkers)" -eq 0 && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S3 argument [$badarg]: one usage line, no marker line, the resolver is not called" "out=[$OUT]"
|
|
231
|
+
done
|
|
232
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"
|
|
233
|
+
sut "S3 no arguments"
|
|
234
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S3 no arguments: the usage line under set -u (not an unbound-variable death), resolver not called" "out=[$OUT]"
|
|
235
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"
|
|
236
|
+
sut "S3 two arguments" 4387 4387
|
|
237
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S3 two arguments: the usage line" "out=[$OUT]"
|
|
238
|
+
|
|
239
|
+
# ── S4 timeout: a hung resolver is cut, even with a detached descendant holding its stdout; a TERM-trapping resolver gets its say ──
|
|
240
|
+
if command -v setsid >/dev/null 2>&1; then
|
|
241
|
+
newrow; printf '%s\n%s\n' "$R_HINT" "$M_ABS" > "$STUBD/body"
|
|
242
|
+
# The holder INHERITS the stub's stdout (the read's capture file). A holder that redirected its own stdout away would hold nothing
|
|
243
|
+
# and make this row vacuous. Its pid goes to the reaper list.
|
|
244
|
+
printf '#!/usr/bin/env bash\nsetsid sleep 12 &\necho $! >> "%s"\nsleep 30\n' "$HOLDER_PIDS" > "$STUBD/pre"; chmod +x "$STUBD/pre"
|
|
245
|
+
ENVV=(REQUIRED_SET_TIMEOUT_S=1)
|
|
246
|
+
_t0=$SECONDS
|
|
247
|
+
sut S4a "$PRN"
|
|
248
|
+
_el=$((SECONDS - _t0))
|
|
249
|
+
[[ "$_el" -lt 9 && "$OUT" == *"no marker (timed out after 1s)"* && "$(nmarkers)" -eq 0 && "$(nlines)" -eq 2 ]] && _v=0 || _v=1; chk "$_v" "S4a a hung read is cut at the timeout though a detached descendant holds its stdout (${_el}s, degraded line names the timeout)" "el=$_el out=[$OUT]"
|
|
250
|
+
[[ -s "$HOLDER_PIDS" ]] && _v=0 || _v=1; chk "$_v" "S4a hygiene: the detached holder really started (its pid was recorded; a holder that never ran proves nothing)" "pids=[$(cat "$HOLDER_PIDS")]"
|
|
251
|
+
_hp="$(head -n 1 "$HOLDER_PIDS")"
|
|
252
|
+
kill -0 "$_hp" 2>/dev/null && _v=0 || _v=1; chk "$_v" "S4a hygiene: the holder is alive after the script returned (it outlived the timeout, so the bound is real)" "pid=$_hp"
|
|
253
|
+
reap
|
|
254
|
+
gone "$_hp" && _v=0 || _v=1; chk "$_v" "S4a hygiene: the reaper kills the holder (a neutered reaper leaves it running and turns this red)" "pid=$_hp still alive"
|
|
255
|
+
else
|
|
256
|
+
chk 0 "S4a skipped: setsid is not installed here (counted so the assertion floor stays exact)" ""
|
|
257
|
+
chk 0 "S4a skipped (holder)" ""; chk 0 "S4a skipped (alive)" ""; chk 0 "S4a skipped (reap)" ""
|
|
258
|
+
fi
|
|
259
|
+
newrow; printf '%s\n%s\n' "$R_HINT" "$M_ERR" > "$STUBD/body"; : > "$STUBD/trap"; ENVV=(REQUIRED_SET_TIMEOUT_S=1)
|
|
260
|
+
_t0=$SECONDS
|
|
261
|
+
sut S4b "$PRN"
|
|
262
|
+
_el=$((SECONDS - _t0))
|
|
263
|
+
[[ "$_el" -lt 9 && "$(last_line)" == "$M_ERR" && "$(nmarkers)" -eq 1 && "$OUT" != *"timed out after"* && "$OUT" != *"gh run rerun 4242"* ]] && _v=0 || _v=1; chk "$_v" "S4b a TERM-trapping resolver cut at the timeout: its error marker is last, no hint beside it (${_el}s)" "el=$_el out=[$OUT]"
|
|
264
|
+
reap
|
|
265
|
+
|
|
266
|
+
# ── S5 never unbounded: no timeout binary, no temp file, bad seam values ──
|
|
267
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; ENVV=(REQUIRED_SET_TIMEOUT_BIN="$ROOT/no-such-timeout")
|
|
268
|
+
sut S5a "$PRN"
|
|
269
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == *"no marker (skipped: no timeout binary)"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S5a an absent timeout binary: one degraded line, the resolver is never called" "out=[$OUT]"
|
|
270
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; TMPDIR_OVERRIDE="$ROOT/no/such/tmpdir"
|
|
271
|
+
sut S5b "$PRN"
|
|
272
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == *"no marker (skipped: no temp file)"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S5b an unusable TMPDIR: 'skipped: no temp file', the resolver is never called" "out=[$OUT]"
|
|
273
|
+
for bad in "REQUIRED_SET_TIMEOUT_S=0" "REQUIRED_SET_TIMEOUT_S=abc" "REQUIRED_SET_TIMEOUT_S=1234567" "REQUIRED_SET_TIMEOUT_S=012" "REQUIRED_SET_TIMEOUT_BIN=a b" "REQUIRED_SET_TIMEOUT_BIN=-x" "REQUIRED_SET_TIMEOUT_BIN=t;id" "REQUIRED_SET_TIMEOUT_BIN=./timeout" "REQUIRED_SET_TIMEOUT_BIN=bin/timeout" "REQUIRED_SET_TIMEOUT_BIN=../timeout" "CI_HEAD_VERDICT_BIN=./ci-head-verdict.sh" "CI_HEAD_VERDICT_BIN=ci-head-verdict.sh" "CI_HEAD_VERDICT_BIN=../req.sh"; do
|
|
274
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; ENVV=("$bad")
|
|
275
|
+
sut "S5c [$bad]" "$PRN"
|
|
276
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S5c bad seam [$bad]: one degraded line, the resolver is never called" "out=[$OUT]"
|
|
277
|
+
done
|
|
278
|
+
|
|
279
|
+
# The timeout is clamped to the fence's 120 s ceiling: 99999 and 121 become 120, 120 and 100 pass through (the seam cannot lengthen the
|
|
280
|
+
# "up to ~125s" the fence announces). The running line and the argv both carry the clamped value.
|
|
281
|
+
for pair in "99999:120" "121:120" "120:120" "100:100"; do
|
|
282
|
+
tv="${pair%%:*}"; want="${pair##*:}"
|
|
283
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; ENVV=(REQUIRED_SET_TIMEOUT_BIN="$STUBD/tbin" REQUIRED_SET_TIMEOUT_S="$tv")
|
|
284
|
+
sut "S5d [$tv]" "$PRN"
|
|
285
|
+
[[ "$(cat "$STUBD/targv" 2>/dev/null)" == "-k 5 $want bash $STUBD/req.sh required 4387" && "$(sed -n 1p "$OUTF")" == "REQUIRED-SET READ — running (up to $((want + 5))s):"* ]] && _v=0 || _v=1; chk "$_v" "S5d REQUIRED_SET_TIMEOUT_S=$tv runs as timeout -k 5 $want (clamped to at most 120) and announces $((want + 5))s" "argv=[$(cat "$STUBD/targv" 2>/dev/null)] out=[$OUT]"
|
|
286
|
+
done
|
|
287
|
+
# A bare name and an absolute path both stay valid (the relative-path refusal above must not eat them).
|
|
288
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; ENVV=(REQUIRED_SET_TIMEOUT_BIN="$STUBD/tbin")
|
|
289
|
+
sut "S5e abs" "$PRN"
|
|
290
|
+
[[ "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S5e an absolute REQUIRED_SET_TIMEOUT_BIN path is accepted" "out=[$OUT]"
|
|
291
|
+
# Non-ASCII digits: [0-9] matches them in some UTF-8 locales. Discover a locale where it really does (a row run under a locale the host lacks
|
|
292
|
+
# makes bash print setlocale warnings and goes red for a reason that has nothing to do with the script). With none, the nine assertions
|
|
293
|
+
# are skipped placeholders so the count stays exact, and on a CI host the missing locale is itself a FAILURE (the rows would be vacuous).
|
|
294
|
+
_wideloc=""
|
|
295
|
+
for _l in en_US.UTF-8 en_US.utf8 C.UTF-8 C.utf8; do
|
|
296
|
+
if LC_ALL=$_l bash -c '[[ "٣" =~ ^[0-9]+$ ]]' 2>/dev/null; then _wideloc="$_l"; break; fi
|
|
297
|
+
done
|
|
298
|
+
if [[ -n "$_wideloc" ]]; then
|
|
299
|
+
chk 0 "S5f control: [0-9] accepts an Arabic-Indic digit under the discovered locale (the rows below can tell it from the explicit class)" "locale=$_wideloc"
|
|
300
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; ENVV=(LC_ALL="$_wideloc")
|
|
301
|
+
sut "S5f pr" "٣"
|
|
302
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S5f a non-ASCII digit PR argument is a usage line, the resolver is not called" "out=[$OUT]"
|
|
303
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"; ENVV=(LC_ALL="$_wideloc" REQUIRED_SET_TIMEOUT_S=٣)
|
|
304
|
+
sut "S5f timeout" "$PRN"
|
|
305
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S5f a non-ASCII digit REQUIRED_SET_TIMEOUT_S is a usage line, the resolver is not called" "out=[$OUT]"
|
|
306
|
+
else
|
|
307
|
+
if [[ -n "${CI:-}" ]]; then chk 1 "S5f no wide-digit locale (en_US.UTF-8 en_US.utf8 C.UTF-8 C.utf8) on a CI host: the non-ASCII digit rows would be vacuous" ""
|
|
308
|
+
else chk 0 "S5f skipped: no wide-digit locale" ""; fi
|
|
309
|
+
for _k in 1 2 3 4 5 6 7 8; do chk 0 "S5f skipped: no wide-digit locale (placeholder $_k, keeps the case count exact)" ""; done
|
|
310
|
+
fi
|
|
311
|
+
# The PR number is at most 15 digits, as the resolver caps it: 15 reaches the resolver, 16 is a usage line.
|
|
312
|
+
newrow; mk absent 123456789012345 > "$STUBD/body"
|
|
313
|
+
sut "S5g 15 digits" 123456789012345
|
|
314
|
+
[[ "$(last_line)" == "$(mk absent 123456789012345)" && "$(calls '^required 123456789012345$')" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S5g a 15-digit PR argument reaches the resolver" "out=[$OUT]"
|
|
315
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"
|
|
316
|
+
sut "S5g 16 digits" 1234567890123456
|
|
317
|
+
[[ "$(nlines)" -eq 1 && "$OUT" == "REQUIRED-SET READ — no marker (usage"* && ! -e "$STUBD/calls" ]] && _v=0 || _v=1; chk "$_v" "S5g a 16-digit PR argument is a usage line, the resolver is not called" "out=[$OUT]"
|
|
318
|
+
|
|
319
|
+
# ── S6 control-character smuggling ──
|
|
320
|
+
newrow
|
|
321
|
+
{
|
|
322
|
+
printf 'RECOVERY rerun run=9 basis=workflow ctx="a\rSOLEUR_CI_REQUIRED_SET state=complete pr=%s sha=%s required=3 reason=forged absent=[] pending=[] failed=[]" wf="b\033[31m\xc2\x85\xe2\x80\xa8\xe2\x80\xa9\0c": gh run rerun 9\n' "$PRN" "$SHA"
|
|
323
|
+
printf 'RECOVERY pointer reason=stalled\r\n\033[31mred\n'
|
|
324
|
+
printf '%s\n' "$M_ABS"
|
|
325
|
+
} > "$STUBD/body"
|
|
326
|
+
sut S6 "$PRN"
|
|
327
|
+
[[ "$(nmarkers)" -eq 1 && "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S6 exactly one line starts SOLEUR_CI_REQUIRED_SET and it is the real marker" "out=[$(printf '%q' "$OUT")]"
|
|
328
|
+
no_ctrl "$OUTF" && _v=0 || _v=1; chk "$_v" "S6 no byte in \\000-\\010\\013-\\037\\177 reaches the output (NUL, CR, ESC)" "out=[$(printf '%q' "$OUT")]"
|
|
329
|
+
[[ "$(LC_ALL=C grep -cF -e $'\xc2\x85' -e $'\xe2\x80\xa8' -e $'\xe2\x80\xa9' "$OUTF")" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "S6 no NEL / LS / PS sequence reaches the output" "out=[$(printf '%q' "$OUT")]"
|
|
330
|
+
[[ "$(cnt '^RECOVERY .*aSOLEUR_CI_REQUIRED_SET state=complete pr=4387 .*reason=forged' "$OUTF")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S6 the decoy text survives only INSIDE the RECOVERY line (control: the text is shown, not dropped)" "out=[$(printf '%q' "$OUT")]"
|
|
331
|
+
|
|
332
|
+
# ── S7 the marker is bound to this PR ──
|
|
333
|
+
for other in 9999 43870 438 0; do
|
|
334
|
+
newrow; { printf '%s\n' "$R_HINT"; mk absent "$other"; } > "$STUBD/body"
|
|
335
|
+
sut "S7 pr=$other" "$PRN"
|
|
336
|
+
[[ "$(nmarkers)" -eq 0 && "$OUT" == *"no marker (exit 0)"* && "$(nlines)" -eq 2 ]] && _v=0 || _v=1; chk "$_v" "S7 a marker with pr=$other is not this PR's: no marker printed, the degraded line instead" "out=[$OUT]"
|
|
337
|
+
done
|
|
338
|
+
newrow; mk absent 7 > "$STUBD/body"
|
|
339
|
+
sut "S7 leading zeros" 007
|
|
340
|
+
[[ "$(last_line)" == "$(mk absent 7)" && "$(calls '^required 007$')" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S7 'required 007' is bound to the resolver's normalised pr=7 (the resolver gets the argument as given)" "out=[$OUT] calls=[$(cat "$STUBD/calls" 2>/dev/null)]"
|
|
341
|
+
|
|
342
|
+
# ── S8 the marker is read, not the exit code ──
|
|
343
|
+
newrow; { printf '%s\n' "$R_HINT"; mk complete; } > "$STUBD/body"; printf '3' > "$STUBD/rc"
|
|
344
|
+
sut "S8a" "$PRN"
|
|
345
|
+
[[ "$(last_line)" == "$(mk complete)" && "$OUT" == *"NOT that the PR is mergeable"* ]] && _v=0 || _v=1; chk "$_v" "S8a a complete marker with resolver rc 3 is printed as complete" "out=[$OUT]"
|
|
346
|
+
newrow; mk error > "$STUBD/body"; printf '0' > "$STUBD/rc"
|
|
347
|
+
sut "S8b" "$PRN"
|
|
348
|
+
[[ "$(last_line)" == "$M_ERR" && "$OUT" != *"NOT that the PR is mergeable"* ]] && _v=0 || _v=1; chk "$_v" "S8b an error marker with resolver rc 0 is printed as error" "out=[$OUT]"
|
|
349
|
+
|
|
350
|
+
# ── S9 candidate cap: 20 candidate lines then the overflow line; pointers and workflow lines are never capped ──
|
|
351
|
+
cand() { printf 'RECOVERY rerun run=%s basis=candidate ctx="c%s" wf="W"\n' "$1" "$1"; }
|
|
352
|
+
newrow
|
|
353
|
+
{
|
|
354
|
+
for i in 1 2 3; do printf 'RECOVERY rerun run=%s basis=workflow ctx="w%s" wf="W": gh run rerun %s\n' "$((900 + i))" "$i" "$((900 + i))"; done
|
|
355
|
+
for i in $(seq 1 25); do cand "$i"; printf 'RECOVERY owner not determined, read the run before re-running ctx="o%s"\n' "$i"; done
|
|
356
|
+
for i in 26 27 28 29 30; do printf 'RECOVERY owner not determined, read the run before re-running ctx="o%s"\n' "$i"; done
|
|
357
|
+
printf '%s\n' "$M_ABS"
|
|
358
|
+
} > "$STUBD/body"
|
|
359
|
+
sut S9 "$PRN"
|
|
360
|
+
[[ "$(cnt 'basis=candidate' "$OUTF")" -eq 20 && "$(cnt 'run=20 basis=candidate' "$OUTF")" -eq 1 && "$(cnt 'run=21 basis=candidate' "$OUTF")" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "S9 25 candidate lines: the first 20 are printed, the rest cut" "out=[$OUT]"
|
|
361
|
+
[[ "$(cnt '^REQUIRED-SET READ — 5 more candidate lines not shown' "$OUTF")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S9 exactly one '5 more candidate lines not shown' line" "out=[$OUT]"
|
|
362
|
+
[[ "$(cnt '^RECOVERY owner not determined, read the run' "$OUTF")" -eq 30 && "$(cnt 'basis=workflow' "$OUTF")" -eq 3 ]] && _v=0 || _v=1; chk "$_v" "S9 all 30 owner-not-determined lines and all 3 workflow lines are printed (only candidates are capped)" "out=[$OUT]"
|
|
363
|
+
[[ "$(last_line)" == "$M_ABS" && "$(nmarkers)" -eq 1 && "$(grep -n '^REQUIRED-SET READ — 5 more' "$OUTF" | cut -d: -f1)" -eq $(( $(nlines) - 1 )) ]] && _v=0 || _v=1; chk "$_v" "S9 the overflow line sits directly before the marker, the marker is last" "out=[$OUT]"
|
|
364
|
+
[[ "$(grep '^RECOVERY ' "$OUTF" | head -n 3 | grep -c 'basis=workflow')" -eq 3 ]] && _v=0 || _v=1; chk "$_v" "S9 RECOVERY lines keep the resolver's own order (the three workflow lines come first)" "out=[$OUT]"
|
|
365
|
+
for n in 20 21; do
|
|
366
|
+
newrow; { for i in $(seq 1 "$n"); do cand "$i"; done; printf '%s\n' "$M_ABS"; } > "$STUBD/body"
|
|
367
|
+
sut "S9 n=$n" "$PRN"
|
|
368
|
+
_st=1
|
|
369
|
+
if [[ "$n" -eq 20 ]]; then
|
|
370
|
+
[[ "$(cnt 'basis=candidate' "$OUTF")" -eq 20 && "$(cnt 'more candidate lines' "$OUTF")" -eq 0 ]] && _st=0
|
|
371
|
+
else
|
|
372
|
+
[[ "$(cnt 'basis=candidate' "$OUTF")" -eq 20 && "$(cnt '^REQUIRED-SET READ — 1 more candidate lines not shown' "$OUTF")" -eq 1 ]] && _st=0
|
|
373
|
+
fi
|
|
374
|
+
chk "$_st" "S9 boundary: $n candidate lines print 20 and $([[ "$n" -eq 20 ]] && echo 'no overflow line' || echo 'a "1 more" line')" "out=[$OUT]"
|
|
375
|
+
done
|
|
376
|
+
|
|
377
|
+
# ── S10 RECOVERY text is never executed ──
|
|
378
|
+
SHIMD="$ROOT/shims"; mkdir -p "$SHIMD"; SHIMLOG="$ROOT/shimlog"; SENT="$ROOT/SENTINEL"; SENT2="$ROOT/SENTINEL2"
|
|
379
|
+
printf '#!/bin/sh\nprintf "gh %%s\\n" "$*" >> "%s"\n' "$SHIMLOG" > "$SHIMD/gh"
|
|
380
|
+
printf '#!/bin/sh\nprintf "touch %%s\\n" "$*" >> "%s"\nexec "%s" "$@"\n' "$SHIMLOG" "$REAL_TOUCH" > "$SHIMD/touch"
|
|
381
|
+
# bash shim: the resolver call passes through (exec the real bash), anything else is logged — an eval/bash -c of hint text would land here.
|
|
382
|
+
printf '#!/bin/sh\ncase "$1" in "%s") exec "%s" "$@" ;; esac\nprintf "bash %%s\\n" "$*" >> "%s"\nexec "%s" "$@"\n' "$STUBD/req.sh" "$REAL_BASH" "$SHIMLOG" "$REAL_BASH" > "$SHIMD/bash"
|
|
383
|
+
chmod +x "$SHIMD/gh" "$SHIMD/touch" "$SHIMD/bash"
|
|
384
|
+
# positive control: the shims log when called (a shim that cannot log makes 'log is empty' vacuous)
|
|
385
|
+
: > "$SHIMLOG"; PATH="$SHIMD:$PATH" gh ping; PATH="$SHIMD:$PATH" bash -c 'true'; PATH="$SHIMD:$PATH" touch "$ROOT/ctl"
|
|
386
|
+
[[ "$(grep -c '' "$SHIMLOG")" -eq 3 ]] && _v=0 || _v=1; chk "$_v" "S10 control: the gh, bash and touch shims each log a call" "log=[$(cat "$SHIMLOG")]"
|
|
387
|
+
rm -f "$ROOT/ctl"; : > "$SHIMLOG"
|
|
388
|
+
newrow
|
|
389
|
+
{
|
|
390
|
+
printf 'RECOVERY rerun run=1 basis=workflow ctx="x" wf="y": gh run rerun 1\n'
|
|
391
|
+
printf 'RECOVERY rerun run=2 basis=workflow ctx="$(touch %s)" wf="`touch %s`": gh run rerun 2\n' "$SENT" "$SENT"
|
|
392
|
+
printf 'RECOVERY rerun run=3 basis=candidate ctx="a;touch %s" wf="W; bash -c \\"touch %s\\"; gh run rerun 3"\n' "$SENT2" "$SENT2"
|
|
393
|
+
printf '%s\n' "$M_ABS"
|
|
394
|
+
} > "$STUBD/body"
|
|
395
|
+
ENVV=(PATH="$SHIMD:$PATH")
|
|
396
|
+
sut S10 "$PRN"
|
|
397
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 3 && "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S10 control: the hostile RECOVERY lines were printed (not dropped), marker last" "out=[$OUT]"
|
|
398
|
+
[[ ! -s "$SHIMLOG" ]] && _v=0 || _v=1; chk "$_v" "S10 the gh / bash / touch shim log is empty after the run" "log=[$(cat "$SHIMLOG")]"
|
|
399
|
+
[[ ! -e "$SENT" && ! -e "$SENT2" ]] && _v=0 || _v=1; chk "$_v" "S10 no sentinel file was created by hint text" "sentinels=[$(ls "$SENT" "$SENT2" 2>&1 | tr '\n' ' ')]"
|
|
400
|
+
|
|
401
|
+
# ── S11 production default: the resolver beside the script, the seam unset ──
|
|
402
|
+
P="$ROOT/s11"; mkdir -p "$P"; cp "$SUT" "$P/required-set-report.sh"
|
|
403
|
+
cat > "$P/ci-head-verdict.sh" <<EOF
|
|
404
|
+
#!/usr/bin/env bash
|
|
405
|
+
d="\$(cd "\$(dirname "\$0")" && pwd)"
|
|
406
|
+
printf '%s\n' "\$*" >> "\$d/calls"
|
|
407
|
+
printf 'RECOVERY no cancelled run at this head ctx="\r\033\007\177\0001"\n'
|
|
408
|
+
printf 'SOLEUR_CI_REQUIRED_SET state=absent pr=%s sha=%s required=3 reason=context-absent absent=["cla-evidence"] pending=[] failed=[]\n' "\$2" "$SHA"
|
|
409
|
+
EOF
|
|
410
|
+
ROWN=$((ROWN + 1)); ROWTMP="$ROOT/row$ROWN"; mkdir -p "$ROWTMP"
|
|
411
|
+
env -u CI_HEAD_VERDICT_BIN -u REQUIRED_SET_TIMEOUT_S -u REQUIRED_SET_TIMEOUT_BIN TMPDIR="$ROWTMP" bash "$P/required-set-report.sh" 4387 > "$ROOT/s11.out" 2>"$ROOT/s11.err"; RC=$?
|
|
412
|
+
[[ "$(cat "$P/calls" 2>/dev/null)" == "required 4387" ]] && _v=0 || _v=1; chk "$_v" "S11 seam unset: the stub beside the script receives 'required 4387' and nothing else" "calls=[$(cat "$P/calls" 2>/dev/null)]"
|
|
413
|
+
[[ "$RC" -eq 0 && "$(tail -n 1 "$ROOT/s11.out")" == "$(mk absent)" && ! -s "$ROOT/s11.err" ]] && _v=0 || _v=1; chk "$_v" "S11 the copied script prints the marker last, exit 0, silent stderr" "rc=$RC out=[$(cat "$ROOT/s11.out")]"
|
|
414
|
+
[[ -z "$(ls -A "$ROWTMP")" ]] && _v=0 || _v=1; chk "$_v" "S11 no temp file left in the private TMPDIR" "left=[$(ls -A "$ROWTMP")]"
|
|
415
|
+
no_ctrl "$ROOT/s11.out" && [[ "$(cnt '^RECOVERY no cancelled run at this head ctx="1"$' "$ROOT/s11.out")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S11 without lib/context-sanitize.sh beside it the fallback sanitiser still drops CR, ESC, BEL, DEL and NUL" "out=[$(printf '%q' "$(cat "$ROOT/s11.out")")]"
|
|
416
|
+
|
|
417
|
+
# ── S12 non-canonical but valid input is printed and parsed ──
|
|
418
|
+
newrow
|
|
419
|
+
{
|
|
420
|
+
printf 'RECOVERY rerun run=5 basis=workflow ctx="has \\"quotes\\" and ] bracket" wf="W [x]": gh run rerun 5\n'
|
|
421
|
+
printf 'SOLEUR_CI_REQUIRED_SET state=absent pr=%s sha=%s required=3 reason=context-absent absent=["a b","c [d]"] pending=[] failed=[]\n' "$PRN" "$SHA"
|
|
422
|
+
} > "$STUBD/body"
|
|
423
|
+
sut S12 "$PRN"
|
|
424
|
+
[[ "$(cnt 'has \\"quotes\\" and \] bracket' "$OUTF")" -eq 1 && "$(last_line)" == *'absent=["a b","c [d]"] pending=[] failed=[]' && "$(nmarkers)" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S12 a marker with spaces and brackets inside its JSON, and a ctx= with quotes and ], are printed whole" "out=[$OUT]"
|
|
425
|
+
|
|
426
|
+
# ── S13 tail truncation: a body larger than 262144 bytes still ends in its marker ──
|
|
427
|
+
newrow
|
|
428
|
+
{ printf 'RECOVERY no cancelled run at this head ctx="early"\n'; head -c 300000 /dev/zero | tr '\0' 'x'; printf '\nRECOVERY no cancelled run at this head ctx="late"\n'; printf '%s\n' "$M_ABS"; } > "$STUBD/body"
|
|
429
|
+
[[ "$(wc -c < "$STUBD/body")" -gt 262144 ]] && _v=0 || _v=1; chk "$_v" "S13 control: the body is larger than 262144 bytes" "size=$(wc -c < "$STUBD/body")"
|
|
430
|
+
sut S13 "$PRN"
|
|
431
|
+
[[ "$(last_line)" == "$M_ABS" && "$(nmarkers)" -eq 1 && "$(cnt '^RECOVERY no cancelled run at this head ctx="late"$' "$OUTF")" -eq 1 && "$(cnt 'ctx="early"' "$OUTF")" -eq 0 && "$(nlines)" -eq 4 ]] && _v=0 || _v=1; chk "$_v" "S13 only the tail is read: the marker is last and the late hint survives; the early hint (before the 262144-byte window) and the padding do not" "lines=$(nlines) last=[$(last_line)]"
|
|
432
|
+
|
|
433
|
+
# ── S14 two markers for this PR in the resolver output: the LAST one is the answer, and only it is printed ──
|
|
434
|
+
newrow; { printf '%s\n' "$R_HINT"; mk complete; mk absent; } > "$STUBD/body"
|
|
435
|
+
sut S14 "$PRN"
|
|
436
|
+
[[ "$(nmarkers)" -eq 1 && "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S14 two matching markers in the body: exactly one marker is printed and it is the LAST one (state=absent)" "out=[$OUT]"
|
|
437
|
+
[[ "$OUT" != *"NOT that the PR is mergeable"* ]] && _v=0 || _v=1; chk "$_v" "S14 the earlier complete marker contributes nothing (no 'mergeable' note)" "out=[$OUT]"
|
|
438
|
+
|
|
439
|
+
P_UNDO='see skills/ship/references/ready-run-wait.md (confirm in the Actions tab that no ready run is still in flight, the undo cancels it; then gh pr ready --undo, then gh pr ready, with a user token)'
|
|
440
|
+
P_APPR='see skills/ship/references/ready-run-wait.md (a maintainer must approve the fork workflow run)'
|
|
441
|
+
# ── S15 RECOVERY lines must match the resolver's CLOSED grammar; the rest is counted, not printed ──
|
|
442
|
+
# Positive control first: one line of each of the ten lines the resolver prints (ci-head-verdict.sh recover_required), all shown.
|
|
443
|
+
newrow
|
|
444
|
+
{
|
|
445
|
+
printf 'RECOVERY rerun run=7 basis=workflow ctx="a" wf="W": gh run rerun 7\n'
|
|
446
|
+
printf 'RECOVERY rerun run=8 basis=candidate ctx="a" wf="W"\n'
|
|
447
|
+
printf 'RECOVERY owner not determined (read failed) ctx="a"\n'
|
|
448
|
+
printf 'RECOVERY owner not determined, read the run before re-running ctx="a"\n'
|
|
449
|
+
printf 'RECOVERY no cancelled run at this head ctx="a"\n'
|
|
450
|
+
printf 'RECOVERY pointer reason=stale-row ctx="test": %s\n' "$P_UNDO"
|
|
451
|
+
printf 'RECOVERY pointer reason=awaiting-approval ctx="test": %s\n' "$P_APPR"
|
|
452
|
+
printf 'RECOVERY pointer reason=stalled ctx="test": %s\n' "$P_UNDO"
|
|
453
|
+
printf 'RECOVERY pointer failed=["x","y z"]: read the failing checks with gh pr checks 4387\n'
|
|
454
|
+
printf 'RECOVERY pointer pending=[]: wait, then read the checks with gh pr checks 4387\n'
|
|
455
|
+
printf 'RECOVERY rerun run=123456789012345 basis=workflow ctx="a" wf="W": gh run rerun 123456789012345\n'
|
|
456
|
+
printf '%s\n' "$M_ABS"
|
|
457
|
+
} > "$STUBD/body"
|
|
458
|
+
sut S15a "$PRN"
|
|
459
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 11 && "$OUT" != *"outside the resolver grammar"* && "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S15a every line the resolver prints (ten printf lines, three pointer reasons, a 15-digit run id) is shown, no 'outside the grammar' line" "out=[$OUT]"
|
|
460
|
+
# Negative rows: each line below is outside the grammar and must be dropped and counted.
|
|
461
|
+
newrow
|
|
462
|
+
{
|
|
463
|
+
printf 'RECOVERY rerun run=2 basis=workflow ctx="x" wf="y": gh run rerun 2 $(touch %s)\n' "$ROOT/S15" # trailing command text
|
|
464
|
+
printf 'RECOVERY rerun run=3 basis=workflow ctx="x" wf="y": gh run rerun 4\n' # id differs from run=
|
|
465
|
+
printf 'RECOVERY rerun run=1234567890123456 basis=workflow ctx="x" wf="y": gh run rerun 1234567890123456\n' # 16 digits
|
|
466
|
+
printf 'RECOVERY rerun run=5 basis=candidate ctx="x" wf="y": bash -c id\n' # candidate with a tail
|
|
467
|
+
printf 'RECOVERY rerun run=6 basis=guess ctx="x" wf="y"\n' # unknown basis
|
|
468
|
+
printf 'RECOVERY rerun run=7 basis=candidate ctx=x wf="y"\n' # ctx not a JSON string
|
|
469
|
+
printf 'RECOVERY no cancelled run at this head ctx="x" and more\n' # trailing text on a closer
|
|
470
|
+
printf 'RECOVERY run this: rm -rf /\n' # an unknown shape
|
|
471
|
+
printf 'RECOVERY pointer reason=bogus ctx="x"\n' # unknown pointer reason
|
|
472
|
+
printf 'RECOVERY pointer pending=: wait, then read the checks with gh pr checks 4387\n' # empty array
|
|
473
|
+
printf 'RECOVERY pointer failed=["a"]: read the failing checks with gh pr checks 4387 && id\n' # different tail
|
|
474
|
+
printf 'RECOVERY pointer failed=["a"]: read the failing checks with gh pr checks 9999\n' # another PR
|
|
475
|
+
printf 'RECOVERY rerun run=3 basis=guess ctx="x" wf="y": gh run rerun 3\n' # unknown basis with the command tail
|
|
476
|
+
printf 'RECOVERY owner not determined, read the run before re-running now ctx="x"\n' # text before ctx=
|
|
477
|
+
printf 'RECOVERY rerun run=%s basis=candidate ctx="x" wf="y"\n' 123456789012345678901234567890 # 30-digit candidate id
|
|
478
|
+
printf 'RECOVERY rerun run=4 basis=candidate ctx="a" wf="b" wf="c"\n' # unescaped embedded " wf="
|
|
479
|
+
printf 'RECOVERY\n' # bare keyword
|
|
480
|
+
printf 'RECOVERY pointer reason=stale-row ctx="test": do something else entirely\n' # fixed-reason pointer, other tail
|
|
481
|
+
printf 'RECOVERY pointer reason=stalled ctx="x": %s and then more\n' "$P_UNDO" # stalled pointer, extra tail
|
|
482
|
+
printf 'RECOVERY pointer reason=awaiting-approval ctx="test": %s && x\n' "$P_APPR" # awaiting-approval, command tail
|
|
483
|
+
printf 'RECOVERY pointer reason=awaiting-approval ctx="test": %s and more\n' "$P_APPR" # awaiting-approval, longer tail
|
|
484
|
+
printf 'RECOVERY pointer reason=stale-row ctx="test": %s and more\n' "$P_UNDO" # stale-row, longer tail
|
|
485
|
+
printf 'RECOVERY pointer pending=["a"]: wait, then read the checks with gh pr checks 4387 && id\n' # pending, command tail
|
|
486
|
+
printf 'RECOVERY pointer pending=["a"]: wait, then read the checks with gh pr checks 9999\n' # pending, another PR
|
|
487
|
+
printf 'RECOVERY pointer failed=[a b]: read the failing checks with gh pr checks 4387\n' # unquoted array element
|
|
488
|
+
printf '%s\n' "$M_ABS"
|
|
489
|
+
} > "$STUBD/body"
|
|
490
|
+
sut S15b "$PRN"
|
|
491
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 0 && "$(cnt "^REQUIRED-SET READ — 25 RECOVERY line(s) outside the resolver grammar not shown (run the read by hand: ready-run-wait.md, 'A green verdict that never enqueues')\$" "$OUTF")" -eq 1 && "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S15b twenty-five lines outside the grammar (command tails, id mismatch, 16- and 30-digit ids, bad bases, unquoted ctx, trailing text, unknown shape and pointer reason, empty array, other PR, embedded wf=, bare keyword): none printed, one count line with the by-hand pointer, marker last" "out=[$OUT]"
|
|
492
|
+
[[ "$(wc -l < "$STUBD/calls")" -eq 1 && ! -e "$ROOT/S15" ]] && _v=0 || _v=1; chk "$_v" "S15b nothing was executed (no sentinel) and the resolver was called once" "calls=$(cat "$STUBD/calls")"
|
|
493
|
+
newrow
|
|
494
|
+
{ printf 'RECOVERY rerun run=2 basis=workflow ctx="x" wf="y": gh run rerun 9\n'; printf 'RECOVERY no cancelled run at this head ctx="ok"\n'; mk error; } > "$STUBD/body"; printf '3' > "$STUBD/rc"
|
|
495
|
+
sut S15c "$PRN"
|
|
496
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 0 && "$OUT" != *"outside the resolver grammar"* ]] && _v=0 || _v=1; chk "$_v" "S15c state=error prints neither hints nor a grammar count line" "out=[$OUT]"
|
|
497
|
+
|
|
498
|
+
# ── S15d nested sequences inside wf= on a RECOVERY line that IS printed. The real resolver cleans wf= (its `clean` filter) and rejects a ctx
|
|
499
|
+
# with such code points (amr_arr_ok); it does NOT clean its stderr, and a substituted resolver cleans nothing, so the script itself must clean
|
|
500
|
+
# to a fixpoint ──
|
|
501
|
+
newrow
|
|
502
|
+
{
|
|
503
|
+
printf 'RECOVERY rerun run=9 basis=workflow ctx="c" wf="a\xc2\xc2\x85\x85b\xe2\x80\xe2\x80\xa8\xa8c\xe2\x80\xe2\x80\xa9\xa9d": gh run rerun 9\n'
|
|
504
|
+
printf 'RECOVERY rerun run=10 basis=candidate ctx="c" wf="%s"\n' "$_deep"
|
|
505
|
+
printf '%s\n' "$M_ABS"
|
|
506
|
+
} > "$STUBD/body"
|
|
507
|
+
sut S15d "$PRN"
|
|
508
|
+
[[ "$(LC_ALL=C grep -cF -e $'\xc2\x85' -e $'\xe2\x80\xa8' -e $'\xe2\x80\xa9' "$OUTF")" -eq 0 && "$(cnt '^RECOVERY rerun run=9 basis=workflow ctx="c" wf="abcd": gh run rerun 9$' "$OUTF")" -eq 1 && "$(cnt '^RECOVERY rerun run=10 basis=candidate' "$OUTF")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S15d nested NEL / LS / PS inside wf= (and 40-deep nesting) do not re-form; both lines are still printed" "out=[$(printf '%q' "$OUT")]"
|
|
509
|
+
|
|
510
|
+
# ── S15e ordinary non-ASCII text survives untouched (the fixpoint must converge on it, not take the lead-byte fallback), and a non-canonical PR ──
|
|
511
|
+
newrow; { printf 'RECOVERY no cancelled run at this head ctx="a\xc2\xa9b\xe2\x80\x94c"\n'; printf '%s\n' "$M_ABS"; } > "$STUBD/body"
|
|
512
|
+
sut S15e "$PRN"
|
|
513
|
+
[[ "$(cnt "^RECOVERY no cancelled run at this head ctx=\"a"$'\xc2\xa9'"b"$'\xe2\x80\x94'"c\"\$" "$OUTF")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S15e a ctx with a copyright sign and an em dash is printed UNCHANGED (the fixpoint converges instead of dropping 0xC2/0xE2)" "out=[$(printf '%q' "$OUT")]"
|
|
514
|
+
newrow; { printf 'RECOVERY pointer failed=["x"]: read the failing checks with gh pr checks 7\n'; printf 'RECOVERY pointer pending=["x"]: wait, then read the checks with gh pr checks 007\n'; mk absent 7; } > "$STUBD/body"
|
|
515
|
+
sut S15f 007
|
|
516
|
+
[[ "$(cnt '^RECOVERY pointer ' "$OUTF")" -eq 2 && "$OUT" != *"outside the resolver grammar"* && "$(last_line)" == "$(mk absent 7)" ]] && _v=0 || _v=1; chk "$_v" "S15f PR argument 007: pointers ending 'checks 7' (normalised) and 'checks 007' (as given) are both printed, no count line" "out=[$OUT]"
|
|
517
|
+
# _fix runs in byte semantics (a 240 KB line took 6-32 s per read in a UTF-8 locale and 1-2 s in C, identical output). A wall-clock bound is not stable
|
|
518
|
+
# across hosts, so the property is pinned on the source: the function declares LC_ALL=C for itself.
|
|
519
|
+
grep -qF 'local t u n=0 LC_ALL=C' "$SUT" && _v=0 || _v=1; chk "$_v" "S15g _fix declares LC_ALL=C for itself (byte semantics, a UTF-8 locale made it 6-13x slower)" ""
|
|
520
|
+
|
|
521
|
+
# ── S18 the grammar is tied to the resolver's SOURCE: every `printf 'RECOVERY` line of ci-head-verdict.sh, instantiated, is accepted ──
|
|
522
|
+
# A resolver edit that adds or rewords a RECOVERY line fails here instead of silently dropping the hint in production. The count (10) is the
|
|
523
|
+
# number of lines S15a covers; the positive control is that those ten instantiated lines all come out.
|
|
524
|
+
mapfile -t _fmts < <(grep -vE '^[[:space:]]*#' "$DIR/ci-head-verdict.sh" | grep -o "printf 'RECOVERY[^']*'" | sed -e "s/^printf '//" -e "s/'\$//" \
|
|
525
|
+
-e 's/failed=%s/failed=["a"]/' -e 's/pending=%s/pending=["a"]/' -e 's/run=%s/run=12345/' -e 's/ctx=%s/ctx="c"/' -e 's/wf=%s/wf="w"/' \
|
|
526
|
+
-e 's/gh run rerun %s/gh run rerun 12345/' -e 's/gh pr checks %s/gh pr checks 4387/' -e 's/\\n$//')
|
|
527
|
+
_left=0; for _f in "${_fmts[@]}"; do [[ "$_f" == *%* ]] && _left=$((_left + 1)); done
|
|
528
|
+
[[ "${#_fmts[@]}" -eq 10 && "$_left" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "S18 ci-head-verdict.sh has exactly 10 (non-comment) printf 'RECOVERY lines and every %s in them is one this suite knows how to fill" "lines=${#_fmts[@]} unfilled=$_left"
|
|
529
|
+
# Any OTHER non-comment line that mentions `RECOVERY ` is an emitter the extraction above cannot see (an echo, a double-quoted printf, a heredoc). The one
|
|
530
|
+
# allowed mention is the --help sentence "RECOVERY lines before the marker print ...".
|
|
531
|
+
_other="$(grep -vE '^[[:space:]]*#' "$DIR/ci-head-verdict.sh" | grep 'RECOVERY ' | grep -v "printf 'RECOVERY" | grep -vc '^ RECOVERY lines before the marker print')" || true
|
|
532
|
+
[[ "${_other:-1}" -eq 0 ]] && _v=0 || _v=1; chk "$_v" "S18 no other non-comment line of ci-head-verdict.sh emits a RECOVERY line (an echo or a double-quoted printf would be invisible to the grammar check)" "other=$_other"
|
|
533
|
+
newrow; { printf '%s\n' "${_fmts[@]}"; printf '%s\n' "$M_ABS"; } > "$STUBD/body"
|
|
534
|
+
sut S18 "$PRN"
|
|
535
|
+
[[ "$(cnt '^RECOVERY ' "$OUTF")" -eq 10 && "$OUT" != *"outside the resolver grammar"* && "$(last_line)" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S18 all ten of the resolver's own RECOVERY lines pass the script's grammar (no 'outside the grammar' line)" "out=[$OUT]"
|
|
536
|
+
|
|
537
|
+
# ── S16 the marker anchors: a marker-shaped fragment inside a RECOVERY line is never the marker; unknown states and short markers are no markers ──
|
|
538
|
+
D_ABS="RECOVERY no cancelled run at this head ctx=\"x $(mk absent | sed 's/"/\\"/g') y\"" # the quotes inside are escaped, as the resolver's @json does
|
|
539
|
+
newrow; { mk complete; printf '%s\n' "$D_ABS"; } > "$STUBD/body"
|
|
540
|
+
sut S16a "$PRN"
|
|
541
|
+
[[ "$(nmarkers)" -eq 1 && "$(last_line)" == "$(mk complete)" && "$(cnt 'ctx="x SOLEUR_CI_REQUIRED_SET state=absent' "$OUTF")" -eq 1 ]] && _v=0 || _v=1; chk "$_v" "S16a a RECOVERY line that CONTAINS an absent marker, placed LAST after the real complete marker: the complete marker is the answer, the decoy is only shown inside its RECOVERY line" "out=[$OUT]"
|
|
542
|
+
newrow; printf '%s\n' "$D_ABS" > "$STUBD/body"
|
|
543
|
+
sut S16b "$PRN"
|
|
544
|
+
[[ "$(nmarkers)" -eq 0 && "$OUT" == *"no marker (exit 0)"* ]] && _v=0 || _v=1; chk "$_v" "S16b a marker-shaped fragment mid-line and NO real marker: the degraded line, not a forged marker" "out=[$OUT]"
|
|
545
|
+
newrow; mk absent | sed 's/state=absent/state=bogus/' > "$STUBD/body"
|
|
546
|
+
sut S16c "$PRN"
|
|
547
|
+
[[ "$(nmarkers)" -eq 0 && "$OUT" == *"no marker (exit 0)"* ]] && _v=0 || _v=1; chk "$_v" "S16c a marker with a state outside the five (state=bogus) is no marker" "out=[$OUT]"
|
|
548
|
+
for cut in sha required reason absent pending failed; do
|
|
549
|
+
newrow; mk absent | sed "s/ $cut=[^ ]*//" > "$STUBD/body"
|
|
550
|
+
sut "S16d $cut" "$PRN"
|
|
551
|
+
[[ "$(nmarkers)" -eq 0 && "$OUT" == *"no marker (exit 0)"* ]] && _v=0 || _v=1; chk "$_v" "S16d a marker without its $cut= field is no marker" "out=[$OUT]"
|
|
552
|
+
done
|
|
553
|
+
|
|
554
|
+
# ── S17 the resolver never inherits the script's stdin ──
|
|
555
|
+
# The stub's pre hook records whether its stdin is at EOF (read returns 1) or open (read times out, 142). The script is run DIRECTLY with
|
|
556
|
+
# a stdin that is an open FIFO (our own read-write fd holds it open), so only the script's inner </dev/null can give the resolver EOF.
|
|
557
|
+
newrow; printf '%s\n' "$M_ABS" > "$STUBD/body"
|
|
558
|
+
printf '#!/usr/bin/env bash\nd="$(cd "$(dirname "$0")" && pwd)"\nread -r -t 2 _x; echo "$?" > "$d/stdin-rc"\n' > "$STUBD/pre"; chmod +x "$STUBD/pre"
|
|
559
|
+
mkfifo "$ROOT/fifo"; exec {_ffd}<>"$ROOT/fifo"
|
|
560
|
+
ROWN=$((ROWN + 1)); ROWTMP="$ROOT/row$ROWN"; mkdir -p "$ROWTMP"
|
|
561
|
+
env CI_HEAD_VERDICT_BIN="$STUBD/req.sh" TMPDIR="$ROWTMP" "$REAL_BASH" "$SUT" "$PRN" >"$ROOT/s17.out" 2>/dev/null <&"$_ffd"
|
|
562
|
+
exec {_ffd}<&-
|
|
563
|
+
[[ "$(cat "$STUBD/stdin-rc" 2>/dev/null)" == 1 && "$(tail -n 1 "$ROOT/s17.out")" == "$M_ABS" ]] && _v=0 || _v=1; chk "$_v" "S17 the resolver's stdin is at EOF though the script's own stdin is an open pipe (read rc 1, not a 2 s timeout)" "stdin-rc=$(cat "$STUBD/stdin-rc" 2>/dev/null)"
|
|
564
|
+
rm -f "$STUBD/stdin-rc"
|
|
565
|
+
|
|
566
|
+
# ── totals and the assertion floor ──
|
|
567
|
+
echo ""
|
|
568
|
+
echo "cases_run=$CASES_RUN passes=$passes fails=$fails ledger=${#FAILED[@]}"
|
|
569
|
+
_min_cases=368
|
|
570
|
+
if [[ "$CASES_RUN" -lt "$_min_cases" ]]; then
|
|
571
|
+
printf '[FATAL] assertion floor: only %s case(s) ran, floor is %s\n' "$CASES_RUN" "$_min_cases" >&2; exit 1
|
|
572
|
+
fi
|
|
573
|
+
if [[ $((passes + fails)) -ne "$CASES_RUN" ]]; then
|
|
574
|
+
printf '[FATAL] %s verdicts for %s cases\n' "$((passes + fails))" "$CASES_RUN" >&2; exit 1
|
|
575
|
+
fi
|
|
576
|
+
if [[ "${#FAILED[@]}" -ne "$fails" ]]; then
|
|
577
|
+
printf '[FATAL] ledger/counter disagree: %s vs %s\n' "${#FAILED[@]}" "$fails" >&2; exit 1
|
|
578
|
+
fi
|
|
579
|
+
if [[ "${#FAILED[@]}" -ne 0 ]]; then
|
|
580
|
+
printf '[FATAL] %s failing assertion(s):\n' "${#FAILED[@]}" >&2
|
|
581
|
+
printf ' - %s\n' "${FAILED[@]}" >&2; exit 1
|
|
582
|
+
fi
|
|
583
|
+
echo "required-set-report: all $passes assertions passed"
|