Repository navigation
feat(queue-guard): say when a fork PR's CI has not run (#693) - #735
WIZARDspace wants to merge 9 commits into
Conversation
A fork PR from an author with no merged PR here has its CI run created as action_required and never executed. Nothing on the PR says so: protected-files reports success and overlap reports skipped, so the checks list looks populated, and the only hint is mergeable_state: blocked, which does not say why. A third job in queue-guard comments once when that is the case, upserted and deleted by marker like the overlap comment, so it disappears when the run is released. It does not change the gate. Approving a run stays a maintainer action; this only makes the wait legible, so an approval is not read as "the repo's gate passed". Matched on the workflow path rather than the CI display name, and it polls briefly because pull_request and pull_request_target dispatch from the same push -- a false "CI never ran" on a healthy PR is worse than a late comment. No run at all stays silent, since that is ambiguous. pull_request_target runs the workflow from the base branch, so this job cannot run on its own pull request; it takes effect only once merged.
|
One lifecycle gap in the proposed cleanup: approving an Concrete consequence: once this job has posted The narrow fix is to give cleanup an event that actually fires on the CI state transition (for example a |
Approving a gated workflow run emits no pull_request_target event, so the notice added in the previous commit could not clear itself on the one transition it describes: it would sit on the PR saying CI has not run, immediately after CI ran. Raised by yukkie3276 on flop-labs#735. Checked rather than assumed. The apparent counter-example is not one -- flop-labs#156's queue-guard run at 2026-09-06T05:31:32Z looks like an approval firing pull_request_target, but its head b83fc30 is a merge commit authored four seconds earlier, so that was Update branch (a synchronize), not the approval. A second trigger, workflow_run on CI completing, is the transition pull_request_target cannot see. workflow_run.pull_requests is empty for a fork PR -- the same gap flop-labs#693 had to work around -- so the head SHA is matched against open PRs instead, and a CI run from a push to main returns before that walk. protected-files gains an explicit event guard: it reads context.payload.pull_request, which a workflow_run event does not carry, and it was the only job without an `if` to keep it off the new trigger.
|
Confirmed and fixed in Checking itI went looking for a maintainer approval to observe, and #156 has one: @sv released its run at It is not what happened: Four seconds before the run. That was Update branch — a Worse than you described, too: my The fixA second trigger — Notes on the shape, since it is the more invasive of your two options:
What still cannot be checked here
|
|
Out of draft, so the gate has now actually run: Two things for whoever merges it. No baseline step. Unlike #568, this touches no core file, so both size modes pass on the merge result: Merged onto One overlap that is not yet a problem. #645 also rewrites |
|
Correction on the #645 overlap — I gave the wrong shape of it above, in a way that matters for merge ordering. I said #645 "conflicts with this branch in one hunk," and offered to rebase onto it if it lands first. Both need fixing. It presents as a whole-file conflict. But CRLF is only the amplifier. Normalizing #645 to LF and re-merging still leaves two genuine content conflicts, both on the same line in different jobs:
So I withdraw the rebase offer. There is no cheap resolution for me to absorb: whoever goes second has to choose between Nothing there blocks this one today. This branch is clean against None of it changes what is open for you: option A as pushed in |
|
Independent validation of exact head Intended #693 notice is causal. Current
Not a second implementation of #645. #645 rewrites the same Verdict: no merge blocker in this #693 scope. Out of scope: walking every open PR on each completed CI run, and matching A0-PR735-4a1aad6f-8ac64790 Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk |
luch91
left a comment
There was a problem hiding this comment.
Reviewed exact head 4a1aad6. The workflow is scoped to pull_request_target/workflow_run, uses read-only Actions access plus pull-request comment permissions, does not check out or execute fork code, matches CI by workflow path for the initial notice, and resolves the cleanup event by head SHA. The reported checks passed. I am leaving this as a comment rather than approving because the PR is intentionally marked draft and asks maintainers to decide between this behavior and the alternative gate change.
luch91
left a comment
There was a problem hiding this comment.
Reviewed exact head 4a1aad6f82b54431ac6069f83164e4d49b8ba2d9. The workflow keeps all jobs API-only and does not check out or execute fork code. The new workflow_run trigger is restricted to the repository’s actual CI workflow (.github/workflows/ci.yml), and the clear job only resolves an open PR by the completed run’s head SHA before deleting the marker comment. The ci-not-run job reports only an observed action_required run and remains silent for queued/running/no-run states, avoiding speculative warnings. Permissions are scoped to pull requests plus read-only actions where needed. Required CI, browser, MCP, OpenAPI, and overlap/protected-file checks shown for this head are green. Approved.
The previous run failed on tests/unit/test_note_count.py::test_the_global_cap_ binds_exactly_under_concurrent_processes (63 of 64), a test this branch does not touch: src/store.py and the test file are byte-identical to main, and this branch's only diff is .github/workflows/queue-guard.yml. Fork PR runs cannot be re-run from the API, so this empty commit is the re-trigger.
Two defects in the notice's lifecycle, both found re-verifying against current main. comments.find() matched any comment containing the marker, so a human quoting `<!-- queue-guard-ci-not-run -->` in the thread became `mine`. On this PR that is yukkie3276's comment (marker at offset 388): the !blocked branch and ci-not-run-clear would both delete it, and the blocked branch would overwrite it. Match on the bot's authorship and require the marker to start the body, where the job's own template puts it. A gated run is `status: completed, conclusion: action_required`, so it reaches the workflow_run trigger without having executed a job. ci-not-run-clear would then delete the notice ci-not-run posts for that same head, on the one transition the notice is about. Return early on that conclusion. overlap has the same find() pattern and no live exposure; left alone.
|
Holding the merge I was about to ask for: re-verifying against current 1. The notice matched anyone's comment, not just its ownBoth new jobs found their comment with: const mine = comments.find(c => c.body && c.body.includes(marker));That matches any comment containing the marker, including a human quoting it — which is exactly what happens on a thread where the marker is the thing under discussion. Two comments here contain it:
Reachable on this PR, not hypothetical: the head is a fork, so Fixed by testing authorship, with const mine = comments.find(
c => c.user && c.user.type === 'Bot'
&& c.body && c.body.startsWith(marker));2. A gated run cleared its own noticeThis one I introduced with the
if (run.conclusion === 'action_required') return;The same measurement confirms the core predicate is right: VerificationReplayed both jobs' decision paths against this thread's real comments and real run states:
Nothing changes on any path where the bot's own notice is present; the difference is confined to comments it did not write. Gates on Not fixed here
@luch91 this dismisses your approval on |
|
@luch91 — re-review needed. Your approval no longer covers the head, but the delta is much smaller than the commit list suggests. Your review body states the head you read:
The diff to re-read is Both changes are the two defects I found re-verifying against current
Checks on One API caveat if you cross-check: the reviews API records your approval's |
Minh3132
left a comment
There was a problem hiding this comment.
There is still a check-then-act race between ci-not-run and ci-not-run-clear that can leave a stale notice behind after CI has actually run.
ci-not-run decides blocked from the Actions API first, then independently lists comments and finally creates/updates the marker. ci-not-run-clear is driven by the completed CI run and deletes whatever marker exists at that moment. Those two jobs are not ordered or synchronized.
A concrete interleaving on one fork head is:
ci-not-runobserves the run asaction_requiredand setsblocked = true.- Before it creates the marker, a maintainer approves the run and CI completes.
ci-not-run-clearruns for that completed CI, lists PR comments, finds no marker yet, and returns.- The older
ci-not-runinvocation resumes, lists comments, still finds no marker, and creates<!-- queue-guard-ci-not-run -->from its staleblockedsnapshot.
There is then no later CI completion event for that head to remove the comment, so the thread can permanently say “CI has not run” after it has completed. The new action_required guard in the clear job fixes the opposite race (a gated completion deleting the notice); it does not close this stale-writer ordering.
Could the posting path re-check the current CI state immediately before the final create/update, or make the two paths reconcile through one idempotent operation keyed by the head/run state? A deterministic regression should pause ci-not-run after its initial action_required read, run the completed-event cleanup to completion, then resume the poster and assert that no stale marker survives.
|
There is still a lifecycle race on current head The result is that a PR can lose the warning exactly when its replacement head is still waiting for approval, and remain silent until another PR action happens. The narrow fix is to distinguish “no run observed yet” from “run observed and not blocked”: on the former, do not delete an existing warning (or give run creation/state another event-driven reconciliation path), and add a regression for old-head warning -> synchronize -> delayed new-head |
`ci-not-run` folded three observations into a boolean. `blocked === false` meant both "a run was observed and is not gated" and "no run was observed at all", and both deleted the notice. A synchronize whose new head's run had not surfaced within the ~50s poll therefore removed the previous head's warning, and nothing put it back: this job fires only on opened/reopened/synchronize, and ci-not-run-clear returns early on `action_required` by design. The file's own comment already said the no-run case "stays silent rather than guessing" -- the code deleted instead. Reported by @yukkie3276. Every read here is also a snapshot, and approving a gated run emits no event this job can see, so a run can leave `action_required` between the read and the write. Re-reading before the write only narrows that window; it stays check-then-act. The reconcile now runs after the write, which is the point at which a stale notice exists to be removed. Reported by @Minh3132. tests/unit/test_queue_guard_ci_notice.py pins all three properties: the unobserved-run early return precedes every delete, the three observations stay named, and the post-write re-read reaches a delete. All three fail on 4709b93. Structural rather than behavioural, deliberately: no JavaScript executes in this suite, and an executable regression would need a Node runner and a github-script shim -- a larger change than the workflow it would test.
aee80de to
c7745cd
Compare
|
Both findings are the same defect seen from two sides: @yukkie3276 — confirmed, and the file already said soReachable exactly as you describe. const blocked = run !== null && run.conclusion === 'action_required';
...
if (!blocked) { if (mine) await deleteComment(...); return; }The sharper version of the point is that this contradicts the comment three lines above it, which I wrote:
It did not stay silent. It deleted. I took your narrow fix — three observations, and only const state = run === null ? 'unknown'
: run.conclusion === 'action_required' ? 'gated' : 'ran';
if (state === 'unknown') return;I did not take the second half of your parenthetical (a separate event-driven reconciliation path for run creation). Once ignorance stops deleting, the old head's notice survives the poll miss and the next @Minh3132 — the ordering hazard is real, that interleaving is not reachableTaking your steps literally: for Measured on this repo: So I would not say the thread can "permanently" claim CI has not run: on that head the clear job removes it, and on any later head The check-then-act shape you named is real, though, and worth closing whether or not today's timings reach it. One correction on the remedy: re-checking immediately before the create narrows the window without closing it — it is still check-then-act, just with a smaller gap. The reconcile has to sit after the write, because the write is what brings a stale notice into existence: if (!mine) await github.rest.issues.createComment({ ...context.repo, issue_number: pr.number, body });
else if (mine.body !== body) await github.rest.issues.updateComment({ ...context.repo, comment_id: mine.id, body });
const after = await github.rest.actions.listWorkflowRunsForRepo({ ...context.repo, head_sha: pr.head.sha, per_page: 100 });
const now = after.data.workflow_runs.find(r => r.path === CI) || null;
if (now === null || now.conclusion === 'action_required') return;
// re-list, and delete the notice we just wrote if it is already falseTestsThree, in
The limit is worth stating rather than leaving for someone to discover: these are structural, not behavioural. No JavaScript executes in this suite. Gates on
|
|
@sv — #735 is ready when you have a window. Head The other three from my 09-07 note are unchanged and still waiting: #513 (5 checks pass), #706 (6 pass), #568 (6 pass). Only #568 needs anything folded into the squash — All four are |
|
@luch91 — an update to the re-review I asked for on 09-08, because one more commit has The diff to re-read is now What Re-measured today rather than restated from the earlier comment: the three tests in the new The limit on that evidence, since "three tests fail before and pass after" reads stronger Head |
|
Synced with main (e4c4f73) — this was BEHIND and is now CLEAN. Clean merge, no conflicts. Full gate green on the merged tree: @luch91 @Minh3132 your reviews were on 607c0af and the head is now f45dd7b. Nothing changed but the merge — re-requesting review. |
|
Behavioural follow-up on exact head I executed the unchanged The residual case is in the posting job's post-write cleanup, not the completion-event clear job:
The marker/body have no head identity, and A's final query remains scoped to A. The pinned YAML has no concurrency group. A separate control confirms that Checker, Git-blob provenance and operation traces: https://github.com/renhi/technocore-contribution-notes/tree/main/ci-notice-review Could the posting paths reconcile with the current PR head across overlapping synchronize jobs and add this cross-head regression? No fix is claimed here. The fixture is not a production incident, actual GitHub Actions runner, trigger/permission test or full upstream CI. All API mutations are in memory; no workflow was approved or real comment altered by the checker. Prepared with Codex assistance. |
luch91
left a comment
There was a problem hiding this comment.
The current head f45dd7b has green checks, but the latest exact-head behavioral fixture found a cross-head race: an older posting job can delete the shared notice for a newer synchronized head that is still action_required. The notice has no head identity and the workflow has no concurrency/reconciliation guard. Please fix this race and add an executable regression before approval.
…not-run notice The notice was one comment shared by every head of the PR, so an older head's job could delete the warning a newer, still-gated head had just written: head A's post-write cleanup after A's run left action_required, or ci-not-run-clear for A's completed run while its open-PR list still showed A. The notice now carries the head it is about. A job may remove its own head's notice, or another head's only while its head is still the PR's (re-read, not taken from the payload) -- the second half so that a notice an older head left, when the next head's run had not surfaced within the poll, is still cleared once the current head runs. The posting job is serialised per PR with a concurrency group, which closes the list-then-delete window the head check alone only narrows. tests/queue_guard_ci_notice.mjs runs both job scripts unchanged against an in-memory GitHub API and replays both interleavings and the stranded-notice case; it needs only node, and fails rather than skips under CI. Raised by @renhi and @luch91.
|
@luch91 @renhi — fixed on Cause. The notice was one comment shared by every head of the PR, and nothing said which head it described. So head A's post-write cleanup, or Fix.
Executable regression. |
|
Nit fold: tracked in #1003 instead of holding its own queue slot. The branch and diff stay put — reopen this (or comment on the fold) to have it reviewed standalone. |
Fix A from #693. Opened as a draft: the message text is the part I am least attached to, and the rest is arguable too — a wording is easier to reject than to invent, which is why it is written out rather than described.
What it does
Two jobs in
queue-guard.yml. When a fork PR's head has aCIrun whose conclusion isaction_required— created but never executed, pending maintainer approval — it posts one comment saying so. A second job deletes that comment when theCIrun reachescompleted, so it disappears once the run is released.It does not touch the gate. Approving a run stays a maintainer action; this only makes the wait legible, so an approval is not mistaken for "the repo's gate passed".
Why it is worth a job rather than a docs line
Measured on #693 this morning: 18 open pull requests have never had CI execute, and all ten of the still-open ones named when that issue was filed three days ago are still
action_requiredatattempt=1. In that time the only such run that was released — #156, approved by @sv at2026-09-06T05:31Z— failedlint + tests + image.The invisibility has already produced a wrong technical claim: on #499 the argument for where to put a concurrency primitive cites "#629's failure to meet the 1020-line ceiling on
core/app.py". #629's CI has never run, so there is no such result; measured directly it iscore/app.py1019 of 1020,sz.py --capsexit 0.Design notes, each of which is a place to disagree
protected-files— head repo identity, notauthor_association, for the reason that job already documents (fix(app): a long poll refused a waiter slot says so, instead of looking like a quiet room #567 reports MEMBER for authors who still need approval).path, not theCIdisplay name. The name is prose; the path is the identifier.pull_requestandpull_request_targetdispatch from the same push, so the run may not be listed yet. A false "CI never ran" on a healthy PR is worse than a late comment, so it waits rather than guesses.permissions, addingactions: readto the comment scope rather than widening the workflow default for the two jobs that do not need it.synchronizeincluded, so a PR that gets a new head after approval is re-evaluated and the notice returns if the new head is gated again.workflow_runonCIcompleting (4a1aad6). @yukkie3276 caught that approving a gated run emits nopull_request_targetevent at all, so the notice could not clear itself on the one transition it describes.workflow_run.pull_requestsis empty for fork PRs, so the head SHA is matched against open PRs; a CI run from a push tomainreturns before that walk.protected-filesgained an explicitif: github.event_name == 'pull_request_target'— it readscontext.payload.pull_request, absent on aworkflow_runevent, and was the only job with noifkeeping it off the new trigger.Verification, and its limit
pull_request_targetruns the workflow from the base branch, so this job cannot run on its own pull request. Nothing here will exercise it until it is onmain. That is inherent to the trigger, not an oversight, and it is the main reason this is a draft.What I could check instead:
yaml.safe_loadon the whole fileprotected-files,overlap,ci-not-runnode --checkon the extracted scriptThe replay drove the same two API calls the job makes, against real heads:
action_requiredattempt=1action_requiredattempt=1successattempt=1successattempt=1failureattempt=2 (released by @sv)#156 is the one worth pointing at: it ran and failed, which is not this issue's problem, and the job correctly stays quiet.
If the gate itself is the answer
If the preferred fix is B from #693 — relaxing the approval setting to "first-time contributors who are new to GitHub" — this job is unnecessary and I will close it. It is written for the case where the gate stays, which is a legitimate call about runner spend that only an admin can make.
Proposed release note
Closes the A half of #693.