Skip to content

chore(gates): check the pull request body sections and word limit - #4841

Merged
thymikee merged 6 commits into
mainfrom
chore/pr-body-check
Nov 20, 2026
Merged

thymikee merged 6 commits into
mainfrom
chore/pr-body-check

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a CI check for the pull request body rule in docs/agents/pull-requests.md, plus a template with the headings. Nothing verified the rule before, so bodies omitted ## Before / after or ## Value.

The check is one 111-line script that reads the title and body from the event payload:

  • ## Summary and ## Validation are required.
  • feat and fix titles need ## Before / after. No observable change with a reason satisfies it.
  • refactor titles need ## Value.
  • The body stays below 250 words outside code blocks, HTML comments and bot footers.
  • Drafts and bot authors are not checked.

An earlier revision also checked the tested SHA against the head and shipped 499 lines of unit tests. Both are removed: the diff went from 1,179 lines to 183.

Validation

Tested at 2863af2cb9.

  • Run by hand against the last 8 merged PRs and this one. fix(daemon): close a detached daemon that finds its registration deleted or replaced #4837 has no sections, and refactor(vega): ship Vega OS as a platform plugin #4828 lacks ## Value and has 591 words; the rest pass.
  • Ten hand cases gave the expected result, among them an unfilled template, a section holding only a code block, an indented fence, a comment marker in inline code, and a bot footer.
  • lint, typecheck, format:check, check:gate-manifest, check:agent-guidance and check:fallow pass.
  • No unit tests ship with the script, by maintainer decision. No local check:affected receipt: hosted CI is the validation.
  • Risk: an open PR whose body follows the old rule fails this check on its next push or edit.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 1 new finding on b96b4d8. The verdict and the full list are in the summary comment.

Comment thread scripts/pr-body/model.ts Resolved
`docs/agents/pull-requests.md` stated body rules nothing checked: an agent
that skipped `## Before / after`, or left a body naming a commit a rebase had
dropped, opened a PR that passed. This adds the missing check, so the prose can
shrink to what no check can say.

`scripts/pr-body/model.ts` holds the decision as one pure function: required
sections, the `No observable change` escape with a stated reason, a 250-word
budget outside code blocks, tables, and bot footers, and a tested SHA that is
still an ancestor of the head. `scripts/pr-body/check.ts` answers only the
question the model cannot: whether a SHA resolves, from the checkout. It reads
the title and body from the event payload the runner writes, so a fork cannot
steer the check by editing its own body. Bot authors and drafts are exempt.
A SHA the checkout cannot look up is printed as a note, not as a stale body.
A run of digits the repository has no commit for is not an object id, so it
neither satisfies the Validation SHA rule nor reports a stale body.
@thymikee
thymikee force-pushed the chore/pr-body-check branch from 0349f65 to b89876b Compare November 20, 2026 17:42
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.47 MB 6.47 MB +81 B
Package (unpacked) 6.47 MB 6.47 MB +81 B
Package (download) 1.97 MB 1.97 MB +19 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.1 ms 21.8 ms +0.8 ms
CLI --help 45.7 ms 44.5 ms -1.2 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The change at b89876b is ready, and the checks pass: Body rules passes for this head (an earlier cancelled run was superseded by a later event) and the diff is the route that job exercises. No conflicts. Nothing blocks merge.

Not blocking, and each can be taken or left: docs/agents/pull-requests.md now gives a type-only rule, so the old "when a caller can observe the change, output and errors included" sentence could return as an "also add it for any other type" line. scripts/pr-body/check.ts and pr-body.yml say the fork contributes nothing the check runs, but under pull_request the merge ref supplies the scripts too, so the comment could say the payload supplies title and body. pr-body.yml runs a full checkout, install and the pr-body-model tests on every body edit, and those tests do not depend on the body. model.ts applies the 8-word floor to "no observable change" even when the section also has fenced output, so the floor could apply only when the section has no fenced or table content. model.ts treats any 7-40 character hex token as a commit, so words like "defaced" or session-id segments get a misleading "not a commit this repository has" message, and a plain "name the tested commit SHA" message could be used unless the token has 10 or more characters or mixes digits and letters. model.ts has the typo "spellyings".

