fix(622): validate rename rows too; name the real blocker when only the verdict is pending
review-verdict/h10 Awaiting review verdict for 07e1e8c
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 12s
Review verdict / Set review-verdict status (pull_request) Successful in 10s
PR Gates / decisions lifecycle (pull_request) Successful in 21s
PR Gates / Docs update reminder (pull_request) Successful in 19s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m19s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m28s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m5s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 15m31s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 15m44s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
review-verdict/h10 Awaiting review verdict for 07e1e8c
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 12s
Review verdict / Set review-verdict status (pull_request) Successful in 10s
PR Gates / decisions lifecycle (pull_request) Successful in 21s
PR Gates / Docs update reminder (pull_request) Successful in 19s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 1m19s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 1m28s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m5s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Successful in 15m31s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 15m44s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Third BLOCKED verdict, third legitimate finding. The per-row guard validated the
DESTINATION only, so `{"filename":"docs/x.md","status":"renamed"}` with no
`previous_filename` passed while its source silently vanished — precisely the
path-hiding that collecting both sides exists to prevent. A rename row must now
carry a non-empty `previous_filename`.
Required for rename rows ONLY. Demanding it globally would reject every ordinary
modified/added row and make the gate refuse all exemptions — which every
"withholds the exemption" test would happily pass through, so that direction gets
its own positive control. Predicate checked against ten shapes before adopting;
mutation-verified in both directions (dropping the clause fails 2 tests, applying
it globally fails 3 including the controls).
Also fixes a wart this PR introduced. `review-verdict/h10` is itself folded into
the COMBINED status, so a PR awaiting its verdict reports combined 'pending' and
the hook's condition (a) reported it as a CI problem — sending a reader to build
logs when the missing thing is the review, and exiting before the H10 branch that
would have said so. The message now names the outstanding contexts, and says
plainly when the verdict is the only one left.
Scope boundary, stated in the record: real Gitea populates `previous_filename` on
renames and returns well-formed pages. Everything past this point defends against
shapes with no evidence of existing, so the guard's claim stays "any page we
cannot fully classify withholds the exemption" rather than growing to cover
unobserved responses.
Decisions-Edit: yes
This commit is contained in:
@@ -104,7 +104,7 @@ while [ "$page" -le 40 ]; do
|
||||
# (an empty array is still valid — that is a genuine end-of-pagination). This also rejects arrays
|
||||
# of scalars, which would otherwise make the `.filename` extraction below fail under `set -e`.
|
||||
if ! printf '%s' "$raw" \
|
||||
| jq -e 'type == "array" and (map(.filename) | all(type == "string" and length > 0))' \
|
||||
| jq -e 'type == "array" and all(.[]; (.filename | type == "string" and length > 0) and (if .status == "renamed" then (.previous_filename | type == "string" and length > 0) else true end))' \
|
||||
>/dev/null 2>&1; then
|
||||
files_complete=no; break
|
||||
fi
|
||||
@@ -158,7 +158,18 @@ if [ "$mwcs" != "true" ]; then
|
||||
case "$state" in
|
||||
success) : ;;
|
||||
"") decide ask "H6 merge gate: could not read CI status for PR #$pr ($sha). Verify CI is green before merging." ;;
|
||||
*) decide deny "H6 merge gate: BLOCKED — PR #$pr CI status is '$state', not 'success'. Wait for a green build (or pass merge_when_checks_succeed to let Gitea gate it) before merging." ;;
|
||||
*)
|
||||
# `review-verdict/h10` is itself one of the contexts folded into the COMBINED state, so a PR
|
||||
# awaiting its verdict reports combined 'pending' and would otherwise be reported as a CI
|
||||
# problem — sending the reader to look at build logs when the actual missing thing is the
|
||||
# review. Name the real blocker when the verdict is the only thing outstanding.
|
||||
vpending=$(gq "repos/$owner/$repo/commits/$sha/status?limit=100" \
|
||||
| jq -r '[.statuses[]? | select(.status == "pending" or .status == "failure")] | map(.context) | join(", ")' 2>/dev/null || true)
|
||||
if [ "$vpending" = "review-verdict/h10" ]; then
|
||||
decide deny "H6/H10 merge gate: BLOCKED — every CI check on PR #$pr is green; the only outstanding context is 'review-verdict/h10' on head ${sha:0:7}, i.e. this head has no review verdict yet. Review it and run: scripts/post-review-verdict.sh $pr MERGEABLE"
|
||||
fi
|
||||
decide deny "H6 merge gate: BLOCKED — PR #$pr CI status is '$state', not 'success' (outstanding: ${vpending:-unknown}). Wait for a green build (or pass merge_when_checks_succeed to let Gitea gate it) before merging."
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# --- SCHEDULED auto-merge: everything this hook proves is a SNAPSHOT (ersatztv#622). ----------
|
||||
|
||||
@@ -133,7 +133,7 @@ jobs:
|
||||
# down. Require every row to carry a non-empty string `filename`; an empty array stays
|
||||
# valid, since that is what a genuine end-of-pagination looks like.
|
||||
if ! printf '%s' "$raw" \
|
||||
| jq -e 'type == "array" and (map(.filename) | all(type == "string" and length > 0))' \
|
||||
| jq -e 'type == "array" and all(.[]; (.filename | type == "string" and length > 0) and (if .status == "renamed" then (.previous_filename | type == "string" and length > 0) else true end))' \
|
||||
>/dev/null 2>&1; then
|
||||
complete=no; break
|
||||
fi
|
||||
|
||||
@@ -113,12 +113,27 @@ described as one:
|
||||
point the guard exists to fail closed. An empty array stays valid, because that is what a genuine
|
||||
end-of-pagination looks like.
|
||||
|
||||
Rename rows carry one extra requirement: a row whose `status` is `renamed` must also carry a
|
||||
non-empty `previous_filename`, or the row validates while its SOURCE silently vanishes — which is
|
||||
exactly the path-hiding that collecting both sides exists to prevent. It is required *only* for
|
||||
rename rows; demanding it globally would reject every ordinary modified/added row and make the gate
|
||||
refuse all exemptions, a failure the "withholds the exemption" tests could not distinguish from
|
||||
working, so there is a positive control for that too.
|
||||
|
||||
This whole class lives only on the *failure* path, so every happy-path run looked correct and the
|
||||
first test suite was green throughout. It took two rounds to close: the first fix validated only the
|
||||
top-level type, which left `[{}]` as a working bypass. The tests therefore error and malform pages
|
||||
mid-pagination rather than only returning data, and include a positive control (an empty final page
|
||||
must still exempt) so that an over-strict guard — which would make every "withholds the exemption"
|
||||
test pass for the wrong reason — is also caught.
|
||||
mid-pagination rather than only returning data, and include positive controls (an empty final page
|
||||
must still exempt; an ordinary row without `previous_filename` must still be valid) so that an
|
||||
over-strict guard — which would make every "withholds the exemption" test pass for the wrong
|
||||
reason — is also caught.
|
||||
|
||||
**Where this hardening stops.** Three review rounds closed: single-page truncation, renames,
|
||||
failure-path pages, top-level-only validation, and malformed rename rows. Real Gitea populates
|
||||
`previous_filename` on renames and returns well-formed pages; everything past this point defends
|
||||
against response shapes with no evidence of existing. The guard's contract is now "any page we
|
||||
cannot fully classify withholds the exemption", and it is worth keeping that claim narrow and true
|
||||
rather than extending it to shapes nobody has observed.
|
||||
|
||||
2b. **Status reads use the combined endpoint.** `GET /statuses/{sha}` returns one row per status *post*
|
||||
(not per context) and pages at 50, so a head with a few CI reruns can push an earlier verdict off the
|
||||
|
||||
@@ -195,6 +195,37 @@ def test_empty_final_page_is_a_legitimate_end_of_pagination(hook):
|
||||
assert hook.exempted() is True
|
||||
|
||||
|
||||
def test_malformed_rename_row_withholds_the_exemption(hook):
|
||||
"""A row marked `renamed` with NO `previous_filename` hides its source path.
|
||||
|
||||
The destination alone is `docs/...`, so validating only `filename` would accept the row and
|
||||
silently drop whatever it was renamed FROM — defeating the reason both sides are collected.
|
||||
Real Gitea always populates it (verified by constructing a rename), so this is the
|
||||
malformed-2xx class the guard claims to fail closed on; the claim should match the behaviour.
|
||||
"""
|
||||
hook.set_pages(_rows([f"docs/f{i}.md" for i in range(50)]),
|
||||
[{"filename": "docs/moved.md", "status": "renamed"}])
|
||||
assert hook.exempted() is False
|
||||
|
||||
|
||||
def test_rename_row_with_empty_previous_filename_withholds_the_exemption(hook):
|
||||
hook.set_pages(_rows([f"docs/f{i}.md" for i in range(50)]),
|
||||
[{"filename": "docs/moved.md", "status": "renamed", "previous_filename": ""}])
|
||||
assert hook.exempted() is False
|
||||
|
||||
|
||||
def test_ordinary_row_without_previous_filename_is_still_valid(hook):
|
||||
"""Positive control: `previous_filename` must be required ONLY for rename rows.
|
||||
|
||||
Requiring it globally would reject every normal modified/added row and make the gate refuse
|
||||
all exemptions — which the 'withholds' tests above could not distinguish from working.
|
||||
"""
|
||||
hook.set_pages([{"filename": "docs/a.md", "status": "modified"},
|
||||
{"filename": "docs/b.md", "status": "added"},
|
||||
{"filename": "docs/c.md"}])
|
||||
assert hook.exempted() is True
|
||||
|
||||
|
||||
def test_exceeding_max_pages_withholds_the_exemption(hook):
|
||||
"""41 full pages: enumeration cannot be proven exhaustive, so no exemption."""
|
||||
hook.set_pages(*[_rows([f"docs/p{p}f{i}.md" for i in range(50)]) for p in range(41)])
|
||||
|
||||
Reference in New Issue
Block a user