Skip to content

fix(ci): start the dispatch trust window at the Dispatch job's start - #18662

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/trusted-trigger-dispatch-window
Nov 24, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/trusted-trigger-dispatch-window

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Closes #18665
Siblings: #18661

Summary

verifyDispatcher bounds a dispatched run's created_at by min(dispatcher.updated_at, run_started_at + WINDOW_MS), 10 min. A pr-dispatch-feedback.yml run whose Dispatch job waits for a runner loses that window: on #18621 the dispatcher's Dispatch job waited 10m21s and dispatched 42 s after it started, 11m04s after the run started, and pr-unblock run 45299457551 was refused with untrusted-actor.

Fix

  • check-trusted-trigger.mjs: for a workflow_run dispatcher (pr-dispatch-feedback.yml), the 10-min cap now runs from the started_at of the dispatcher attempt's one started job named Dispatch, read through GET /actions/runs/{id}/jobs (one more read). started <= created against run_started_at and the updated_at bound are unchanged. A failed jobs read, or no started Dispatch job at the dispatcher's attempt (or more than one), refuses with untrusted-actor; there is no fallback to a wider window.
  • Unchanged: the push/schedule/workflow_dispatch dispatcher (pr-unblock-dispatch.yml) and the pull_request_target dispatcher (pr-merge.yml) keep the window from run_started_at; their dispatching job is not named as clearly, so they were left alone.
  • README: the workflow_run dispatcher section states the new window start.
  • The comment lint refused the rewritten comment on WINDOW_MS and the doc comment above verifyDispatcher, so both are deleted; their updated content is in the commit message.

Loosened checks

Newly accepted: a dispatch more than 10 min after the dispatcher run started but within 10 min of its Dispatch job's start (GitHub's started_at). Unchanged: the dispatcher workflow, branch and event, the record naming this run, the upstream checks, the updated_at bound. Forging it needs code running inside the default-branch dispatcher job. Seen: #18621, run 45299457551 (Dispatch queued 10m21s).

