Skip to content

ci: refresh the live PR body before the required no-mistakes check - #266

Merged
HelloWorldSungin merged 9 commits into
mainfrom
fm/fm-required-check-python-missing
Sep 4, 2026
Merged

HelloWorldSungin merged 9 commits into
mainfrom
fm/fm-required-check-python-missing

Conversation

@HelloWorldSungin

@HelloWorldSungin HelloWorldSungin commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

Intent

Fix the required GitHub check named "PR must be raised via no-mistakes" so a firstmate pull request that takes a fix round can reach fully green. Evidence is #258.

Reproduce the synchronize path first from the failing run logs, not from the workflow file. The reported error was "python interpreter not found; cannot parse pipeline attestation", and the hypothesized split was opened passes / synchronize fails, with reruns of synchronize run 33810709843 staying red. Do not treat that python-missing diagnosis as given: establish why the interpreter would be present on one trigger and absent on the other, and do not guess. The likely remedy of adding actions/setup-python before the check was unverified and only a starting point.

Scope: the fix goes in this repository's own workflow. Do not modify, unpin, re-pin, fork, or vendor the pinned upstream action kunchenguid/no-mistakes@32d396a. If the defect is genuinely inside that pinned action and cannot be worked around from our side, stop and report a blocker rather than touching it.

A green opened run is not evidence. Name the trigger event behind every check result cited. The pull request body must name the reproduction (which run, which trigger, what was observed, what was established about the mechanism or explicitly could not be), quote the verbatim error line from a failing run log, state the trigger behind every cited check result, reference #258, include Closes #258, and amend the pipeline-owned PR body rather than replacing it. Comment on issue 258 with a substantive delivery summary. Do not merge.

Decisions made while reproducing: the python-not-found string is the pinned action's script source printed by GitHub on every run, including green opened runs; it is not an executed error. Python ran on synchronize. The executed failures were a real checker verdict: missing signature on some synchronize runs, and on 33810709843 all three attempts "Pipeline attestation head_sha does not match the current PR head" (attestation 4079582 vs head 6d2304c). Reruns replay the original webhook snapshot, so they cannot see a body the pipeline wrote afterwards. Therefore setup-python was not shipped. The workaround in our workflow is to fetch the live pull-request body (without checking out PR code) and write it into the event payload before the unchanged pinned action, waiting briefly for the attestation to bind the triggering head, then still writing a still-stale live body through so the action reports a real mismatch instead of a missing signature.

What Changed

  • Added .github/scripts/nm-required-refresh-event-body.py, which reads the live pull-request body over the GraphQL API and writes it into pull_request.body in GITHUB_EVENT_PATH before the compliance gate reads it. It polls until the body's no-mistakes-pipeline-attestation:v1 head_sha binds the expected head, stops early for a body carrying neither the attestation nor the no-mistakes signature marker, and writes a still-stale body through once the budget is spent so the action reports a real mismatch rather than a missing signature. Every failure path (no token, no GITHUB_REPOSITORY, transport or GraphQL error, malformed response) prints a ::warning:: and exits 0, and a single failed attempt costs one poll rather than the whole wait.
  • .github/workflows/no-mistakes-required.yml gained pull-requests: read and a step ahead of the unchanged pinned require-no-mistakes@32d396ac action: it downloads the helper from the contents API at github.sha (no PR checkout), runs it under python3 or python with a 120s budget at an 8s interval, and annotates a warning while leaving the webhook snapshot in place when the helper is unfetchable, the interpreter is absent, or the helper exits non-zero.
  • Extended tests/fm-no-mistakes-required-gate.test.sh by ~1100 lines covering the wait, the still-stale write-through, the signature-only and hand-authored bodies, mid-wait transient failures, exhausted budgets, and the workflow's step order, fetch ref, and degrade annotations; documented the divergence in docs/fork-divergence.md as its own entry, stated the live-body read and its fallback in CONTRIBUTING.md, and added .github/scripts/ to the shared tracked material list in AGENTS.md.

Risk Assessment

✅ Low: The change is well-bounded and every failure path I traced - unfetchable helper, missing interpreter, helper crash, unreachable or malformed GraphQL response, spent wait budget - degrades to the pre-change behavior of judging the webhook snapshot with a warning annotation, the pinned action is untouched, and the helper's bind predicate was confirmed identical to the pinned verifier's own attestation parse.

Testing

