fix(778): round 2 — recursive population, and grade down five more overclaims
Build ErsatzTV Image / Delimiter ban (release path) (pull_request) Successful in 22s
PR Gates / Fix proofs (Proves trailers) (pull_request) Successful in 14s
PR Gates / Docs update reminder (pull_request) Successful in 23s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 9s
PR Gates / decisions lifecycle (pull_request) Successful in 24s
review-verdict/h10 Awaiting review verdict for 84b4c11
Review verdict / Set review-verdict status (pull_request_target) Successful in 22s
PR Gates / Script tests (pytest) (pull_request) Successful in 4m10s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 9m22s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Canceled after 5m4s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Canceled after 0s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Canceled after 0s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Canceled after 0s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Canceled after 0s
Build ErsatzTV Image / Delimiter ban (release path) (pull_request) Successful in 22s
PR Gates / Fix proofs (Proves trailers) (pull_request) Successful in 14s
PR Gates / Docs update reminder (pull_request) Successful in 23s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 9s
PR Gates / decisions lifecycle (pull_request) Successful in 24s
review-verdict/h10 Awaiting review verdict for 84b4c11
Review verdict / Set review-verdict status (pull_request_target) Successful in 22s
PR Gates / Script tests (pytest) (pull_request) Successful in 4m10s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 9m22s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Canceled after 5m4s
Build ErsatzTV Image / Functional E2E (curl + UI contracts) (pull_request) Canceled after 0s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Canceled after 0s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Canceled after 0s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Canceled after 0s
Second cold review: no Blockers, 4 High / 1 Medium / 2 Low. All accepted. POPULATION, WRONG A SECOND TIME. Round 1 removed a content filter that had omitted `git fetch`. Round 2 found the replacement traversal used non-recursive `Path.glob`, so four nested files were still outside it — including scripts/scripted-schedules/entrypoint.py, which calls get_context() against a live ErsatzTV server and then drives define_content/reset_playout/build_playout off the result. Now rglob, with scripts/tests/ as the single stated DIRECTORY-level exclusion (a scope choice, reviewable in one line; not a predicate over content). Population 55 -> 59, rows 63 -> 68. The generalisation is in the record, because the deliverable made the same mistake twice: the scope may be hand-written, but anything narrowing the POPULATION has to be executed and its output compared against the filesystem — the members it drops are invisible by construction. That is the #774 rule turned on the artifact meant to enforce it. FIVE MORE OVERCLAIMS GRADED DOWN. Both merge-consent head/base rows (the hook returns `allow` and a separate call merges, so the window is small, not absent — "no async window" was simply false); the release smoke pull and the ci-image verify (the concurrency group is PER-REF, so a branch build and a tag build of one commit can publish the same :<short-sha>); and the workflow base-fetch rows, which are not advisory — the merge hook reads the COMBINED status, so any red context blocks the auto-grant. Also fixed a stale cross-reference where the enumeration row still said it "inherits that row's pins" from a row graded down in the same commit. Four PINNED rows survive out of 68. That ratio is the honest finding. CIRCULAR JUSTIFICATION REMOVED. The scheduled-merge row said its residual was "closed one layer down" by the very branch protection an admin may have removed. It is not closed, it is BOUNDED by a trust assumption, and the row now says so. Low: jq's `//` fires on `false` as well as null, so `status_check_contexts: false` was defaulted to [] and produced a confident deny from a shape never understood — absent and null are now defaulted explicitly, everything else is "unknown". And the title sentence claimed "every executable in this repo" while the guard covers four directories; both it and the docs/README entry now say what is actually enforced. refs #778 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -380,8 +380,13 @@ else
|
||||
# `null` and `[]` are legitimate (an unprotected-in-practice branch) and answer "no", not
|
||||
# "unknown": absent IS the finding here, not a read failure. The word is then matched
|
||||
# exhaustively, because "" is not a third synonym for "no".
|
||||
# `// []` defaults on FALSE as well as on null, because jq's alternative operator fires for both.
|
||||
# So `"status_check_contexts": false` — a malformed shape — became `[]` and answered "no", i.e. a
|
||||
# confident DENY derived from a payload that was never understood. Absent and null are defaulted
|
||||
# explicitly; every other non-array is "unknown".
|
||||
guarded=$(printf '%s' "$bp" \
|
||||
| jq -r 'def ctxs: (.status_check_contexts // []);
|
||||
| jq -r 'def ctxs: if (has("status_check_contexts") | not) or .status_check_contexts == null
|
||||
then [] else .status_check_contexts end;
|
||||
if (ctxs | type) != "array" or any(ctxs[]; type != "string") then "unknown"
|
||||
elif (.enable_status_check == true) and any(ctxs[]; . == "review-verdict/h10") then "yes"
|
||||
else "no" end' 2>/dev/null || true)
|
||||
|
||||
+4
-2
@@ -113,8 +113,10 @@ bounds, what's mined per issue): `docs/handoffs/chicorytv-issue-queue.md` → "K
|
||||
and an audit of which configured hooks/MCP servers/LSPs are actually invoked. Read it before
|
||||
proposing a new guard or CI check — §4 is the detector menu, and it argues against enumerating
|
||||
cases one incident at a time.
|
||||
- **`docs/remote-state-inventory.md`** — every executable that reads live remote state and acts on
|
||||
that read, classified `PINNED` / `CAS` / `UNSAFE-KNOWN` / `N/A` with the window and what bounds it.
|
||||
- **`docs/remote-state-inventory.md`** — every executable **in `scripts/`, `.claude/hooks/`,
|
||||
`.husky/` and `.gitea/workflows/`** that reads live remote state and acts on that read, classified
|
||||
`PINNED` / `CAS` / `UNSAFE-KNOWN` / `N/A` with the window and what bounds it. Code outside those
|
||||
four directories is out of scope and the doc says so.
|
||||
The population is derived from the filesystem and compared for set equality by
|
||||
`scripts/tests/test_remote_state_inventory.py`, so a new script that talks to a remote service
|
||||
cannot ship unclassified. Read it with `process.check-and-use-pins-a-version`; it is that record's
|
||||
|
||||
@@ -76,6 +76,28 @@ over — `MARKED_JOBS` in `test_ci_dropped_step_guard.py` is a hand-written mirr
|
||||
required contexts, annotated with a date. A dated comment is a claim about the past. Two independent
|
||||
guards now depend on that configuration; one of them checks it.
|
||||
|
||||
**The deliverable's own population was wrong twice, and that is the most transferable part of this
|
||||
record.** The inventory is the detector, so its population *is* the guard. Round one derived it by
|
||||
filtering the scope on an outbound-network token list — which omitted `git fetch`, this repo's
|
||||
commonest remote read, so a hook that fetches `origin/main` and derives a push decision was
|
||||
invisible. Round two dropped the filter but used non-recursive `glob`, so four nested files stayed
|
||||
out, one of them calling a live ErsatzTV API and acting on the reply. Both rounds shipped with an
|
||||
argument for why the traversal was sufficient, and both arguments were wrong in the same way: a
|
||||
completeness claim resting on a traversal nobody had compared against the filesystem. The
|
||||
generalisation is not "use rglob"; it is that **the scope may be hand-written and reviewable, but
|
||||
anything narrowing the population must be executed and its output eyeballed against `ls`**, because
|
||||
the members it drops are invisible by construction — which is `testing.guard-derives-population-from-source`
|
||||
turned on the very artifact meant to enforce it.
|
||||
|
||||
**Grade down before you argue.** Cold review demoted six rows across two rounds — the scheduled-merge
|
||||
path, both merge-consent head/base reads, the file enumerator and every registry-tag row — and in
|
||||
each case the row asserted a property the code did not have while the code beneath it was fine. Four
|
||||
`PINNED` rows survive out of 68. That ratio is the honest finding about this class in a tooling
|
||||
codebase: almost nothing that talks to a remote service is genuinely pinned, most of it is bounded by
|
||||
an argument, and the argument is what has to be written down. A row that overstates is worse than a
|
||||
row that admits a gap, because this repo's own record is that a guard described as sound stops being
|
||||
re-examined.
|
||||
|
||||
**What this record does not claim.** The inventory grades *files*, so it cannot see an existing file
|
||||
growing a second unpinned read — the sites-in-code limit tracked in #777. And nothing verifies that a
|
||||
row marked `PINNED` is telling the truth. Both residues are stated in
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
# Remote-state inventory (ersatztv#778)
|
||||
|
||||
Every executable in this repo that reads live remote state and later acts on that read, and whether
|
||||
the read is bound to something that cannot change underneath it.
|
||||
Every executable **in the four scoped directories** (see limit 3) that reads live remote state and
|
||||
later acts on that read, and whether the read is bound to something that cannot change underneath it.
|
||||
|
||||
The scope qualifier is load-bearing, not throat-clearing: this file twice claimed to cover "every
|
||||
executable in this repo" while its own derivation missed real remote readers, so the title now says
|
||||
what the guard actually enforces. C#/TypeScript guards, `web/`, and anything outside those four
|
||||
directories are **not** covered — stated in limit 2.
|
||||
|
||||
`scripts/tests/test_remote_state_inventory.py` derives the population from the filesystem and
|
||||
asserts **set equality** against the `Site` column, so a new script that talks to a remote service
|
||||
@@ -39,9 +44,9 @@ classifications differ; otherwise the strictest applies and the Note names the e
|
||||
|
||||
| Site | Class | Note |
|
||||
|---|---|---|
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — head-sha reads (CI status, H10 status, verdict comments) | `PINNED` | Every comparison uses the **full** 40-char `.head.sha`; `${sha:0:7}` appears only in human-readable strings. On the immediate-merge path there is no async window — the merge happens in the tool call this hook is gating. |
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — scheduled auto-merge (`merge_when_checks_succeed`) | `UNSAFE-KNOWN` | **Preflight, not a pin** — graded down by cold review, which was right: the hook's own comment concedes the branch-protection read pins nothing, so calling it `PINNED` contradicted this file's definition. What the hook proves is a snapshot; Gitea merges later; and since #778 it also verifies that `review-verdict/h10` is a required check (404/absent → deny, unreadable → ask) instead of asserting it. That converts an unobserved assumption into an observed precondition and detects drift, but an admin can still weaken the protection *after* the read. Accepted because the residual is closed one layer down rather than here: the required check is enforced server-side per-sha at merge time (#622), so a commit pushed after scheduling cannot inherit the verdict regardless of what this hook concluded. A PreToolUse hook cannot add `head_commit_id` to the merge call, so it can never convert its own grant into a CAS — it can only refuse, which is what it now does. |
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — base-retarget detection | `PINNED` | `recorded_base` parsed from the H10 status description is compared against the PR's live `.base.ref` (#632). Deliberately compares the base **ref**, not `base.sha` — the tip moves on every unrelated merge, and comparing it would deadlock every open PR. |
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — head-sha reads (CI status, H10 status, verdict comments) | `UNSAFE-KNOWN` | Every comparison uses the **full** 40-char `.head.sha` (`${sha:0:7}` appears only in human-readable strings), which is the right identifier — but the hook returns `allow` and the merge is executed afterwards by a separate call, so the window is small rather than absent. "No async window" was the second overclaim cold review removed from this file. The merge API accepts an optional `head_commit_id`, which would make the call a true CAS; a PreToolUse hook cannot ADD that argument, only refuse without it, and requiring it changes every merge call's shape — tracked as follow-up rather than smuggled in here. Accepted meanwhile because the window is one tool call wide with no scheduler in it, and the server-side per-sha required check still refuses an unreviewed head. |
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — scheduled auto-merge (`merge_when_checks_succeed`) | `UNSAFE-KNOWN` | **Preflight, not a pin** — graded down by cold review, which was right: the hook's own comment concedes the branch-protection read pins nothing, so calling it `PINNED` contradicted this file's definition. What the hook proves is a snapshot; Gitea merges later; and since #778 it also verifies that `review-verdict/h10` is a required check (404/absent → deny, unreadable → ask) instead of asserting it. That converts an unobserved assumption into an observed precondition and detects drift, but an admin can still weaken the protection *after* the read. Accepted, and the earlier wording here was **circular** — it said the residual was "closed one layer down" by the very branch protection an admin may have removed. It is not closed; it is BOUNDED, and the bound is a trust assumption that should be stated rather than dressed as a mechanism: everything on this path assumes repo-admin branch-protection config is not hostile. If protection is present at preflight and removed afterwards, an unreviewed head can merge, and nothing in this repo would detect it. What the check does buy is that the far commoner case — protection already weakened when the merge is attempted — stops being silent. A PreToolUse hook cannot add `head_commit_id` to the merge call, so it can never convert its own grant into a CAS — it can only refuse, which is what it now does. |
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — base-retarget detection | `UNSAFE-KNOWN` | `recorded_base` parsed from the H10 status description is compared against the PR's live `.base.ref` (#632), and it deliberately compares the base **ref** rather than `base.sha` — the tip moves on every unrelated merge, so comparing it would deadlock every open PR. The residual is the same ABA the enumerator has: a name can be retargeted away and back, and the comparison cannot see it. Accepted because the alternative that CAN see it is the monotonic event count, which lives in the workflow that writes the enforced status rather than in this advisory hook. |
|
||||
| `.claude/hooks/pretooluse-merge-consent.sh` — `## Done-when` issue-body read | `UNSAFE-KNOWN` | The issue body carries an `updated_at` that is not used, so a box unticked between the read and the merge is invisible. Accepted: the only actor who can edit the issue is the one requesting the merge, so this is a self-inflicted race with no adversary and no silent-failure mode. |
|
||||
| `.claude/hooks/prepush-donewhen.sh` — `## Done-when` issue-body read | `UNSAFE-KNOWN` | No pin, but the hook's exit code gates the push synchronously — git blocks on this process. Blast radius is near zero regardless: `main` carries `enable_push: false` and `block_admin_merge_override: true`, so the direct push this hook exists to block is refused server-side for every account (#743). This is belt-and-braces over a path the server already refuses. |
|
||||
| `.claude/hooks/pretooluse-nav-guard.sh` | `N/A` | Reads only the proposed tool call's own parameters and decides synchronously; the `curl` mentions in the file are prose, not executed lines. |
|
||||
@@ -103,6 +108,10 @@ classifications differ; otherwise the strictest applies and the Note names the e
|
||||
| `scripts/ci-step-ran.sh` | `N/A` | Reads no live remote state — reads runner-supplied env vars and local marker files it wrote itself. |
|
||||
| `scripts/set-provider.sh` | `N/A` | Reads no live remote state — sets local `dotnet user-secrets` values. |
|
||||
| `scripts/__init__.py` | `N/A` | Empty package marker — executes nothing. |
|
||||
| `scripts/scripted-schedules/entrypoint.py` — `ScriptedScheduleApi.get_context(build_id)`, then `define_content` / `reset_playout` / `build_playout` against the same live server | `UNSAFE-KNOWN` | A genuine read-then-act over live ErsatzTV state, and the row cold review found missing when the population was still non-recursive. The context is fetched, handed to user-supplied script functions that mutate the playout, and re-fetched after a reset with nothing pinning either read — a concurrent build or edit between them is invisible. Accepted because it runs inside a single scripted-schedule build the server itself serialises per playout, and because the API exposes no version or ETag on the context to compare against; the honest bound is that the blast radius is one playout's content, reversible by rebuilding. |
|
||||
| `scripts/macOS/bundle.sh` | `N/A` | Reads no live remote state — moves files and creates symlinks in a local app bundle. |
|
||||
| `scripts/macOS/sign.sh` | `N/A` | `codesign --timestamp` contacts Apple's timestamp server, but resolution and use are one step with no earlier check whose answer is later trusted — the same boundary as limit 1. |
|
||||
| `scripts/macOS/sign-dmg.sh` | `N/A` | Same shape as `sign.sh` — a timestamped `codesign` over a local DMG, no check-then-act over remote state. |
|
||||
|
||||
### Workflows
|
||||
|
||||
@@ -110,13 +119,14 @@ classifications differ; otherwise the strictest applies and the Note names the e
|
||||
|---|---|---|
|
||||
| `.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 twice rather than claimed closed: a monotonic `change_target_branch` **event-count** fence refuses to write if the count moved (`ci.verdict-write-retarget-fence`; the count is used because the branch *name* is ABA-vulnerable), and a high-water-mark re-read repairs a `success` posted over a human verdict back to `pending`. 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 | `PINNED` | Delegates to `scripts/pr-changed-files.sh` with the head sha and expected base; inherits that row's pins. |
|
||||
| `.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** — this row said "inherits that row's pins" while the row it points at was being graded down, which is exactly the stale-cross-reference a multi-round edit produces. Accepted on better terms than the enumerator alone, though: this is the one caller that also runs the monotonic `change_target_branch` event-count fence (`ci.verdict-write-retarget-fence`), which is precisely the control that catches the ABA the enumerator cannot see. |
|
||||
| `.gitea/workflows/docker-build.yml` — CI toolchain image | `UNSAFE-KNOWN` | Graded down by cold review, correctly: 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. |
|
||||
| `.gitea/workflows/docker-build.yml` — release smoke pull | `PINNED` | The one registry row that genuinely qualifies, and for a reason the tag itself does not supply: it pulls `${IMAGE}:${SMOKE_SHORT_SHA}` — the tag *this same job* pushed moments earlier, inside one `concurrency` group, so no other run can be repointing it in the window. |
|
||||
| `.gitea/workflows/docker-build.yml` — `api-docs` / `format` base fetch | `N/A` | Fetches the live base tip to diff generated artifacts. Advisory, non-required contexts; re-fetched fresh on every trigger with no state carried across runs. |
|
||||
| `.gitea/workflows/ci-image.yml` — verify the pushed image | `PINNED` | Pulls back the `:<sha>` tag it pushed in the immediately preceding step of the same `concurrency`-serialized run — same argument as the release smoke pull, and the same caveat that the tag is immutable by convention, not by the registry. |
|
||||
| `.gitea/workflows/docker-build.yml` — release smoke pull | `UNSAFE-KNOWN` | Pulls `${IMAGE}:${SMOKE_SHORT_SHA}`, the tag this same job pushed moments earlier. The first draft called that `PINNED` on the strength of the job's `concurrency` group; cold review showed the group is **per-ref**, so a branch build and a tag build of the same commit sit in DIFFERENT groups and can publish the same `:<short-sha>` — the smoke step can therefore pull the other run's image. Accepted rather than fixed here because the fix is the same one-line change as the row above (pull `image@sha256:…`, propagated from the push step) and belongs with it; until then no registry row in this file claims to be pinned. |
|
||||
| `.gitea/workflows/docker-build.yml` — `api-docs` / `format` base fetch | `UNSAFE-KNOWN` | Fetches the live base tip to diff generated artifacts, with nothing pinning it. Graded up from `N/A` by cold review, which was right that "advisory" was too quick: these are not branch-protection-required contexts, but the merge-consent hook reads Gitea's **combined** status, and a combined state that is not `success` blocks the auto-grant — so a wrong answer here does participate in merge consent. Accepted because the failure direction is benign: a base that advanced mid-job makes a generated artifact look stale and FAILS the job, costing a re-run, rather than passing something it should not. |
|
||||
| `.gitea/workflows/ci-image.yml` — verify the pushed image | `UNSAFE-KNOWN` | Pulls back the `:<sha>` tag it pushed in the immediately preceding step. Same demotion and same reason as the two rows above: a registry tag is not a digest, and anything able to write to the registry can repoint it between the push and the verify, which would make the verification confirm an image other than the one built. Accepted on the same terms — the exposure requires registry write access, i.e. an actor already inside the trust boundary — and the same fix applies. |
|
||||
| `.gitea/workflows/pr-checks.yml` — `prove-fix` | `PINNED` | `base`/`head` are full shas from the event payload, immune to later PR mutation. |
|
||||
| `.gitea/workflows/pr-checks.yml` — `ci-image-pin`, `docs-reminder`, `decisions-guard` | `N/A` | Local-tree comparisons or advisory base fetches; none authorize a merge or a write. |
|
||||
| `.gitea/workflows/pr-checks.yml` — `ci-image-pin` | `N/A` | A purely local comparison — `git log` over the checked-out tree against a literal in `docker-build.yml`. It never queries the registry, which is exactly why it cannot bound the retagging the image rows above describe. |
|
||||
| `.gitea/workflows/pr-checks.yml` — `docs-reminder` / `decisions-guard` base fetch | `UNSAFE-KNOWN` | Both fetch the live base tip and diff against it, unpinned. `docs-reminder` is explicitly non-blocking; `decisions-guard` can fail its job and therefore reaches the combined status the merge hook reads. Accepted on the same grounds as the `api-docs`/`format` row: a base that moved mid-job produces a spurious FAILURE and a re-run, never a spurious pass, and both re-fetch fresh on every trigger with no state carried between runs. |
|
||||
| `.gitea/workflows/renovate.yml` — `renovate/renovate:43` | `N/A` | Out of this class, in scope for a different one — see the limits below. |
|
||||
| `.gitea/workflows/dependency-scan.yml` — NuGet advisory query | `N/A` | `dotnet list package --vulnerable` queries a live advisory database and fails the job on the report marker in the same step, so there is no check-then-act split. Worth one line anyway: a green here means "no advisories **as of this run**", which is a dated claim about mutable remote data rather than a property of the tree — which is why the scan runs on a weekly schedule instead of only on PRs. |
|
||||
|
||||
|
||||
@@ -86,6 +86,10 @@ if "/branch_protections/" in url:
|
||||
# string is substring search, so the naive membership test answers "yes" here.
|
||||
respond('{"enable_status_check": true,'
|
||||
' "status_check_contexts": "prefix-review-verdict/h10-suffix"}')
|
||||
if mode == "FALSE-CONTEXTS":
|
||||
# jq's `//` alternative fires on FALSE as well as null, so `// []` silently turned this
|
||||
# malformed shape into an empty list and produced a confident deny.
|
||||
respond('{"enable_status_check": true, "status_check_contexts": false}')
|
||||
if mode == "NON-STRING-MEMBER":
|
||||
respond('{"enable_status_check": true, "status_check_contexts": [7, "review-verdict/h10"]}')
|
||||
if mode == "EMPTY-CONTEXTS":
|
||||
@@ -252,6 +256,15 @@ def test_an_empty_or_null_contexts_list_DENIES_rather_than_asking(hook, shape):
|
||||
f"{shape} was treated as unreadable rather than as a confirmed absent required check")
|
||||
|
||||
|
||||
def test_a_FALSE_contexts_value_asks_rather_than_denying(hook):
|
||||
"""jq's `//` alternative fires on `false`, not only on null, so `// []` mapped this malformed
|
||||
payload to an empty list and answered "no" — a confident deny derived from a shape that was
|
||||
never understood. Absent and null are defaulted explicitly; everything else is unknown."""
|
||||
hook.set_branch_protection("FALSE-CONTEXTS")
|
||||
reason = hook.reason()
|
||||
assert "ask" in reason, "a false contexts value was defaulted to [] and produced a deny"
|
||||
|
||||
|
||||
def test_a_non_string_MEMBER_inside_the_array_asks(hook):
|
||||
"""`[7, "review-verdict/h10"]` contains the context, but the payload is not the shape this
|
||||
guard knows how to reason about. Answering "yes" would mean trusting a structure we cannot
|
||||
@@ -323,10 +336,15 @@ def test_an_UNREADABLE_branch_protection_asks_rather_than_denying_or_passing(hoo
|
||||
|
||||
|
||||
def test_an_IMMEDIATE_merge_is_not_subjected_to_this_check(hook):
|
||||
"""Scope, deliberately narrow. Without `merge_when_checks_succeed` there is no async window:
|
||||
the merge happens now, against the head just verified. The required check is what protects the
|
||||
SCHEDULED path specifically, so denying an immediate merge over branch-protection config would
|
||||
block a safe operation and invite the guard being switched off wholesale."""
|
||||
"""Scope, deliberately narrow — and stated without the overclaim cold review removed.
|
||||
|
||||
An immediate merge is not window-FREE: the hook returns `allow` and a separate call performs the
|
||||
merge, so a push can still land in between. What it lacks is a SCHEDULER — nothing waits on
|
||||
pending checks, so the gap is one tool call rather than however long CI takes. The required
|
||||
branch-protection check is what protects the scheduled path specifically, so extending this deny
|
||||
to immediate merges would block a materially safer operation and invite the whole guard being
|
||||
switched off. The residual on this path is carried in docs/remote-state-inventory.md.
|
||||
"""
|
||||
hook.set_branch_protection("MISSING-CONTEXT")
|
||||
reason = hook.reason(scheduled=False)
|
||||
assert "NOT a required status check" not in reason, (
|
||||
|
||||
@@ -15,11 +15,20 @@ The split is deliberate and mirrors `test_guard_inventory.py`:
|
||||
* whether a `PINNED` row is TELLING THE TRUTH is not checked here and cannot be. That stays with
|
||||
review, and the inventory's prose is what review reads.
|
||||
|
||||
SCOPE vs POPULATION, per `testing.guard-derives-population-from-source`: the scope (which
|
||||
directories, and the outbound-network token set) is a hand-written policy choice. The population
|
||||
inside that scope is derived every run. The token filter deliberately OVER-includes — a file
|
||||
mentioning `curl` only in a comment still needs a row — because over-inclusion costs one row and
|
||||
under-inclusion costs a blind spot.
|
||||
SCOPE vs POPULATION, per `testing.guard-derives-population-from-source`: the SCOPE — four
|
||||
directories, two file extensions, and one excluded subdirectory — is a hand-written policy choice
|
||||
and is reviewable as one. The POPULATION inside that scope is derived on every run, RECURSIVELY,
|
||||
with no content predicate at all: a file that reads no remote state earns an explicit `N/A` row
|
||||
rather than staying out.
|
||||
|
||||
That wording is the third version, and the history is the point. The first filtered the scope by an
|
||||
outbound-network token list, which omitted `git fetch` — this repo's commonest remote read — so a
|
||||
hook that fetches `origin/main` and derives a push decision was invisible. The second dropped the
|
||||
filter but used non-recursive `glob`, so four nested files were invisible, including one that calls
|
||||
a live ErsatzTV API and acts on the reply. Both were the same error at different depths: a
|
||||
completeness claim resting on a traversal nobody had compared against the filesystem. Hence the
|
||||
anti-vacuity floor below, and hence the scope being stated as directories rather than as a
|
||||
predicate over content.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -55,6 +64,19 @@ SCOPE = (
|
||||
(REPO_ROOT / ".gitea" / "workflows", ("*.yml",)),
|
||||
)
|
||||
|
||||
# RECURSIVE. `Path.glob` is not, and the second cold review found the consequence: four nested files
|
||||
# were outside the population, one of them `scripts/scripted-schedules/entrypoint.py`, which calls
|
||||
# `get_context` against a live ErsatzTV server and then acts on the result. That is the third time
|
||||
# this population has been found incomplete, each time by a different mechanism — first a content
|
||||
# filter that omitted `git fetch`, then a non-recursive glob. Both were the same error: a claim of
|
||||
# completeness resting on a traversal nobody had checked against the filesystem.
|
||||
#
|
||||
# `scripts/tests/` is the one DIRECTORY-level exclusion, and it is a scope decision rather than a
|
||||
# content filter: those files run only under pytest, authorize nothing, and their only network calls
|
||||
# are to stub executables the tests themselves place on PATH. Excluding a directory is reviewable in
|
||||
# one line; excluding files by what they contain is what kept failing.
|
||||
EXCLUDED_DIRS = (REPO_ROOT / "scripts" / "tests",)
|
||||
|
||||
# `| ` + backticked path, optionally followed by ` — <site description>`, then the class cell.
|
||||
_ROW = re.compile(r"^\|\s*`([^`]+?)`[^|]*\|\s*`([^`]+)`\s*\|", re.M)
|
||||
|
||||
@@ -66,9 +88,12 @@ def derived_population() -> set[str]:
|
||||
if not directory.is_dir():
|
||||
continue
|
||||
for pattern in globs:
|
||||
for path in sorted(directory.glob(pattern)):
|
||||
if path.is_file():
|
||||
found.add(path.relative_to(REPO_ROOT).as_posix())
|
||||
for path in sorted(directory.rglob(pattern)):
|
||||
if not path.is_file():
|
||||
continue
|
||||
if any(excluded in path.parents for excluded in EXCLUDED_DIRS):
|
||||
continue
|
||||
found.add(path.relative_to(REPO_ROOT).as_posix())
|
||||
return found
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user