24 h counts: 1 of 45 runs past the window (#18621 run 45299457551; Dispatch queued 10m21s), which also needed PR A; B alone would have passed 0 runs, A with B passes all 3.

Verification

  • node --test .github/actions/check-trusted-trigger/check-trusted-trigger.test.mjs: 509 of 509 pass, with fix(ci): accept recorded reconciler re-runs in the dispatcher trust check #18661 merged in.
  • node --test .github/actions/resolve-config/callers.test.mjs (drives the gate's inputs through the action's main): 306 of 306 pass.
  • No changed export, so no importer suite beyond these; no shell changed.
  • New tests (check-trusted-trigger.test.mjs):
    • workflow_run dispatcher: the window runs from the Dispatch job's start, so a runner wait does not count (Dispatch job queued 10m21s, dispatch 42 s after its start)
    • workflow_run dispatcher: refused with untrusted-actor when ... the dispatch came 10m01s after the Dispatch job started, the jobs read fails, the dispatcher run lists no Dispatch job, the Dispatch job is still queued, the Dispatch job listed is of another attempt, the dispatcher run lists two started Dispatch jobs at its attempt, the Dispatch job listed is of another run, the Dispatch job has no start time, the dispatch came after the dispatcher run's last update
    • dispatcher: a push dispatcher's window still runs from its run's start and reads no jobs
    • workflow_run dispatcher: the captured jobs listing of a run whose Dispatch job queued 10m22s proceeds (fixtures/api-run-dispatcher-jobs.json is GitHub's jobs listing for pr-dispatch-feedback run 45297965850, steps dropped; the job fixtures spread its job objects)

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp

verifyDispatcher bounds a dispatched run's created_at by the earlier of
the dispatcher run's updated_at and WINDOW_MS (10 min) after its
run_started_at. A pr-dispatch-feedback.yml run whose Dispatch job waits
for a runner loses that window: on run 45299457551 the job waited 10m21s
and dispatched 42 s after it started, 11m04s after the run started, and
the gate refused it with untrusted-actor.

For a workflow_run dispatcher the cap now runs from the started_at of
the dispatcher attempt's one started job named Dispatch, read through
GET /actions/runs/{id}/jobs. created_at must still be no earlier than
run_started_at and no later than updated_at. A failed jobs read, or no
started Dispatch job at the dispatcher's attempt, refuses with
untrusted-actor; there is no fallback to a wider window. The push,
schedule and workflow_dispatch dispatcher (pr-unblock-dispatch.yml) and
the pull_request_target dispatcher keep the window from run_started_at.

The comment lint refused a rewrite of the comment on WINDOW_MS, so it
is deleted. It said the dispatcher dispatches within seconds of
starting, which holds only without a runner wait; the rule now is that
a dispatch must come within WINDOW_MS of the dispatcher run's start, or
of a workflow_run dispatcher's Dispatch job's start, so a runner wait
does not count, and a longer run must not keep its window open.

The lint also refused the doc comment above verifyDispatcher, so it is
deleted; the README's dispatcher section
states the same rules. Its content, updated: a dispatch sent by
github-actions[bot] names no human, so it is trusted only through the
dispatcher run it names: that workflow, on the default branch, started
by a push, a schedule or a listed human, its head SHA an ancestor of the
branch tip, a re-run attempt started by a listed human, its record
listing this run, and this run, the dispatched workflow on the default
branch, created between the dispatcher run's start and the earlier of
its last update and WINDOW_MS after its start (for a workflow_run
dispatcher, after its Dispatch job's start). A dispatcher started by
workflow_run must be runDispatcherWorkflow instead, and no actor of it
is checked: the upstream run its record names must be one of
runDispatcherUpstreams, run on pull_request in this repository, started
(and any re-run) by the lanes App or a listed human, at the PR's current
head or at expectedUpstreamHead with the PR at it or at pushedCommit
(upstreamHeadHolds). An upstream of runDispatcherRelay instead must have
run on pull_request_review_comment, name the PR among its pull_requests,
and be started (and any re-run) by a listed human, never the lanes App
(ADR 0088). A dispatcher started by pull_request_target vouches for a
pr-refine.yml run only: its head repository is this one, one
pull_requests entry names this PR on the default branch with base and
head in this repository and the run's head_branch as head ref, its actor
and triggering actor are the lanes App or a listed human, and the
ancestry check reads the commit its record names in place of head_sha
(ADR 0090). Returns this run's own record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 24, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Held for the owner: this changes check-trusted-trigger, a security control's mechanism (R388). Merge only on the owner's word; the question is in the GitHub Optimization away report.

Keeps the Dispatch job window code alongside #18661's merged reconciler
re-run path; both had deleted the same doc comment above verifyDispatcher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UJUn7MnPkm1aG9ivrZ2Enp
@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 24, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Owner decision recorded: https://github.com/melodic-software/architecture/blob/main/docs/owner-decisions.md#L381; verbatim "go w/ recommendations". Hold lifted.

@kyle-sexton
kyle-sexton marked this pull request as ready for review November 24, 2026 03:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T03:12:07.190325Z 12097fe 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12097fe4b2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… GitHub response

fixtures/api-run-dispatcher-jobs.json is GitHub's jobs listing for
pr-dispatch-feedback run 45297965850 (steps dropped), the run whose Dispatch
job queued 10m22s before pr-unblock run 45299457551 was refused. The Dispatch
and other-job fixtures now spread its job objects, and a new test replays the
captured listing with that run's real times. The capture corrects two
hand-built assumptions: the other job is named "Post Verify Notes", and a
skipped job reports status completed with a started_at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 964fbde76f174824fa614db144f43425bedcf589; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 219d474ebf923e9989eb207870d3f8a4ef5e3197: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #18662, incremental since 9d73328

I found no security issues. This lane already reviewed an earlier head, so this pass reported only blocking findings. I read every hunk of all 5 files in the incremental change.

What changed. Commit 219d474 moves three pieces from check-trusted-trigger.mjs into a new module, .github/actions/check-trusted-trigger/close-trust.mjs:

  • isTrustedClose
  • its helper appDoneClose
  • appCloseKind

Three files now import from the new module: admit.mjs, label-unblocked.mjs and the test file. check-trusted-trigger.mjs no longer imports the now-unused paginate.

Trust-control check. The trusted-trigger directory is a trusted path, so I compared the moved code line by line with what was removed. The logic is the same, with no change in who or what a close is trusted for:

  • (a) Listed human: the closer must match a listed human by id.
  • (b) Merge or commit here: the GraphQL closer must be a merged pull request or a commit in this same repository. The repository name is compared without regard to case.
  • (c) Lanes App close: a close by the lanes App counts only through appDoneClose. That path accepts only verified-done (through parentDone, which checks each child close again) or already-done (through doneEvidence). Any thrown error returns false.

One thing was renamed: the PR_NUMBER regex is now ISSUE_NUMBER. Both have the same pattern, /^[1-9][0-9]{0,9}$/, quoted from

and
const ISSUE_NUMBER = /^[1-9][0-9]{0,9}$/;
.

The non-test code that calls these functions is admit.mjs and label-unblocked.mjs. I searched for other non-test callers that still import isTrustedClose or appCloseKind from the old module and found none. The change adds no actor, token scope or untrusted input that the base blocked.

Embedded text: the PR context contains no directives aimed at the review.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 219d474ebf923e9989eb207870d3f8a4ef5e3197: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: isTrustedClose / appCloseKind move to close-trust.mjs

Blocking findings: none.

This lane already reviewed an earlier head, so this review reports blocking findings only.

Scope. This is an incremental review of the push since 9d73328. It covers 5 files, all on trusted paths, and I read every hunk:

  • check-trusted-trigger.mjs
  • check-trusted-trigger.test.mjs
  • the new close-trust.mjs
  • intake-triage/admit.mjs
  • work-unblock/label-unblocked.mjs

What changed. The push moves isTrustedClose, appDoneClose, appCloseKind and CLOSER_QUERY out of check-trusted-trigger.mjs into close-trust.mjs and repoints the three importers.

Checks I made by reading the source (I ran nothing; this lane has no shell):

  • Logic is unchanged. The moved functions match the removed ones line for line, including the trust order: listed human, then a merge or commit in this repository, then the App's close. The relative done-evidence.mjs dynamic import still resolves from the same directory.
  • Regex is identical. The new local ISSUE_NUMBER regex is the same as the PR_NUMBER regex it replaces (check-trusted-trigger.mjs#L11).
  • No leftover uses. paginate has no other use in check-trusted-trigger.mjs, so dropping it from the import is safe. PR_NUMBER is still used at L693 and L778.
  • No stale importers. A repository-wide search finds no remaining import of isTrustedClose or appCloseKind from check-trusted-trigger.mjs. The only callers are admit.mjs, label-unblocked.mjs and the test, and all three are repointed. check-wip-cap.mjs and the other modules that import admit.mjs pick up the new module through it.
  • Sparse checkouts still work. The workflows that check out the action's files sparsely (intake-triage.yml, pr-dispatch-feedback.yml, pr-review-hosted.yml, pr-review-security-hosted.yml, post-merge-test-mutation.yml) take the whole /.github/actions/check-trusted-trigger/ directory. The two pr-require-checks.yml lists that name check-trusted-trigger.mjs alone run no code that imports close-trust.mjs, and that file now needs fewer dependencies than before.
  • Merge-hold floor still covers it. The floor glob .github/actions/check-trusted-trigger/** matches close-trust.mjs.

Advisory, not posted. Two comments still say isTrustedClose lives in check-trusted-trigger: .github/scripts/lib/done-evidence.mjs:4 and docs/conventions/pr-pipeline/pr-run-activity.md:2498. Advisory findings are dropped in a blocking-only review, so this is neither posted nor counted.

Prior findings. None re-posted. The earlier advisory thread was handled in the previous round.

Closing issue #18665. This push is a refactor and does not touch the acceptance criteria.

Loosened checks. The prompt has no loosened_check_verdict: or loosened_check_patterns: lines, so I used fail with no consumer entries. There is no decision-record line either, so the citation requirement was not checked. This push loosens no check.

Spend: none in this push (refactor only).

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 2 commits November 23, 2026 22:20
…job, and no start time

Each new case refuses with untrusted-actor at a dispatch that the window
alone would pass. The first two fail when their filter term is removed; the
started_at guard is an equivalent mutant at the gate's output, since a NaN
window start already refuses in the window comparison, so its case pins the
refusal rather than the term.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check-trusted-trigger.mjs grew to 1012 lines, past the 1000-line size
reference. isTrustedClose and appCloseKind decide whether an issue close
counts, a concern separate from trigger trust that admit.mjs and
label-unblocked.mjs consume. They now live in close-trust.mjs, and those
importers and the test read them from there. check-trusted-trigger.mjs
gains no import, so the sparse checkouts that list it by name still load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 9e27b9c Nov 24, 2026
54 checks passed
@kyle-sexton
kyle-sexton deleted the fix/trusted-trigger-dispatch-window branch November 24, 2026 04:09
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check-trusted-trigger: accept recorded reconciler re-runs and time the dispatch window from the Dispatch job

1 participant