The open inline thread on digit-run tokens is fixed at this head and can be resolved: #4841 (comment)

Not verified here: fork-PR and rebased-PR runs, the tests locally, and the numbers on earlier merged PRs.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
Drop the tested-SHA ancestry rule, its git plumbing and full-history checkout,
the Markdown table handling, and the unit tests. One script reads the event
payload and checks the required sections by title type and the word limit.
@thymikee thymikee changed the title chore(gates): enforce the pull request body rules chore(gates): check the pull request body sections and word limit Nov 20, 2026
Comment thread scripts/check-pr-body.ts Fixed
CodeQL reads the regex replace as incomplete HTML sanitization. The text is only
counted, never rendered, but a split-based strip avoids the pattern and also
handles an unclosed comment.
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 3 new findings on b99ee73. The verdict and the full list are in the summary comment.

Comment thread scripts/check-pr-body.ts Resolved
Comment thread .github/pull_request_template.md Resolved
Comment thread scripts/check-pr-body.ts Resolved
…rs inside fences

A fenced block is replaced by a bare fence before sections and comments are
read. The template no longer says table words are free.
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 4 new findings on a54a777. The verdict and the full list are in the summary comment.

Comment thread scripts/check-pr-body.ts Resolved
Comment thread scripts/check-pr-body.ts Resolved
Comment thread scripts/check-pr-body.ts Resolved
Comment thread scripts/check-pr-body.ts Resolved
… text, anchor the bot footer

An indented fence inside a list item is a code block. A `<!--` in an inline
code span opens no comment. A footer marker quoted mid-line is not a footer.
@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 2863af2

Since the review of a54a777: 0 new · 3 still open · 1 no longer raised (1 marked fixed)

3 finding(s): 2 nit, 1 minor.

🟡 Minor (1)

Where Finding
scripts/check-pr-body.ts:10 Any line-initial <!-- before the last required section reports that section as missing
🔵 Nit (2)
Where Finding
scripts/check-pr-body.ts:64 Indented code blocks are still read as prose, so a fake heading inside one passes the gate
scripts/check-pr-body.ts:52 Text between an inline <!-- and a later --> is erased, so real sections read as missing

Reviewed with this repository's own Sentinel configuration (357e0d4a7513).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 2863af2. It fixes the unclosed <!-- case and the other points from the earlier review (#4841 (comment)). CI is green. The cancelled Body rules run was replaced by a newer run for the same head, and that run passed. No conflicts. Nothing else must happen before merge except the maintainer's approval.

Not blocking, and fine to take or leave: withoutComments() still pairs a <!-- in one inline code span with a --> in another, so a body with those in different sections loses the text between them and the gate reports a missing ## Validation section that exists (stripping inline code spans before the comment strip would fix it); and the message at check-pr-body.ts:77 says Add a "## X" section for a heading that is present but empty, where Add or fill would read better.

Of the earlier inline threads, these no longer apply and can be resolved: #4841 (comment) (the SHA-token parsing was deleted), #4841 (comment) (no regex replace is left in the comment strip), #4841 (comment) (a section with only a fenced block now counts as empty), #4841 (comment) (the template text now matches the script), #4841 (comment) (fences are replaced before the comment strip), #4841 (comment) (an indented heading only makes the gate accept more), #4841 (comment) (the footer cut is intended and the failure names the section), and #4841 (comment) (indented fences no longer count toward the limit). One lower-priority thread still applies, #4841 (comment), and it matches the first note above.

Not verified here: lint, typecheck, format:check, check:gate-manifest, check:agent-guidance and check:fallow were not re-run locally. They rely on the checks listing. The head script was run on this PR's title and body in the event shape and printed PR body: ok., but it was not run through a real GitHub event for a fork PR or an empty body.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee merged commit 18c6c42 into main Nov 20, 2026
26 of 27 checks passed
@thymikee
thymikee deleted the chore/pr-body-check branch November 20, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants