Skip to content

fix(pr-pipeline): post fix-docs's check on the head it ran on when the PR moves mid-run - #9223

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/w9207-superseded-verdict-neutral
Oct 22, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/w9207-superseded-verdict-neutral

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #9207

Summary

When the PR head moved while pr-unblock's fix-docs ran, its report job posted failure on the new head, and the guardrails merge guard refused the merge until someone re-dispatched by hand. Example: on #9201, fix-docs run 39857913086 gated 2f0697ef, the head moved to 6aed779a, and check 120101945136 posted failure on 6aed779a.

Root cause. The fault is in the head the check is posted on, not in decide.mjs. The fix-docs and fix-docs-subscription calls in .github/workflows/pr-unblock.yml passed no head-sha. The run is a workflow_dispatch, so it has no event head either. The read report job's "Choose the head the check is posted on" step (.github/workflows/pr-run-activity-read.yml) then trusted only the PR head it read from the API at report time. Any push mid-run made the run's own head look forged, so the step set forged=true, which forces run-result: failure and posts on the API head. decide.mjs:107-115 only supplies the message text. The report job log for that run shows:

RUN_HEAD: 2f0697efb5090661affeffbef6b705cfdbc56e64
CALLER_HEAD:
EVENT_HEAD:
API_HEAD: 6aed779a813c933a832bea77bfb1e0fbd8179e18
##[error]the run job's head-sha or pr-number is not the gated PR's; failure is posted on the trusted head 6aed779a…
report-check-run: posted pr-unblock / fix-docs failure on 6aed779a…

fix-ci is not affected, because both of its calls already pass fix-ci-context's head.

Fix

  • A new fix-docs-head job in pr-unblock.yml reads the PR head over the API. It runs no head code and holds only pull-requests: read. Both fix-docs calls pass that head as head-sha, the same way fix-ci uses fix-ci-context. When the head moves mid-run, the run's head matches the gated head, so the check posts the run's real outcome on the head it ran on. The new head gets no stale check.
  • The report step's trust logic is unchanged: a run head that matches no gated head still posts failure.
  • Docs: pr-run-activity.md and the head-sha input description name fix-docs-head. Changelog fragment under .changes/pr-pipeline/.

The fix lives in the caller rather than in decide.mjs because the verdict's head-sha is the same value the run job can forge. decide cannot tell a superseded head from a forged one, and turning that mismatch neutral would also turn real forgery neutral. Posting on the run's own head is the "posts on its own head only" option in the issue's direction.

How this maps to the Done-when items.

  • Superseded verdict. It posts its real outcome on its own head rather than neutral on the new head. The merge guard reads check runs only on the PR's current head (plugins/guardrails/hooks/block-unresolved-pr-merge.sh:675, :709) and blocks only on a completed failing conclusion (:759), so a check on an older commit, or a missing one, does not block.
  • Genuine mismatch. A foreign run head still posts failure. The new test covers this.
  • Tests. They live in .github/actions/resolve-config/callers.test.mjs, beside the other pr-unblock caller-contract tests, and not in report-check-run/, because the defect is in the caller and the head step.

Two limits, both unchanged by this PR.

  • fix-docs runs once per PR by design. fix-docs-dispatch.mjs:186-189 skips any PR whose earlier commit has a pr-unblock / fix-docs check, so the new head does not get its own fix-docs run, before or after this change.
  • fix-docs-head reads the head before fix-docs waits in the pr-pipeline-write-<pr> queue. If the head moves in that window, the run gates a newer head. The step then treats it as forged and posts failure on the older, gated head, never on the current head, so the merge is not blocked. fix-ci-context has the same window.

