fix(849): round 2 — the uncertainty paths that still resolved toward success
Two independent cold reviews (Codex/GPT-5.6 cross-family, and a cold Claude reviewer in
its own worktree) converged on the same class: paths where "this job cannot establish
what is on the head" still resolved by leaving the head alone, which protects a real
verdict and leaves a forged one.
Behaviour:
1. The four page-2 completeness refusals now replace the unknown state too. They were
excluded on the reasoning that the probe fires when NO row for this context was on page
1, so there is no green of any provenance to leave standing — self-contradictory, since
the only reason page 2 is read is that the row may be beyond page 1, which the probe's
own message says. Accepted cost, stated in the record: a head with more CONTEXTS than
the 50-row cap stalls every run; measured 2026-08-29, this repo puts 8 on a `main` head,
and that case already stalled with an ABSENT check.
2. The no-mark downgrade covers every re-derivable write, not only `success`. Restricting
it analysed the wrong PR: the damaging case is one that IS exemptible and got the
generic `pending` only from a transient enumeration failure. That description carries no
marker, nothing verifies it without a mark, and the next run re-derives it into the
exemption with the human row below its own mark — route 2's damage through route 1's
condition. `$REPAIR_DESC` stays exempt, being stronger and not re-derivable.
3. The fence branch that cannot trust its retarget count while holding a derived `success`
writes the sentinel instead of abstaining. It is reached only after the classification
DECLINED to inherit the row the head carries, so posting nothing left that row current;
the message said the context "stays absent", true only of a head that had none.
4. Reconciliation needs a WITNESS: it may clear only over a complete history containing the
sentinel's own row. `ex_unverified` means the combined endpoint just returned that row
and `/statuses/{sha}` keeps one per POST, so a complete-but-empty history contradicts a
write that demonstrably happened — and `page_statuses` accepts an empty page 1 as
complete, which is what made it reachable. Both reviewers reproduced the clear-then-exempt
outcome. The shipped positive test used exactly that impossible fixture, so it was
pinning the defect; it now seeds the sentinel row, and an impossible-empty negative plus
a witness mutation proof were added.
5. The mid-run "did this row change" comparison now includes the row ID. The two sentinels
are byte-identical by design, so a mid-run replacement of one by another was invisible to
a state/creator/description triple. Measured 2026-08-29 (Gitea 1.27.1, head 736649b3):
the COMBINED endpoint carries `id` on every row, ids 14..30 ascending — the job had only
ever read ids from `/statuses/{sha}`. Where a server omits it both sides are empty and
the comparison degrades to the pre-existing text test.
6. The repair has a FLOOR — it may never write a description weaker than the one this run
decided — and is skipped when it would rewrite what is already there. Widening the gate
to every write meant a transient post-write read could rewrite a correct `$REPAIR_DESC`
carry-forward with the machine-clearable sentinel, reversing the ordering rule the
classification chain states.
Writing the sentinel and failing the job are separate decisions, which is why
`replace_unknown_state` and `replace_unknown_and_die` are two functions: the read refusals
were already non-zero exits on `main` and stay red; the fence branch exited 0 there and
still does, because an unreadable timeline is an ordinary hiccup and reddening every one is
noise this file elsewhere refuses to add.
Prose corrected where it now overclaimed: "the green never stands" after the post-POST
re-check is wrong — it is live between the POST and the repair, so the check makes a
permanent green TRANSIENT; "a later run reconciles this automatically" is wrong in the one
case where the replacement costs anything, since finding a masked verdict UPGRADES to the
human-only sentinel; and the mutation-proof framing claimed every mutant restores the exact
predecessor, when two do, one restores the shape #742 withdrew, and the rest disarm clauses
that have no predecessor. The quiet-timeline positive control now counts timeline walks,
because a single POST is also what a skipped re-check produces.
refs #849
Decisions-Edit: yes
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019T79beF1Ufid3dXju4yqkF
This commit is contained in:
@@ -413,6 +413,44 @@ jobs:
|
||||
return 1
|
||||
}
|
||||
|
||||
# EVERY "this job cannot establish what is on the head" EXIT GOES THROUGH HERE
|
||||
# (ersatztv#849). Declining to write protects a real verdict and leaves a FORGED one — an
|
||||
# off-list `success` is the row #742 exists to revoke, revocation happens by re-deriving
|
||||
# it, and an unreadable read is the one thing that stops it while this job goes red on a
|
||||
# status branch protection does not read.
|
||||
#
|
||||
# Factored rather than repeated because the four page-2 refusals below used to be the
|
||||
# exception, on the reasoning that the probe "fires when NO row for this context was on
|
||||
# page 1, so there is no green of any provenance to leave standing". That is
|
||||
# self-contradictory: the ONLY reason page 2 is read at all is that the row MAY be beyond
|
||||
# page 1, which the probe's own message says. Whatever a future reader concludes about
|
||||
# reachability, the two branches must not resolve the same uncertainty in opposite
|
||||
# directions.
|
||||
#
|
||||
# ACCEPTED COST, stated rather than discovered later: a head carrying more CONTEXTS than
|
||||
# the server-wide page cap (measured 50) stalls on every run, because the probe refuses
|
||||
# every time. Measured 2026-08-29, this repo puts 8 contexts on a `main` head. That case
|
||||
# already stalled before this change — with an ABSENT required check, which reads as "not
|
||||
# reviewed yet" — so what changes is that the stall now says why.
|
||||
replace_unknown_state() { # $1 = the ::error:: naming what could not be established
|
||||
echo "::error::$1"
|
||||
if repair_status_to "$UNVERIFIED_DESC"; then
|
||||
echo "::error::Replaced ${CONTEXT} on ${SHA:0:7} with the unverified-write sentinel rather than leaving a state this job could not read standing. A later run will either clear it, or — if it finds a verdict underneath — ask you to re-post that verdict. To settle it now: scripts/post-review-verdict.sh ${PR} <VERDICT>"
|
||||
else
|
||||
echo "::error::COULD NOT WRITE THE UNVERIFIED SENTINEL to ${SHA:0:7}. Whatever ${CONTEXT} this head carries is standing unread. Post a verdict immediately: scripts/post-review-verdict.sh ${PR} <VERDICT>"
|
||||
fi
|
||||
}
|
||||
# WRITING THE SENTINEL AND FAILING THE JOB ARE SEPARATE DECISIONS, and only the read paths
|
||||
# take both. `read_existing_verdict`'s refusals already exited non-zero on `main`, so
|
||||
# keeping them red changes nothing about how often this job is red. The FENCE's untrusted
|
||||
# branch exited 0 there — an unreadable timeline is an ordinary API hiccup, and turning
|
||||
# every one of them into a red run is the noise this file elsewhere refuses to add. It
|
||||
# calls `replace_unknown_state` and returns cleanly.
|
||||
replace_unknown_and_die() {
|
||||
replace_unknown_state "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# DEFINED HERE, BEFORE ANY USE. An earlier round defined these AFTER the classification
|
||||
# chain that calls them, so `count_matching` was `command not found` on every run, the
|
||||
# PROTECTED branch silently never fired, and three "protected path" tests still passed —
|
||||
@@ -572,17 +610,7 @@ jobs:
|
||||
# a stall, clearable in one command, and it is the direction this whole job resolves
|
||||
# uncertainty in everywhere else.
|
||||
#
|
||||
# SCOPED TO AN UNREADABLE BODY, deliberately. The page-2 completeness probe below also
|
||||
# refuses, and is deliberately NOT routed here: it fires precisely when NO row for this
|
||||
# context was on page 1, i.e. when there is no green of any provenance for this job to
|
||||
# be leaving standing. Its refusal withholds a conclusion; this branch replaces a state.
|
||||
echo "::error::Could not read existing commit statuses for ${SHA:0:7} (.statuses was '${st_kind:-unparseable}', total_count '${st_total}') after a retry, so any ${CONTEXT} already on this head — including one posted by an account this gate does not accept verdicts from — can neither be read nor re-derived."
|
||||
if repair_status_to "$UNVERIFIED_DESC"; then
|
||||
echo "::error::Replaced ${CONTEXT} on ${SHA:0:7} with the unverified-write sentinel rather than leaving an unreadable state standing. A later run reconciles this automatically; to clear it now, post a verdict: scripts/post-review-verdict.sh ${PR} <VERDICT>"
|
||||
else
|
||||
echo "::error::COULD NOT WRITE THE UNVERIFIED SENTINEL to ${SHA:0:7}. Whatever ${CONTEXT} this head carries is standing unread. Post a verdict immediately: scripts/post-review-verdict.sh ${PR} <VERDICT>"
|
||||
fi
|
||||
exit 1
|
||||
replace_unknown_and_die "Could not read existing commit statuses for ${SHA:0:7} (.statuses was '${st_kind:-unparseable}', total_count '${st_total}') after a retry, so any ${CONTEXT} already on this head — including one posted by an account this gate does not accept verdicts from — can neither be read nor re-derived."
|
||||
fi
|
||||
# `// []` so the null case cannot hard-error here under `set -e` once it is accepted above.
|
||||
row=$(printf '%s' "$json" | jq -r --arg c "$CONTEXT" '[(.statuses // [])[] | select(.context == $c)] | first // {}')
|
||||
@@ -593,8 +621,7 @@ jobs:
|
||||
if [ "$(printf '%s' "$row" | jq -r '.context // ""')" = "" ]; then
|
||||
more=$(gh "$BASE_URL/repos/$REPO/commits/$SHA/status?limit=100&page=2") || more=""
|
||||
if [ -z "${more//[[:space:]]/}" ]; then
|
||||
echo "::error::Could not read page 2 of the commit statuses for ${SHA:0:7}, so 'no verdict exists' cannot be established. Refusing to post anything."
|
||||
exit 1
|
||||
replace_unknown_and_die "Could not read page 2 of the commit statuses for ${SHA:0:7}, so 'no verdict exists' cannot be established."
|
||||
fi
|
||||
more_kind=$(printf '%s' "$more" | jq -r '.statuses | type' 2>/dev/null) || more_kind=""
|
||||
more_len=$(printf '%s' "$more" | jq -r '(.statuses // []) | length' 2>/dev/null) || more_len=""
|
||||
@@ -603,18 +630,28 @@ jobs:
|
||||
array)
|
||||
case "$more_len" in
|
||||
''|*[!0-9]*)
|
||||
echo "::error::Page 2 of the commit statuses for ${SHA:0:7} had a non-numeric length; refusing to conclude that no verdict exists."
|
||||
exit 1 ;;
|
||||
replace_unknown_and_die "Page 2 of the commit statuses for ${SHA:0:7} had a non-numeric length, so it cannot be concluded that no verdict exists." ;;
|
||||
0) ;;
|
||||
*)
|
||||
echo "::error::${CONTEXT} was not on page 1 of the statuses for ${SHA:0:7}, but page 2 carries ${more_len} more row(s) — the list is longer than one page and an existing verdict may be beyond it. Refusing to post anything rather than overwrite a verdict this job cannot see. A human verdict clears this: scripts/post-review-verdict.sh ${PR} MERGEABLE."
|
||||
exit 1 ;;
|
||||
replace_unknown_and_die "${CONTEXT} was not on page 1 of the statuses for ${SHA:0:7}, but page 2 carries ${more_len} more row(s) — the list is longer than one page, so a verdict of ANY provenance may be sitting beyond it where this job cannot read it." ;;
|
||||
esac ;;
|
||||
*)
|
||||
echo "::error::Page 2 of the commit statuses for ${SHA:0:7} was '${more_kind:-unparseable}'; refusing to conclude that no verdict exists."
|
||||
exit 1 ;;
|
||||
replace_unknown_and_die "Page 2 of the commit statuses for ${SHA:0:7} was '${more_kind:-unparseable}', so it cannot be concluded that no verdict exists." ;;
|
||||
esac
|
||||
fi
|
||||
# THE ROW ID, so "did this row change" can be asked about IDENTITY rather than about
|
||||
# TEXT (ersatztv#849). Two sentinel POSTs are byte-identical by design — that is what
|
||||
# makes them fixed points — so a mid-run REPLACEMENT of one sentinel by another is
|
||||
# invisible to a state/creator/description comparison, and the run then overwrites a row
|
||||
# another run had just written. The same blind spot applies to any replacement whose
|
||||
# triple happens to match.
|
||||
#
|
||||
# MEASURED 2026-08-29 on this instance (Gitea 1.27.1), because the rest of this job reads
|
||||
# ids only from `/statuses/{sha}`: the COMBINED endpoint's rows carry `id` too — head
|
||||
# 736649b3 returned 8 rows keyed id/context/status/creator/description/created_at/
|
||||
# updated_at/url, ids 14..30 ascending. `// ""` so a server that ever stopped sending it
|
||||
# degrades to the pre-existing text comparison rather than to a false "changed".
|
||||
ex_id=$(printf '%s' "$row" | jq -r 'if (.id | type) == "number" then (.id | tostring) else "" end')
|
||||
ex_state=$(printf '%s' "$row" | jq -r '.status // ""')
|
||||
ex_creator=$(printf '%s' "$row" | jq -r '.creator.login // ""')
|
||||
ex_desc=$(printf '%s' "$row" | jq -r '.description // ""')
|
||||
@@ -1064,6 +1101,7 @@ jobs:
|
||||
}
|
||||
|
||||
ex_repair=no
|
||||
ex_unverified=no
|
||||
count_pr_mutations
|
||||
retargets_before=$rt_count
|
||||
pushes_before=$hp_count
|
||||
@@ -1172,6 +1210,12 @@ jobs:
|
||||
pre_state=$ex_state
|
||||
pre_creator=$ex_creator
|
||||
pre_desc=$ex_desc
|
||||
# THE ID IS PART OF THE SNAPSHOT (ersatztv#849, round 2). The triple cannot see a
|
||||
# REPLACEMENT whose text matches, and the two sentinels are byte-identical by design, so
|
||||
# "another run replaced this row while we classified" was invisible for exactly the rows
|
||||
# where it matters most. Where the server does not send an id both sides are empty and the
|
||||
# comparison falls back to the triple, which is the pre-existing behaviour.
|
||||
pre_id=$ex_id
|
||||
if [ -n "$ex_state" ]; then
|
||||
# STATE-NEUTRAL WORDING. Control also reaches here for an ALLOW-LISTED creator whose row is
|
||||
# in some state other than `success`/`failure`, so this must not assert the row is
|
||||
@@ -1215,8 +1259,27 @@ jobs:
|
||||
if [ "$ex_unverified" = yes ]; then
|
||||
echo "${CONTEXT} on ${SHA:0:7} carries the unverified-write sentinel from an earlier run — reconciling it against the per-POST status history."
|
||||
page_statuses
|
||||
if [ "$ph_ok" != yes ]; then
|
||||
echo "::warning::Could not read a complete status history for ${SHA:0:7}, so the unverified write from an earlier run still cannot be reconciled. Carrying the sentinel forward; ${CONTEXT} stays pending and no exemption is granted."
|
||||
# THE WITNESS: THE SENTINEL'S OWN ROW MUST BE IN THE HISTORY (ersatztv#849, round 2).
|
||||
# `ex_unverified=yes` means the COMBINED endpoint just returned the sentinel for this
|
||||
# sha, and `/statuses/{sha}` keeps one row per POST — so a complete history that does
|
||||
# NOT contain it, empty ones included, is a response that cannot be true. The post-write
|
||||
# check already refuses an empty history for exactly this reason; reconciliation stands
|
||||
# in the same position and had no such guard, so a single anomalous `[]` cleared the
|
||||
# sentinel and let the run exempt a head carrying a buried rejection. `page_statuses`
|
||||
# deliberately accepts an empty page 1 as complete (correct for a first-run mark), which
|
||||
# is what made the shape reachable.
|
||||
#
|
||||
# THIS IS NOT THE WITHDRAWN CURRENCY WITNESS. That asked "is there ANY row above the
|
||||
# mark", which an unrelated newer row satisfied, and it converted one anomaly into a
|
||||
# PERMANENT sentinel. This asks for a SPECIFIC row already known to exist, and failing it
|
||||
# carries the sentinel forward for THIS run only — the next run retries.
|
||||
witness=$(printf '%s' "$ph_rows" | jq -r --arg c "$CONTEXT" --arg ud "$UNVERIFIED_DESC" \
|
||||
'[.[] | select(type == "object")
|
||||
| select(.context? == $c)
|
||||
| select(((.description | type) == "string") and (.description == $ud))] | length') || witness=""
|
||||
case "$witness" in ''|*[!0-9]*) witness=0 ;; esac
|
||||
if [ "$ph_ok" != yes ] || [ "$witness" -eq 0 ]; then
|
||||
echo "::warning::Could not read a status history for ${SHA:0:7} that is both complete and contains the sentinel this head carries (complete=${ph_ok}, sentinel rows found=${witness}), so the unverified write from an earlier run still cannot be reconciled. Carrying the sentinel forward; ${CONTEXT} stays pending and no exemption is granted."
|
||||
else
|
||||
# `.description` IS TYPE-TESTED BEFORE `startswith`, exactly as the post-write filter
|
||||
# does it and for the same reason: a row whose description is a number makes
|
||||
@@ -1512,13 +1575,30 @@ jobs:
|
||||
# publish a green and take it back: a repair leaves a window in which branch protection can
|
||||
# see the exemption, and an already-scheduled auto-merge can fire inside it.
|
||||
#
|
||||
# ONLY `success` IS DOWNGRADED. A `pending` write cannot be verified either, and that is
|
||||
# handled where it belongs — by the post-write check now covering every write (route 2).
|
||||
# Rewriting a generic `pending` into the sentinel HERE would make every ordinary PR sticky
|
||||
# whenever this endpoint blinks, which withholds nothing (an unreviewed PR is blocked
|
||||
# already) and costs the next docs-only run its exemption for no gain.
|
||||
if [ "$state" = "success" ] && [ "$max_id_before" -lt 0 ]; then
|
||||
echo "::error::No status high-water mark could be established for ${SHA:0:7}, so an exemption posted now could not be checked for a human verdict landing in the write window. Withholding it and writing the unverified-write sentinel instead. A later run reconciles this automatically once the history can be read; to clear it now, post a verdict: scripts/post-review-verdict.sh ${PR} <VERDICT>"
|
||||
# EVERY RE-DERIVABLE WRITE IS DOWNGRADED, not only `success` (corrected in round 2). An
|
||||
# earlier version restricted this to the exemption, reasoning that a sticky generic
|
||||
# `pending` "withholds nothing, since an unreviewed PR is blocked already". That analysed
|
||||
# the wrong PR. The damaging case is a PR that IS exemptible and only got the generic
|
||||
# `pending` from a transient enumeration failure: the generic description carries no
|
||||
# marker, the post-write check below does not run without a mark, so a human verdict
|
||||
# landing in the write window is buried and the NEXT run re-derives that `pending` into
|
||||
# the exemption with the human row below its own mark. That is route 2's damage reached
|
||||
# through route 1's condition.
|
||||
#
|
||||
# `$REPAIR_DESC` IS EXEMPT because it is the stronger fact and is not re-derivable — the
|
||||
# classification refuses to exempt over it. Downgrading it here would lose a verdict this
|
||||
# head is known to have lost.
|
||||
#
|
||||
# POSITIONED AFTER THE MARK, NOT WITH THE CLASSIFICATION. `$max_id_before` does not exist
|
||||
# up there and referencing it early is an unbound variable under `set -u` — a job that
|
||||
# dies before posting anything, on every PR.
|
||||
#
|
||||
# NOT POST-THEN-REPAIR, which is what happens when the mark DOES exist and the check then
|
||||
# fires. Here the defect is known BEFORE the write, so there is no reason to publish a
|
||||
# green and take it back: a repair leaves a window in which branch protection can see the
|
||||
# exemption, and an already-scheduled auto-merge can fire inside it.
|
||||
if [ "$max_id_before" -lt 0 ] && [ "$desc" != "$REPAIR_DESC" ]; then
|
||||
echo "::error::No status high-water mark could be established for ${SHA:0:7}, so nothing can check this run's '${state}' write for a human verdict landing in the write window. Writing the unverified-write sentinel instead of a status a later run would re-derive. A later run will either clear it, or — if it finds a verdict underneath — ask you to re-post that verdict. To settle it now: scripts/post-review-verdict.sh ${PR} <VERDICT>"
|
||||
state=pending
|
||||
desc="$UNVERIFIED_DESC"
|
||||
fi
|
||||
@@ -1537,7 +1617,8 @@ jobs:
|
||||
# whenever the high-water mark could not be established.
|
||||
read_existing_verdict
|
||||
if [ "$ex_attributable" = yes ] \
|
||||
&& { [ "$ex_state" != "$pre_state" ] || [ "$ex_creator" != "$pre_creator" ] || [ "$ex_desc" != "$pre_desc" ]; }; then
|
||||
&& { [ "$ex_state" != "$pre_state" ] || [ "$ex_creator" != "$pre_creator" ] \
|
||||
|| [ "$ex_desc" != "$pre_desc" ] || [ "$ex_id" != "$pre_id" ]; }; then
|
||||
echo "::notice::An attributable verdict ('${ex_state}' by '${ex_creator}') landed on ${SHA:0:7} while this job was classifying — leaving it alone and posting nothing."
|
||||
exit 0
|
||||
fi
|
||||
@@ -1585,7 +1666,8 @@ jobs:
|
||||
#
|
||||
# A run whose own write IS a sentinel is exempt from the guard: replacing a sentinel with a
|
||||
# sentinel loses nothing, and the repair sentinel outranks this one.
|
||||
if [ "$ex_unverified" = yes ] && [ "$ex_desc" != "$pre_desc" ] \
|
||||
if [ "$ex_unverified" = yes ] \
|
||||
&& { [ "$ex_desc" != "$pre_desc" ] || [ "$ex_id" != "$pre_id" ]; } \
|
||||
&& [ "$desc" != "$REPAIR_DESC" ] && [ "$desc" != "$UNVERIFIED_DESC" ]; then
|
||||
echo "::notice::An unverified-write sentinel was written on ${SHA:0:7} while this job was classifying, so another run posted something it could not check. This run would overwrite that record with an unmarked status a later run could re-derive into an exemption — posting NOTHING and leaving the sentinel standing."
|
||||
exit 0
|
||||
@@ -1635,7 +1717,19 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
if { [ "$retargets_before_ok" != yes ] || [ "$rt_ok" != yes ]; } && [ "$state" = "success" ]; then
|
||||
echo "::error::Could not establish a trusted retarget/push count for PR #${PR} (before=${retargets_before_ok}, after=${rt_ok}), so an exemption 'success' cannot be shown to have been computed against the PR's current base, nor at a single head. Posting nothing; ${CONTEXT} stays absent, which blocks the merge. NOTE a later run only helps if the cause was transient — a PR whose timeline exceeds the page cap will fail this way on every run, and needs a human verdict."
|
||||
# ABSTAINING HERE WAS A FAIL-OPEN WHEN THE HEAD ALREADY CARRIED A ROW (ersatztv#849,
|
||||
# round 2). This branch is reached only after the classification DECLINED to inherit
|
||||
# whatever `review-verdict/h10` the head carries — that is why it is re-deriving — so
|
||||
# posting nothing leaves the declined row current. The old message said the context
|
||||
# "stays absent", which is true only for a head that had none; on a head carrying a
|
||||
# machine or off-list `success` it is the opposite of what happens, and no retarget or
|
||||
# push need have occurred, so no successor run is guaranteed either.
|
||||
#
|
||||
# The sentinel is the right write rather than the exemption: it states what was actually
|
||||
# established (this run could not verify its own classification), blocks the merge, and
|
||||
# is cleared by the next run that can read the timeline — so a transient outage costs one
|
||||
# event rather than a human verdict.
|
||||
replace_unknown_state "Could not establish a trusted retarget/push count for PR #${PR} (before=${retargets_before_ok}, after=${rt_ok}), so an exemption 'success' cannot be shown to have been computed against the PR's current base, nor at a single head. NOTE a later run only helps if the cause was transient — a PR whose timeline exceeds the page cap will fail this way on every run, and needs a human verdict."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -1923,10 +2017,25 @@ jobs:
|
||||
raced=1 ;;
|
||||
esac
|
||||
fi
|
||||
# NEVER WRITE A WEAKER DESCRIPTION THAN THIS RUN ALREADY DECIDED (ersatztv#849, round
|
||||
# 2). `repair_desc` is set to the reconcilable sentinel by every "could not check" arm,
|
||||
# and since this block started running for EVERY write it also runs after a
|
||||
# carry-forward write of `$REPAIR_DESC`. One transient post-write read then rewrote that
|
||||
# head with the strictly weaker, machine-clearable sentinel — the exact reverse of the
|
||||
# ordering rule the classification chain states, and the input to a two-step green if
|
||||
# anything later cleared it wrongly.
|
||||
if [ "$desc" = "$REPAIR_DESC" ]; then repair_desc="$REPAIR_DESC"; fi
|
||||
# NORMALISE FIRST, THEN ACT ONCE. Setting `raced=1` inside a `case` arm and expecting the
|
||||
# repair to happen in a SIBLING arm does not work — the case has already dispatched. That
|
||||
# is why the unusable-count branch above sets the flag and the decision lives out here,
|
||||
# where every path that concluded "raced" reaches the same single writer.
|
||||
# A REPAIR THAT WOULD WRITE WHAT IS ALREADY THERE IS NOT A REPAIR. Reachable once the
|
||||
# floor above pins `repair_desc` to this run's own description: without this the job
|
||||
# POSTs a duplicate row and logs "Repaired …" for a change that did not happen.
|
||||
if [ "$raced" -gt 0 ] && [ "$repair_desc" = "$desc" ]; then
|
||||
echo "::notice::Post-write verification for ${SHA:0:7} could not clear the write window (${raced_why}), but ${CONTEXT} already carries the description the repair would write, so nothing is re-posted."
|
||||
raced=0
|
||||
fi
|
||||
if [ "$raced" -gt 0 ]; then
|
||||
# The last-moment re-read found no human verdict, so any row present now was
|
||||
# written during the window and has just been masked by this job's write.
|
||||
@@ -1973,7 +2082,14 @@ jobs:
|
||||
# RE-COUNTING AFTER THE POST closes the induction. A retarget landing after this check
|
||||
# necessarily queues a successor that STARTS after the stale `success` already exists — and
|
||||
# a machine-written `success` is re-derived, not inherited, so that successor changes the
|
||||
# answer. A retarget landing before it is caught here and the green never stands.
|
||||
# answer. A retarget landing before it is caught here.
|
||||
#
|
||||
# WHAT THAT BUYS IS TRANSIENT INSTEAD OF PERMANENT, not "the green never stands" — which is
|
||||
# what this comment claimed until round-2 review. The `success` is live between its POST
|
||||
# and the repair below, including the timeline round trips in between, so branch protection
|
||||
# or an already-scheduled auto-merge can observe it. Closing THAT window needs a
|
||||
# compare-and-set or serialization the API does not offer; what is removed is the case
|
||||
# where no event remained to correct it.
|
||||
#
|
||||
# ONLY WHEN AN EXEMPTION `success` IS WHAT STANDS. A `pending` cannot be a forged green, and
|
||||
# `$state` is re-read after the repair above precisely so a write already downgraded is not
|
||||
|
||||
+27
-9
@@ -1711,7 +1711,10 @@ this is why** — the job log names the counts.
|
||||
`ci.verdict-unverified-write-sentinel`). The pre-write fence covers *writing while overtaken*; it never
|
||||
covered *being overtaken after writing*, which was the worse of the two — a retarget landing after the
|
||||
final pre-write count left a stale `success` with the `edited` event already consumed by a successor
|
||||
that short-circuited, so nothing remained to reclassify. The retarget axis only: a push after the POST
|
||||
that short-circuited, so nothing remained to reclassify. It makes that green **transient rather than
|
||||
permanent**, not absent: the `success` is live between its POST and the repair, so branch protection
|
||||
or a scheduled auto-merge can still observe it. Closing that window needs a compare-and-set the API
|
||||
does not offer. The retarget axis only: a push after the POST
|
||||
moves the head, so the status no longer gates that PR, while a retarget changes the effective diff with
|
||||
the sha unchanged.
|
||||
|
||||
@@ -1764,15 +1767,30 @@ interchangeable (`ci.verdict-unverified-write-sentinel`):
|
||||
it — upgrading to the repair sentinel — or finds none and clears it, so a transient API failure does
|
||||
not cost a head its exemption permanently.
|
||||
|
||||
**No high-water mark means no exemption**, withheld before the POST rather than posted and repaired:
|
||||
the defect is known in advance, and publishing a green to take it back opens a window branch
|
||||
protection — and an already-scheduled auto-merge — can see.
|
||||
**No high-water mark means the write becomes the sentinel** — every re-derivable state, not only the
|
||||
exemption — withheld before the POST rather than posted and repaired: the defect is known in advance,
|
||||
and publishing a green to take it back opens a window branch protection, and an already-scheduled
|
||||
auto-merge, can see. A generic `pending` is included because it is exactly what a later run
|
||||
re-derives; `$REPAIR_DESC` is not, being the stronger fact.
|
||||
|
||||
**An unreadable combined-status read replaces the unknown state** rather than merely declining to
|
||||
write. Declining protects a real verdict and leaves a *forged* one standing, which is what an off-list
|
||||
`success` is; the job went red on a status branch protection does not read. The read is retried once
|
||||
first, and nothing is destroyed — `/statuses/{sha}` keeps one row per POST, so the next run's
|
||||
reconciliation finds a masked verdict and tells the reviewer to re-post.
|
||||
**Every path that cannot establish what the head carries REPLACES the unknown state** rather than
|
||||
merely declining to write: the combined read (retried once first), all four page-2 completeness
|
||||
refusals, and the fence branch that cannot trust its retarget count while holding a derived
|
||||
`success`. Declining protects a real verdict and leaves a *forged* one standing, which is what an
|
||||
off-list `success` is; the job went red on a status branch protection does not read, and the fence
|
||||
branch was reached only after the classification had DECLINED to inherit the very row it then left
|
||||
current. Nothing is destroyed — `/statuses/{sha}` keeps one row per POST, so the next run's
|
||||
reconciliation finds a masked verdict and tells the reviewer to re-post. Writing the sentinel and
|
||||
failing the job are separate decisions: the read refusals were already non-zero exits and stay red,
|
||||
the fence branch exited 0 and still does.
|
||||
|
||||
**Reconciliation needs a witness.** It may clear the sentinel only over a complete history that
|
||||
CONTAINS the sentinel's own row. `ex_unverified` means the combined endpoint just returned that row
|
||||
and `/statuses/{sha}` keeps one row per POST, so a complete-but-empty history contradicts a write
|
||||
that demonstrably happened — and `page_statuses` accepts an empty page 1 as complete, which is what
|
||||
made the shape reachable. The cost lands where the replacement actually cost something: on an
|
||||
APPROVED PR, reconciliation finds the masked verdict and upgrades to the repair sentinel, so the
|
||||
recovery is "you are asked to re-post", not "it clears itself".
|
||||
|
||||
**Both `/statuses/{sha}` reads are PAGED** (ersatztv#763). The history is read twice — before the write
|
||||
for the high-water mark, after it for the race check — and `limit` clamps to `MAX_RESPONSE_ITEMS`
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -235,9 +235,18 @@ to every row it extracts since #643, and the walk whose counts gate the write di
|
||||
|
||||
**Not closed by this.** Two residuals, and the second is the one to read carefully.
|
||||
|
||||
1. The residual named in "What is NOT closed" item 1 applies unchanged to the head axis: a push
|
||||
landing between the final pre-write count and the POST is not seen, and by the #849 argument that
|
||||
leaves a permanent rather than transient forged green.
|
||||
1. The residual named in "What is NOT closed" item 1 applies to the head axis with the base axis's
|
||||
remedy DELIBERATELY WITHHELD: a push landing between the final pre-write count and the POST is
|
||||
not seen, and #849 re-counts only the RETARGET axis after the POST. The reason is not neglect — a
|
||||
push moves the head, so the status is no longer on the PR's head and cannot gate its merge, while
|
||||
a retarget changes the effective diff with the sha unchanged; re-checking pushes here would
|
||||
instead strand a sentinel on a sha that becomes the head again after a revert. Do not read the
|
||||
#849 argument as concurring that this axis needs the same treatment.
|
||||
|
||||
Worth flagging for whoever settles it: the wording above may overstate its own case, since the
|
||||
enumeration is COMPLETE before the final count is taken, so a push inside that window cannot have
|
||||
split the file list across heads. That is #803's text and settling it needs its own analysis;
|
||||
#849 did not attempt one.
|
||||
|
||||
2. **The walk's terminator is defeatable, so neither axis is closed outright** — pre-existing, found
|
||||
by cross-family review of #803 from the v1.27.1 source, and tracked as ersatztv#870 because fixing
|
||||
|
||||
@@ -145,7 +145,7 @@ classifications differ; otherwise the strictest applies and the Note names the e
|
||||
|
||||
| Site | Class | Note |
|
||||
|---|---|---|
|
||||
| `.gitea/workflows/review-verdict.yml` — status read → status POST | `UNSAFE-KNOWN` | The residual this whole class reduces to. Gitea's status API has no ETag, no If-Match and no expected-previous-state, so read and write cannot be made one operation. Narrowed rather than claimed closed: a monotonic **event-count** fence refuses to write if the PR timeline's `change_target_branch` OR `pull_push` count moved (`ci.verdict-write-retarget-fence`; counts are used because the branch *name* and the head *sha* are both ABA-vulnerable — the head axis added by #803), and a high-water-mark re-read repairs a status posted over a human verdict back to `pending` — after EVERY write since #849, not only an exemption `success`, because a generic `pending` masks a rejection just as well and was then re-derived green by the next run. Since #849 the write side is also fenced on the far end: the retarget count is re-taken AFTER the POST on the exemption path (closing the permanent forged green that record listed as residual 1), an exemption no high-water mark can cover is withheld rather than posted, and an unreadable combined-status read REPLACES the unknown state instead of leaving a possibly-forged green standing (`ci.verdict-unverified-write-sentinel`). The file states the residual window explicitly rather than asserting safety. |
|
||||
| `.gitea/workflows/review-verdict.yml` — status read → status POST | `UNSAFE-KNOWN` | The residual this whole class reduces to. Gitea's status API has no ETag, no If-Match and no expected-previous-state, so read and write cannot be made one operation. Narrowed rather than claimed closed: a monotonic **event-count** fence refuses to write if the PR timeline's `change_target_branch` OR `pull_push` count moved (`ci.verdict-write-retarget-fence`; counts are used because the branch *name* and the head *sha* are both ABA-vulnerable — the head axis added by #803), and a high-water-mark re-read repairs a status posted over a human verdict back to `pending` — after EVERY write since #849, not only an exemption `success`, because a generic `pending` masks a rejection just as well and was then re-derived green by the next run. Since #849 the write side is also fenced on the far end: the retarget count is re-taken AFTER the POST on the exemption path (closing the permanent forged green that record listed as residual 1), a write no high-water mark can cover becomes the sticky sentinel rather than a status a later run re-derives, and every path that cannot establish what the head carries — the combined read, the four page-2 completeness refusals, and an untrusted fence holding a derived `success` — REPLACES that unknown state instead of leaving a possibly-forged green standing (`ci.verdict-unverified-write-sentinel`). The post-POST re-count makes the retarget green TRANSIENT, not absent: it is live between its POST and the repair. The file states the residual window explicitly rather than asserting safety. |
|
||||
| `.gitea/workflows/review-verdict.yml` — base-ref checkout | `PINNED` | `ref: ${{ github.event.pull_request.base.sha }}` — a full sha from the fixed event payload, so the PR head cannot supply the workflow definition that judges it. |
|
||||
| `.gitea/workflows/review-verdict.yml` — changed-file enumeration | `UNSAFE-KNOWN` | Delegates to `scripts/pr-changed-files.sh` with the head sha and expected base, and therefore **inherits that row's residual, not a pin** — a cross-reference to another row's GRADE goes stale the moment that row is regraded, so this one names what it inherits. Accepted on better terms than the enumerator alone — this is the one caller that also runs the monotonic event-count fence (`ci.verdict-write-retarget-fence`), and since #803 that fence covers BOTH axes: `change_target_branch` for the base alias and `pull_push` for the HEAD alias described in the enumerator's row (`H1 -> H2 -> H1` during pagination). What remains is the residual the fence shares with the base axis — a mutation landing between the final pre-write count and the POST — not an unwatched axis, and since #849 the RETARGET half of it is caught by a post-POST re-count while the push half is deliberately not (a push moves the head, so the status no longer gates that PR). |
|
||||
| `.gitea/workflows/docker-build.yml` — CI toolchain image | `UNSAFE-KNOWN` | This file's own definition of `PINNED` names an image **digest**, and `ersatztv-ci:<short-sha>` is a mutable **tag**. A registry tag can be repointed after `ci-image-pin` verifies it and before a job pulls it, and a 7-hex short sha is additionally collision-prone. Accepted rather than fixed here because the exposure needs write access to our own LAN registry — i.e. an attacker already inside the trust boundary — and two controls bound it: jobs never consume `:latest`, and `pr-checks.yml`'s `ci-image-pin` fails the build if the tag drifts from the last commit touching `docker/ci/`. Consuming `image@sha256:…` is the real fix and is the natural companion to **#772**, which already covers the availability half of this tag's weakness. |
|
||||
|
||||
@@ -1355,6 +1355,14 @@ if "/statuses/" in url:
|
||||
seen = int(ctr.read_text()) if ctr.exists() else 0
|
||||
ctr.write_text(str(seen + 1))
|
||||
pages = [ordinary[:50], ordinary[50:], [dict(raced_row)] if seen > 0 else []]
|
||||
# SEEDED ROWS (ersatztv#849 round 2). The reconciliation may only clear the sentinel over a
|
||||
# history that CONTAINS it, which is the one shape the mode-driven fixtures above cannot
|
||||
# express: they describe a head as it was BEFORE this job ever wrote to it, and the sentinel
|
||||
# is by definition a row an EARLIER run already POSTed. Seeding is how a fixture says "this
|
||||
# head has been written to before", which is exactly the precondition `ex_unverified` states.
|
||||
extra = os.environ.get("STUB_HISTORY_EXTRA", "")
|
||||
if extra:
|
||||
rows = list(rows) + json.loads(extra)
|
||||
if order_faithful and not want_asc:
|
||||
rows = list(reversed(rows))
|
||||
if pages is None:
|
||||
@@ -1619,6 +1627,7 @@ def _run_classify(
|
||||
timeline_pages: int = 1,
|
||||
history_mode: str = "none",
|
||||
history_creator: str = "timothy",
|
||||
history_extra: list | None = None,
|
||||
midrun_creator: str = "timothy",
|
||||
pre_row: str = "",
|
||||
midrun_row: str = "",
|
||||
@@ -1664,6 +1673,7 @@ def _run_classify(
|
||||
env["STUB_STATUS_EMPTY_SHAPE"] = status_empty_shape
|
||||
env["STUB_HISTORY_MODE"] = history_mode
|
||||
env["STUB_HISTORY_CREATOR"] = history_creator
|
||||
env["STUB_HISTORY_EXTRA"] = json.dumps(history_extra) if history_extra else ""
|
||||
env["STUB_MIDRUN_CREATOR"] = midrun_creator
|
||||
env["STUB_PRE_ROW"] = pre_row
|
||||
env["STUB_MIDRUN_ROW"] = midrun_row
|
||||
@@ -1702,10 +1712,10 @@ def _run_classify(
|
||||
if mutate is not None:
|
||||
# DISARM A CLAUSE OF THE SHIPPED BODY, for the mutation proofs (ersatztv#849).
|
||||
#
|
||||
# THE MUTANT IS THE REAL PREDECESSOR, not a hand-written stand-in: every use below restores
|
||||
# the exact text this branch replaced, so a proof shows the fix — rather than showing that
|
||||
# some plausible-looking wrong version would fail. A hand-written mutant proves a test can go
|
||||
# red, which is not the same claim.
|
||||
# WHICH MUTANT EACH USE IS — a restored predecessor, a withdrawn draft, or a disarmed new
|
||||
# clause — is enumerated at the ersatztv#849 section header below. Two restore `origin/main`
|
||||
# verbatim; the rest disarm clauses that have no predecessor to restore, which is the precise
|
||||
# mutation for a NEW guard and is not the same claim as "this is what the code used to be".
|
||||
#
|
||||
# The count assertion is the binding. Without it a clause that has since been reworded or
|
||||
# moved substitutes ZERO times, the "mutant" is the unmutated body, and the proof asserts the
|
||||
@@ -1745,6 +1755,27 @@ def _run_classify(
|
||||
DOCS_ONLY = 'printf "docs/a.md\\ndocs/b.md\\n"\n'
|
||||
|
||||
|
||||
def _assert_withheld(posted, r, why):
|
||||
"""The gate refused to grant the exemption — which since ersatztv#849 means the head is MARKED,
|
||||
not left alone.
|
||||
|
||||
Every one of these tests asserted `posted is None`. That was right while "withhold" meant
|
||||
"write nothing", and it became a fail-open assertion when it stopped meaning that: declining to
|
||||
write protects a REAL verdict on the head and leaves a FORGED one, and this job's own red status
|
||||
is not a required check, so branch protection still sees whatever was already there.
|
||||
|
||||
Asserted positively — state AND description — because `pending` alone does not distinguish the
|
||||
sticky sentinel from the generic awaiting-verdict text a later run happily re-derives.
|
||||
"""
|
||||
assert posted is not None, (
|
||||
f"{why}: nothing was posted, so whatever {'{CONTEXT}'} this head already carries is standing "
|
||||
f"unread and unre-derived.\n{r.stdout[-900:]}"
|
||||
)
|
||||
assert posted["state"] == "pending" and posted["description"] == UNVERIFIED_DESC, (
|
||||
f"{why}: expected the unverified-write sentinel, got {posted}\n{r.stdout[-900:]}"
|
||||
)
|
||||
|
||||
|
||||
def test_a_FAILING_enumeration_withholds_the_exemption_even_when_stdout_looks_docs_only(tmp_path):
|
||||
"""The mutation that previously survived: ignore the exit status, trust stdout."""
|
||||
posted, r = _run_classify(tmp_path, "#!/usr/bin/env bash\n" + DOCS_ONLY + "exit 1\n")
|
||||
@@ -1942,7 +1973,7 @@ def test_DOCS_ONLY_anchors_the_markdown_extension(tmp_path):
|
||||
assert posted["state"] == "pending", "a .mdx file was accepted as docs-only"
|
||||
|
||||
|
||||
def test_a_transport_failure_under_jq_1_6_STILL_posts_nothing(tmp_path):
|
||||
def test_a_transport_failure_under_jq_1_6_STILL_refuses_to_classify(tmp_path):
|
||||
"""The ersatztv#647 fail-open, tested where it actually lives: jq 1.6.
|
||||
|
||||
The shell emptiness check exists because `jq -e` over EMPTY input exits 4 on jq >= 1.7 but **0 on
|
||||
@@ -3218,7 +3249,7 @@ def test_the_head_arm_DEFERS_to_the_trust_guard_when_the_second_count_fails(tmp_
|
||||
timeline_mode="trusted-then-unreadable",
|
||||
push_mode="stable:3",
|
||||
)
|
||||
assert posted is None, f"an exemption was granted on an untrusted count. Log:\n{r.stdout[-900:]}"
|
||||
_assert_withheld(posted, r, "test_the_head_arm_DEFERS_to_the_trust_guard_when_the_second_count_fails")
|
||||
assert "Could not establish a trusted retarget/push count" in r.stdout, (
|
||||
f"the untrusted re-count was not reported as such. Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
@@ -3356,10 +3387,7 @@ def test_an_EMPTY_FIRST_page_is_untrusted_WHICHEVER_empty_shape_it_is(tmp_path,
|
||||
timeline_mode="empty-first-page",
|
||||
timeline_terminator=terminator,
|
||||
)
|
||||
assert posted is None, (
|
||||
f"an exemption was granted from an empty FIRST page ({terminator}) — a zero count was "
|
||||
f"trusted from a response the walk cannot explain. Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
_assert_withheld(posted, r, "test_an_EMPTY_FIRST_page_is_untrusted_WHICHEVER_empty_shape_it_is")
|
||||
|
||||
|
||||
def test_a_timeline_row_with_NO_READABLE_TYPE_is_not_counted_as_nothing(tmp_path):
|
||||
@@ -3371,10 +3399,7 @@ def test_a_timeline_row_with_NO_READABLE_TYPE_is_not_counted_as_nothing(tmp_path
|
||||
IT extracts, which the walk gating the write did not have.
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), timeline_mode="untyped-rows")
|
||||
assert posted is None, (
|
||||
"an exemption was granted over a timeline page whose rows carry no readable `.type` — the "
|
||||
f"count was trusted from rows the walk cannot classify. Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
_assert_withheld(posted, r, "test_a_timeline_row_with_NO_READABLE_TYPE_is_not_counted_as_nothing")
|
||||
|
||||
|
||||
def test_the_head_fence_reports_the_OBSERVED_counts_in_its_notice(tmp_path):
|
||||
@@ -3431,10 +3456,7 @@ def test_an_UNTRUSTED_retarget_count_withholds_the_EXEMPTION(tmp_path, mode):
|
||||
"""A `success` that cannot be shown to describe the PR's current base must not be written. An
|
||||
absent required check blocks the merge, which is the safe direction."""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), timeline_mode=mode)
|
||||
assert posted is None, (
|
||||
"an exemption success was posted even though the retarget count could not be established "
|
||||
f"({mode}). Log:\n{r.stdout[-900:]}"
|
||||
)
|
||||
_assert_withheld(posted, r, "test_an_UNTRUSTED_retarget_count_withholds_the_EXEMPTION")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mode", ["unreadable", "transport-error"])
|
||||
@@ -3643,7 +3665,7 @@ def test_an_UNTRUSTED_count_withholds_the_exemption_BY_THAT_BRANCH(tmp_path):
|
||||
"""Round 2 test-gap: the existing untrusted-count test asserted only "posted nothing", which a
|
||||
crash also produces. Assert the discriminator and a clean exit."""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), timeline_mode="unreadable")
|
||||
assert posted is None
|
||||
_assert_withheld(posted, r, "test_an_UNTRUSTED_count_withholds_the_exemption_BY_THAT_BRANCH")
|
||||
assert r.returncode == 0, f"the job died rather than declining cleanly: {r.stderr[-800:]}"
|
||||
# The wording covers BOTH axes since ersatztv#803 — one walk certifies one trust flag, so an
|
||||
# unreadable page abandons the push count and the retarget count together.
|
||||
@@ -4327,10 +4349,7 @@ def test_a_terminator_on_PAGE_ONE_does_not_certify_a_zero_retarget_count(tmp_pat
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), timeline_mode="empty-first-page")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert posted is None, (
|
||||
"an exemption `success` was posted from a timeline whose FIRST page was already the "
|
||||
f"terminator, so no page of events was ever actually read: {posted}\n{r.stdout[-800:]}"
|
||||
)
|
||||
_assert_withheld(posted, r, "test_a_terminator_on_PAGE_ONE_does_not_certify_a_zero_retarget_count")
|
||||
assert "trusted=no" in r.stdout, (
|
||||
f"the exemption was withheld, but not because the count was untrusted:\n{r.stdout[-800:]}"
|
||||
)
|
||||
@@ -4354,10 +4373,7 @@ def test_a_SECOND_PAGE_of_statuses_refuses_to_conclude_that_no_verdict_exists(tm
|
||||
the list is longer than one page and the verdict may be beyond it.
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), status_mode="twopage")
|
||||
assert posted is None, (
|
||||
"an exemption was posted while the status list ran to a second page, so an existing verdict "
|
||||
f"beyond page 1 would have been silently overwritten: {posted}\n{r.stdout[-800:]}"
|
||||
)
|
||||
_assert_withheld(posted, r, "test_a_SECOND_PAGE_of_statuses_refuses_to_conclude_that_no_verdict_exists")
|
||||
assert "page 2" in (r.stdout + r.stderr).lower(), (
|
||||
f"nothing was posted, but not because of the page-2 completeness probe:\n{r.stdout[-800:]}"
|
||||
)
|
||||
@@ -4410,10 +4426,7 @@ def test_an_UNREADABLE_page_2_refuses_to_conclude_that_no_verdict_exists(tmp_pat
|
||||
that cannot be read justifies nothing.
|
||||
"""
|
||||
posted, r = _run_classify(tmp_path, _emitting("docs/a.md"), status_mode=mode)
|
||||
assert posted is None, (
|
||||
f"an exemption was posted despite {why}, so 'no verdict exists' was concluded without "
|
||||
f"evidence: {posted}\n{r.stdout[-800:]}"
|
||||
)
|
||||
_assert_withheld(posted, r, "test_an_UNREADABLE_page_2_refuses_to_conclude_that_no_verdict_exists")
|
||||
assert "page 2" in (r.stdout + r.stderr).lower(), (
|
||||
f"nothing was posted, but not because of the page-2 probe:\n{r.stdout[-800:]}"
|
||||
)
|
||||
@@ -4927,9 +4940,24 @@ def test_an_UNREADABLE_history_page_2_also_repairs_rather_than_leaving_green(tmp
|
||||
# --- ersatztv#849: post-write verification, the five routes ------------------------------------
|
||||
#
|
||||
# Each route left an exemption `success` — or a generic `pending` a later run re-derives into one —
|
||||
# standing over a human `failure`. The tests below pair a behavioural assertion with a MUTATION that
|
||||
# restores the exact predecessor text, so each proof shows the shipped clause is what produces the
|
||||
# outcome rather than showing that some plausible wrong version would fail.
|
||||
# standing over a human `failure`. Each behavioural assertion below is paired with a MUTATION that
|
||||
# disarms the shipped clause it names, so the proof shows THAT clause is what produces the outcome.
|
||||
#
|
||||
# BE PRECISE ABOUT WHAT THE MUTANTS ARE, because "restores the exact predecessor" is true of only
|
||||
# some of them and claiming it of all would be the overclaim this repo treats as its own defect:
|
||||
#
|
||||
# * `test_MUTATION_a_SUCCESS_only_post_write_gate_...` and
|
||||
# `test_MUTATION_restoring_the_default_operator_on_the_description_...` DO restore `origin/main`
|
||||
# text verbatim.
|
||||
# * `test_MUTATION_a_GENERIC_pending_...` restores the shape #742 attempted and WITHDREW, not
|
||||
# `main` — which had no downgrade at all.
|
||||
# * the `if false` mutants disarm clauses that have NO predecessor, because the blocks they gate
|
||||
# are new. Disarming the condition isolates the DECISION from the round-trip beside it, which
|
||||
# deleting the block would not; they are counterfactual mutants and are sound as such.
|
||||
#
|
||||
# The count assertion in `_run_classify(mutate=...)` is what keeps every one of them bound: a clause
|
||||
# that has since been reworded substitutes zero times and fails loudly rather than quietly measuring
|
||||
# the unmutated body.
|
||||
|
||||
|
||||
def test_a_verdict_racing_a_PENDING_write_is_repaired_to_the_repair_sentinel(tmp_path):
|
||||
@@ -5110,6 +5138,10 @@ def test_MUTATION_a_GENERIC_pending_for_an_unverifiable_write_is_re_derived_into
|
||||
status_creator=None,
|
||||
status_desc=f1["description"], # <-- the chain
|
||||
history_mode="stale-human-already-present",
|
||||
# Seeded on THIS arm only, and the asymmetry is the fixture being faithful rather than
|
||||
# convenient: the shipped run 1 POSTed the sentinel, so its row is in the per-POST history;
|
||||
# the mutant's run 1 POSTed a generic `pending`, so no sentinel row exists on that head.
|
||||
history_extra=[_sentinel_row()],
|
||||
)
|
||||
assert f2 is not None and f2["state"] == "pending" and f2["description"] == REPAIR_DESC, (
|
||||
"the shipped chain re-derived its own sentinel into an exemption over a buried verdict: "
|
||||
@@ -5117,6 +5149,24 @@ def test_MUTATION_a_GENERIC_pending_for_an_unverifiable_write_is_re_derived_into
|
||||
)
|
||||
|
||||
|
||||
def _sentinel_row(row_id=4000):
|
||||
"""The row an earlier run POSTed when it wrote the unverified sentinel.
|
||||
|
||||
A fixture that puts the sentinel on the COMBINED endpoint without putting it in the per-POST
|
||||
history describes a head that cannot exist: `/statuses/{sha}` returns one row per POST, so the
|
||||
sentinel the combined endpoint is showing must be in there. Seeding it is not decoration — the
|
||||
reconciliation now requires exactly this row as its witness, and the first version of these tests
|
||||
passed against the impossible shape.
|
||||
"""
|
||||
return {
|
||||
"id": row_id,
|
||||
"context": "review-verdict/h10",
|
||||
"status": "pending",
|
||||
"creator": None,
|
||||
"description": UNVERIFIED_DESC,
|
||||
}
|
||||
|
||||
|
||||
def test_the_unverified_sentinel_is_RECONCILED_AWAY_once_the_history_can_be_read(tmp_path):
|
||||
"""The bound on the stall, and the reason this is a second sentinel rather than the repair one.
|
||||
|
||||
@@ -5134,6 +5184,14 @@ def test_the_unverified_sentinel_is_RECONCILED_AWAY_once_the_history_can_be_read
|
||||
status_mode="existing:pending",
|
||||
status_creator=None,
|
||||
status_desc=UNVERIFIED_DESC,
|
||||
# A REAL history: the sentinel's own row, plus an unrelated one so "non-empty" is not what is
|
||||
# being tested. Without the sentinel row this fixture is the impossible shape and the test
|
||||
# passed against a defect — the reconciliation used to clear over an EMPTY history, which
|
||||
# cannot be true for a head whose combined endpoint is showing a row.
|
||||
history_extra=[
|
||||
{"id": 3900, "context": "ci/other", "status": "success", "creator": None, "description": "unrelated"},
|
||||
_sentinel_row(),
|
||||
],
|
||||
)
|
||||
assert posted is not None, f"nothing was posted: {r.stderr[-800:]}"
|
||||
assert posted["state"] == "success", (
|
||||
@@ -5162,6 +5220,7 @@ def test_the_reconciliation_UPGRADES_to_the_repair_sentinel_when_a_verdict_is_BU
|
||||
status_creator=None,
|
||||
status_desc=UNVERIFIED_DESC,
|
||||
history_mode="stale-human-already-present",
|
||||
history_extra=[_sentinel_row()],
|
||||
)
|
||||
assert posted is not None, f"nothing was posted: {r.stderr[-800:]}"
|
||||
assert posted["state"] == "pending" and posted["description"] == REPAIR_DESC, (
|
||||
@@ -5179,9 +5238,14 @@ def test_MUTATION_reconciling_on_an_UNREADABLE_history_re_exempts_a_head(tmp_pat
|
||||
pending. Treating it as "nothing buried" is the fail-open, and it is a tempting simplification
|
||||
because the happy path looks identical.
|
||||
|
||||
The mutant inverts the trust test. The fixture makes the reconciliation walk fail while a verdict
|
||||
IS present in the history, so the shipped code carries the sentinel forward and the mutant
|
||||
exempts the head over a buried verdict.
|
||||
The mutant disarms the trust test. BE EXACT ABOUT WHAT THE FIXTURE SHOWS, because an earlier
|
||||
version of this docstring claimed it "makes the reconciliation walk fail while a verdict IS
|
||||
present in the history" — `premark-page1-error` serves ordinary rows and no verdict, so that was
|
||||
a description of a different fixture. What is shown here is narrower and sufficient: on a walk
|
||||
that could not be read, the shipped code carries the sentinel forward and the mutant clears it
|
||||
and grants the exemption. That the cleared sentinel can be sitting on a real verdict is shown by
|
||||
`test_the_reconciliation_UPGRADES_to_the_repair_sentinel_when_a_verdict_is_BURIED`, which is the
|
||||
test that supplies one.
|
||||
"""
|
||||
posted, r = _run_classify(
|
||||
tmp_path / "fixed",
|
||||
@@ -5202,7 +5266,10 @@ def test_MUTATION_reconciling_on_an_UNREADABLE_history_re_exempts_a_head(tmp_pat
|
||||
status_creator=None,
|
||||
status_desc=UNVERIFIED_DESC,
|
||||
history_mode="premark-page1-error",
|
||||
mutate=('\n if [ "$ph_ok" != yes ]; then\n', "\n if false; then\n"),
|
||||
mutate=(
|
||||
'\n if [ "$ph_ok" != yes ] || [ "$witness" -eq 0 ]; then\n',
|
||||
"\n if false; then\n",
|
||||
),
|
||||
)
|
||||
assert mutant is not None and mutant["state"] == "success", (
|
||||
"the mutant did not re-exempt, so the trust test is not what holds the sentinel and the "
|
||||
@@ -5210,6 +5277,63 @@ def test_MUTATION_reconciling_on_an_UNREADABLE_history_re_exempts_a_head(tmp_pat
|
||||
)
|
||||
|
||||
|
||||
def test_an_IMPOSSIBLE_EMPTY_history_does_NOT_reconcile_the_sentinel_away(tmp_path):
|
||||
"""A complete-but-empty history is the one shape this read cannot legitimately return.
|
||||
|
||||
`ex_unverified=yes` means the COMBINED endpoint just returned the sentinel for this sha, and
|
||||
`/statuses/{sha}` keeps one row per POST — so the sentinel it is showing MUST be in the history.
|
||||
A complete walk that comes back empty therefore contradicts a write that demonstrably happened,
|
||||
exactly as the post-write check already argues about its own read.
|
||||
|
||||
It is reachable rather than theoretical: `page_statuses` deliberately accepts an empty page 1 as
|
||||
complete, because a head nothing has posted to genuinely has no statuses and the high-water mark
|
||||
needs that answer. Clearing on it let the run classify normally and exempt a head whose sentinel
|
||||
may have been sitting on a rejection.
|
||||
|
||||
The first version of the RECONCILED_AWAY test above used exactly this fixture, so the clear path
|
||||
was only ever asserted against the impossible shape.
|
||||
"""
|
||||
posted, r = _run_classify(
|
||||
tmp_path,
|
||||
_emitting("docs/a.md"),
|
||||
status_mode="existing:pending",
|
||||
status_creator=None,
|
||||
status_desc=UNVERIFIED_DESC,
|
||||
) # no history_extra: the walk completes over ZERO rows
|
||||
assert posted is not None, f"nothing was posted: {r.stderr[-800:]}"
|
||||
assert posted["state"] == "pending" and posted["description"] == UNVERIFIED_DESC, (
|
||||
"an impossible empty history reconciled the sentinel away, so the run exempted a head whose "
|
||||
f"write was never verified: {posted}\n{r.stdout[-900:]}"
|
||||
)
|
||||
assert "sentinel rows found=0" in (r.stdout + r.stderr), (
|
||||
f"the sentinel was carried forward, but not because the witness was missing:\n{r.stdout[-900:]}"
|
||||
)
|
||||
|
||||
|
||||
def test_MUTATION_dropping_the_reconciliation_WITNESS_clears_on_an_impossible_history(tmp_path):
|
||||
"""Disarming the witness conjunct alone, so the empty-history refusal is isolated.
|
||||
|
||||
`ph_ok` is `yes` on this fixture — the walk really does complete — so the trust half of the
|
||||
condition cannot be what refuses. Only the witness count can, and dropping it must produce the
|
||||
exemption.
|
||||
"""
|
||||
posted, r = _run_classify(
|
||||
tmp_path / "mutant",
|
||||
_emitting("docs/a.md"),
|
||||
status_mode="existing:pending",
|
||||
status_creator=None,
|
||||
status_desc=UNVERIFIED_DESC,
|
||||
mutate=(
|
||||
'[ "$ph_ok" != yes ] || [ "$witness" -eq 0 ]; then',
|
||||
'[ "$ph_ok" != yes ]; then',
|
||||
),
|
||||
)
|
||||
assert posted is not None and posted["state"] == "success", (
|
||||
"the mutant did not clear the sentinel, so the witness conjunct is not what refuses on an "
|
||||
f"empty history and the test above proves nothing about it: {posted}\n{r.stdout[-900:]}"
|
||||
)
|
||||
|
||||
|
||||
def test_a_MALFORMED_description_row_does_not_kill_the_post_write_count(tmp_path):
|
||||
"""Route 4, the twin of the malformed-`creator` row already covered above.
|
||||
|
||||
@@ -5317,6 +5441,16 @@ def test_positive_control_a_QUIET_timeline_after_the_POST_leaves_the_exemption_a
|
||||
assert len(seq) == 1 and seq[0]["state"] == "success", (
|
||||
f"a quiet timeline cost the PR its exemption: {seq}\n{r.stdout[-900:]}"
|
||||
)
|
||||
# THE SINGLE POST DOES NOT PROVE THE RECOUNT RAN — a job that skipped it entirely produces the
|
||||
# identical result, so the assertion above is satisfied by the very regression it is meant to
|
||||
# exclude. The stub counts REAL PAGES SERVED, one per walk at `STUB_TIMELINE_PAGES=1`, so three
|
||||
# is the exempt path: before classifying, at the pre-POST fence, and after the POST.
|
||||
walks = int((tmp_path / "timeline_reads.txt").read_text())
|
||||
assert walks == 3, (
|
||||
f"expected three timeline walks on the exemption path (before, pre-POST fence, post-POST "
|
||||
f"re-check); the stub served {walks}, so the post-POST re-check did not run and the "
|
||||
f"assertion above proves nothing about it"
|
||||
)
|
||||
|
||||
|
||||
def test_MUTATION_deleting_the_POST_POST_retarget_check_leaves_the_stale_green(tmp_path):
|
||||
@@ -5353,8 +5487,8 @@ def test_MUTATION_declining_to_replace_an_unreadable_combined_read_leaves_the_fo
|
||||
_emitting("docs/a.md"),
|
||||
status_mode="transport-error",
|
||||
mutate=(
|
||||
' if repair_status_to "$UNVERIFIED_DESC"; then',
|
||||
" if false; then",
|
||||
' if repair_status_to "$UNVERIFIED_DESC"; then',
|
||||
" if false; then",
|
||||
),
|
||||
)
|
||||
assert r.returncode != 0
|
||||
|
||||
Reference in New Issue
Block a user