Skip to content

ci: validate initial PR readiness declarations - #3302

Merged
morluto merged 1 commit into
mainfrom
codex/pr-readiness-gate
Oct 14, 2026
Merged

morluto merged 1 commit into
mainfrom
codex/pr-readiness-gate

Conversation

@morluto

@morluto morluto commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

Non-draft PRs can request maintainer review with the human readiness declarations still unchecked. Add a PR readiness status 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

  • Semantic owner and earliest changed stage: trusted PR template owns declaration wording; the new checker owns parsing and GitHub status publication.
  • Contribution scope fit and linked maintainer decision: repository CI only; provider/capability scope approval is not applicable.
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: no runtime change.
  • Target selection, authority, upstream behavior, and cleanup details: pull_request_target reads 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.
  • Generated metadata, package, or installation impact: no shipped runtime or dependency changes.

Expected effects:

  • Contact network services — GitHub metadata reads and status publication.

Evidence and regression coverage

  • 32 readiness tests passed, including missing/unchecked declarations, hidden examples, drafts, later pushes retaining readiness, unavailable API state, duplicate heads, and PR changes during a check.
  • The production workflow script executed in a Node subprocess with a recording GitHub API substitute. The test asserts trusted checkout and status-only write authority.
  • 213 CI classification tests passed, including selection of code checks when this workflow changes.
  • Live GitHub execution remains unverified until the trusted workflow is merged. Tests do not establish hosted behavior.

Validation performed

  • CI classification suite — 213 tests passed.
  • 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.
  • Changed-file formatting and Git diff checks — passed.
  • Real analysis-provider verification: not applicable.
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:

Run Elapsed CPU Peak single-process family memory Model tokens
Cold task 0.821 ms 1.281 ms 45,808 KiB 0
Warm task 0.224 ms 0.239 ms 46,416 KiB 0

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

  • Existing PRs can copy the updated Author readiness section; checked declaration wording must match the trusted template.
  • GitHub shares commit statuses, so separate open PRs must use distinct head commits.
  • Activation after merge: dispatch the workflow for existing open PRs, then add PR readiness from GitHub Actions to the existing required status checks. Branch protection has not been changed by this PR.
  • Deploy the workflow to a target branch before requiring the status there.
  • Existing administrator overrides and maintainer review remain separate from this declaration check.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Material scope and authority questions are resolved.
  • Required checks pass.

@morluto
morluto marked this pull request as ready for review October 14, 2026 08:51
@morluto
morluto merged commit 5f0065c into main Oct 14, 2026
7 checks passed
@morluto
morluto deleted the codex/pr-readiness-gate branch October 14, 2026 08:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

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 ✅ Completed 2026-10-14T08:55:23.292806Z 4c127aa 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: 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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High impact] Adds a new CI workflow that validates PR readiness declarations.

The PR appears safe to merge, with two non-blocking cases that can leave ready PRs showing failed checks.

Fix All in CodexFindings

  1. P2 Inline code hides completed declarations ▶
  2. P2 Resolved duplicates stay failed ▶
Fix with agent prompt
### Issue 1
scripts/ci/pr-readiness.mjs:28-35
`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.

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!

### Issue 2
scripts/ci/pr-readiness.mjs:144-155
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

Adds a metadata-only PR readiness status that checks the named owner and three declarations against the trusted template.

  • PR readiness checks confirm the owner's initial review declaration.
  • The readiness declaration stays valid after later pushes.

Superseded status could not be checked because GitHub access was unauthenticated. No scripts or tests were executed during this review.

Intentional behavior acknowledged in morluto's supplied PR description: open PRs must use distinct head commits because GitHub shares commit statuses, and later pushes retain the initial declaration without repeated human sign-off.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[PR event or manual recheck] --> B[Check out trusted default branch]
  B --> C[Read live PR metadata]
  C --> D{Open PR on supported branch?}
  D -- No --> E[Stop]
  D -- Yes --> F[Publish pending on current head]
  F --> G[Read trusted template and check declarations]
  G --> H{Declarations complete?}
  H -- Yes --> I[Check for other open PRs sharing head]
  H -- No --> J[Choose pending or failure]
  I --> K[Read PR metadata again]
  J --> K
  K --> L{PR changed?}
  L -- Yes --> M[Publish pending]
  L -- No --> N[Publish chosen status]
Loading

Reviews (1) · Last reviewed commit: "ci: validate initial PR readiness declar..." · Reviewed by Greptile

Comment on lines +28 to +35
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;

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.

P2 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!

Fix in Codex

Comment on lines +144 to +155
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.",
);

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.

P2 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.

Fix in Codex

@morluto morluto added area: build Build, CI, packaging, and publishing area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build, CI, packaging, and publishing area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant