fix(870): review round — the fix NARROWS the defeat, and the prose said "closed"
Two independent cold reviews (Codex GPT-5.6 cross-family; a fresh Opus agent in an isolated
worktree, which executed the walk against synthetic page shapes). Both landed on the same
substantive defect, and it was in the prose, not the code.
THE OVERCLAIM. The fix moves the unprovable inference from page 2 to the page cap; it does not
remove it. An empty page 20 is still trusted, for the same reason an empty page 2 used to be —
this endpoint cannot distinguish a filtered page from the end of the list at ANY offset. Six
sentences across three docs and the workflow said otherwise, including "no longer accepted as
exhaustion at all", "STOP INFERRING THE END AT ALL", and — in the paragraph that describes the
case where it fails OPEN — "an over-cap timeline fails CLOSED ... it does not pass silently".
All rewritten to NARROWED, not closed, with the residual stated where a reader meets the claim.
THE PRICE, IN ONE UNIT. "50 rows instead of 1000" compared an authored-comment count against a
total-row count and flattered the change. Before: ~100 timeline rows (a non-empty page 1, then a
50-row filtered block at a 50-aligned offset). After: over 1000, with the block pinned to offsets
950..999. About 10x, and the attacker authors 50 inline comments either way.
THE PARITY CLAIM WAS FALSE. "The two walks now agree" — they do not. `page_statuses` still returns
on its FIRST empty page; what the two share is only the cap rule. Worse, the diff asserted parity
it had not established: whether `/statuses/{sha}` is subject to the same post-pagination filtering
was never checked. Measured instead of asserted (Gitea 1.27.1, 2026-08-30): that endpoint returns
a TRUE `X-Total-Count` (105 at both `?limit=1` and `?limit=50`) where `/issues/{n}/timeline`
returns the post-filter page length. Consistent with counting before filtering — evidence, not
proof, since no filtering predicate has been exhibited either way. Filed as #893 rather than
resolved here.
CODE CHANGES, both answering the amplification this fix introduced (~2 requests per walk to a
fixed 20, three walks per exempt run):
- Each page is now bounded `--connect-timeout 5 --max-time 15`. `gh` is bare `curl -sf` with no
timeout, and the THIRD call site runs after the exemption `success` is posted, so a hang leaves
the green standing with no repair attempted. Bounded at this call rather than inside `gh`, so no
other call site changes behaviour.
- Each page is retried once, mirroring `page_statuses` and its stated reason — "one transient blip
would cost that head its exemption until a human clears it by hand". That walk retries; this one
did not, and it just took 10x the round trips.
- The four jq reads carry `2>/dev/null || x=""`, as `page_statuses`'s do. Unreachable today thanks
to the ordering above them, which is exactly the "safe because of a property three lines up"
reasoning the adjacent comment says it is retiring.
STALE CONTRACT TEXT swept: the function's own header still said "trusted ONLY when paging reached a
validated EMPTY page" and listed a short page as untrusted (false before and after — a short page
is tallied and the walk continues); the record's `mechanics:` field still described the old
terminator and omitted the new fixtures.
TESTS (+3, and one reviewer claim refuted):
- `test_a_FILTERED_page_before_a_FULL_cap_page_is_still_untrusted` — filtered page 19, full page 20.
This kills the "trust if ANY page was empty" mutant, which the Opus review proved survived the
previous round's suite; every earlier fixture ends on an empty page, so a latching flag and a
correct one agree there.
- `test_a_SINGLE_transient_blip_does_not_cost_the_exemption`, with a `flaky-first` stub mode. The
existing `transport-error`/`unreadable` modes fail EVERY attempt, so a retrying walk and a
non-retrying one refuse identically and neither could measure this.
- `test_the_timeline_read_is_TIME_BOUNDED` — structural; a hang cannot be provoked through a stub
that answers instantly.
Each was mutated and witnessed red. Codex claimed the per-iteration `empty=no` reset was unguarded
and that deleting it would leave all four new tests green; deleting it turns THREE of them red — a
stale `yes` also suppresses the tally on every later non-empty page. The Opus review mutated the
same line independently and got the same red. Recorded because a wrong mechanism claim in a review
is as executable as a right one.
Full suite: 1354 passed, 2 skipped.
Fixes #870
Refs: #803, #706, #664, #751, #893
Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -917,10 +917,13 @@ jobs:
|
||||
# Completeness is a guard, not an assumption (`ci.verdict-write-retarget-fence`; this
|
||||
# cited `ci.paged-endpoint-completeness` until 2026-08-06, a key that has never existed as
|
||||
# a record — resolve decisions through the catalog, never through a key or path quoted in a
|
||||
# comment). The count is
|
||||
# trusted ONLY when paging reached a validated EMPTY page. A short page, a non-array body, a
|
||||
# non-numeric length or the page cap all leave `rt_ok=no`, and an untrusted count is treated
|
||||
# below as "cannot tell" rather than as zero.
|
||||
# comment). The count is trusted ONLY when the walk read EVERY page up to its 20-page cap
|
||||
# AND the LAST page came back empty (ersatztv#870 — reaching an empty page earlier is no
|
||||
# longer sufficient, and no longer ends the walk). A page that is unreadable, a non-array
|
||||
# body, a non-numeric length, an empty FIRST page, or a cap reached on a NON-empty page all
|
||||
# leave `rt_ok=no`, and an untrusted count is treated below as "cannot tell" rather than as
|
||||
# zero. A SHORT page is not in that list and never was: it is tallied and the walk carries
|
||||
# on — the sentence here said otherwise until 2026-08-30.
|
||||
# THE SAME WALK CARRIES A SECOND AXIS: HEAD MUTATION (ersatztv#803/#664).
|
||||
#
|
||||
# The base fence above closes `main -> S -> main`. The HEAD aliases the same way and was
|
||||
@@ -987,10 +990,39 @@ jobs:
|
||||
rt_count=0
|
||||
hp_count=0
|
||||
rt_ok=no
|
||||
local page=1 raw n m p bad kind total=0 ptotal=0 empty=no
|
||||
local page=1 raw n m p bad kind try total=0 ptotal=0 empty=no
|
||||
while [ "$page" -le 20 ]; do
|
||||
raw=$(gh "$BASE_URL/repos/$REPO/issues/$PR/timeline?limit=50&page=${page}") || return 0
|
||||
if [ -z "${raw//[[:space:]]/}" ]; then return 0; fi
|
||||
# BOUNDED AND RETRIED ONCE, because this walk got 10x longer (ersatztv#870 review).
|
||||
# Both halves answer the same amplification and neither is decoration.
|
||||
#
|
||||
# BOUNDED: `gh` is bare `curl -sf` with no timeout of its own, and the THIRD call site
|
||||
# runs AFTER the exemption `success` is already posted — a hang there leaves the green
|
||||
# standing with no repair attempted. That exposure predates this change, but going
|
||||
# from ~2 requests per walk to a fixed 20 multiplies the chances of hitting it. The
|
||||
# bound is applied HERE rather than inside `gh` so every other call site keeps the
|
||||
# behaviour it was reviewed with: widening a shared helper changes callers nobody
|
||||
# re-examined. 15s is ~100x the measured per-request latency, so it bounds a hang
|
||||
# without reddening a slow-but-working instance.
|
||||
#
|
||||
# RETRIED: `page_statuses` retries each page once and states why — "one transient blip
|
||||
# would cost that head its exemption until a human clears it by hand". That argument
|
||||
# applies here with 10x the force after this change, because `rt_ok=no` on the
|
||||
# exemption path writes the sticky sentinel too. This walk had no retry when it made
|
||||
# ~2 requests; at 20 it needs the sibling's. Same shape deliberately: same `for try`,
|
||||
# same one-second sleep BETWEEN attempts only, same "an outage still refuses".
|
||||
raw=""
|
||||
kind=""
|
||||
# `if`/`then`, never `cmd && var=yes`: under `set -e` a bare `A && B` whose test fails
|
||||
# is itself a failing command, and as the last command of a loop body it would kill
|
||||
# the job. (Carried from `page_statuses`, where the same trap was found.)
|
||||
for try in 1 2; do
|
||||
raw=$(gh --connect-timeout 5 --max-time 15 "$BASE_URL/repos/$REPO/issues/$PR/timeline?limit=50&page=${page}") || raw=""
|
||||
if [ -n "${raw//[[:space:]]/}" ]; then
|
||||
kind=$(printf '%s' "$raw" | jq -r 'type' 2>/dev/null) || kind=""
|
||||
fi
|
||||
if [ "$kind" = array ] || [ "$kind" = null ]; then break; fi
|
||||
if [ "$try" -eq 1 ]; then sleep 1; fi
|
||||
done
|
||||
# A PAGE PAST THE END IS JSON `null` HERE, NOT `[]` (ersatztv#751). Measured on this
|
||||
# instance at Gitea 1.27.1 (page 1 non-empty, page 2 exhausted): page 2 of PR #752's timeline is the
|
||||
# four bytes `null`, while `/issues/{n}/comments` with no comments returns `[]`. The
|
||||
@@ -1013,7 +1045,6 @@ jobs:
|
||||
# false" through it means relying on the same exit-status subtlety that already bit this
|
||||
# workflow once at jq 1.6 (ersatztv#647). A `case` over `jq -r 'type'` cannot be read
|
||||
# two ways. Anything that is neither `null` nor `array` is still "cannot tell".
|
||||
kind=$(printf '%s' "$raw" | jq -r 'type' 2>/dev/null) || kind=""
|
||||
# AN EMPTY PAGE IS NOT EXHAUSTION, AND THIS WALK NO LONGER TREATS IT AS ONE
|
||||
# (ersatztv#870). Gitea pages this endpoint at the DATABASE level and filters
|
||||
# AFTERWARDS: `FindComments` applies the LIMIT/OFFSET, then
|
||||
@@ -1026,14 +1057,24 @@ jobs:
|
||||
# PR author can create on their own PR, were enough to truncate both walks at the same
|
||||
# place: both counts then agreed, the sha comparison agreed, and the ABA went unseen.
|
||||
#
|
||||
# THE FIX IS TO STOP INFERRING THE END AT ALL, not to count empty pages. This loop
|
||||
# already carries a 20-page cap, and the sibling status walk below already states the
|
||||
# contract this one was breaking — "the 20th request has to be the EMPTY terminator
|
||||
# for the walk to be validated". So the walk now reads EVERY page up to that cap and
|
||||
# decides afterwards: past page 1 an empty page is SKIPPED, never believed. A "require
|
||||
# K consecutive empty pages" rule was rejected because K is arbitrary and only moves
|
||||
# the bar to 50K filtered rows; the cap is not arbitrary — it is the coverage this
|
||||
# walk already claimed to perform.
|
||||
# THE FIX MOVES THE INFERENCE TO THE CAP; IT DOES NOT REMOVE IT, and saying so
|
||||
# precisely matters more here than a tidy claim. This loop already carries a 20-page
|
||||
# cap, and the sibling status walk below already states the CAP half of the contract
|
||||
# this one was breaking — "the 20th request has to be the EMPTY terminator for the
|
||||
# walk to be validated". Only the cap half: `page_statuses` still returns on its FIRST
|
||||
# empty page, so the two walks do NOT now share a termination rule and saying they do
|
||||
# would be a parity claim nobody established (ersatztv#893 tracks whether that walk
|
||||
# needs the same change; `/statuses/{sha}` returns a TRUE `X-Total-Count`, which this
|
||||
# endpoint does not, so its terminator may well mean what it says). So the walk now
|
||||
# reads EVERY page up to that cap and decides afterwards:
|
||||
# an empty page BEFORE the cap is SKIPPED, never believed. The ONE empty page still
|
||||
# trusted is the page-20 terminator, and it is trusted for the same unprovable reason
|
||||
# the old page-2 terminator was — the endpoint cannot distinguish a filtered page from
|
||||
# the end of the list, at ANY offset. What changes is the price: 50 attacker-authored
|
||||
# rows bought silence before, and ~1000 buy it now. A "require K consecutive empty
|
||||
# pages" rule was rejected because K is arbitrary and only moves the bar to 50K
|
||||
# filtered rows; the cap is not arbitrary — it is the coverage this walk already
|
||||
# claimed to perform.
|
||||
#
|
||||
# MEASURED AT GITEA 1.27.1 ON THIS INSTANCE (2026-08-30), because the cheaper
|
||||
# alternatives are ruled out by measurement rather than by reasoning:
|
||||
@@ -1053,12 +1094,31 @@ jobs:
|
||||
# page 1 being anomalous. The cost of reading to the cap is 20 requests per walk,
|
||||
# measured at 2.6s against this instance.
|
||||
#
|
||||
# WHAT REMAINS UNCOVERED, stated because #803's whole point is that a contract must
|
||||
# not assert more than its code does: the walk confirms offsets 0..949 and requires
|
||||
# the last page it reads to be empty, so an event can still be hidden by a timeline
|
||||
# that carries more than 1000 rows AND presents a fully-filtered block at offsets
|
||||
# 950..999. That costs ~1000 timeline rows instead of 50, and it is the same
|
||||
# over-long-history residual the status walk already accepts and documents.
|
||||
# WHAT REMAINS UNCOVERED — NOT CLOSED, NARROWED — stated because #803's whole point
|
||||
# is that a contract must not assert more than its code does. Pages 1-19 cover offsets
|
||||
# 0..949 and page 20 covers 950..999, so an event is still hidden by a timeline of
|
||||
# more than 1000 rows that ALSO presents a fully-filtered block at offsets 950..999:
|
||||
# the walk reads an empty page 20, never requests page 21, and publishes a too-low
|
||||
# count with `rt_ok=yes`. Both re-reads share the blind spot, so the counts agree and
|
||||
# the exemption is granted — the SAME construction as before, at the cap instead of at
|
||||
# page 2, at roughly 10x the price. State that price in ONE unit or it flatters the
|
||||
# change: BEFORE, the timeline needed ~100 rows (a non-empty page 1, then a 50-row
|
||||
# filtered block at a 50-aligned offset); AFTER it needs more than 1000, with the
|
||||
# block pinned to offsets 950..999. The number of COMMENTS the attacker authors is 50
|
||||
# either way — "50 vs 1000" compares an authored-comment count with a total-row count.
|
||||
#
|
||||
# This is NOT the same residual as the status walk's, and equating them would
|
||||
# understate it: there a non-empty page 20 is the only over-cap shape, because
|
||||
# `/statuses/{sha}` does not filter after paging. Only this endpoint lets a page-20
|
||||
# response be empty while later pages hold rows. A timeline that fills the cap with
|
||||
# READABLE pages does fail closed; one that fills it and hides the 20th behind a
|
||||
# filtered block does not.
|
||||
#
|
||||
# No terminator on this endpoint can do better — that is measured, not assumed. See
|
||||
# the measurements above: there is no total to page against, no row-type filter to
|
||||
# make the paged and serialized sets agree, and a `since` bound leaves the identical
|
||||
# ambiguity inside its window. Closing this needs a monotonic key that is not served
|
||||
# by a filtered, paged endpoint, and none is known (ersatztv#870 option 3).
|
||||
#
|
||||
# Read the type as a VALUE rather than through `jq -e` — see the `kind` note above.
|
||||
empty=no
|
||||
@@ -1068,7 +1128,7 @@ jobs:
|
||||
*) return 0 ;;
|
||||
esac
|
||||
if [ "$empty" = no ]; then
|
||||
n=$(printf '%s' "$raw" | jq -r 'length')
|
||||
n=$(printf '%s' "$raw" | jq -r 'length' 2>/dev/null) || n=""
|
||||
case "$n" in ''|*[!0-9]*) return 0 ;; esac
|
||||
# `[]` AND `null` TAKE THE SAME RULE (ersatztv#803 review). `/issues/{n}/comments`
|
||||
# really does return `[]` when empty while this endpoint returns `null`, so both
|
||||
@@ -1090,6 +1150,15 @@ jobs:
|
||||
# withholds the exemption and asks for a human verdict — the safe direction.
|
||||
if [ "$page" -eq 1 ]; then return 0; fi
|
||||
else
|
||||
# EVERY jq READ BELOW IS GUARDED `2>/dev/null || x=""`, matching `page_statuses`
|
||||
# (added ersatztv#870 review). Today none of them can error — the `array` gate above
|
||||
# and the `bad -eq 0` ordering see to that — but "safe because of a property three
|
||||
# lines up" is exactly the reasoning the `jq -e` note below says it is retiring, and
|
||||
# an unguarded jq error dies under `set -e`. At the POST-WRITE call site that death
|
||||
# lands after the exemption `success` is on the head and before any repair, which is
|
||||
# the shape this file already fixed once for `.creator`. The `case` validation on
|
||||
# each value turns an empty string into the existing untrusted path.
|
||||
#
|
||||
# VALIDATE THE FIELD THE SECURITY DECISION READS, on every row (ersatztv#803 review).
|
||||
# Both tallies below select on `.type`; a row without a string `.type` matches neither
|
||||
# and is silently treated as an irrelevant event. That is the same
|
||||
@@ -1107,16 +1176,16 @@ jobs:
|
||||
# accident — the array is known non-empty by the check above, so the empty-input
|
||||
# divergence could not fire — but "safe because of a property three lines up" is
|
||||
# exactly the reasoning the rule exists to retire.)
|
||||
bad=$(printf '%s' "$raw" | jq -r '[.[] | select(type != "object" or (.type | type) != "string")] | length')
|
||||
bad=$(printf '%s' "$raw" | jq -r '[.[] | select(type != "object" or (.type | type) != "string")] | length' 2>/dev/null) || bad=""
|
||||
case "$bad" in ''|*[!0-9]*) return 0 ;; esac
|
||||
if [ "$bad" -ne 0 ]; then return 0; fi
|
||||
m=$(printf '%s' "$raw" | jq -r '[.[] | select(.type == "change_target_branch")] | length')
|
||||
m=$(printf '%s' "$raw" | jq -r '[.[] | select(.type == "change_target_branch")] | length' 2>/dev/null) || m=""
|
||||
case "$m" in ''|*[!0-9]*) return 0 ;; esac
|
||||
# Counted in the SAME pass over the SAME page, so the head axis costs no extra round
|
||||
# trip and cannot be certified by a different set of pages than the base axis. A
|
||||
# non-numeric length here abandons BOTH counts, exactly as it does above — a page whose
|
||||
# push tally is unreadable has not established the retarget tally either.
|
||||
p=$(printf '%s' "$raw" | jq -r '[.[] | select(.type == "pull_push")] | length')
|
||||
p=$(printf '%s' "$raw" | jq -r '[.[] | select(.type == "pull_push")] | length' 2>/dev/null) || p=""
|
||||
case "$p" in ''|*[!0-9]*) return 0 ;; esac
|
||||
total=$(( total + m ))
|
||||
ptotal=$(( ptotal + p ))
|
||||
@@ -1852,7 +1921,7 @@ jobs:
|
||||
# nothing to buy by writing a value this run already knows was computed against a base the
|
||||
# PR no longer targets. One rule, one direction, nothing to reason about per state.
|
||||
#
|
||||
# An UNTRUSTED count on either side (`rt_ok=no`: paging never reached a validated empty
|
||||
# An UNTRUSTED count on either side (`rt_ok=no`: the walk did not reach its cap on an empty
|
||||
# page, a page was unreadable, the cap was hit) is NOT treated as "no retarget". It blocks
|
||||
# the exemption `success` only, and lets `pending` through — because a `success` written on a
|
||||
# count we could not verify is exactly the forged-green outcome this fence exists to
|
||||
|
||||
+12
-6
@@ -2019,15 +2019,21 @@ Two things kept it invisible, and both are worth generalising:
|
||||
fidelity, that claim is a test assertion and needs re-measuring like any other.
|
||||
|
||||
The type is now read as a value (`case` over `jq -r 'type'`) rather than through `jq -e`, whose
|
||||
exit-status semantics already bit this workflow once at jq 1.6, and both `null` and `[]` terminate the
|
||||
walk. The regression test is parameterised over both shapes because both are live on this server.
|
||||
An empty page — `null` OR `[]`, which take the SAME rule since ersatztv#803 — is **no longer accepted
|
||||
as exhaustion at all** (ersatztv#870, 2026-08-30). Gitea pages this endpoint at the database level and
|
||||
exit-status semantics already bit this workflow once at jq 1.6, and both `null` and `[]` are read as
|
||||
the same EMPTY shape. The regression test is parameterised over both because both are live on this
|
||||
server. An empty page — `null` OR `[]`, which take the SAME rule since ersatztv#803 — is **no longer
|
||||
accepted as exhaustion before the page cap** (ersatztv#870, 2026-08-30). Gitea pages this endpoint at the database level and
|
||||
filters afterwards, so a page whose 50 rows are all inline-code comments serializes as exactly the
|
||||
value the walk used to trust as the end of the list, while later pages still hold events — 50 comments,
|
||||
which a PR author can create on their own PR, bought silence on both axes. The walk now SKIPS an empty
|
||||
page past page 1, reads every page up to its 20-page cap, and trusts the counts only when the LAST
|
||||
page it read came back empty — the same rule the status walk above already stated for itself. An empty
|
||||
page before the cap, reads every page up to its 20-page cap, and trusts the counts only when the LAST
|
||||
page it read came back empty — the same rule the status walk above states for the CAP, though not for termination: that walk still returns on its first empty page, and whether it needs the same change is tracked at ersatztv#893 rather than assumed (measured 2026-08-30, `/statuses/{sha}` returns a TRUE `X-Total-Count`, which this endpoint does not). **That
|
||||
moves the inference to the cap rather than removing it, and the residual is real**: pages 1-19 cover
|
||||
offsets 0..949, so a timeline of more than 1000 rows whose offsets 950..999 are all filtered still
|
||||
returns an empty page 20, and the walk publishes a too-low count as trusted. Both re-reads share the
|
||||
blind spot, so this is the same defeat at about 10x the price — a timeline over 1000 rows rather
|
||||
than ~100, the attacker authoring 50 inline comments either way — not a closed hole. It is NOT the status walk's over-cap residual: `/statuses/{sha}` does not
|
||||
filter after paging, so only here can a page-20 response be empty while later pages hold rows. An empty
|
||||
FIRST page still ends the walk untrusted: every real PR's first page carries events (spot-checked
|
||||
non-empty across #752/#753/#749/#739/#717; the counts are deliberately not recorded here because
|
||||
timelines grow and such figures go stale within days), so an empty first page is ANOMALOUS rather than
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -97,7 +97,7 @@ classifications differ; otherwise the strictest applies and the Note names the e
|
||||
| Site | Class | Note |
|
||||
|---|---|---|
|
||||
| `scripts/post-review-verdict.sh` — commit-status write | `PINNED` | Re-reads the PR and compares **both** `.head.sha` and `.base.ref` immediately before the POST, and `die`s (exit 1, no status written) on a mismatch **or on a field it cannot read**. That last clause is load-bearing: guarding both comparisons with `[ -n "$x" ] &&` alone makes a well-formed 2xx body that merely omits the field a no-op, and the status is posted having confirmed nothing. Regression-tested against the real predecessor (#778), since the redundant-looking `-z` arm alone mutates green. Closes #706 and #632 for this path by read-compare-refuse, not by CAS: Gitea's status API offers no conditional write. Residual closed on the write ORDER since #792: the status is written first and the comment second, so a refusal can no longer leave a verdict comment with no status behind it — the only reachable half-state is a status with no comment, which the merge hook resolves as `ask` (`release.verdict-writes-status-before-comment`). Since #845 the status is also READ BACK after the POST and refused unless it is the write just made, and — for a `success` only, mirroring the gate's own asymmetry — unless its `.creator.login` is on the allow-list derived from the gate (a `failure` is inherited from any attributable account, so requiring membership there would refuse a rejection the gate honours) — the same read-compare-refuse shape, applied to WHOSE verdict it is rather than to which commit it covers. That read is check-then-act too and is graded with this row rather than separately: it can only withhold this tool's success report, never authorize anything, and the residual it leaves — a non-inheritable status standing with no comment beside it — is the `ask` half-state above. Two properties of that read are recorded because neither is visible in the response. `GET /commits/{sha}/status` PAGES and its `total_count` reports the PAGE rather than the total (measured Gitea 1.27.1, 2026-08-29 — `?limit=2` on a 15-context head returned 2 rows and `total_count: 2`), so a truncated body is indistinguishable from a complete one. That looked like a risk of the verdict row falling off a page and is NOT, because of the second property: the endpoint selects each context's MAX row id and orders those DESCENDING before paginating (same measurement — ids `[17,19,...,41,43]`, and `?limit=2` returns 41 and 43, the two highest). The row this tool has just POSTed is the newest on the head, so it sorts first and page 1 holds it at any page size. `?limit=100` (the instance clamps `limit` to `MAX_RESPONSE_ITEMS`, measured at 50) is kept as insurance against a burst of concurrent status writes and against that ordering changing, and has no observable effect otherwise — stated so it is not mistaken for an untested guard. A row it cannot find is therefore refused with the row count it read and no stated cause; an earlier version of this row named truncation as the candidate cause, before the ordering was measured. |
|
||||
| `scripts/pr-changed-files.sh` — paged file enumeration | `UNSAFE-KNOWN` | #707's fix: `.base.ref`, `.base.sha` and `.head.sha` are captured before paging and re-checked after, and any *observed* movement fails the whole enumeration closed rather than emitting a short list. But before-and-after equality is **ABA-vulnerable** — a `main → scratch → main` retarget during paging can return the same ref and, if nothing merged meanwhile, the same base sha, while the pages in between were diffed against the scratch base. The script's own comment says it narrows rather than erases — "any movement fails" would be stronger than the code. Accepted here because the enumerator cannot close it alone, but be exact about what the caller-side fence does and does not cover: `ci.verdict-write-retarget-fence` counts `change_target_branch` events, so it catches the BASE alias and **nothing else**. A HEAD alias — a force-push `H1 -> H2 -> H1` during pagination — leaves the final `.head.sha` comparison equal while the middle pages were enumerated against `H2`, and NOTHING inside this script can see it. **Fenced at the enforced caller since #803** (2026-08-28): the same timeline walk now also counts `pull_push`, so a head that moved at all during classification withholds the write — subject to that walk's own terminator, which was defeatable by a page of filtered rows until **#870** closed it (2026-08-30): the walk no longer reads an empty page as the end of the list, but reads to its 20-page cap and requires the last page to be empty, so hiding an event now costs ~1000 timeline rows instead of 50 and an over-cap timeline fails closed. The grade stays `UNSAFE-KNOWN` for the SCRIPT, because the script's own guarantee is unchanged and one-way — a caller that does not run the fence inherits the alias. Enumeration bound to an immutable tree remains unavailable: re-probed at 1.27.1 on 2026-08-28, `compare/{base}...{head}` still returns no `files` key. |
|
||||
| `scripts/pr-changed-files.sh` — paged file enumeration | `UNSAFE-KNOWN` | #707's fix: `.base.ref`, `.base.sha` and `.head.sha` are captured before paging and re-checked after, and any *observed* movement fails the whole enumeration closed rather than emitting a short list. But before-and-after equality is **ABA-vulnerable** — a `main → scratch → main` retarget during paging can return the same ref and, if nothing merged meanwhile, the same base sha, while the pages in between were diffed against the scratch base. The script's own comment says it narrows rather than erases — "any movement fails" would be stronger than the code. Accepted here because the enumerator cannot close it alone, but be exact about what the caller-side fence does and does not cover: `ci.verdict-write-retarget-fence` counts `change_target_branch` events, so it catches the BASE alias and **nothing else**. A HEAD alias — a force-push `H1 -> H2 -> H1` during pagination — leaves the final `.head.sha` comparison equal while the middle pages were enumerated against `H2`, and NOTHING inside this script can see it. **Fenced at the enforced caller since #803** (2026-08-28): the same timeline walk now also counts `pull_push`, so a head that moved at all during classification withholds the write — subject to that walk's own terminator, which is defeatable by a page of filtered rows — **NARROWED, not closed, by #870** (2026-08-30): the walk no longer reads an empty page BEFORE the cap as the end of the list, but reads to its 20-page cap and requires the last page to be empty, so the same defeat now needs a timeline of more than 1000 rows rather than ~100, with the filtered block pinned to offsets 950..999 — about 10x the price, the attacker authoring 50 inline comments either way. A cap filled with READABLE pages fails closed; a cap hidden behind a filtered block still certifies a too-low count. The grade stays `UNSAFE-KNOWN` for the SCRIPT, because the script's own guarantee is unchanged and one-way — a caller that does not run the fence inherits the alias. Enumeration bound to an immutable tree remains unavailable: re-probed at 1.27.1 on 2026-08-28, `compare/{base}...{head}` still returns no `files` key. |
|
||||
| `scripts/select-queue.sh` — issue list, then per-issue `/dependencies` | `UNSAFE-KNOWN` | The open-issue list (labels, milestone, priority) is snapshotted once; per-candidate dependency reads happen seconds later and never re-read the issue's own labels, so an issue claimed `in-progress` in that gap still appears on the shortlist. Accepted: the script authorizes **no write**. The real gate is the four-way claim check in `process.parallel-session-claim`, which runs after selection and re-reads live state by construction. Tightening this would move a check that must be adversarial into a tool that is advisory. |
|
||||
| `scripts/ci-detect-already-validated.sh` — prior-head combined status | `UNSAFE-KNOWN` | Reads the PR head's status and emits `skip=true`, with nothing re-checking before the consuming job runs. Accepted and narrow: the skip elides only **re-running** test/migrations on a tree already validated; the `build` job still builds and pushes unconditionally, so no image ever ships from unvalidated source. |
|
||||
| `scripts/issue-qualification-audit.sh` — paged issue list, then a report | `UNSAFE-KNOWN` | Pages the open-issue list and reports which issues lack a `priority:` label, so like every paged read here its pages can straddle a change and the report can name a state no single instant held. Graded to match `select-queue.sh` rather than `N/A`: the two run the same shape, and the reason offered for accepting `select-queue.sh` — it authorizes no write — cannot simultaneously be the reason this one is out of the class. Accepted on the same terms: it is advisory, session-end, human-read, and the labels it prompts for are applied by hand afterwards. |
|
||||
|
||||
@@ -1012,6 +1012,17 @@ if "/timeline" in url:
|
||||
for part in url.split("?", 1)[-1].split("&"):
|
||||
if part.startswith("page="):
|
||||
page = int(part.split("=", 1)[1])
|
||||
if os.environ.get("STUB_TIMELINE_FLAKY_FIRST") == "1":
|
||||
# ONE TRANSIENT BLIP, on the very first timeline request of the run (ersatztv#870 review).
|
||||
# This is the only arrangement that separates a walk that retries from one that does not:
|
||||
# `transport-error` and `unreadable` fail EVERY attempt, so a retry changes nothing and both
|
||||
# implementations refuse identically. Counting REQUESTS, not pages, because the retry is
|
||||
# per-request — `timeline_reads.txt` bumps once per walk and cannot see a second attempt.
|
||||
rctr = out / "timeline_requests.txt"
|
||||
rseen = int(rctr.read_text()) if rctr.exists() else 0
|
||||
rctr.write_text(str(rseen + 1))
|
||||
if rseen == 0:
|
||||
sys.exit(22)
|
||||
if mode == "empty-first-page":
|
||||
# A terminator on PAGE 1 — no real page ever read (ersatztv#751). The job must NOT certify a
|
||||
# zero retarget count from this, so the exemption is withheld.
|
||||
@@ -1095,8 +1106,11 @@ if "/timeline" in url:
|
||||
# indistinguishable to the walk on the wire, which is the entire defect, so a double that made
|
||||
# them distinguishable would test a server we do not have.
|
||||
#
|
||||
# It exits BEFORE the last-real-page branch, so it does not touch `timeline_reads.txt`: that
|
||||
# counter means "real pages served", and a filtered page served no rows.
|
||||
# It exits BEFORE the last-real-page branch, so it does not touch `timeline_reads.txt`. Be exact
|
||||
# about what that counter is, because the comment above it is not: it increments ONLY on the
|
||||
# last-real-page branch, so it counts WALKS (one bump each, at the walk's last real page), not
|
||||
# pages served. A filtered page must not bump it either way, or the `moves:`/`stable:` sequences
|
||||
# would advance a walk early and address the wrong element.
|
||||
filtered = {
|
||||
int(x) for x in os.environ.get("STUB_TIMELINE_FILTERED_PAGES", "").split(",") if x.strip()
|
||||
}
|
||||
@@ -1787,6 +1801,7 @@ def _run_classify(
|
||||
push_mode: str = "none",
|
||||
timeline_pages: int = 1,
|
||||
timeline_filtered_pages: str = "",
|
||||
timeline_flaky_first: bool = False,
|
||||
history_mode: str = "none",
|
||||
history_creator: str = "timothy",
|
||||
history_extra: list | None = None,
|
||||
@@ -1833,6 +1848,7 @@ def _run_classify(
|
||||
env["STUB_PUSH_MODE"] = push_mode
|
||||
env["STUB_TIMELINE_PAGES"] = str(timeline_pages)
|
||||
env["STUB_TIMELINE_FILTERED_PAGES"] = timeline_filtered_pages
|
||||
env["STUB_TIMELINE_FLAKY_FIRST"] = "1" if timeline_flaky_first else ""
|
||||
env["STUB_TIMELINE_TERMINATOR"] = timeline_terminator
|
||||
env["STUB_STATUS_EMPTY_SHAPE"] = status_empty_shape
|
||||
env["STUB_HISTORY_MODE"] = history_mode
|
||||
@@ -3663,6 +3679,80 @@ def test_a_timeline_that_FILLS_the_page_cap_is_untrusted(tmp_path):
|
||||
)
|
||||
|
||||
|
||||
def test_a_FILTERED_page_before_a_FULL_cap_page_is_still_untrusted(tmp_path):
|
||||
"""A filtered page must not survive as trust when the walk then runs into the cap.
|
||||
|
||||
Page 19 comes back empty (filtered), page 20 is full. The walk must finish `empty=no` and refuse.
|
||||
This is what makes the per-iteration `empty=no` reset load-bearing in the direction the other
|
||||
fixtures cannot see: they all END on an empty page, so a stale flag and a correct one agree
|
||||
there. Here they disagree — without the reset the flag is still `yes` from page 19 when the loop
|
||||
falls out, and line `if [ "$empty" = yes ]` would certify a walk that never reached a terminator.
|
||||
|
||||
(The reset is ALSO covered from the other side: deleting it makes the three filtered-page tests
|
||||
above go red, because a stale `yes` suppresses the tally on every later non-empty page and the
|
||||
hidden events stop being counted. Measured, not assumed — an early review round predicted those
|
||||
three would stay green.)
|
||||
"""
|
||||
posted, r = _run_classify(
|
||||
tmp_path,
|
||||
_emitting("docs/a.md"),
|
||||
timeline_mode="none",
|
||||
push_mode="stable:0",
|
||||
timeline_pages=25,
|
||||
timeline_filtered_pages="19",
|
||||
)
|
||||
assert posted is None or posted["state"] != "success", (
|
||||
"an exemption was granted over a walk that hit the page cap on a NON-empty page after a "
|
||||
f"filtered one — the empty flag is stale. Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
assert "Could not establish a trusted retarget/push count" in r.stdout, (
|
||||
f"nothing was exempted, but NOT because the count was untrusted. Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
|
||||
|
||||
def test_a_SINGLE_transient_blip_does_not_cost_the_exemption(tmp_path):
|
||||
"""The walk retries each page once, as `page_statuses` does and for its stated reason.
|
||||
|
||||
This walk had no retry while it made ~2 requests per call. At a fixed 20 it makes 10x as many,
|
||||
so a blip is 10x likelier — and `rt_ok=no` on the exemption path writes the STICKY sentinel,
|
||||
which costs that head its exemption until a human clears it by hand. That is a regression this
|
||||
change would otherwise have shipped.
|
||||
|
||||
`transport-error` and `unreadable` cannot measure this: they fail every attempt, so a retrying
|
||||
walk and a non-retrying one refuse identically. Only a blip that clears on the second attempt
|
||||
separates them.
|
||||
"""
|
||||
posted, r = _run_classify(
|
||||
tmp_path,
|
||||
_emitting("docs/a.md"),
|
||||
timeline_mode="none",
|
||||
push_mode="stable:0",
|
||||
timeline_flaky_first=True,
|
||||
)
|
||||
assert posted is not None and posted["state"] == "success", (
|
||||
"a docs-only PR lost its exemption to ONE transient timeline blip — the walk does not "
|
||||
f"retry. Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
|
||||
|
||||
def test_the_timeline_read_is_TIME_BOUNDED(tmp_path):
|
||||
"""`gh` is bare `curl -sf` with no timeout, and this walk now issues 20 requests instead of ~2.
|
||||
|
||||
The third call site runs AFTER the exemption `success` is posted, so a hang there leaves the
|
||||
green standing with no repair attempted. The bound is applied at THIS call rather than inside
|
||||
`gh`, so the other call sites keep the behaviour they were reviewed with. Asserted structurally
|
||||
because a hang cannot be provoked through the stub — the stub answers instantly by construction.
|
||||
"""
|
||||
body = _classify_step()["run"]
|
||||
line = [ln for ln in body.splitlines() if "/timeline?limit=50&page=" in ln]
|
||||
assert len(line) == 1, f"expected exactly one timeline read, found {len(line)}: {line}"
|
||||
assert "--max-time" in line[0], (
|
||||
"the timeline read carries no --max-time; a hung request on the POST-WRITE walk leaves an "
|
||||
f"exemption success standing with no repair attempted. Line: {line[0]}"
|
||||
)
|
||||
assert "--connect-timeout" in line[0], f"the timeline read carries no --connect-timeout. Line: {line[0]}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("terminator", ["null", "[]"])
|
||||
def test_an_EMPTY_FIRST_page_is_untrusted_WHICHEVER_empty_shape_it_is(tmp_path, terminator):
|
||||
"""Both empty shapes must fall through to `rt_ok=no`, and only one of them did.
|
||||
|
||||
Reference in New Issue
Block a user