Skip to content

refactor(ci): run pr-dispatch-feedback's ci-status re-run from a tested script - #18438

Merged
kyle-sexton merged 5 commits into
mainfrom
refactor/dispatch-feedback-rerun-script
Nov 23, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
refactor/dispatch-feedback-rerun-script

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

No related issue: candidate 17 (part 1) of an /architecture:improve deepening pass over the CI lanes, run in a local session.

Summary

pr-dispatch-feedback.yml's "Find the ci-status to re-run" step carried 316 lines of stateful inline bash (polling, rate-limit waits, approval and reconciler checks). Its only test reached it by awk-extracting the step body out of the YAML.

Fix

  • The step's logic moves verbatim into .github/scripts/pr-dispatch-feedback/rerun-ci-status.sh. The step keeps its id, env and outputs and now runs bash .base/.github/scripts/pr-dispatch-feedback/rerun-ci-status.sh (the script sets -e); /.github/scripts/pr-dispatch-feedback/ joins the job's .base sparse checkout. The script runs only from the default branch's tip, the same base code the inline step was.
  • Behavior change in degraded mode only: when the default-branch checkout or its tip step fails, the find step now fails and re-runs nothing. Before, it re-ran ci-status unrecorded, and pr-verify refused that attempt anyway. No path now re-runs what it did not before.
  • The script wraps its gh calls with api_budget_wrap_gh, loading api-budget.bash from beside itself as report-escalation.sh does (api-budget-coverage.test.mjs requires it of a script). Its own budget() recorder and the step's API_BUDGET_SH env go, since the wrapper records each reading. The wrapper's rate guard also refuses a call before a recorded reset and annotates a 403 or 429; the script already sleeps until reset+1 before retrying, so its retries are unchanged on a real clock.
  • The reset time is printed with jq strftime in place of GNU-only date -d @; same value.
  • scripts/ci-rerun-ci-status.test.sh runs the script instead of the awk-extracted body and keeps every assertion.
  • Hold floor: the script is a gate row; sync-hold-floor.py regenerated its copies and the floor pins moved.
  • Not done: the five repeated Name/Scan/Record steps collapse only through a new composite action, which removes the record-N and scan-upload-N step ids workflow-gates.test.mjs:1516,1668 pins, so the result is not clearly smaller. pr-unblock-dispatch.yml repeats the same triple.

Reasons kept from deleted comments

  • A rate-limit wait fits only inside RATE_WAIT_SECONDS, counted with the poll's waits: twelve minutes fit the job's timeout, and the brake holds the pool a median 12 minutes (7 days to 2026-11-19). A wait past it fails the job naming the reset, since no other run re-runs a ci-status this job leaves stale; an extra attempt from two racing re-runs has no record, so pr-verify refuses it and the head is stranded for a person, never let through.
  • Polls are conditional GETs on the last 200's ETag; a 304 stands for that body, as request-budget.mjs does, and keeps its reading.
  • The run judged is ci-status's own choice: the newest pull_request run of the file on the head, never a fork's run at the same SHA. One head listing answers every file only when whole (the reconcile.mjs sharedRuns rule); otherwise each file's runs are read.
  • Only the lane that finished last re-runs ci-status (ties: higher run id).
  • The gate job is CI Status, else a pre-rename ci-status, never the alias: re-running the alias alone replays its old needs result.
  • ci-status's review-lanes step waits for a running review (REVIEW_WAIT_SECONDS), so a polled run's jobs are read again.
  • A lanes App PR's attempt-1 ci-status is left while the kill switch is on or unread: its re-run would fail and spend attempt 2, the reconciler's only re-run. An unread author counts as the App's, as ci-status reads it.
  • A re-run is recorded only for a first review attempt, a listed human's re-run, or the reconciler's (attempt 2, github-actions[bot] 41898282, accepted by reconciler-record.mjs): anyone with write access can re-run a review run, and the record vouches for the ci-status attempt it causes.
  • Only a listed person's approval, at relay attempt 1, re-runs ci-status: a relay re-run's triggering actor is the re-runner, not the reviewer.
  • The job's checkout is the default branch's, never the PR head: the find script, the trusted-actors list, the reconciler-record check, the api-budget library, the kill-switch check and the upload scanner.
  • A failed Node setup leaves the reconciler's review re-runs unrecorded.

