fix(751): re-review round — a truncation hole, and the tests that closed findings needed closing
Cross-family re-review of the previous fix commit. It did NOT pass, and it was right
not to: the round that fixed the reviewers' findings introduced two of its own, both in
the tests written to close them. That is this file's recurring shape, and it is the
reason the fix commit gets re-reviewed rather than the initial diff only.
TRUNCATION (High). `read_existing_verdict` asks for 100 statuses and never checked
whether the page was full. If a head ever carried more contexts than that, an existing
`review-verdict/h10` could fall off page 1, the job would conclude no verdict exists,
and it could post an exemption `success` over a human `failure` — the worst thing this
gate can do. Six contexts exist today, so this guards a future shape, not a live bug.
BUT THE PROPOSED GUARD WAS A NO-OP, and measuring is what showed it. The review asked
for `.statuses | length` compared against `.total_count`. On this instance `total_count`
is the count for the PAGE RETURNED, not for the commit: on 3aed43c6 (6 contexts),
`?limit=1` gives `len=1, total_count=1` and `?limit=3` gives `len=3, total_count=3`.
The two are equal by construction, so that check would have read as a completeness
proof while proving nothing — and it would have been the second guard in this file to
look like a check and not be one. What IS observable is a page at the requested limit,
which means "maybe more", so that is now treated as unreadable: post nothing, leave the
required check absent. The stub mirrors the per-page `total_count` deliberately, so the
new test cannot pass for the wrong reason either.
THE TESTS THAT CLOSED THE LAST ROUND'S FINDINGS:
* The behavioural guard test — added to answer "a bare `exit 1` substring is satisfiable
by dead code" — extracted the two marker lines BY TEXT and ran them alone. That
passes even if the write is moved into a function nobody calls: the extractor finds
the text, runs it at top level, the marker appears, and the test reports the guard
proven while production writes no marker. It now executes the classify body's real
PREFIX down to and including the write, which reproduces the production control flow
instead of a reconstruction of it. Mutation: move the write into an uncalled function
-> RED (it previously passed).
* The anti-vacuity check — added to replace an over-broad assertion — hand-counted
`run:` keys with a regex that only matched an indented `run:` starting `|` or `>`. It
false-redded legal spellings (`- run: |`, a single-line `run: echo ok`) and could
count a `run: |` sitting inside a heredoc. Hand-parsing YAML to validate a YAML parse
is the wrong shape: it adds a second, worse parser whose every disagreement is a
false alarm, and a red here blocks all merges. Now asserted on CONTENT — the walk
reached >=3 bodies and one over 5000 chars.
FALSE RED, THIRD INSTANCE IN THIS FILE. The repo-wide expression test scanned raw file
text, so a delimiter in an inert top-level YAML comment redded the repo even though the
runner never evaluates it. It now scans PARSED scalars: PyYAML drops YAML comments,
while a `run:` body is itself a scalar and keeps its SHELL comments — which is exactly
the distinction that matters, since inside a `run:` scalar a comment is not inert.
Verified in both directions: an inert top-level comment passes, the same payload in a
run-body comment still reds.
Also: the `total_count` zero check now requires the JSON TYPE to be number — `jq -r`
renders `0` and `"0"` identically, so a text compare accepted a corrupted
`"total_count": "0"` as "no statuses".
Verification: 455 green. Six further mutations, each landing as intended — the uncalled
function (red), an inert YAML comment (PASSES, no false red), the same payload in a
run-body comment (red), accepting a full status page (red), comparing total_count as
text (red), and breaking the YAML walk's job key (red). Seventeen mutations across the
three rounds.
Re-probe of both live controls follows on this body; the previous probe evidence was
taken before this commit and no longer describes what would merge.
Refs: #751
Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -393,15 +393,42 @@ jobs:
|
||||
# `total_count` is required to agree, so `null` is accepted only as the empty case and not
|
||||
# as a body that merely lost its array. Anything else is still "cannot tell" and still
|
||||
# refuses to post, which is what protects an existing verdict from a transient API error.
|
||||
# A FULL PAGE MEANS "MAYBE MORE", AND `total_count` CANNOT TELL YOU (ersatztv#751,
|
||||
# raised by cold re-review as a truncation hole, then measured — the risk is real but the
|
||||
# obvious guard for it is a no-op HERE). Cold review proposed comparing
|
||||
# `.statuses | length` against `.total_count`. On this instance that detects nothing:
|
||||
# `total_count` is the count for the PAGE RETURNED, not the number of statuses on the
|
||||
# commit. Measured at Gitea 1.27.1 on 3aed43c6, which has 6 contexts —
|
||||
# `?limit=1` returns `len(statuses)=1, total_count=1`, and `?limit=3` returns
|
||||
# `len=3, total_count=3`. So the two are equal by construction and a guard comparing them
|
||||
# would look like a completeness check while proving nothing.
|
||||
#
|
||||
# What CAN be observed is that the page came back full. This endpoint returns the latest
|
||||
# status per CONTEXT (measured: 12 rows combined vs 24 per-POST on the same head), so a
|
||||
# head would need >100 distinct contexts to truncate — six exist today. But if it ever
|
||||
# did, `review-verdict/h10` could fall off the page, the job would conclude no verdict
|
||||
# exists, and it could post an exemption `success` over a human `failure`. Refusing on a
|
||||
# full page is therefore the safe reading: "cannot tell" here means DO NOT POST, which is
|
||||
# the same direction as every other unreadable case below.
|
||||
STATUS_LIMIT=100
|
||||
st_kind=$(printf '%s' "$json" | jq -r '.statuses | type' 2>/dev/null) || st_kind=""
|
||||
st_total=$(printf '%s' "$json" | jq -r '.total_count // "x"' 2>/dev/null) || st_total="x"
|
||||
st_len=$(printf '%s' "$json" | jq -r '(.statuses // []) | length' 2>/dev/null) || st_len=""
|
||||
# NUMBER, not `jq -r` text: `jq -r` renders the JSON number 0 and the JSON string "0"
|
||||
# identically, so a schema-corrupted `"total_count": "0"` would satisfy a string compare
|
||||
# (cold review reproduced this). Requiring the type as well keeps the accept path pinned to
|
||||
# a real numeric zero.
|
||||
st_total=$(printf '%s' "$json" | jq -r 'if (.total_count | type) == "number" then (.total_count | tostring) else "x" end' 2>/dev/null) || st_total="x"
|
||||
st_ok=no
|
||||
case "$st_kind" in
|
||||
array) st_ok=yes ;;
|
||||
array)
|
||||
case "$st_len" in
|
||||
''|*[!0-9]*) ;;
|
||||
*) if [ "$st_len" -lt "$STATUS_LIMIT" ]; then st_ok=yes; fi ;;
|
||||
esac ;;
|
||||
null) if [ "$st_total" = "0" ]; then st_ok=yes; fi ;;
|
||||
esac
|
||||
if [ -z "${json//[[:space:]]/}" ] || [ "$st_ok" != yes ]; then
|
||||
echo "::error::Could not read existing commit statuses for ${SHA:0:7} (.statuses was '${st_kind:-unparseable}', total_count '${st_total}'). Refusing to post anything rather than risk overwriting an existing verdict."
|
||||
echo "::error::Could not read existing commit statuses for ${SHA:0:7} (.statuses was '${st_kind:-unparseable}', ${st_len:-?} rows against a limit of ${STATUS_LIMIT}, total_count '${st_total}'). A FULL page means an existing verdict may have been truncated off it. Refusing to post anything rather than risk overwriting an existing verdict."
|
||||
exit 1
|
||||
fi
|
||||
# `// []` so the null case cannot hard-error here under `set -e` once it is accepted above.
|
||||
|
||||
@@ -1092,6 +1092,29 @@ error. `scripts/pr-changed-files.sh` was swept and is unaffected (`pulls/{n}/fil
|
||||
**The generalisable rule: a nil Go slice serialises to `null`, so every list-shaped field on this API
|
||||
is suspect and only a per-endpoint measurement settles it.**
|
||||
|
||||
**`total_count` on the combined endpoint is the count for the PAGE, not for the commit** — worth
|
||||
knowing because the intuitive completeness guard is a no-op. `read_existing_verdict` asks for 100
|
||||
statuses, and if a head ever carried more contexts an existing `review-verdict/h10` could fall off the
|
||||
page, letting the job conclude no verdict exists and post an exemption `success` over a human
|
||||
`failure`. The obvious guard — compare `.statuses | length` to `.total_count` — **detects nothing
|
||||
here**: measured at 1.27.1 on `3aed43c6` (6 contexts), `?limit=1` returns `len=1, total_count=1` and
|
||||
`?limit=3` returns `len=3, total_count=3`. The two are equal by construction, so that check would read
|
||||
as a completeness proof while proving nothing. What *is* observable is that the page came back **full**,
|
||||
which means "maybe more" — so a page at the limit is treated as unreadable and the job posts nothing.
|
||||
Six contexts exist today, so this is a guard against a future shape, not a live bug. The test's stub
|
||||
mirrors the per-page `total_count` deliberately, so the test cannot pass for the wrong reason.
|
||||
|
||||
The `total_count` zero-check also requires the JSON **type** to be a number: `jq -r` renders `0` and
|
||||
`"0"` identically, so a text compare would accept a schema-corrupted `"total_count": "0"` as "no
|
||||
statuses".
|
||||
|
||||
**The repo-wide expression guard scans PARSED scalars, not raw file text.** A delimiter in an ordinary
|
||||
top-level YAML comment is inert — the runner never evaluates it — so redding on it is a false positive,
|
||||
and this file has now produced that false red twice. PyYAML drops those comments. A `run:` body is
|
||||
itself a scalar and keeps its *shell* comments, which is the point: inside a `run:` scalar a comment is
|
||||
not inert. Verified both directions by mutation — an inert top-level comment passes; the same payload
|
||||
in a run-body comment still reds.
|
||||
|
||||
**`CLAUDE.md` and `AGENTS.md` are now PROTECTED paths.** `DOCS_ONLY` matched them, so the documents
|
||||
that *define* the completion protocol, the merge-consent convention and the H10 rule were themselves
|
||||
docs-only-exemptible while `.claude/` was protected — the same self-exemption the gate rules out, one
|
||||
|
||||
@@ -68,6 +68,23 @@ directory over. Reachable only because exemptions work again, hence fixed here (
|
||||
sub-round-trip ABA window, "narrowed and observable, not closed" — comes back with the working fence:
|
||||
while `rt_ok` was never `yes`, route 1 was closed by accident.
|
||||
|
||||
**Two measurements from the re-review worth keeping, because both refute an intuitive guard.** First,
|
||||
`total_count` on `/commits/{sha}/status` is the count for the PAGE returned, not for the commit
|
||||
(`?limit=1` on a 6-context head gives `len=1, total_count=1`), so comparing length to total_count as a
|
||||
truncation check is a no-op; a page at the requested limit is the observable signal, and it is treated
|
||||
as unreadable. Second, `jq -r` renders the number `0` and the string `"0"` identically, so the zero
|
||||
check requires the JSON type as well. Neither was a live failure — both are the difference between a
|
||||
guard that holds because the input happens to be well-formed and one that holds because it checks.
|
||||
|
||||
**The tests written to close a review finding then needed closing themselves**, which is the honest
|
||||
shape of work on this file. The behavioural guard test first extracted the two marker lines by text and
|
||||
ran them alone — which passes even if the write is moved into a function nobody calls. It now executes
|
||||
the classify body's real PREFIX down to the write, reproducing the production control flow instead of a
|
||||
reconstruction of it. The anti-vacuity check first hand-counted `run:` keys with a regex, which
|
||||
false-redded legal spellings (`- run: |`, a single-line `run: echo ok`) and could count a `run: |`
|
||||
inside a heredoc; hand-parsing YAML to validate a YAML parse is the wrong shape, so it now asserts on
|
||||
content — the walk reached at least three bodies and one over 5000 characters.
|
||||
|
||||
**Verified by mutation, not by a green suite.** All six mutations produce a red and the restored tree
|
||||
is green: reintroducing the exact defect (caught by both the strict and the general test), deleting
|
||||
the guard step, deleting only the marker write, weakening `if: always()`, turning the guard's
|
||||
|
||||
@@ -1048,6 +1048,22 @@ if "/status" in url:
|
||||
{"context": "review-verdict/h10", "status": "pending", "creator": None,
|
||||
"description": "Human verdict raced this exemption write — re-post the verdict"}]}))
|
||||
sys.exit(0)
|
||||
if mode.startswith("rows:"):
|
||||
# N decoy contexts and NO `review-verdict/h10`, to exercise the truncation guard. `total_count`
|
||||
# deliberately MIRRORS the page length, because that is what the real endpoint does — it is the
|
||||
# count for the page returned, not for the commit (measured at 1.27.1: `?limit=1` on a 6-context
|
||||
# head returns len=1, total_count=1). A stub that reported the true total would make a
|
||||
# length-vs-total guard look like it worked, which is the trap this models.
|
||||
n = int(mode.split(":", 1)[1])
|
||||
print(json.dumps({"state": "pending", "total_count": n,
|
||||
"statuses": [{"context": f"ci/decoy{i}", "status": "pending"}
|
||||
for i in range(n)]}))
|
||||
sys.exit(0)
|
||||
if mode == "total-count-string":
|
||||
# A schema-corrupted `total_count` as a STRING alongside a null `.statuses`. `jq -r` renders 0
|
||||
# and "0" identically, so a text compare would accept this.
|
||||
print(json.dumps({"state": "pending", "total_count": "0", "statuses": None}))
|
||||
sys.exit(0)
|
||||
if mode == "transport-error":
|
||||
# Real `gh()` is `curl -sf`: an HTTP error exits 22 with EMPTY stdout.
|
||||
sys.exit(22)
|
||||
@@ -2187,6 +2203,37 @@ _EXPR_FUNCTIONS = frozenset({
|
||||
_EXPR_LITERALS = frozenset({"true", "false", "null"})
|
||||
|
||||
|
||||
def _yaml_string_scalars(path: Path):
|
||||
"""Every string scalar in the parsed document — keys and values, recursively.
|
||||
|
||||
Deliberately PARSED rather than raw (ersatztv#751, cold re-review). A `${{ … }}` in an ordinary
|
||||
top-level YAML comment is inert: the runner never evaluates it, so redding on it would be a false
|
||||
positive of exactly the kind this file has now produced twice. PyYAML drops those comments, which
|
||||
is the behaviour wanted here.
|
||||
|
||||
A `run:` body IS one of these scalars, and it keeps its SHELL comments — which is the whole point,
|
||||
because inside a `run:` scalar a comment is not inert. So this covers the real defect class in
|
||||
every workflow while ignoring the one place a delimiter is genuinely harmless.
|
||||
"""
|
||||
import yaml
|
||||
out: list[str] = []
|
||||
|
||||
def walk(node):
|
||||
if isinstance(node, str):
|
||||
out.append(node)
|
||||
elif isinstance(node, dict):
|
||||
for k, v in node.items():
|
||||
if isinstance(k, str):
|
||||
out.append(k)
|
||||
walk(v)
|
||||
elif isinstance(node, list):
|
||||
for v in node:
|
||||
walk(v)
|
||||
|
||||
walk(yaml.safe_load(path.read_text()))
|
||||
return out
|
||||
|
||||
|
||||
def _workflow_files():
|
||||
# `*.y*ml` for the reason test_no_OTHER_workflow_writes_the_review_verdict_status gives: a
|
||||
# workflow added as `.yaml` is just as executable and would otherwise go unscanned.
|
||||
@@ -2232,15 +2279,24 @@ def test_the_verdict_workflow_has_NO_expression_delimiter_in_any_run_body():
|
||||
# merge through the combined status, so the guard was strictly more dangerous than the thing it
|
||||
# was protecting against.
|
||||
#
|
||||
# The honest anti-vacuity check is that the walk SAW every `run:` body: compare the number of
|
||||
# bodies the parse produced against the number of `run:` keys in the raw text. That fails if the
|
||||
# walk misses a step and says nothing about delimiters anywhere else.
|
||||
walked = sum(1 for _, s in _iter_workflow_steps(WORKFLOW) if s.get("run"))
|
||||
declared = len(re.findall(r"^\s{4,}run:\s*[|>]", raw, re.M))
|
||||
assert walked == declared, (
|
||||
f"the YAML walk reached {walked} run: bodies but the file declares {declared}. The assertion "
|
||||
"above may not have examined every body, so a green here proves nothing — find the step the "
|
||||
"walk missed before trusting this test")
|
||||
# ANTI-VACUITY WITHOUT A SECOND PARSER. A first attempt counted `run:` keys in the raw text and
|
||||
# compared that to the walk. Cold re-review showed the regex only recognised an indented `run:`
|
||||
# whose value starts with `|` or `>`, so legal spellings (`- run: |`, a single-line
|
||||
# `run: echo ok`) counted as zero declarations and false-redded the file, while a `run: |` line
|
||||
# sitting INSIDE a shell heredoc counted as a declaration. Hand-parsing YAML to check a YAML parse
|
||||
# is the wrong shape: it adds a second, worse parser whose disagreements are all false alarms, and
|
||||
# a red here blocks every merge through the combined status.
|
||||
#
|
||||
# The property that actually matters is that the walk reached the body that carries the risk. The
|
||||
# classifier is ~700 lines; a walk that returned nothing, or only the short steps, is the failure
|
||||
# to catch. Both are asserted on content, which no spelling change can spoof.
|
||||
bodies = [s["run"] for _, s in _iter_workflow_steps(WORKFLOW) if s.get("run")]
|
||||
assert len(bodies) >= 3, (
|
||||
f"the YAML walk reached only {len(bodies)} run: bodies in review-verdict.yml; the assertion "
|
||||
"above cannot have examined the classifier, so a green here proves nothing")
|
||||
assert max(len(b) for b in bodies) > 5000, (
|
||||
"the YAML walk did not reach a substantial run: body — the ~700-line classifier is the one "
|
||||
"that must be scanned, so this test would be vacuous")
|
||||
|
||||
|
||||
def _iter_workflow_steps(path: Path):
|
||||
@@ -2291,7 +2347,8 @@ def test_every_workflow_expression_names_a_REAL_context_or_function():
|
||||
"""
|
||||
offenders = []
|
||||
for wf in _workflow_files():
|
||||
for m in _EXPR.finditer(wf.read_text()):
|
||||
for scalar in _yaml_string_scalars(wf):
|
||||
for m in _EXPR.finditer(scalar):
|
||||
payload = m.group(1).strip()
|
||||
# Strip string literals first: a path inside `hashFiles('web/package-lock.json')` is
|
||||
# data, not an identifier, and would otherwise read as an unknown context.
|
||||
@@ -2428,15 +2485,31 @@ def test_the_fence_TRUSTS_the_count_and_POSTS_when_the_timeline_terminates(tmp_p
|
||||
|
||||
|
||||
def _marker_steps():
|
||||
"""(classify prologue that CREATES the marker, guard body that CHECKS it) — from one parse."""
|
||||
"""(classify body PREFIX through the marker write, guard body that CHECKS it) — from one parse.
|
||||
|
||||
THE PREFIX, NOT THE MATCHING LINES. An earlier version picked out the lines matching `RAN_MARKER=`
|
||||
and `: > "$RAN_MARKER"` and ran those two alone. Cold re-review showed that passes even if the
|
||||
write is moved into a function nobody calls, or under `if false`: the extractor finds the text,
|
||||
runs it at top level, the marker appears, and the test reports the guard proven while production
|
||||
writes no marker at all. Executing the real prefix — everything from the top of the body down to
|
||||
and including the write — reproduces the production control flow instead of a reconstruction of
|
||||
it, so a write that is defined-but-not-reached simply does not happen and case B fails.
|
||||
#
|
||||
It also pins the property the marker needs anyway: that the write happens EARLY, before anything
|
||||
in the classifier can fail. If it drifts down past code that needs credentials or network, this
|
||||
prefix stops executing cleanly and the test says so.
|
||||
"""
|
||||
steps = [s for _, s in _iter_workflow_steps(WORKFLOW)]
|
||||
idx = [i for i, s in enumerate(steps) if "review-verdict/h10" in (s.get("run") or "")]
|
||||
classify = steps[idx[0]]
|
||||
prologue = [ln for ln in classify["run"].splitlines()
|
||||
if re.match(r'\s*RAN_MARKER=', ln) or re.match(r'\s*:\s*>\s*"\$RAN_MARKER"', ln)]
|
||||
lines = classify["run"].splitlines()
|
||||
write_at = [i for i, ln in enumerate(lines) if re.match(r'\s*:\s*>\s*"\$RAN_MARKER"', ln)]
|
||||
assert len(write_at) == 1, (
|
||||
f"expected exactly one `: > \"$RAN_MARKER\"` in the classify body, found {len(write_at)}")
|
||||
prefix = "\n".join(lines[:write_at[0] + 1])
|
||||
guard = next(s for i, s in enumerate(steps)
|
||||
if i != idx[0] and "h10-classifier-started" in (s.get("run") or ""))
|
||||
return "\n".join(ln.strip() for ln in prologue), guard["run"]
|
||||
return prefix, guard["run"]
|
||||
|
||||
|
||||
def test_the_dropped_step_guard_BEHAVIOURALLY_fails_without_the_marker_and_passes_with_it(tmp_path):
|
||||
@@ -2456,6 +2529,11 @@ def test_the_dropped_step_guard_BEHAVIOURALLY_fails_without_the_marker_and_passe
|
||||
prologue, guard = _marker_steps()
|
||||
assert prologue.count("RAN_MARKER=") == 1 and ': > "$RAN_MARKER"' in prologue, (
|
||||
f"could not extract the classify step's marker prologue; got {prologue!r}")
|
||||
# The prefix must be the REAL top of the body, so a write hidden in an uncalled function is not
|
||||
# executed by this test either.
|
||||
assert prologue.lstrip().startswith("set -euo pipefail"), (
|
||||
"the extracted prefix does not start at the top of the classify body, so it is a "
|
||||
f"reconstruction rather than the production path: {prologue[:120]!r}")
|
||||
env = {"PATH": os.environ["PATH"], "RUNNER_TEMP": str(tmp_path),
|
||||
"GITHUB_RUN_ID": "424242", "GITHUB_RUN_ATTEMPT": "7"}
|
||||
|
||||
@@ -2476,6 +2554,16 @@ def test_the_dropped_step_guard_BEHAVIOURALLY_fails_without_the_marker_and_passe
|
||||
"the guard rejected a marker written by the classify step's OWN prologue — the two steps "
|
||||
f"disagree on the path, so this guard would fail on every run.\nstdout: {b.stdout}\n"
|
||||
f"stderr: {b.stderr}")
|
||||
# C — the write must be reached by STRAIGHT-LINE code. Guarding the prefix trick itself: if the
|
||||
# write were wrapped in a function or an `if`, the prefix would still contain it but production
|
||||
# might not reach it. Executing the prefix with the function/conditional intact is the test; this
|
||||
# assertion makes the intent explicit and fails loudly rather than subtly.
|
||||
body_before = "\n".join(ln for ln in prologue.splitlines()
|
||||
if not ln.lstrip().startswith("#"))
|
||||
assert not re.search(r"^\s*\w+\s*\(\)\s*\{", body_before, re.M), (
|
||||
"a function is defined before the marker write, so the write may be inside it and unreached "
|
||||
f"in production while this test still passes:\n{body_before}")
|
||||
|
||||
written = [q.name for q in tmp_path.glob("h10-classifier-started*")]
|
||||
assert written == ["h10-classifier-started-424242-7"], (
|
||||
f"the marker is not keyed on the run id/attempt as intended; found {written}. A fixed name in "
|
||||
@@ -2551,3 +2639,54 @@ def test_a_terminator_on_PAGE_ONE_does_not_certify_a_zero_retarget_count(tmp_pat
|
||||
f"terminator, so no page of events was ever actually read: {posted}\n{r.stdout[-800:]}")
|
||||
assert "trusted=no" in r.stdout, (
|
||||
f"the exemption was withheld, but not because the count was untrusted:\n{r.stdout[-800:]}")
|
||||
|
||||
|
||||
def test_a_FULL_status_page_refuses_to_conclude_that_no_verdict_exists(tmp_path):
|
||||
"""Truncation, raised by cold re-review — and the guard it proposed does not work here.
|
||||
|
||||
`read_existing_verdict` asks for 100 statuses. If a head ever had more contexts than that, an
|
||||
existing `review-verdict/h10` could fall off the page, the job would conclude no verdict exists,
|
||||
and it could post an exemption `success` over a human `failure` — the worst outcome this gate can
|
||||
produce.
|
||||
|
||||
The review's proposed fix was to compare `.statuses | length` against `.total_count`. MEASURED on
|
||||
this instance, that detects nothing: `total_count` is the count for the PAGE RETURNED, not for the
|
||||
commit. On 3aed43c6 (6 contexts), `?limit=1` returns `len=1, total_count=1` and `?limit=3` returns
|
||||
`len=3, total_count=3`. The two are equal by construction, so that guard would have read as a
|
||||
completeness check while proving nothing — the stub above mirrors the real behaviour precisely so
|
||||
this test cannot pass for that wrong reason.
|
||||
|
||||
What is observable is a FULL page, which means "maybe more". This asserts the safe reading:
|
||||
refuse, post nothing, leave the required check absent.
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), status_mode="rows:100")
|
||||
assert posted is None, (
|
||||
"an exemption was posted after reading a FULL page of statuses, so an existing verdict could "
|
||||
f"have been truncated off it and silently overwritten: {posted}\n{r.stdout[-800:]}")
|
||||
assert "full page" in (r.stdout + r.stderr).lower(), (
|
||||
f"nothing was posted, but not because the page was full:\n{r.stdout[-800:]}")
|
||||
|
||||
|
||||
def test_a_page_BELOW_the_limit_is_still_read_normally(tmp_path):
|
||||
"""The positive control for the guard above — without it, "refuse on a full page" could be
|
||||
satisfied by refusing on every page, which would deadlock every PR while looking safe.
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), status_mode="rows:99")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert posted is not None and posted["state"] == "success", (
|
||||
f"a 99-row page (below the 100 limit) should read normally and still exempt; got {posted}\n"
|
||||
f"{r.stdout[-800:]}")
|
||||
|
||||
|
||||
def test_a_STRING_total_count_is_not_accepted_as_numeric_zero(tmp_path):
|
||||
"""`jq -r` renders the JSON number 0 and the JSON string "0" identically, so a text compare
|
||||
accepts a schema-corrupted `"total_count": "0"` as "no statuses" (cold re-review reproduced it).
|
||||
|
||||
The live schema uses an integer, so this is not a live failure — it is the difference between a
|
||||
guard that holds because the input happens to be well-formed and one that holds because it checks.
|
||||
The accept path requires the TYPE to be number.
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), status_mode="total-count-string")
|
||||
assert posted is None, (
|
||||
f"a string total_count was accepted as numeric zero, so a body that merely lost its statuses "
|
||||
f"array reads as 'no verdict exists': {posted}\n{r.stdout[-800:]}")
|
||||
|
||||
Reference in New Issue
Block a user