Reproduced the reported failure from the real GitHub run first (run 33810709843, trigger synchronize on PR #254), confirming from its raw log that the python-not-found string is the pinned action's echoed script source and the executed failure is the head_sha mismatch (attestation 4079582 vs head 6d2304c). Then demonstrated the fix end-to-end by executing the workflow's own refresh step and the pinned action's own composite step against the real verify.py at 32d396ac: the same event payload that reds pre-refresh goes green post-refresh after a 16s wait on the declared 120s/8s budget, a genuinely stale live body still produces the real mismatch verdict, and both degrade paths annotate with a warning and let the action emit a verdict instead of reddening the gate. The targeted gate suite (18 cases) and the sibling pinned-action suite pass, the gate suite is stable over four consecutive runs, and the same suite fails on the base commit, so the regression is really covered. This change is CI/workflow only and has no rendered UI surface of its own; its end-user surface is the GitHub check-run result, captured both as a screenshot of the real failing run's annotations and as a full CLI transcript of the simulated job. No test failures, setup problems, or flakiness found, and no transient files were left in the worktree.

  • Evidence: Real failing required check on GitHub (run 33810709843, trigger synchronize) - annotations show the executed error (local file: ~/.no-mistakes/evidence/01M1N08VM3082R4P4F91T6AX0N/repro-github-check-run-33810709843.png)
Evidence: End-to-end transcript: the required check red before the fix, green after it, and every degrade path
Simulated required check: "PR must be raised via no-mistakes"
Reproduction target : HelloWorldSungin/firstmate PR #254, run 33810709843, trigger = synchronize
Push-time body      : attestation head_sha=40795826e3ed81e347eb9cd0ffd604cad12ea014
Triggering head     : 6d2304c0d5a84707b1cca0963802e806f0b946bc
Pinned action       : kunchenguid/no-mistakes/.github/actions/require-no-mistakes@32d396ac0f29135daf7fcb9964aba9d5f4e796d6 (unchanged)
Wait budget declared: NM_REQUIRED_BODY_TIMEOUT_SEC=120 NM_REQUIRED_BODY_INTERVAL_SEC=8

================================================================
ARM 1  BEFORE the fix - trigger: synchronize (what run 33810709843 did)
================================================================
-- The job runs the pinned action directly on the webhook snapshot.
::error::Pipeline attestation head_sha does not match the current PR head.

attestation.head_sha: 40795826e3ed81e347eb9cd0ffd604cad12ea014
PR head: 6d2304c0d5a84707b1cca0963802e806f0b946bc

A later push must not pass on an older attestation. Re-run 'git push no-mistakes' so the PR body attestation binds to the current head.

See CONTRIBUTING.md for setup and the full workflow.

PR author: HelloWorldSungin
Found no-mistakes signature in PR #254 body.

>> required check exit code: 1  => RED

================================================================
ARM 2  AFTER the fix - trigger: synchronize, pipeline writes the body mid-job
================================================================
-- GraphQL serves the push-time body twice, then the body the pipeline wrote.
   [refresh step] fake contents API GET https://api.github.com/repos/HelloWorldSungin/firstmate/contents/.github/scripts/nm-required-refresh-event-body.py?ref=b7c0f4d18a6e5c93f2a1d0b8e7c6a5f4d3b2a1c0
   [refresh step] Refreshed pull_request.body from the live pull request (attestation.head_sha=6d2304c0d5a84707b1cca0963802e806f0b946bc; triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
   [refresh step] exit code: 0
   [graphql stub]
   [graphql stub] [+  0.1s] GraphQL request 1 for pull request #254 -> served the push-time (stale) body
   [graphql stub] [+  8.1s] GraphQL request 2 for pull request #254 -> served the push-time (stale) body
   [graphql stub] [+ 16.1s] GraphQL request 3 for pull request #254 -> served the post-push (live) body
   [refresh step] waited 16s before the attestation bound the triggering head
-- The pinned action now judges the refreshed event payload.
Found no-mistakes signature in PR #254 body.
Found structurally compliant pipeline step attestation.
::warning::PR-body attestation is author-editable and is not cryptographic proof that no-mistakes produced it.

>> required check exit code: 0  => GREEN

================================================================
ARM 3  AFTER the fix - the live body is genuinely still stale (budget spent)
================================================================
-- GraphQL never serves a fresh body; the still-stale live body is written through.
   [refresh step] fake contents API GET https://api.github.com/repos/HelloWorldSungin/firstmate/contents/.github/scripts/nm-required-refresh-event-body.py?ref=b7c0f4d18a6e5c93f2a1d0b8e7c6a5f4d3b2a1c0
   [refresh step] Refreshed pull_request.body from the live pull request (attestation.head_sha=40795826e3ed81e347eb9cd0ffd604cad12ea014; triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
   [refresh step] exit code: 0
   [refresh step] wait budget spent after 120s
::error::Pipeline attestation head_sha does not match the current PR head.

attestation.head_sha: 40795826e3ed81e347eb9cd0ffd604cad12ea014
PR head: 6d2304c0d5a84707b1cca0963802e806f0b946bc

A later push must not pass on an older attestation. Re-run 'git push no-mistakes' so the PR body attestation binds to the current head.

See CONTRIBUTING.md for setup and the full workflow.

PR author: HelloWorldSungin
Found no-mistakes signature in PR #254 body.

>> required check exit code: 1  => RED (a real mismatch verdict, not a missing signature)

================================================================
ARM 4  Degrade - no python interpreter on the runner
================================================================
-- PATH carries neither python3 nor python: the step must annotate, not red the check.
   [refresh step] fake contents API GET https://api.github.com/repos/HelloWorldSungin/firstmate/contents/.github/scripts/nm-required-refresh-event-body.py?ref=b7c0f4d18a6e5c93f2a1d0b8e7c6a5f4d3b2a1c0
   [refresh step] ::warning::no python interpreter for the live-body refresh; judging the webhook snapshot
   [refresh step] exit code: 0
::error::Pipeline attestation head_sha does not match the current PR head.

attestation.head_sha: 40795826e3ed81e347eb9cd0ffd604cad12ea014
PR head: 6d2304c0d5a84707b1cca0963802e806f0b946bc

A later push must not pass on an older attestation. Re-run 'git push no-mistakes' so the PR body attestation binds to the current head.

See CONTRIBUTING.md for setup and the full workflow.

PR author: HelloWorldSungin
Found no-mistakes signature in PR #254 body.

>> required check exit code: 1 => RED with a real compliance verdict, not a step error

================================================================
ARM 5  Degrade - the helper cannot be fetched at github.sha
================================================================
-- The contents API fails (stale test-merge / deleted tree): annotate and hand the snapshot on.
   [refresh step] fake contents API GET https://api.github.com/repos/HelloWorldSungin/firstmate/contents/.github/scripts/nm-required-refresh-event-body.py?ref=b7c0f4d18a6e5c93f2a1d0b8e7c6a5f4d3b2a1c0
   [refresh step] ::warning::live-body refresh helper unavailable at b7c0f4d18a6e5c93f2a1d0b8e7c6a5f4d3b2a1c0; judging the webhook snapshot
   [refresh step] exit code: 0
::error::Pipeline attestation head_sha does not match the current PR head.

attestation.head_sha: 40795826e3ed81e347eb9cd0ffd604cad12ea014
PR head: 6d2304c0d5a84707b1cca0963802e806f0b946bc

A later push must not pass on an older attestation. Re-run 'git push no-mistakes' so the PR body attestation binds to the current head.

See CONTRIBUTING.md for setup and the full workflow.

PR author: HelloWorldSungin
Found no-mistakes signature in PR #254 body.

>> required check exit code: 1 => RED with a real compliance verdict, not a step error

================================================================
END
================================================================
Evidence: Before/after of the required check (excerpt of the end-to-end transcript)
ARM 1 BEFORE the fix - trigger: synchronize (what run 33810709843 did)
-- The job runs the pinned action directly on the webhook snapshot.
::error::Pipeline attestation head_sha does not match the current PR head.

attestation.head_sha: 40795826e3ed81e347eb9cd0ffd604cad12ea014
PR head: 6d2304c0d5a84707b1cca0963802e806f0b946bc

PR author: HelloWorldSungin
Found no-mistakes signature in PR #254 body.

>> required check exit code: 1 => RED

ARM 2 AFTER the fix - trigger: synchronize, pipeline writes the body mid-job
[refresh step] fake contents API GET https://api.github.com/repos/HelloWorldSungin/firstmate/contents/.github/scripts/nm-required-refresh-event-body.py?ref=b7c0f4d1...
[refresh step] Refreshed pull_request.body from the live pull request (attestation.head_sha=6d2304c0...; triggering head=6d2304c0...).
[graphql stub] [+ 0.1s] GraphQL request 1 for pull request #254 -> served the push-time (stale) body
[graphql stub] [+ 8.1s] GraphQL request 2 for pull request #254 -> served the push-time (stale) body
[graphql stub] [+ 16.1s] GraphQL request 3 for pull request #254 -> served the post-push (live) body
[refresh step] waited 16s before the attestation bound the triggering head
Found no-mistakes signature in PR #254 body.
Found structurally compliant pipeline step attestation.

>> required check exit code: 0 => GREEN
Evidence: Raw log of the reproduced failing run 33810709843 (synchronize) - python-not-found is echoed script source, the mismatch is the executed error
2026-09-03T23:11:59.9105297Z Current runner version: '2.337.0'
2026-09-03T23:11:59.9134678Z ##[group]Runner Image Provisioner
2026-09-03T23:11:59.9136111Z Hosted Compute Agent
2026-09-03T23:11:59.9137034Z Version: 20260819.586
2026-09-03T23:11:59.9138124Z Commit: 3cc4a88dfa507ef76119ad1bb3eccc6378bb2b76
2026-09-03T23:11:59.9139682Z Build Date: 2026-08-18T23:20:18Z
2026-09-03T23:11:59.9140683Z Worker ID: {c35f5cad-1329-4b9b-828b-e64096a8b35f}
2026-09-03T23:11:59.9141961Z Azure Region: centralus
2026-09-03T23:11:59.9142885Z ##[endgroup]
2026-09-03T23:11:59.9145138Z ##[group]Operating System
2026-09-03T23:11:59.9146147Z Ubuntu
2026-09-03T23:11:59.9146919Z 24.04.4
2026-09-03T23:11:59.9147855Z LTS
2026-09-03T23:11:59.9148854Z ##[endgroup]
2026-09-03T23:11:59.9149664Z ##[group]Runner Image
2026-09-03T23:11:59.9150843Z Image: ubuntu-24.04
2026-09-03T23:11:59.9151711Z Version: 20260823.283.1
2026-09-03T23:11:59.9153815Z Included Software: https://github.com/actions/runner-images/blob/ubuntu24/20260823.283/images/ubuntu/Ubuntu2404-Readme.md
2026-09-03T23:11:59.9156302Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu24%2F20260823.283
2026-09-03T23:11:59.9158061Z ##[endgroup]
2026-09-03T23:11:59.9160113Z ##[group]GITHUB_TOKEN Permissions
2026-09-03T23:11:59.9163033Z Contents: read
2026-09-03T23:11:59.9163929Z Metadata: read
2026-09-03T23:11:59.9164884Z ##[endgroup]
2026-09-03T23:11:59.9167678Z Secret source: Actions
2026-09-03T23:11:59.9170029Z Prepare workflow directory
2026-09-03T23:11:59.9540186Z Prepare all required actions
2026-09-03T23:11:59.9600269Z Getting action download info
2026-09-03T23:12:00.2225027Z Download action repository 'kunchenguid/no-mistakes@32d396ac0f29135daf7fcb9964aba9d5f4e796d6' (SHA:32d396ac0f29135daf7fcb9964aba9d5f4e796d6)
2026-09-03T23:12:01.0741696Z Complete job name: PR must be raised via no-mistakes
2026-09-03T23:12:01.1433873Z ##[group]Run kunchenguid/no-mistakes/.github/actions/require-no-mistakes@32d396ac0f29135daf7fcb9964aba9d5f4e796d6
2026-09-03T23:12:01.1435151Z with:
2026-09-03T23:12:01.1435627Z   exempt-bot-authors: false
2026-09-03T23:12:01.1436259Z ##[endgroup]
2026-09-03T23:12:01.1527789Z ##[start-action display=Verify no-mistakes signature and pipeline attestation;id=__kunchenguid_no-mistakes.verify]
2026-09-03T23:12:01.1582712Z ##[group]Run set -eu
2026-09-03T23:12:01.1583282Z ^[[36;1mset -eu^[[0m
2026-09-03T23:12:01.1583847Z ^[[36;1mif command -v python3 >/dev/null 2>&1; then^[[0m
2026-09-03T23:12:01.1584488Z ^[[36;1m  PY=python3^[[0m
2026-09-03T23:12:01.1585038Z ^[[36;1melif command -v python >/dev/null 2>&1; then^[[0m
2026-09-03T23:12:01.1585653Z ^[[36;1m  PY=python^[[0m
2026-09-03T23:12:01.1586105Z ^[[36;1melse^[[0m
2026-09-03T23:12:01.1586830Z ^[[36;1m  echo "::error::python interpreter not found; cannot parse pipeline attestation." >&2^[[0m
2026-09-03T23:12:01.1587649Z ^[[36;1m  exit 1^[[0m
2026-09-03T23:12:01.1588124Z ^[[36;1mfi^[[0m
2026-09-03T23:12:01.1588937Z ^[[36;1m"$PY" "${GITHUB_ACTION_PATH}/verify.py"^[[0m
2026-09-03T23:12:01.1634439Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2026-09-03T23:12:01.1635207Z env:
2026-09-03T23:12:01.1635783Z   PR_BODY: 
2026-09-03T23:12:01.1636437Z   PR_HEAD_SHA: 
2026-09-03T23:12:01.1636996Z   PR_HEAD_REF: 
2026-09-03T23:12:01.1637624Z   PR_AUTHOR: 
2026-09-03T23:12:01.1638179Z   PR_NUMBER: 
2026-09-03T23:12:01.1638959Z   NM_EXEMPT_AUTHORS: 
2026-09-03T23:12:01.1639636Z   NM_EXEMPT_BOT_AUTHORS: false
2026-09-03T23:12:01.1640281Z   NM_EXEMPT_HEAD_BRANCHES: 
2026-09-03T23:12:01.1640880Z ##[endgroup]
2026-09-03T23:12:01.2024412Z ##[error]Pipeline attestation head_sha does not match the current PR head.
2026-09-03T23:12:01.2025264Z 
2026-09-03T23:12:01.2026132Z attestation.head_sha: 40795826e3ed81e347eb9cd0ffd604cad12ea014
2026-09-03T23:12:01.2027418Z PR head: 6d2304c0d5a84707b1cca0963802e806f0b946bc
2026-09-03T23:12:01.2028032Z 
2026-09-03T23:12:01.2029209Z A later push must not pass on an older attestation. Re-run 'git push no-mistakes' so the PR body attestation binds to the current head.
2026-09-03T23:12:01.2030146Z 
2026-09-03T23:12:01.2030731Z See CONTRIBUTING.md for setup and the full workflow.
2026-09-03T23:12:01.2031241Z 
2026-09-03T23:12:01.2031497Z PR author: HelloWorldSungin
2026-09-03T23:12:01.2032266Z Found no-mistakes signature in PR #254 body.
2026-09-03T23:12:01.2038588Z ##[error]Process completed with exit code 1.
2026-09-03T23:12:01.2116967Z ##[end-action id=__kunchenguid_no-mistakes.verify;outcome=failure;conclusion=failure;duration_ms=58]
2026-09-03T23:12:01.2252797Z Cleaning up orphan processes
Evidence: Fail-before-fix: the new suite run against base commit bb26893
ok - reproduction demonstrates how un-coalesced edited check runs accumulate orphan failure on same head SHA
ok - no-mistakes-required workflow triggers on code/branch events and excludes edited
ok - no-mistakes-required workflow uses unified per-PR concurrency with cancellation enabled
ok - signature verification step correctly approves valid body and rejects missing body
python3: can't open file '/tmp/nm-base/.github/scripts/nm-required-refresh-event-body.py': [Errno 2] No such file or directory
not ok - refresh helper exited non-zero on a live body that matches the head
Evidence: Targeted suite output (tests/fm-no-mistakes-required-gate.test.sh)
ok - reproduction demonstrates how un-coalesced edited check runs accumulate orphan failure on same head SHA
ok - no-mistakes-required workflow triggers on code/branch events and excludes edited
ok - no-mistakes-required workflow uses unified per-PR concurrency with cancellation enabled
ok - signature verification step correctly approves valid body and rejects missing body
Refreshed pull_request.body from the live pull request (attestation.head_sha=6d2304c0d5a84707b1cca0963802e806f0b946bc; triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
ok - synchronize snapshot with a stale attestation is replaced by the live matching body
Refreshed pull_request.body from the live pull request (attestation.head_sha=40795826e3ed81e347eb9cd0ffd604cad12ea014; triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
ok - still-stale live body is written through so the action can emit the real mismatch
Refreshed pull_request.body from the live pull request (attestation.head_sha=6d2304c0d5a84707b1cca0963802e806f0b946bc; triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
ok - refresh helper re-fetches until the live attestation binds the triggering head
Refreshed pull_request.body from the live pull request (attestation.head_sha=6d2304c0d5a84707b1cca0963802e806f0b946bc; triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
ok - a signed live body with no attestation yet still waits for the attestation to bind
Refreshed pull_request.body from the live pull request (attestation.head_sha=(missing); triggering head=6d2304c0d5a84707b1cca0963802e806f0b946bc).
ok - a live body with neither no-mistakes marker is judged without polling
ok - an unreachable live body leaves the webhook snapshot for the pinned action to judge
ok - a successful live GraphQL fetch lands the live body in the event payload
ok - a transient mid-wait costs one attempt, not the whole wait budget
ok - a budget spent against a failing endpoint keeps the last body read and annotates the run
ok - a response that is valid JSON but not an object degrades to the webhook snapshot
ok - a response the transport drops mid-flight degrades to the webhook snapshot
ok - the required check refreshes the live body before the pinned action and annotates every degrade instead of reddening
ok - the pinned verifier goes from the issue-258 mismatch to compliant on the refreshed event payload
ok - PR opened without no-mistakes signature strictly fails compliance gate

all fm-no-mistakes-required-gate tests passed
Evidence: End-to-end harness used to produce the transcript (workflow step extractor, GraphQL stub, run script)
#!/usr/bin/env bash
# End-to-end simulation of the required check "PR must be raised via no-mistakes"
# for the issue-258 reproduction (PR #254, synchronize run 33810709843).
#
# Everything executed here is real: the workflow's own `run:` block (extracted
# with PyYAML), the repository's live-body helper, and the pinned action's own
# composite `run:` block driving its own verify.py fetched at the pinned SHA.
# Only GitHub's HTTP surfaces are stubbed - the contents API (a fake `curl` on
# PATH) and the GraphQL API (a local HTTP server).
set -u

ROOT=${ROOT:?}
EV=${EV:?}
WORK="$EV/e2e"
PIN=32d396ac0f29135daf7fcb9964aba9d5f4e796d6
OLD_HEAD=40795826e3ed81e347eb9cd0ffd604cad12ea014   # attestation on the push-time body
NEW_HEAD=6d2304c0d5a84707b1cca0963802e806f0b946bc   # head that triggered run 33810709843
MERGE_SHA=b7c0f4d18a6e5c93f2a1d0b8e7c6a5f4d3b2a1c0 # github.sha: the test-merge commit
SIGNATURE='Updates from [git push no-mistakes](https://github.com/kunchenguid/no-mistakes)'
STEPS='[{"step":"review","status":"completed"},{"step":"test","status":"completed"},{"step":"document","status":"completed"}]'

rule() { printf '\n================================================================\n%s\n================================================================\n' "$1"; }
say()  { printf -- '-- %s\n' "$1"; }

body() { printf '%s\n<!-- no-mistakes-pipeline-attestation\:v1 {"head_sha":"%s","steps":%s} -->\n' "$SIGNATURE" "$1" "$STEPS"; }

write_event() { # <path> <body>
  python3 -c '
import json, sys
json.dump({"action": "synchronize",
           "pull_request": {"number": 254, "body": sys.argv[2],
                            "head": {"sha": sys.argv[3], "ref": "fm/fm-test-suite-robustness"},
                            "user": {"login": "HelloWorldSungin"}}},
          open(sys.argv[1], "w", encoding="utf-8"))
' "$1" "$2" "$NEW_HEAD"
}

# The pinned action's own composite step, run exactly as action.yml declares it.
run_pinned_action() { # <event path>  -> prints the step log, returns its exit code
  GITHUB_EVENT_PATH="$1" GITHUB_ACTION_PATH="$WORK/action" \
    PR_BODY= PR_HEAD_SHA= PR_HEAD_REF= PR_AUTHOR= PR_NUMBER= \
    NM_EXEMPT_AUTHORS= NM_EXEMPT_BOT_AUTHORS=false NM_EXEMPT_HEAD_BRANCHES= \
    bash "$WORK/action/step.sh" 2>&1
}

# ---------------------------------------------------------------- fixtures --
mkdir -p "$WORK/action" "$WORK/fakebin" "$WORK/runner"
curl -fsSL "https://raw.githubusercontent.com/kunchenguid/no-mistakes/$PIN/.github/actions/require-no-mistakes/verify.py" \
  -o "$WORK/action/verify.py" || { echo "FATAL: could not fetch the pinned verifier"; exit 1; }
curl -fsSL "https://raw.githubusercontent.com/kunchenguid/no-mistakes/$PIN/.github/actions/require-no-mistakes/action.yml" \
  -o "$WORK/action/action.yml" || { echo "FATAL: could not fetch the pinned action"; exit 1; }
python3 -c '
import sys, yaml
doc = yaml.safe_load(open(sys.argv[1], encoding="utf-8"))
open(sys.argv[2], "w", encoding="utf-8").write(doc["runs"]["steps"][0]["run"])
' "$WORK/action/action.yml" "$WORK/action/step.sh"

# Fake contents API: serves whatever CURL_SERVE_FILE names, or fails with CURL_EXIT.
cat > "$WORK/fakebin/curl" <<'CURL'
#!/usr/bin/env bash
url=; out=
while [ "$#" -gt 0 ]; do
  case "$1" in
    -o) out=$2; shift 2 ;;
    -H) shift 2 ;;
    -*) shift ;;
    *) url=$1; shift ;;
  esac
done
printf 'fake contents API GET %s\n' "$url" >&2
[ "${CURL_EXIT:-0}" -eq 0 ] || exit "${CURL_EXIT}"
cp "${CURL_SERVE_FILE:?}" "$out"
CURL
chmod +x "$WORK/fakebin/curl"

body "$OLD_HEAD" > "$WORK/stale-body"   # body as the synchronize webhook snapshotted it
body "$NEW_HEAD" > "$WORK/live-body"    # body the pipeline writes seconds after the push

STEP="$WORK/refresh-step.sh"
EVENT="$WORK/event.json"

start_stub() { # <plan>
  rm -f "$WORK/port" "$WORK/graphql.log"
  python3 "$WORK/graphql-stub.py" "$WORK/port" "$WORK/stale-body" "$WORK/live-body" "$WORK/graphql.log" "$1" &
  STUB_PID=$!
  local waits=200
  while [ ! -s "$WORK/port" ] && [ "$waits" -gt 0 ]; do sleep 0.05; waits=$((waits-1)); done
}
stop_stub() { kill "${STUB_PID:-0}" 2>/dev/null || true; wait "${STUB_PID:-0}" 2>/dev/null || true; }

refresh_step_env() { # runs the workflow's own step with the workflow's own env values
  PATH="$WORK/fakebin:$PATH" \
  RUNNER_TEMP="$WORK/runner" \
  GITHUB_API_URL="https://api.github.com" \
  GITHUB_GRAPHQL_URL="http://127.0.0.1:$(cat "$WORK/port" 2>/dev/null || echo 1)/graphql" \
  GITHUB_TOKEN="ghs-simulated-job-token" \
  GITHUB_REPOSITORY="HelloWorldSungin/firstmate" \
  GITHUB_EVENT_PATH="$EVENT" \
  NM_REQUIRED_EXPECTED_HEAD="$NEW_HEAD" \
  NM_REQUIRED_SCRIPT_REF="$MERGE_SHA" \
  NM_REQUIRED_BODY_TIMEOUT_SEC="120" \
  NM_REQUIRED_BODY_INTERVAL_SEC="8" \
  "$@"
}

printf 'Simulated required check: "PR must be raised via no-mistakes"\n'
printf 'Reproduction target : HelloWorldSungin/firstmate PR #254, run 33810709843, trigger = synchronize\n'
printf 'Push-time body      : attestation head_sha=%s\n' "$OLD_HEAD"
printf 'Triggering head     : %s\n' "$NEW_HEAD"
printf 'Pinned action       : kunchenguid/no-mistakes/.github/actions/require-no-mistakes@%s (unchanged)\n' "$PIN"
printf 'Wait budget declared: NM_REQUIRED_BODY_TIMEOUT_SEC=120 NM_REQUIRED_BODY_INTERVAL_SEC=8\n'

# =============================================================== ARM 1 ======
rule 'ARM 1  BEFORE the fix - trigger: synchronize (what run 33810709843 did)'
say 'The job runs the pinned action directly on the webhook snapshot.'
write_event "$EVENT" "$(body "$OLD_HEAD")"
rc=0; out=$(run_pinned_action "$EVENT") || rc=$?
printf '%s\n' "$out"
printf '\n>> required check exit code: %s  => %s\n' "$rc" "$([ "$rc" -eq 0 ] && echo GREEN || echo RED)"

# =============================================================== ARM 2 ======
rule 'ARM 2  AFTER the fix - trigger: synchronize, pipeline writes the body mid-job'
say 'GraphQL serves the push-time body twice, then the body the pipeline wrote.'
write_event "$EVENT" "$(body "$OLD_HEAD")"
start_stub "stale,stale,data"
t0=$(date +%s)
rc=0
CURL_SERVE_FILE="$ROOT/.github/scripts/nm-required-refresh-event-body.py" \
  refresh_step_env bash "$STEP" > "$WORK/step.out" 2>&1 || rc=$?
sed 's/^/   [refresh step] /' "$WORK/step.out"
printf '   [refresh step] exit code: %s\n' "$rc"
t1=$(date +%s)
stop_stub
printf '   [graphql stub]\n'; sed 's/^/   [graphql stub] /' "$WORK/graphql.log"
printf '   [refresh step] waited %ss before the attestation bound the triggering head\n' "$((t1-t0))"
say 'The pinned action now judges the refreshed event payload.'
rc=0; out=$(run_pinned_action "$EVENT") || rc=$?
printf '%s\n' "$out"
printf '\n>> required check exit code: %s  => %s\n' "$rc" "$([ "$rc" -eq 0 ] && echo GREEN || echo RED)"

# =============================================================== ARM 3 ======
rule 'ARM 3  AFTER the fix - the live body is genuinely still stale (budget spent)'
say 'GraphQL never serves a fresh body; the still-stale live body is written through.'
write_event "$EVENT" "$(body "$OLD_HEAD")"
start_stub "$(python3 -c 'print(",".join(["stale"]*24))')"
t0=$(date +%s)
rc=0
CURL_SERVE_FILE="$ROOT/.github/scripts/nm-required-refresh-event-body.py" \
  refresh_step_env bash "$STEP" > "$WORK/step.out" 2>&1 || rc=$?
sed 's/^/   [refresh step] /' "$WORK/step.out"
printf '   [refresh step] exit code: %s\n' "$rc"
t1=$(date +%s)
stop_stub
printf '   [refresh step] wait budget spent after %ss\n' "$((t1-t0))"
rc=0; out=$(run_pinned_action "$EVENT") || rc=$?
printf '%s\n' "$out"
printf '\n>> required check exit code: %s  => %s (a real mismatch verdict, not a missing signature)\n' \
  "$rc" "$([ "$rc" -eq 0 ] && echo GREEN || echo RED)"

# =============================================================== ARM 4 ======
rule 'ARM 4  Degrade - no python interpreter on the runner'
say 'PATH carries neither python3 nor python: the step must annotate, not red the check.'
NOPY="$WORK/nopython"; mkdir -p "$NOPY"
cp "$WORK/fakebin/curl" "$NOPY/curl"
ln -sf "$(command -v bash)" "$NOPY/bash"; ln -sf "$(command -v cp)" "$NOPY/cp"
write_event "$EVENT" "$(body "$OLD_HEAD")"
rc=0
PATH="$NOPY" RUNNER_TEMP="$WORK/runner" GITHUB_API_URL="https://api.github.com" \
  GITHUB_TOKEN=t GITHUB_REPOSITORY="HelloWorldSungin/firstmate" GITHUB_EVENT_PATH="$EVENT" \
  CURL_SERVE_FILE="$ROOT/.github/scripts/nm-required-refresh-event-body.py" \
  NM_REQUIRED_SCRIPT_REF="$MERGE_SHA" NM_REQUIRED_EXPECTED_HEAD="$NEW_HEAD" \
  NM_REQUIRED_BODY_TIMEOUT_SEC=120 NM_REQUIRED_BODY_INTERVAL_SEC=8 \
  bash "$STEP" > "$WORK/step.out" 2>&1 || rc=$?
sed 's/^/   [refresh step] /' "$WORK/step.out"
printf '   [refresh step] exit code: %s\n' "$rc"
rc=0; out=$(run_pinned_action "$EVENT") || rc=$?
printf '%s\n' "$out"
printf '\n>> required check exit code: %s => %s with a real compliance verdict, not a step error\n' \
  "$rc" "$([ "$rc" -eq 0 ] && echo GREEN || echo RED)"

# =============================================================== ARM 5 ======
rule 'ARM 5  Degrade - the helper cannot be fetched at github.sha'
say 'The contents API fails (stale test-merge / deleted tree): annotate and hand the snapshot on.'
write_event "$EVENT" "$(body "$OLD_HEAD")"
rc=0
CURL_EXIT=22 CURL_SERVE_FILE="$ROOT/.github/scripts/nm-required-refresh-event-body.py" \
  refresh_step_env bash "$STEP" > "$WORK/step.out" 2>&1 || rc=$?
sed 's/^/   [refresh step] /' "$WORK/step.out"
printf '   [refresh step] exit code: %s\n' "$rc"
rc=0; out=$(run_pinned_action "$EVENT") || rc=$?
printf '%s\n' "$out"
printf '\n>> required check exit code: %s => %s with a real compliance verdict, not a step error\n' \
  "$rc" "$([ "$rc" -eq 0 ] && echo GREEN || echo RED)"

rule 'END'

CI note (unresolved elsewhere, not resolved here)

Portable serial 6 and 8 failed on the first pass of run 33835336284. Serial 6 (job 100906573610) exited 124 where the test expected 137. Serial 8 (job 100906573770) did not see a remote job worker become ready after startup. A re-run of those two jobs on the same run did not reproduce either (serial 6 job 100909448093 pass, serial 8 job 100909448082 pass). That is the known shared-runner condition tracked as #262, not evidence that those suites are sound, and not a defect in this PR. This PR being green is not proof those tests are reliable. The question stays open on #262. Bounds were not widened. The required check "PR must be raised via no-mistakes" passed on this PR's opened run 33835336291.

Pipeline

Updates from git push no-mistakes

... (3 earlier update rounds omitted to keep the PR body within GitHub's 65536-char limit; full history is in the run log.)

⚠️ **Review** - 1 info

🔧 Fix: harden required-check live-body refresh against 404s and fetch failures
6 issues (1 warning, 5 infos) still open:

  • ⚠️ tests/fm-no-mistakes-required-gate.test.sh:306 - No test exercises a successful live-body fetch. Tests 5, 6, 7 and the executed step in test 9 all pass --body-file/NM_REQUIRED_BODY_FILE, which returns from fetch_live_body at .github/scripts/nm-required-refresh-event-body.py:82 before the GraphQL path; test 8 only exercises the transport failure. The fix round then turned every fetch failure into return 0 with a ::warning:: (helper lines 183-190), so a broken fetch is now silent. Concrete failure: change the query to pullRequest(number:$p){bodyText} - GitHub replies with errors, fetch_live_body raises LiveBodyUnavailable, main() prints a warning and exits 0, the step is GREEN, the pinned action judges the webhook snapshot, and the required check keeps failing exactly as it did in run 33810709843. Every test in this suite still passes. (I verified the query as written is correct today: executed against api.github.com/graphql for PR Merge upstream round 3 through kunchenguid/firstmate@9e3df47b #264, errors=None, 27092-byte body - so this is a regression-detection gap, not a live defect.) Mechanical remedy, no behavior change: add a case that points GITHUB_GRAPHQL_URL at a local stub returning {&#34;data&#34;:{&#34;repository&#34;:{&#34;pullRequest&#34;:{&#34;body&#34;:...}}}} and asserts that body lands in the event payload.
  • ℹ️ .github/scripts/nm-required-refresh-event-body.py:187 - When a fetch fails after an earlier one succeeded, body is not None, so the except block falls through to line 192 and writes the last body - but prints nothing about the failure, and then prints "Refreshed pull_request.body from the live pull request" as if the full wait budget had been spent. Trace: fetch at t=0 returns the pre-push body (attestation 4079582, head 6d2304c), sleep 8, fetch at t=8 gets a 502 -> loop aborts at 8s of a 120s budget -> the stale body is written -> the action emits "Pipeline attestation head_sha does not match the current PR head". The operator sees the same mismatch text issue Required no-mistakes check errors with "python interpreter not found", producing a red that is not a verdict #258 was filed over, with no signal that the wait was cut short by an API error rather than genuinely exhausted. Emit the same ::warning:: on that branch before falling through.
  • ℹ️ .github/workflows/no-mistakes-required.yml:38 - The comment claims fetching at github.sha "resolves for every open PR once this reaches main". That is not true for a PR that conflicts with main: GitHub cannot recompute refs/pull/N/merge, so the stale ref keeps pointing at a merge of an older base. Verified on currently-open PR fix(bin): harden guarded merge execution in fm-pr-merge #241: REST reports mergeable:false, mergeable_state:dirty, merge_commit_sha:null, yet refs/pull/241/merge still exists at 80af4f7f71c1a68a037f2093d19b8b577fc67124, whose base parent 0c51a080 is a 2026-09-02 main - two days behind current main bb268932. Once this lands, that tree will not contain the helper, curl 404s, and the step degrades to the webhook snapshot. Behaviorally that is the honest fallback the fix round added, so nothing is broken - but the comment (and the matching error message in tests/fm-no-mistakes-required-gate.test.sh:~430, "a PR head ref 404s until the branch takes main") overstates the guarantee. Scope the remedy to correcting the claim; adding a base-branch (github.base_ref) fallback ref would extend the change and needs authorization.
  • ℹ️ .github/scripts/nm-required-refresh-event-body.py:53 - The workflow sets no timeout/interval, so every run whose live body does not bind the triggering head burns the full default budget: 120s with an 8s interval = ~16 GraphQL calls before the pinned action can report anything. Concrete case: a contributor opens a PR by hand with body "please merge" - attestation_head() returns "" which never equals the head SHA, so the helper polls for two minutes before the action emits "This PR was not raised through no-mistakes", where it previously reported in seconds. The same knob cuts the other way: if the pipeline's post-push body write takes longer than 120s, the run still reds and green still depends on a manual rerun. Remedy changes behavior (skip the wait when the live body carries no signature marker at all, and/or set the budget explicitly in the workflow), so it needs your call rather than a silent fix.
  • ℹ️ tests/fm-no-mistakes-required-gate.test.sh:321 - fm_run_timed 30 bounds the helper at exactly the 30s socket timeout the helper passes to urlopen (helper line 112). On a host where loopback port 1 is DROPped by a firewall rather than refused, connect() hangs instead of failing fast, and the two 30s deadlines race: fm_run_timed can TERM the process first, giving rc=124 and "an unreachable live body failed the required check" - a false red for a suite that is asserting the opposite. Raise the outer bound (e.g. 60) so the helper's own failure always wins.
  • ℹ️ .github/workflows/no-mistakes-required.yml:46 - Re-verifying round 1's gate-executes-pr-head-code finding against the fix: moving the ref from the PR head SHA to github.sha did NOT make the helper base-trusted. github.sha is the PR merge commit, so a PR that edits .github/scripts/nm-required-refresh-event-body.py still gets its own version downloaded and run by the gate. It is reduced to parity with what was already exposed: pull_request workflows load their definition from that same merge ref, so a PR could already rewrite this workflow's steps directly, and the pinned verify.py states the NON-GOAL explicitly ("a hand-written body that reproduces the documented format passes this check"). No residual action recommended - recording the accurate status so the fix is not read as having closed it.

🔧 Fix: scope the live-body wait and cover its transport paths
3 issues (2 warnings, 1 info) still open:

  • ⚠️ .github/scripts/nm-required-refresh-event-body.py:129 - The degrade path misses the transport errors urllib raises after the request is sent, so an ordinary GitHub transient reds the required check with a traceback instead of falling back to the webhook snapshot. In CPython's urllib.request.AbstractHTTPHandler.do_open, only h.request(...) is wrapped into URLError; r = h.getresponse() is not, and neither is response.read() at line 128. So http.client.RemoteDisconnected (ConnectionResetError + BadStatusLine), IncompleteRead, and a mid-stream ConnectionResetError/SSLError all escape this except tuple, escape main's except LiveBodyUnavailable at line 202, and abort the process. Reproduced against the real helper: an endpoint that accepts the POST and closes without a response produces http.client.RemoteDisconnected: Remote end closed connection without response and EXIT=1, which under the workflow step's set -eu (.github/workflows/no-mistakes-required.yml:57) fails the step, so "PR must be raised via no-mistakes" is red with no compliance verdict at all - the exact outcome the comment at lines 203-205 and test 10 claim this path prevents, and strictly worse than the pre-change behavior where the same PR still reached a verdict from the snapshot. Test 10 does not cover it: a refused connection fails inside h.request() and so IS wrapped into URLError, which is why it passes today. Remedy is mechanical and stays inside the existing contract: add import http.client and broaden to except (OSError, http.client.HTTPException, json.JSONDecodeError) as err (OSError already subsumes URLError and TimeoutError), and cover it with a stub that closes the connection without answering.
  • ⚠️ tests/fm-no-mistakes-required-gate.test.sh:276 - The new tests start background fixtures whose PIDs are never recorded or killed, so a failing assertion turns a one-second red into a 480s bounded timeout. Concrete sequence for test 7: the helper regresses and stops re-fetching, so the writer subshell is parked in attestation_body &#34;$NEW_HEAD&#34; &gt; &#34;$live&#34; - an open-for-write on a FIFO with no reader, which unlinking the fixture does not wake. The test calls fail, which exits 1; tests/lib.sh's EXIT trap only removes temp dirs, so the orphan survives holding the inherited stdout write end. bin/fm-test-run.sh:2154 runs each script as bash &#34;$1&#34; 2&gt;&amp;1 | tee &#34;$2&#34;, so tee never sees EOF, the pipeline never completes, and fm_run_timed bounds it at the 480s DEFAULT_PER_SCRIPT_TIMEOUT_SECS - which that file's own shard arithmetic (bin/fm-test-run.sh:163-180) says can push a portable-serial shard past its lane cap and lose per-script attribution entirely. Same shape at line 324 (test 8) and line 503, where the GraphQL stub blocks forever in server.handle_request() if the helper makes fewer requests than its plan. The repo already has the precedent for this (fm_test_stop_remote_job_worker in tests/lib.sh): capture $! when starting each fixture and kill it before fail / on test exit.
  • ℹ️ tests/fm-no-mistakes-required-gate.test.sh:175 - The same four-line python3 skip guard is copy-pasted into all nine new tests (lines 175, 216, 256, 309, 352, 395, 522, 570, 751), 36 lines that all print the identical string. The suite cannot use the repo's top-of-file command -v python3 ... || exit 0 convention because tests 1-4 and 14 must still run without python3, but a single require_python3() helper returning non-zero (called as require_python3 || return 0) collapses all nine to one line each with no behavior change.

🔧 Fix: degrade on post-request transport errors and bound test fixtures
3 issues (2 warnings, 1 info) still open:

  • ⚠️ .github/scripts/nm-required-refresh-event-body.py:187 - The try: wraps the entire while True: poll, so the first LiveBodyUnavailable from any single attempt ends the whole wait budget rather than just that attempt - and the failure it produces is exactly the red this change exists to eliminate. Concrete trace with the workflow's shipped settings (no-mistakes-required.yml:54-55, 120s at an 8s interval, 15 fetches against api.github.com/graphql): fetch feat(harness): add crew-only cursor and agy adapters #1 at t0 returns the pre-push body whose attestation binds H1 while expected is H2, so attestation_head(body) == expected is false and raised_through_no_mistakes(body) is true (the signature is present) and the helper sleeps 8s; fetch feat(spawn): add a design crewmate profile that lands an ADR #2 at t~8 gets an ordinary GitHub 502, which round 3 correctly made catchable (HTTPError is an OSError, line 129), so LiveBodyUnavailable propagates out of the loop; the handler at line 202 sees body is not None, prints the warning, and line 214 writes the H1 body through. The pinned verify.py I read at 32d396ac then hits check_head_bind and fails with "Pipeline attestation head_sha does not match the current PR head" - verbatim the issue-258 red, produced at 8 seconds of a 120-second budget that had 14 attempts left and would have gone green. Test 12 codifies this shape and its own comment (line 610) calls that 502 "the transient the full 120s budget is meant to ride out", which is the opposite of what the code does. The remedy stays inside the existing loop and adds no new state, subsystem, or persistence: catch LiveBodyUnavailable per attempt, retain the last successfully read body, warn once, and keep polling until the deadline; fall through to the write only when the budget is genuinely exhausted, and keep the existing body is None degrade for the case where no fetch ever succeeded. This is a claim about control flow and is distinct from round 2's decision on this branch, which chose the warning text so an aborted wait is not reported as a clean refresh - it did not decide that one blip should end the wait.
  • ⚠️ tests/fm-no-mistakes-required-gate.test.sh:212 - The single assumption the whole change rests on is asserted nowhere: that the pinned action reads the pull-request body from $GITHUB_EVENT_PATH at run time, so a step that rewrites that file beforehand changes the verdict (stated as fact in the workflow comment at no-mistakes-required.yml:32). Every new helper case (tests 5-13) asserts only what the helper wrote into event.json and stops there; test 14 executes the workflow's own run block but still ends at event.json. The sibling suite tests/fm-no-mistakes-required.test.sh does drive the real verify.py, but run_verifier (line 36) always passes PR_BODY explicitly, which is precisely the branch this change never uses. So if the pinned verifier had instead read ${{ github.event.pull_request.body }} - an expression GitHub resolves from the job's in-memory context, which is never refreshed from disk - the change would be an inert no-op, every added test would still be green, and the required check would stay red: the exact shape of Required no-mistakes check errors with "python interpreter not found", producing a red that is not a verdict #258. I confirmed out of band against the pinned source at 32d396ac that event_payload() opens GITHUB_EVENT_PATH at run time and Facts.body falls back to it when PR_BODY is empty, so the mechanism does hold today; what is missing is the regression that keeps it holding when the pin is next bumped. The remedy reuses machinery already in the repo rather than adding any: tests/fm-no-mistakes-required.test.sh already has fetch_shared_verifier downloading that verifier at this same ref, so add one case that runs it with GITHUB_EVENT_PATH pointed at the pre-refresh event (expect non-zero and "head_sha does not match") and again at the event the helper rewrote (expect 0). That is the red-before/green-after reproduction of the reported failure that the current cases stop one link short of.
  • ℹ️ tests/fm-no-mistakes-required-gate.test.sh:111 - This change introduced workflow_model_json (line 689), which normalizes the required-check workflow into a typed job/step model and refuses any construct it cannot represent, and test 14 asserts the step order, env, and pin against that model. Tests 2 and 3 still assert the same file with sed -n &#39;/^[[:space:]]*types:/p&#39; and sed -n &#39;/^[[:space:]]*group:/p&#39; compared for exact string equality against hardcoded lines including their leading indentation, so a purely cosmetic reflow of on: or concurrency: reds them while a semantically identical model passes, and the types: pattern would silently concatenate two lines if any future step ever carried that key. Reading on.pull_request.types and concurrency.group/concurrency.cancel-in-progress off $tmp/model.json expresses the same two divergence invariants (which docs/fork-divergence.md:177 says this suite pins) as meaning rather than as file text, with no behavior change. Scoped to these two cases in this file, not a repository-wide sweep.

🔧 Fix: retry per attempt and drive the pinned verifier
2 issues (1 warning, 1 info) still open:

  • ⚠️ tests/fm-no-mistakes-required-gate.test.sh:109 - On a host without python3, 14 of this suite's 17 cases silently no-op and the run is still recorded as a clean pass, so the workflow this change ships is asserted by nothing. require_python3 || return 0 returns before pass, and bin/fm-test-run.sh:1469 detect_gate_skip only recognizes a gate skip when the FIRST non-empty output line starts with skip:. Test 1 (test_reproduce_issue_98_sequence, line 62) needs no python3 and always prints ok - ... first, so every later skip: line is invisible: the script exits 0 and FM_TEST_END records gate_skip=false. What still runs is tests 1, 4 and 17, which are self-contained bash reimplementations of a grep and touch neither .github/workflows/no-mistakes-required.yml nor the refresh helper. The last fix round widened this: tests 2 and 3 (lines 109 and 133) were previously unconditional sed-and-string comparisons and now sit behind the same guard, so the edited-trigger and per-PR concurrency divergence that docs/fork-divergence.md:177 names this suite as the pin for has no enforcement at all on such a host. The suite's own toolchain comment (line 20) states python3 is optional here and bin/fm-bootstrap.sh does not install it, so this is a host the repo expects. tests/lib.sh:82-89 already names this exact failure shape - "a test that is defined and never invoked reports safety it never checked, and it is invisible while it does". Remedy reuses the pattern the sibling suite already has at tests/fm-no-mistakes-required.test.sh:16-19: a top-of-file command -v python3 &gt;/dev/null 2&gt;&amp;1 || { echo &#34;skip: python3 not found ...&#34;; exit 0; } so the first output line is the skip and the runner records gate_skip=true, replacing the per-case guards. No new machinery, no product behavior change.
  • ℹ️ tests/fm-no-mistakes-required-gate.test.sh:1037 - Test 16 is the only case that proves the assumption the whole change rests on - that the pinned verifier's verdict turns on what the helper wrote to GITHUB_EVENT_PATH - and it silently disappears when the network is unavailable: a curl failure echoes skip: mid-run and returns 0. Because that line is not the first non-empty output line, bin/fm-test-run.sh:1469 does not see a gate skip, so an offline run reports this suite green with the load-bearing case never executed. The sibling suite fetches the same file from the same ref and calls fail instead (tests/fm-no-mistakes-required.test.sh:28-34), so the repo's own convention for this fetch is hard-fail; a full sweep would be red anyway, but a change-selected run of this suite alone would not. Aligning line 1037 (and the curl-missing branch at 1025) with fail matches the established pattern and costs nothing when the network is up.

🔧 Fix: fail rather than skip when the pinned verifier is unreachable
3 issues (2 warnings, 1 info) still open:

  • ⚠️ .github/workflows/no-mistakes-required.yml:38 - The step comment (lines 36-39) says the helper is fetched at github.sha, "the pull-request merge commit ... so it carries whatever the base branch held", and tests/fm-no-mistakes-required-gate.test.sh:934 repeats it ("which carries the copy on the base branch; a PR head ref carries it only once that branch itself takes main"). That is inverted. On a pull_request event github.sha is the test-merge commit refs/pull/N/merge, whose tree is the PR head merged INTO base, so the contents API at that ref returns the pull request's own copy of .github/scripts/nm-required-refresh-event-body.py. The change in fact depends on this: the helper does not exist on main, so if the merge ref carried only base content the curl would 404 on this very PR and the refresh would be inert. So the ref choice is right and MUST NOT be changed to github.event.pull_request.base.sha - what is wrong is the recorded rationale, and it matters twice over. First, it is the sole justification given for the ref, so the next reader cannot check it. Second, it asserts the required check runs base-controlled code when the job actually downloads and executes PR-authored Python with GITHUB_TOKEN in the environment - the property the pinned action explicitly advertises it does not have ("Nothing here reads the repository contents, so a fork's code is never executed"), and the property the intent's "without checking out PR code" was protecting. This is not a new bypass (under pull_request the workflow YAML itself already comes from the merge ref, and the pinned verifier documents itself as a contributor guardrail rather than a security boundary), so the minimal remedy is to correct the comment and the test message to say the merge ref carries the PR's copy. Flagged ask-user rather than auto-fix because you may instead want to decide that executing PR-authored Python inside the required check is not acceptable, which is a design call and not mine to make.
  • ⚠️ .github/scripts/nm-required-refresh-event-body.py:131 - fetch_live_body catches OSError, http.client.HTTPException and json.JSONDecodeError around urlopen, then calls payload.get("errors") on whatever json.loads produced. json.loads succeeds on any valid JSON value, so a response body that is a JSON array or scalar - a proxy or GHES error page that is valid JSON but not an object - makes payload.get raise AttributeError, which is not a LiveBodyUnavailable and is caught nowhere. The helper exits non-zero with a traceback, the workflow step is under set -eu, and "PR must be raised via no-mistakes" reports failure with the pinned action never having run - strictly worse than the webhook-snapshot verdict this change was written to improve on, and the exact outcome the step comment at .github/workflows/no-mistakes-required.yml:41-44 promises cannot happen ("a live body that cannot be read leaves the webhook snapshot in place for the pinned action to judge rather than reddening the required check without a verdict"). Remedy is mechanical and stays inside the existing degrade path: after json.loads, if not isinstance(payload, dict): raise LiveBodyUnavailable(f&#34;unexpected response shape: {payload!r}&#34;), which routes it through the same per-attempt retry and snapshot fallback every other transport failure already uses.
  • ℹ️ .github/workflows/no-mistakes-required.yml:67 - The step comment states the refresh is best effort and must leave the webhook snapshot for the pinned action rather than red the required check, but the run block only honors that for the curl 404 branch. python3 &#34;$script&#34; under set -eu fails the step for any non-zero helper exit, and the interpreter resolution is narrower than the pinned action's own: action.yml at 32d396ac tries python3, then falls back to python, and only errors when neither exists, so a runner carrying python but not python3 would satisfy the pinned action while this new step reds the gate ahead of it. runs-on is ubuntu-latest today so the interpreter half is not reachable now, which is why this is info rather than warning; the general half is reachable through any unhandled helper exception (see the AttributeError path above) or an OSError rewriting the event payload. Mirroring the action's command -v python3 || command -v python resolution and letting a helper failure emit ::warning::live-body refresh failed; judging the webhook snapshot instead of failing the step would make the code match the contract the comment states. Note the tradeoff: swallowing the helper's exit code also hides genuine helper bugs behind a warning, so if you prefer a loud failure there, the honest fix is to narrow the comment instead.

🔧 Fix: correct the merge-ref rationale and annotate every degrade
1 info still open:

  • ℹ️ .github/scripts/nm-required-refresh-event-body.py:239 - The helper rewrites GITHUB_EVENT_PATH in place with open(path, &#34;w&#34;) + json.dump, which truncates the only artifact the required check's verdict is computed from before it has a replacement to write. If that write does not complete (ENOSPC on the runner, or the process dying between truncate and flush), verify.py's event_payload() swallows the JSONDecodeError and returns {}, so Facts.body becomes "" and check_signature reds a compliant PR with "This PR was not raised through no-mistakes" - a wrong verdict rather than the degrade the step promises, and one the step's if ! &#34;$PY&#34; &#34;$script&#34; guard cannot restore because the damage is already on disk. I could not construct a likely trigger on ubuntu-latest (job cancellation reports the check as cancelled, not red), so this is info rather than warning. The remedy is mechanical and stays inside the existing write: dump to a sibling temp file in the same directory and os.replace it over the event path, so a partial write can never be what the pinned action reads.
✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-no-mistakes-required-gate.test.sh - 18/18 pass (repeated 4x, no flakiness)
  • bash tests/fm-no-mistakes-required.test.sh - sibling pinned-action suite, 3/3 pass
  • Fail-before-fix check: ran the new suite against a temp checkout of base commit bb268932 - fails at test_refresh_replaces_stale_synchronize_snapshot because the helper does not exist there
  • gh-axi run view 33810709843 --repo HelloWorldSungin/firstmate --log - pulled the real failing synchronize run log and confirmed the executed error vs. the echoed run-script source
  • Browser capture of the real failing check-run annotations at github.com/HelloWorldSungin/firstmate/actions/runs/33810709843/job/100849798818 via chrome-devtools-axi
  • End-to-end job simulation bash evidence/e2e/run-e2e.sh - 5 arms: pre-fix synchronize (red), post-fix synchronize with mid-job body write (green after 16s), still-stale live body (real mismatch verdict), missing python interpreter (warning + verdict), unfetchable helper (warning + verdict)
  • Extracted the workflow's refresh step and the pinned action's composite step with PyYAML (evidence/e2e/extract-step.py) and executed both verbatim against the real verify.py fetched at 32d396ac
  • git show bb268932:.github/workflows/no-mistakes-required.yml | grep uses: vs target - confirmed the pinned action ref is unchanged and no copy of it was vendored
🔧 **Document** - 2 issues found → auto-fixed ✅
  • ℹ️ docs/fork-divergence.md:174 - The entry heading is still "Fork-local no-mistakes compliance-gate event scope", but the entry now records two separate divergences: the omitted edited trigger plus per-PR concurrency (2026-08-14) and the live-body refresh step and its fork-local helper (2026-09-04). The body states both and I left the heading alone deliberately: retitling or splitting into a second ledger entry is a curation call for the ledger's owner, and the ledger's convention is one entry per divergence with its own dated introduction and retirement condition. No in-repo link targets this anchor, so a split or rename would break nothing.
  • ℹ️ CONTRIBUTING.md:46 - This change adds .github/scripts/ as a new tracked directory holding shared material that must ship through the no-mistakes pipeline, but the three enumerations of shared tracked material (CONTRIBUTING.md:46 "Only shared material is tracked: ...", CONTRIBUTING.md:74, AGENTS.md:49) and the AGENTS.md layout tree do not name it. I did not add it because those lists already omit tests/ and docs/, which are equally tracked and equally gated, so they are evidently curated categories rather than an exhaustive tracked-path inventory; adding one path would deepen that inconsistency rather than fix it. The real fix is deciding whether those lists are exhaustive and reconciling all three plus the layout tree in one pass, which is a consolidation beyond this change's scope.

🔧 Fix: split the refresh ledger entry and record .github/scripts
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Sungin Kim and others added 9 commits September 4, 2026 01:20
A synchronize webhook, and a GitHub rerun of that job, carries the previous
head's attestation snapshot. Loading the live body before the pinned action
lets a fix-round rerun see the rebound attestation instead of failing as a
frozen mismatch or a missing signature.

Co-authored-by: Cursor <cursoragent@cursor.com>
@HelloWorldSungin
HelloWorldSungin merged commit 0f364f1 into main Sep 4, 2026
31 of 33 checks passed
@HelloWorldSungin
HelloWorldSungin deleted the fm/fm-required-check-python-missing branch September 4, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Required no-mistakes check errors with "python interpreter not found", producing a red that is not a verdict

1 participant