Verification

  • scripts/ci-rerun-ci-status.test.sh: 325 pass, 0 fail. The step-env API_BUDGET_SH check goes with that env; the date stub now advances by the stubbed sleeps, as a real clock does, and the missing-library case runs a copy of the script with no library beside it. Breaking the script fails 52.
  • api-budget-coverage.test.mjs 5 pass with its expected list unchanged; scripts/check-shell-portability.sh origin/main clean.
  • Node suites that read this workflow: 2775 pass. Python floor suites OK (test_diff_risk skips 11 locally for missing PyYAML; CI installs it). Review-lanes shell suite 295 pass, dispatcher-gate suite 10 pass; shellcheck clean.

Related

Part of the .github deepening series; later parts move the other large inline steps.

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits November 23, 2026 00:23
The "Find the ci-status to re-run" step's inline bash moves to
.github/scripts/pr-dispatch-feedback/rerun-ci-status.sh, which sets -e as
the step's default shell did. The step keeps its id, env and outputs and
runs the default branch's copy from .base, added to the job's sparse
checkout. scripts/ci-rerun-ci-status.test.sh runs the script in place of
the awk-extracted body, keeps every assertion, and adds two: the step runs
.base's script, and the checkout carries its folder.

A failed default-branch checkout now fails the find step, so nothing is
re-run; before, ci-status was re-run unrecorded.

The script joins the hold floor as a gate row, like the workflow that
runs it; the generated copies and the floor pins follow.

Reasons kept from deleted comments:
- A rate-limit wait fits only inside RATE_WAIT_SECONDS, counted with the
  poll's waits: twelve minutes fit the job's timeout, and the brake holds
  the pool a median 12 minutes (7 days to 2026-11-19). A wait past it fails
  the job naming the reset, since no other run re-runs a ci-status this job
  leaves stale; an extra attempt from two racing re-runs has no record, so
  pr-verify refuses it and the head is stranded for a person, never let
  through.
- Polls are conditional GETs on the last 200's ETag; a 304 stands for that
  body, as request-budget.mjs does, and keeps its reading.
- The run judged is ci-status's own choice: the newest pull_request run of
  the file on the head, never a fork's run at the same SHA. One head
  listing answers every file only when whole (the reconcile.mjs sharedRuns
  rule); otherwise each file's runs are read.
- Only the lane that finished last re-runs ci-status (ties: higher run id).
- The gate job is CI Status, else a pre-rename ci-status, never the alias:
  re-running the alias alone replays its old needs result.
- ci-status's review-lanes step waits for a running review
  (REVIEW_WAIT_SECONDS), so a polled run's jobs are read again.
- A lanes App PR's attempt-1 ci-status is left while the kill switch is on
  or unread: its re-run would fail and spend attempt 2, the reconciler's
  only re-run. An unread author counts as the App's, as ci-status reads it.
- A re-run is recorded only for a first review attempt, a listed human's
  re-run, or the reconciler's (attempt 2, github-actions[bot] 41898282,
  accepted by reconciler-record.mjs): anyone with write access can re-run a
  review run, and the record vouches for the ci-status attempt it causes.
- Only a listed person's approval, at relay attempt 1, re-runs ci-status: a
  relay re-run's triggering actor is the re-runner, not the reviewer.
- The job's checkout is the default branch's, never the PR head: the find
  script, the trusted-actors list, the reconciler-record check, the
  api-budget library, the kill-switch check and the upload scanner.
- A failed Node setup leaves the reconciler's review re-runs unrecorded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dback-rerun-script

Generated hold-floor files take main's version, regenerated by
scripts/sync-hold-floor.py with this branch's rerun-ci-status.sh gate row.
Floor pins are main's counts plus that one gate row.

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

