Skip to content

fix(pr-feedback-dispatch): defer a verify verdict the kill switch stops - #11221

Merged
kyle-sexton merged 11 commits into
mainfrom
fix/defer-verify-verdict-on-kill-switch
Oct 30, 2026
Merged

kyle-sexton merged 11 commits into
mainfrom
fix/defer-verify-verdict-on-kill-switch

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

No related issue: a pr-verify verdict that finished during the 09:23-09:37Z kill-switch trip was dropped (#11186 kept a stale pr-verify-failed label)

Summary

While the lanes kill switch was on, pr-feedback-dispatch.yml's post-verify-notes job skipped its work and still went green. A pr-verify verdict that finished during a trip was therefore dropped, not deferred: a PASS kept a stale pr-verify-failed label, and a FAIL posted no notes and added no hold label, which the merge gate depends on.

Fix

This reuses the existing lost-run reconciler (maintenance-reconcile-lost-runs) and the record pr-verify already uses on the kill switch. No new store or workflow is added.

  • post-verify-notes now fails at a Stop on the kill switch step, before any read, as pr-verify.yml does on the switch. That failed first attempt is the record of the pending verdict. It costs no API call and no artifact.

  • reconcile.mjs gains a Verdict kind. It picks a pr-feedback-dispatch.yml run that meets all of these:

    • it is at attempt 1;
    • its only failed job is post-verify-notes;
    • the only failed step in that job is VERDICT_STOP_STEP.

    The reconciler re-runs that run's failed jobs once, over the full lookback, and the re-run takes no place under MAX_IN_FLIGHT. verify-notes.mjs posts only what is missing, so a re-run never posts twice.

  • Safety limits kept. The reconciler reads nothing while the switch is on (KILL_SWITCH), and the attempt number is the once-only record. A job that failed at any other step, such as a refused dequeue or a verdict name no reader takes, is left for a person.

  • The dispatch job's gate skips a pr-verify run re-run by github-actions[bot] at attempt 2 or later. check-trusted-trigger trusts a dispatcher only at attempt 1 or when a listed human re-ran it, so without this skip the re-run would send a round the lanes refuse.

  • Only a verdict-bearing upstream is recorded. The Stop step fails only when the pr-verify run succeeded. While the switch is on, every pr-verify run fails at its own kill step and holds no verdict (pr-verify.yml:110-117; a FAIL verdict does not fail the run, only "Fail without a verdict" does). The reconciler's Lane kind already re-runs such a run, and that completion starts this workflow again.

  • Lanes App rounds. On a lanes App PR, the re-run uploads a pr-feedback-deferred-<head>-<fail|pass> record. On a later idle tick, recoverLost calls recoverDeferred first:

    • It reads the record by exact name for each open lanes App head.
    • It checks that the uploading run is a github-actions[bot] re-run of pr-feedback-dispatch.yml on main, because any workflow can upload that name.
    • It sends the round through dispatchFeedback, as main() would for an on-time verdict. A FAIL gets a normal round, with notesSince set to the record's upload time (when the notes reached the PR). A PASS gets a pass-only round that resolves the stale fail-note threads.
    • A pr-unblock run for the PR created after the record holds it, so each record is sent once.
    • A record whose read fails, including on a rate limit, is logged and left to the next tick, and lost-run recovery still runs.
  • No new trust. The tick is an attempt-1 dispatcher, and its dispatch record names the head's newest review run as the upstream, as the existing sweeps do. No trust path or token scope is added, and check-trusted-trigger's attempt rule is unchanged. The record keeps for 1 day (artifact-retention.json entry added).

Limits

  • Lookback. A trip longer than LOOKBACK_HOURS (24 h) still drops the verdicts created before the window. The Switch kind avoids this because it reads each PR's newest run with no lookback.
  • One delivery attempt. A deferred verdict gets one round. If that round is refused or fails, this path does not send it again.
  • A late PASS can race a newer FAIL. A deferred PASS applied after the lift can arrive after a newer FAIL at the same head and resolve fail-note threads from earlier heads. A FAIL at the same head is not touched, because staleVerifyNotes resolves only notes from other heads.
  • Delay on a busy tick. A deferred round goes out only on a tick where the released-heads sweep sent nothing, the same rule recoverLost follows.

Verification

  • Red: before the fix, reconcile.test.mjs failed one case: "a verdict the kill switch kept from its PR is applied once the switch lifts". The file ran 1 fail and 105 pass.

  • Green: after the merge of main, reconcile.test.mjs runs 107 pass, 0 fail. The whole maintenance-reconcile-lost-runs package runs 133 pass, 0 fail.

  • Red, review fixes: before the fixes, feedback-dispatch.test.mjs failed 4 cases (162 pass):

    • a deferred FAIL is sent though a round ran after the pr-verify run but before the notes;
    • a deferred PASS gets its pass-only round;
    • a record is found by name with 100 unrelated runs in the window;
    • one unreadable record does not block the next head.

    workflow-gates.test.mjs failed 2 (30 pass):

    • the Stop step fails only for an upstream that succeeded, so a pr-verify run its own switch stopped is not re-run;
    • the workflow's bash name builder matches DEFERRED_RECORD.
  • Green: feedback-dispatch.test.mjs 166 pass, workflow-gates.test.mjs 32 pass, reconcile.test.mjs 107 pass. The forged-upload cases send nothing: another workflow, a pull_request run, attempt 1, a person's re-run, another repository, an expired record.

  • Unchanged suites: check-trusted-trigger.test.mjs 370 pass, callers.test.mjs 205 pass.

  • Retention: scripts/check-artifact-retention.sh --check passes.

  • New reconcile cases:

    • zero calls while the switch is on;
    • no re-run for a failure at another step, a failed dispatch job, another job name, attempt 2, a run past the lookback, or an empty job list;
    • no re-run when the run was already re-run since the listing;
    • a pin that the workflow step sits between Check the kill switch and Download the verdict, with exit 1.
  • workflow-gates.test.mjs: 30 pass. It pins that the reconciler's attempt-2 re-run by github-actions[bot] dispatches nothing and a person's re-run still does.

  • Other suites: log-api-budget.test.mjs 47 pass.

  • actionlint is clean on pr-feedback-dispatch.yml.

  • check-affected: CHECK_DATA_ROOT=$PWD bash scripts/check-affected.sh --tests printed check-affected: 10 passed, 6 skipped over 7 changed files since b6dcb4aa.

Metrics

GITHUB_TOKEN reads per tick and per reconciler pass. They are counted from the code paths, not measured on GitHub.

  • N is the number of open lanes App PRs.
  • R is the number of github-actions[bot] re-runs in the 24 h window.
  • F is the number of failed pr-feedback-dispatch runs in the 24 h window.
Path main 718ba0e This head
Idle tick, recovery part (recoverLost) 1 run listing 1 + R artifact listings 1 run listing + 2N exact-name artifact reads. The open-PR listing is shared with the sweep, so it adds 0.
Tick that finds a record none +4 (PR, run listing, 2 review listings) + dispatchFeedback +5 (uploading run, run listing, 2 review listings) + dispatchFeedback
Reconciler pass after a trip 0 1 listing + 1 jobs read per failed run (each killed pr-verify run added one, up to 500) 1 listing + 1 jobs read per failed run whose upstream succeeded
Reconciler pass, steady state 0 1 listing + F jobs reads 1 listing + F jobs reads

Related

🤖 Generated with Claude Code

kyle-sexton and others added 7 commits October 30, 2026 05:48
post-verify-notes skipped its work and went green while the lanes kill
switch was on, so a pr-verify verdict that finished during a trip was
dropped: a PASS kept a stale pr-verify-failed label, and a FAIL posted no
notes and no hold label.

The job now fails at a "Stop on the kill switch" step before any read, as
pr-verify does. That failed first attempt is the record of the pending
verdict. The lost-run reconciler, which reads nothing while the switch is
on, gains a Verdict kind: a pr-feedback-dispatch run at attempt 1 whose
only failed job is post-verify-notes, failed only at that step, has its
failed jobs re-run once, and verify-notes.mjs posts what is missing. The
re-run's dispatch job sends no round, since the lanes trust a dispatcher
only at attempt 1 or re-run by a listed human.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dispatch job's gate now reads github.run_attempt and
github.triggering_actor, so the gate evaluator's contexts carry both, and
a case pins that the reconciler's re-run of a stopped verdict, by
github-actions[bot] at attempt 2, dispatches nothing while a person's
re-run still does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reconciler's re-run of a kill-switch-stopped post-verify-notes job
posts a FAIL's notes, or finds a PASS's stale fail-note threads, on a
lanes App PR, but sends no round: check-trusted-trigger trusts a
dispatcher only at attempt 1 or re-run by a listed human.

That re-run now uploads a pr-feedback-deferred-<head>-<fail|pass>-<ms>
record naming the head, the verdict and the pr-verify run's creation
time. The half-hourly tick, an attempt-1 dispatcher, reads it in
recoverLost's existing run listing (recoverDeferred) and sends the round
through dispatchFeedback as main() would have: a FAIL with notesSince
set to the pr-verify run's creation, a PASS as a pass-only round. A
pr-unblock run for the PR created after the record holds it, so each
verdict is sent once. No new trust path or token scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ctless runs

Review of #11221:

- post-verify-notes fails at the kill switch only for a pr-verify run
  that succeeded. Every pr-verify run fails at its own kill step while
  the switch is on and holds no verdict; the reconciler's Lane kind
  already re-runs it, so recording it here only queued empty re-runs.
- recoverDeferred reads the record by exact name for each open lanes
  App head (pr-feedback-deferred-<head>-<fail|pass>) instead of the
  24 h run listing, whose single page a busy window or a re-run's old
  created_at pushed the record off. It checks the uploading run is a
  github-actions[bot] re-run of pr-feedback-dispatch.yml on main, since
  any workflow can upload that name.
- notesSince is the record's upload time, when the notes reached the PR.
- A record whose read fails is logged and skipped; lost-run recovery
  still runs. The tick lists open PRs once for every sweep.
- A test runs the workflow's name builder against DEFERRED_RECORD.

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

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 ⚠️ Failed 2026-10-30T10:24:50.992148Z
We couldn’t complete this review. Comment @codex review to try again.
ae6709a 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Incremental security review of .github/workflows/pr-feedback-dispatch.yml since ae6709a: no security findings.

The change reflows the Name the deferred verdict step's if: onto a single line, adds a comment, and adds # zizmor: ignore[bot-conditions]. The condition is the same as before: run_attempt != '1' && triggering_actor == 'github-actions[bot]' && (head-sha != '' || pass-head-sha != '').

I checked the comment's claim against the code. feedback-dispatch.mjs:812 requires run.triggering_actor?.login === "github-actions[bot]", and line 837 skips any record that was not uploaded by a github-actions[bot] re-run of this workflow on main. So the step's actor test only saves a write. A spoofed record name can't cause a round to be sent.

The zizmor suppression is advisory-lane noise, and the trust boundary doesn't rest on it. The trusted-path match on this workflow is not a finding. No token scope, trusted-actor list, kill-switch logic or merge hold changes in this increment.

critical-findings: 0

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed a29db25d2303e8607372b92c108078a71a20c30d: 0 finding(s), 0 as inline comments.

Incremental review of .github/workflows/pr-feedback-dispatch.yml since ae6709a. I found nothing to flag.

The change to the Name the deferred verdict step is behavior-neutral:

  • Condition: The folded multi-line if: >- becomes a single-line if: with the same three clauses: run_attempt != '1', triggering_actor == 'github-actions[bot]', and a non-empty head-sha or pass-head-sha.
  • zizmor suppression: It adds # zizmor: ignore[bot-conditions]. That is the only use of that rule ID in the workflows, and the new comment explains it.
  • Comment claim: The comment says recoverDeferred re-reads the uploading run through the API and drops a record whose triggering actor is not github-actions[bot]. I checked this against .github/scripts/pr-unblock/feedback-dispatch.mjs:806-839. deferringRun requires triggering_actor.login === "github-actions[bot]", run_attempt > 1, event === "workflow_run", head_branch === "main", this workflow's path, and this repository. A record from any other run is skipped. The workflow-level actor test is therefore only an optimization, and the real trust check sits in the consumer.
  • Tests: workflow-gates.test.mjs finds this step's script by looking for the run: | line. It does not parse the if: gate, so the reformatting breaks neither it nor the test of the gate at the dispatch job.

Trusted-path scrutiny: the step only names a one-day artifact and does no privileged action. I found no new security issue. Nothing adds spend, so there is no hold.

kyle-sexton and others added 4 commits October 30, 2026 06:49
…ts condition

zizmor bot-conditions flags a github.triggering_actor name comparison in an
if: as spoofable. The step now reads the actor from env and exits quietly
unless it is the reconciler's github-actions[bot] re-run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ust check

zizmor bot-conditions flags the github.triggering_actor name test as spoofable. It only saves a write: recoverDeferred re-reads the uploading run and drops one not triggered by github-actions[bot]. The step keeps the test in its condition with a cited ignore rather than hiding it in shell.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit b7019ef Oct 30, 2026
47 checks passed
@kyle-sexton
kyle-sexton deleted the fix/defer-verify-verdict-on-kill-switch branch October 30, 2026 11:10
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.

1 participant