Automate PR review and rebase decisions

Merged
JS
1d ago
+817-114

A triage run spent most of its time on steps a script can settle: deciding who each open pull request waits on, finding the ones ready for a maintainer review, noticing a Refs line that closes nothing, diagnosing a cargo-audit failure that only needs a rebase, and checking that a pull request had not moved before posting a confirmed review. Doing them by hand also went wrong, as when a maintainer's standing request for Closes #141 on #143 went unseen. This moves those decisions into the sweep scripts, so the skills read their output instead of re-deriving it.

pr-sweep.sh gives each pull request a waits_on (author, maintainer, ci, approval) read from the same table as its grade, a review queue of the ones waiting on a maintainer, refs_only for pull requests that close nothing yet name an issue with Refs, and a rebase list whose entries carry a reason: conflicts, or stale_base when ci-failure.sh finds the only failure is an advisory main has since moved past. stale_base holds only when the pull request changes none of the files the audit reads, main's passing run is newer than the failing one, and no other check is failing or pending. issue-sweep.sh names the open pull requests that close each unanswered or waiting issue. The new post-review.sh refuses to post when the head or updatedAt moved, a comment would fall outside the diff, or the payload has no event. CONTRIBUTING.md and the contributor skill now ask pull requests to avoid Refs unless it sits beside a Closes or a full account of the motivation and the implementation.

Verified with ./scripts/test.sh (no failed gates; browser lanes skipped here for want of Chromium), python3 -m unittest tests.test_skill_scripts (56 tests, 15 of them new or extended), shellcheck, scripts/indent.sh --check and scripts/check-skill-refs.py. Against the live repository the sweep queued #422, #396, #411 and #401 for review, flagged #143 as already asked, marked #334 a stale base and #423 not, and post-review.sh refused a payload on a stale head with exit 3.

Left out: pr-sweep.sh and ci-failure.sh each read main's latest check run; sharing that lookup means a helper both scripts source, which is a structural change of its own.


Summary by cubic

Moves triage decisions out of triage runs and into the sweep scripts: who each open pull request waits on, which are ready for a maintainer review, which Refs lines close nothing, and which failing cargo-audit checks a rebase fixes. Confirmed reviews post through a new guard that refuses when the pull request changed.

  • pr-sweep.sh reports a waits_on per PR, a review queue, refs_only entries, and rebase entries carrying a conflicts or stale_base reason. A stale_base diagnosis only counts for the head the sweep read; one for any other head is dropped.
  • post-review.sh exits 3 without posting when the head or updatedAt moved, a comment falls outside the diff, or the payload has no event. It posts the checked text, not the payload file again, so a rewrite after the checks cannot slip in.
  • issue-sweep.sh names the open pull requests that close each unanswered or waiting issue; past ten closing PRs the issue is marked truncated, and the reference narrows the candidates without settling them.
  • CONTRIBUTING.md and the contributor skill now ask PRs to avoid Refs unless it sits beside a Closes or a full account of the motivation and the implementation, and reviews record the updatedAt the guard compares against.