Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .claude/rules/pr-body-contract.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# PR body contract

Every pull request body must satisfy the required `pr-issue-linkage` check
before merge:
`ci-status` is the single required check on every pull request. It fails on a
title that is not Conventional Commits and on a `do-not-merge` label. A body
missing the closing keyword or a section does NOT turn it red: the gate leaves
an advisory comment and the `needs-issue-linkage` label instead. The body
contract below is still expected on every pull request; it is reported, not
Comment thread
kyle-sexton marked this conversation as resolved.
Resolved
gating.

- Open with a native closing-keyword line: `Closes #<issue>` (`Fixes`/`Resolves`
Every pull request body:

- Opens with a native closing-keyword line: `Closes #<issue>` (`Fixes`/`Resolves`
also accepted, one keyword per issue), or, when the PR closes nothing, the
literal `No related issue: <reason>`.
- Carry a non-empty section for each of `## Summary`, `## Fix`,
- Carries a non-empty section for each of `## Summary`, `## Fix`,
`## Verification`, and `## Related`.

Draft the body to this contract BEFORE creating the PR (`gh pr create`, MCP, or
web); the gate fails closed, and a first-run failure is exactly what this rule
exists to prevent.
web); the advisory comment and label are noise this rule exists to prevent.

The canonical machine-readable convention is
`components/pr-convention-policy/policy.json` in `melodic-software/standards`;
the SHA-pinned ci-workflows `pr-issue-linkage.yml` reusable is the enforcement
authority, and its check output is the statement of record.
the SHA-pinned ci-workflows `pr-contract` composite that runs as a step inside
`ci-status` is the enforcement authority, and its step output is the statement
of record.
41 changes: 32 additions & 9 deletions components/pr-convention-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ Conventional Commits titles, required body sections, and native closing
keywords (or an explicit no-issue marker). This is a standards-internal record
and self-test. It is not distributed to consumers
([ADR-0005](../../docs/adr/0005-retire-pr-convention-policy-distribution.md));
the gate consumers actually run is the `ci-workflows` `pr-issue-linkage.yml`
reusable, which each repository pins directly.
the gate consumers actually run is the `ci-workflows` `pr-contract` composite
(v0.20.0 onward, `449157aaa8e30f7b1457305d8048ebe6168e174a`), which each
repository pins directly as a step inside its `ci-status` job. Its predecessor
is the `pr-issue-linkage.yml` reusable, which every repository leaves during
Phase 3 of the ci-perf program (melodic-software/github-iac#396), one pull
request each; a repository runs one artifact or the other, never both.

Run the validator locally:

Expand All @@ -30,6 +34,13 @@ the allowed types listed in [`policy.json`](policy.json). The fleet includes
and it is not a semver/changelog axis (that remains on PR titles that ship
release-impacting work under `feat`/`fix`).

The `pr-contract` composite's `types` input defaults to exactly these twelve,
`security` included, so the gate and `policy.json` now agree. The predecessor
`semantic-pr` reusable carried the action's eleven spec-aligned defaults and no
caller passed a `types:` value, which meant a `security:` title this policy
allows failed that gate. Adopting the composite ends that drift; the lockstep
check below reads the composite's default so it cannot reopen.

### PR bodies

Every pull request carries:
Expand All @@ -43,16 +54,28 @@ Every pull request carries:
entries the PR does not close).

The `## Related` section is fleet-wide house style (reconciled in #247); this
component encodes the rule the `pr-issue-linkage` gate enforces. The
authoritative gate is the `ci-workflows` `pr-issue-linkage.yml` reusable,
which hardcodes its own copy of the section list (four sections as of
v0.14.2, `7107b34`). The two lists must change in lockstep; letting them
drift is exactly the failure #393 recorded. That lockstep is now enforced by
component encodes the rule the gate enforces. The authoritative gate is the
`ci-workflows` `pr-contract` composite, which hardcodes its own copy of the
contract: the section list as the `section_report("<name>")` calls in
[`run.sh`](https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-contract/run.sh),
the closing keywords and no-issue markers as the awk patterns beside them, and
the allowed title types and the scope requirement as the `types` and
`require-scope` input defaults in `action.yml`. Those
copies must change in lockstep with `policy.json`; letting them drift is
exactly the failure #393 recorded. That lockstep is enforced by
[`lockstep-drift.mjs`](lockstep-drift.mjs) (ADR-0008), which the
`pr-convention-lockstep` CI lane runs against the live gate source, the
source-control plugin's hook validator, the org PR template, the distributed
`.claude/rules/pr-body-contract.md` rule, and the contract of the reusable at
every caller's pinned SHA.
`.claude/rules/pr-body-contract.md` rule, and the contract of the artifact each
consumer pins (the composite, or the reusable until that repository takes its
Phase 3 pull request) at that pinned SHA.

Only the title and the `do-not-merge` label fail the composite's step. A body
missing a closing keyword or a section is advisory: a warning, one upserted
comment, and the `needs-issue-linkage` label, with the step still exiting 0
(`linkage-mode: enforce` restores the hard gate per repository). The body
contract is still the standard; it is reported rather than gating so a body
edit never re-runs the file-lint lanes.

## Security

Expand Down
Loading