chatgpt-codex-connector Bot commented Nov 23, 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-23T12:57:10.629086Z b7f24e0 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 Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 6879c5e7f9bf3f51bf678f227aea08711adcc061: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental, blocking only): no findings

This lane already reviewed an earlier head (408d1e83), so this review looked only for blocking findings. I read the whole incremental diff. It covers one file, .github/scripts/pr-dispatch-feedback/rerun-ci-status.sh.

What changed since the last review

The rate-limit error message used to print the reset time with GNU-only date -u -d "@$reset" +%H:%M:%SZ. It now uses jq -rn --argjson t "$reset" '$t | strftime("%H:%M:%SZ")' instead (rerun-ci-status.sh#L72).

What I checked

  • $reset is always a plain integer when this line runs. The line runs only when wait is set.
    • In the Retry-After branch, reset is computed by shell arithmetic ($(date +%s) + 10#$after, L63).
    • In the x-ratelimit-reset branch, reset has already matched ^[0-9]{1,10}$ (L64).
    • So --argjson gets a valid JSON number in both cases.
  • Same output as before. jq's strftime on a number converts it with gmtime, so the time is UTC, as date -u printed it.
  • Failure mode. If jq failed here, the command substitution would print an empty time. The exit 1 on the next line still runs, so the job still fails as intended.

Spend: none. No runs, turns or schedules change.

Loosened checks: none found. The prompt had no loosened_check_verdict: or loosened_check_patterns: line, so I used fail and no consumer entries. It had no loosened_check_decision_record: line either, so I did not check the citation requirement.

Loosened checks would be marked: fail (bundled default); patterns: 0

Closing issue: none. The PR says it has no related issue.

The PR context file has no instructions aimed at the review lane.

I ran nothing myself. The test counts in the PR body are the author's claim and unverified.

Verifier dropped 0 of 0 candidates.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6879c5e7f9bf3f51bf678f227aea08711adcc061: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #18438 (incremental since 408d1e8)

I found no security issues. This lane already reviewed an earlier head, so this review was blocking only: it would have reported CRITICAL and IMPORTANT findings and dropped SUGGESTIONs.

Scope. I read the whole change since 408d1e8. It is one hunk in one file, .github/scripts/pr-dispatch-feedback/rerun-ci-status.sh, which matches a trusted path, so I also read the read_api function around it.

What changed. The rate-limit error message used to print the reset time with GNU date -u -d "@$reset". It now uses jq -rn --argjson t "$reset" '$t | strftime("%H:%M:%SZ")' (rerun-ci-status.sh#L72).

Injection. $reset reaches jq as a separate argument through --argjson, never inside the jq program text. That line can only run when wait is set, and wait is set on two paths only:

  • reset=$(($(date +%s) + 10#$after)), an integer computed after $after matched ^[0-9]{1,5}$;
  • a branch that first requires $reset =~ ^[0-9]{1,10}$ (L62-L66).

So a response header cannot get anything but digits into jq.

Control flow. The swap leaves control flow alone. The command substitution only builds the message text, and exit 1 on the next line still runs, so the job fails and re-runs nothing.

Trust controls. Nothing is widened. The diff touches no permissions:, if: condition, trusted-actor check, token request, kill switch or merge hold.

PR context. It contains no text aimed at the review lane.

Spend. None: the change starts no billed resource.

critical-findings: 0

kyle-sexton and others added 2 commits November 23, 2026 08:07
As a script run as its own process, it now sources api-budget.bash beside
it and calls api_budget_wrap_gh, which the api-budget coverage test counts
and which records each reading itself, so the hand-rolled budget() and the
step's API_BUDGET_SH input go. The test's clock advances with each stubbed
sleep, so the wrapper's rate stop lifts once the script waits out a reset,
as it does on a real clock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit aadb198 Nov 23, 2026
88 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/dispatch-feedback-rerun-script branch November 23, 2026 13:34
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 23, 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.

1 participant