Verification

  • New test pr-unblock.yml: a read activity whose PR head moved mid-run posts on its own head, never on the new one. It runs the report job's head step, lifted from the YAML, with each pr-unblock read-call's head-sha and an API head that moved. It failed before the fix (fix-docs passes the head a base job read: actual '') and passes after. A foreign run head still yields forged=true.
  • Updated two existing assertions that pinned the old no-head-sha behavior for fix-docs.
  • node --test in .github/actions/resolve-config (callers.test.mjs): 97/97 pass. .github/actions/report-check-run: 100/100 pass. check-trusted-trigger, every .github/scripts/pr-unblock/*.test.mjs, and pr-merge/refire-refused.test.mjs: 0 failures.
  • scripts/read-runner-dispatcher-gate.test.sh (9/9), scripts/pr-unblock-trusted-base.test.sh (20/20), and the morning-brief suites (450 cases plus the view suite): pass.
  • actionlint is clean on both workflows. zizmor --offline on pr-unblock.yml reports no findings. runner-policy.mjs --root . passed.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits October 22, 2026 18:24
…e PR moves mid-run

fix-docs passed no head-sha, so the read report job's head step trusted
only the PR head it read at report time. A push while the run went made
the finished run's head look forged, and the step posted failure on the
new head, which blocked the merge until a hand re-dispatch (#9207).

A fix-docs-head job, running no head code, reads the PR head and both
fix-docs calls pass it as head-sha, as fix-ci does with fix-ci-context's.

Closes #9207

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 22, 2026 22:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T22:33:24.945712Z 6d25a48 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 41de6a76cb1ec497420d265b711d42be2d7a1993: 0 finding(s), 0 as inline comments.

Security review (incremental, 6d25a48 → 41de6a7)

No security findings. No manifest, instruction-surface or guardrail changes in this diff, so there are no manifest <field> lines. I read the five changed files and the whole "Choose the head the check is posted on" step in pr-run-activity-read.yml.

  • New post-decline input (pr-run-activity-read.yml):
    • It is a boolean workflow_call input that defaults to true, and the step reads it only through an env: variable. No expression is interpolated into the run: script, so there is no injection surface.
    • It is set only by trusted workflow YAML in pr-unblock.yml, never by PR content.
    • The step's logic is fail-safe. With false, it takes the same out "" false branch that the trusted-skip case already took. That branch posts no check, and the "Post the check run" step also guards against an empty sha off pull_request.
  • Effect on trust: the change only removes a neutral not-assessed check from fix-docs declines.
    • The step never posts failure or success on that path, and the forged-head branch (forged=true, failure on the trusted head) is untouched.
    • An attacker cannot turn a decline into an approval, and cannot use this to add a blocking check. The check is withheld, not forged.
    • The retry, which re-dispatches a fix-docs run that declined, depends on the existing once-per-PR dispatcher. The diff adds no new unauthenticated trigger. Whether that retry can loop is a cost and availability question, not an exploit path, so I did not report it.
  • Test, docs and changelog changes (callers.test.mjs, pr-run-activity.md, the .changes fragment) have no security surface.
  • Not consulted: the instruction exception register was not needed, since no standing instruction was deleted or narrowed.

Comment thread .github/workflows/pr-unblock.yml Resolved
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 41de6a76cb1ec497420d265b711d42be2d7a1993: 1 finding(s), 1 as inline comments.

Incremental review of 41de6a7 against 6d25a48. The change adds a post-decline input (default true) to the read runner. pr-unblock.yml passes false for both fix-docs calls, so a run that declines before its trigger gate posts nothing and the PR is dispatched again. The head-choice logic, the test additions in callers.test.mjs, the changelog fragment and the docs all agree with each other. I did not run the tests; I only read the diff and the code around it.

Finding (1, inline, unconfirmed risk): .github/workflows/pr-run-activity-read.yml:2560. A persistently declining PR has no retry bound. fix-docs-dispatch.mjs stops re-dispatching only when a pr-unblock / fix-docs check run exists or a markHandled record is set. Both come from observing a check run. A PR whose trigger gate declines every time now has no check run, so each dispatcher cycle starts another run, up to maxDispatch per cycle. Before this change the neutral not-assessed check ended that. I did not trace every decline path, so whether any is persistent is unconfirmed.

Checks that passed:

  • ${{ inputs.post-decline }} expands to the string false, which matches the shell comparison.
  • Off pull_request, an empty sha already posts nothing: the "Post the check run" step is skipped by its own if:.
  • The new test's expected values match the step's outputs for both post-decline settings.

Closing issue #9207: the issue's "Done when" asks for a neutral result from decide.mjs and tests in report-check-run/. The PR instead fixes the head the check is posted on, and explains why in its description. That design choice is for the owner to confirm.

…ispatched again

Passing fix-docs a caller head made the report job post neutral
not-assessed on it when the run stopped before its trigger gate, and the
once-per-PR fix-docs dispatcher then never retried the PR. The read
runner's new post-decline input (default true) is false for both fix-docs
calls, so a decline posts nothing, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 1e75ffd Oct 22, 2026
28 checks passed
@kyle-sexton
kyle-sexton deleted the fix/w9207-superseded-verdict-neutral branch October 22, 2026 22:48
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.

fix(pr-pipeline): report a pr-unblock verdict superseded by a newer head as neutral, not failure

1 participant