Repository navigation
ci: validate initial PR readiness declarations - #3302
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c127aa77d
ℹ️ 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".
| const repository = context.repo; | ||
| const getPull = async () => | ||
| (await github.rest.pulls.get({ ...repository, pull_number: number })).data; | ||
| const pull = await getPull(); |
There was a problem hiding this comment.
Clear stale readiness before fetching PR metadata
When an edited or synchronize rerun encounters a transient failure in this initial pulls.get, execution exits before publishing the pending status at lines 118–121. A previous successful PR readiness commit status therefore remains satisfied even though the declarations may have been removed, while only the separate Actions job reports failure; this matters because CONTRIBUTING.md instructs maintainers to require the legacy PR readiness status. Publish pending using the event head before the fallible fetch, or require the workflow check itself so metadata/API failures cannot fail open.
AGENTS.md reference: AGENTS.md:L104-L110
Useful? React with 👍 / 👎.
| const owners = lines.filter((line) => line.startsWith("Human owner:")); | ||
| if ( | ||
| owners.length !== 1 || | ||
| !/^Human owner: @[a-z\d](?:[a-z\d-]*[a-z\d])?$/iu.test(owners[0]) |
There was a problem hiding this comment.
Restrict owner names to valid GitHub handles
For non-draft PRs, this expression accepts values that cannot identify a GitHub account: with Unicode-aware case folding, [a-z] matches characters such as K and ſ, and the pattern also permits consecutive hyphens and unbounded lengths. Consequently, Human owner: @K plus three checked declarations produces success despite naming no valid human owner. Validate GitHub's ASCII handle grammar and length constraints, or resolve the named account before accepting it.
AGENTS.md reference: AGENTS.md:L94-L97
Useful? React with 👍 / 👎.
|
| while (offset < source.length) { | ||
| const marker = comment ? "-->" : "<!--"; | ||
| const index = source.indexOf(marker, offset); | ||
| if (!comment) | ||
| line += source.slice(offset, index === -1 ? source.length : index); | ||
| if (index === -1) break; | ||
| offset = index + marker.length; | ||
| comment = !comment; |
There was a problem hiding this comment.
Inline code hides completed declarations
readinessLines treats <!-- inside inline code as an HTML comment. A PR description that says “the marker is <!--” before its completed readiness section therefore fails the check, even though GitHub displays the declarations normally. Authors must change unrelated description text to pass.
Skip comment markers inside code spans and add a regression test with that description followed by the unchanged, checked template section.
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/ci/pr-readiness.mjs
Line: 28-35
Comment:
**Inline code hides completed declarations**
`readinessLines` treats `<!--` inside inline code as an HTML comment. A PR description that says “the marker is `<!--`” before its completed readiness section therefore fails the check, even though GitHub displays the declarations normally. Authors must change unrelated description text to pass.
Skip comment markers inside code spans and add a regression test with that description followed by the unchanged, checked template section.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| else if ( | ||
| associated.some( | ||
| (other) => | ||
| other.state === "open" && | ||
| other.number !== number && | ||
| other.head.sha === pull.head.sha, | ||
| ) | ||
| ) | ||
| verdict = result( | ||
| "failure", | ||
| "Open PRs must have distinct head commits because GitHub shares commit statuses.", | ||
| ); |
There was a problem hiding this comment.
Resolved duplicates stay failed
When two open PRs share a head commit, the checker writes failure to that commit. Closing one triggers no check, and pushing a new head to one only checks its new commit. The remaining PR stays failed even after it satisfies the distinct-head rule, so a maintainer must manually rerun the check.
Recheck affected PRs on the old head when those associations change, and test both recovery paths.
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/ci/pr-readiness.mjs
Line: 144-155
Comment:
**Resolved duplicates stay failed**
When two open PRs share a head commit, the checker writes failure to that commit. Closing one triggers no check, and pushing a new head to one only checks its new commit. The remaining PR stays failed even after it satisfies the distinct-head rule, so a maintainer must manually rerun the check.
Recheck affected PRs on the old head when those associations change, and test both recovery paths.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary
Non-draft PRs can request maintainer review with the human readiness declarations still unchecked. Add a
PR readinessstatus that checks the named owner and three declarations.Readiness is declared once when opening the PR for review. Later pushes keep that declaration valid. Drafts remain allowed with the readiness status pending.
Problem and expected behavior
See #3294 for a non-draft PR with all three declarations unchecked. Documentation alone does not produce a failing check. Missing or unchecked declarations should fail the readiness status, while a completed initial declaration should continue to pass after further commits.
Change and scope
Add a metadata-only workflow and checker, cover the status boundary and workflow step with tests, and update the template and contributor/agent guidance to remove repeated human sign-off and checkbox-reset requirements.
The check reads the canonical declarations from the trusted repository template. It ignores examples in HTML comments, fenced code blocks, and quotes. It does not assess code quality, verify a person's reading, edit PR bodies, or close PRs.
Maintainer-requested CI change within the existing contribution scope; no target-analysis capability or advance provider scope decision is involved.
Contract and boundary impact
pull_request_targetreads live PR metadata and checks out only the repository's default branch. Write authority is limited to commit statuses; credentials are not persisted by checkout.Expected effects:
Evidence and regression coverage
Validation performed
npm run test:focused -- tests/boundary/filesystem/prReadiness.test.ts— final 32 tests passed.npm run check:fast— passed.npm run docs:check— passed, including 5 README consistency tests.npm run verify:test-discovery— all 1,264 test files discovered exactly once.go run github.com/rhysd/actionlint/cmd/[email protected] -shellcheck= -pyflakes= .github/workflows/pr-readiness.yml— passed.Gate overhead
The previous workflow has no readiness task. The new ready-PR task makes five GitHub REST calls when commit associations fit one page; drafts and incomplete declarations use four. It installs no dependencies and invokes no model.
Completed local tasks with an in-process GitHub substitute:
The module was loaded before the cold task; the warm task reused the process. Node startup, real GitHub latency, and hosted runner elapsed/CPU/memory costs are unmeasured. These measurements do not predict hosted job duration.
Compatibility, safety, and release
PR readinessfrom GitHub Actions to the existing required status checks. Branch protection has not been changed by this PR.Author readiness
Human owner: @morluto
Before merge