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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: patch
---

### Fixed

- The PR-body linkage hooks (`pr-body-linkage-gate`, `pr-linkage-mcp-gate`) enforce again in a repository whose ci-status job runs the ci-workflows `report-ci-status` composite, which runs check-contract inside it. Before, they stopped checking in every repository moved to that composite.
16 changes: 10 additions & 6 deletions plugins/source-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ the calls that bypass the skill.

Enforcement is keyed to the consuming repository's own policy: it runs only
where one of the repo's `.github/workflows/*.yml` / `*.yaml` files `uses:` the
contract composite step `pr-require-checks/check-contract` (the SHA-pinned
contract composite step `pr-require-checks/check-contract`, or the
`pr-require-checks/report-ci-status` composite that runs it (the SHA-pinned
`melodic-software/ci-workflows/.github/actions/<path>@<sha>` form, or
ci-workflows' own local `./.github/actions/<path>`). A body the hook
cannot read statically always passes: an unexpanded variable, an absent body
Expand Down Expand Up @@ -257,7 +258,8 @@ covers both the `mcp__github__<tool>` names and the
`mcp__plugin_<plugin>_github__<tool>` names of a plugin-bundled server.
It blocks only the same negated closing reference, under the same authority (a
workflow in the consuming repository's own `.github/workflows/` that `uses:` the
`pr-require-checks/check-contract` composite step), with the same block message. The MCP payload hands over the body as a plain JSON field, so the
`pr-require-checks/check-contract` composite step, or the `pr-require-checks/report-ci-status`
composite that runs it), with the same block message. The MCP payload hands over the body as a plain JSON field, so the
Bash sibling's static-readability caveats don't apply here; the scope guards
that remain are the workflow scan above, an origin-remote match on the call's
`owner`/`repo` (another repository's PR is not this repo's policy), and an
Expand Down Expand Up @@ -409,8 +411,8 @@ repo's owner.
|---|---|---|
| `lane_instance` | string | a random `lane-<hex>` id made once and kept in the plugin data dir, never the hostname (writer identity suffixing `babysit-loop`'s telemetry marker; must be distinct across concurrent lane instances) |
| `lane_app_slug` | string | none (the telemetry write identity comes from the token's user; set it under a GitHub App installation token so `babysit-loop` resolves `<slug>[bot]`) |
| `pr_body_linkage_gate_enabled` | boolean | `true` (the PR-body hook above; inert in a repo with no workflow using the `check-contract` step) |
| `pr_linkage_mcp_gate_enabled` | boolean | `true` (the MCP-surface sibling; inert in a repo with no workflow using the `check-contract` step) |
| `pr_body_linkage_gate_enabled` | boolean | `true` (the PR-body hook above; inert in a repo with no workflow using the `check-contract` or `report-ci-status` step) |
| `pr_linkage_mcp_gate_enabled` | boolean | `true` (the MCP-surface sibling; inert in a repo with no workflow using the `check-contract` or `report-ci-status` step) |
| `babysit_watched_owners` | string (multiple) | infer the current repo's owner |
| `babysit_self_logins` | string (multiple) | your `gh api user` login (extras add to it) |
| `babysit_default_tier` | string | `safe` (explicit invocations only) |
Expand Down Expand Up @@ -466,13 +468,15 @@ The plugin-scope finding-classification gate accepts extra posting identities vi
**`pr_body_linkage_gate_enabled`.** Blocks only a negated closing reference. A missing closing
line or a missing or empty `## Summary`, `## Fix`, `## Verification` or `## Related` section
passes, since CI reports those as advisory. Enforced only in a repository whose
`.github/workflows` carry a workflow that uses the `check-contract` composite step.
`.github/workflows` carry a workflow that uses the `check-contract` composite step or the
`report-ci-status` composite that runs it.

**`pr_linkage_mcp_gate_enabled`.** The MCP-surface sibling of `pr-body-linkage-gate`, covering
cloud and remote sessions that open PRs through MCP tools rather than `gh` (see
[docs/cloud-sessions.md](../../docs/cloud-sessions.md#github-mcp-tools-vs-the-gh-cli)). It blocks
the same negated closing reference, with the same policy scope: enforced only in a repository
whose `.github/workflows` carry a workflow that uses the `check-contract` composite step.
whose `.github/workflows` carry a workflow that uses the `check-contract` composite step or the
`report-ci-status` composite that runs it.

**`branch_issue_pattern`.** The last capture group must resolve to digits (`Closes #N` honors only
a numeric issue). Set it for a non-default branch scheme that places the number differently, for
Expand Down
16 changes: 11 additions & 5 deletions plugins/source-control/hooks/pr-body-linkage-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
#
# WHAT IT ENFORCES — no negated closing reference anywhere in the body, judged
# as the consuming repository's `.github/actions/pr-require-checks/check-contract`
# composite step (melodic-software/ci-workflows) judges it, after stripping HTML comments
# composite step (melodic-software/ci-workflows; `report-ci-status` runs it,
# https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-require-checks/report-ci-status/action.yml) judges it, after stripping HTML comments
# (terminated ones, then an unterminated `<!--` swallowing the rest) and masking
# Markdown code. The rest of that contract (a closing line and non-empty
# `## Summary`, `## Fix`, `## Verification` and `## Related` sections) is
# advisory in CI, so a body missing any of it is allowed.
#
# SCOPE GUARD — enforcement is keyed to the repository's OWN policy: the gate
# runs only when one of the repo's `.github/workflows/*.yml` / `*.yaml` files
# `uses:` the contract composite step `pr-require-checks/check-contract`, in
# `uses:` the contract composite step `pr-require-checks/check-contract`, or
# the `pr-require-checks/report-ci-status` composite that runs it
# (https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-require-checks/report-ci-status/action.yml), in
# either fleet form (the SHA-pinned
# `melodic-software/ci-workflows/.github/actions/<path>@<sha>`, or
# ci-workflows' own local `./.github/actions/<path>`). The first
Expand Down Expand Up @@ -148,9 +151,12 @@ GATE_FILE=""
# Both `uses:` forms the fleet writes: the SHA-pinned cross-repo reference
# (`melodic-software/ci-workflows/.github/actions/<path>@<sha>`) and
# ci-workflows' own local dogfood (`./.github/actions/<path>`), where <path> is
# `pr-require-checks/check-contract`. The trailing class keeps a longer sibling
# directory (`check-contract-foo`) out.
gate_re='\.github/actions/pr-require-checks/check-contract([@[:space:]]|$)'
# `pr-require-checks/check-contract` or the `pr-require-checks/report-ci-status`
# composite that runs it
# (https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-require-checks/report-ci-status/action.yml).
# The trailing class keeps a longer sibling directory
# (`check-contract-foo`) out.
gate_re='\.github/actions/pr-require-checks/(check-contract|report-ci-status)([@[:space:]]|$)'
for candidate in "$REPO_ROOT"/.github/workflows/*.yml "$REPO_ROOT"/.github/workflows/*.yaml; do
# An unmatched glob stays literal; skipped here rather than leaking
# `shopt -s nullglob` out of the hook.
Expand Down
9 changes: 9 additions & 0 deletions plugins/source-control/hooks/pr-body-linkage-gate.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ new_repo() {
printf 'jobs:\n ci-status:\n steps:\n - uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/check-contract@5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c # v0.58.0\n' \
>"$r/.github/workflows/ci.$gated"
;;
composite)
mkdir -p "$r/.github/workflows"
printf 'jobs:\n ci-status:\n steps:\n - uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/report-ci-status@9c5bedfbfdbdfe733b9ce4cd7ca80c1574bd4cb8 # v0.76.3\n' \
>"$r/.github/workflows/pr-require-checks.yml"
;;
nostep)
mkdir -p "$r/.github/workflows"
printf 'jobs:\n ci-status:\n steps:\n - uses: actions/checkout@v5\n' \
Expand All @@ -82,6 +87,8 @@ new_repo "$GATED" yml
new_repo "$UNGATED" plain
new_repo "$NOSTEP" nostep
new_repo "$GATED_YAML" yaml
GATED_COMPOSITE="$WORK/gated-composite"
new_repo "$GATED_COMPOSITE" composite
new_repo "$OTHER" yml

# mk_payload <repo> <command> -> the PreToolUse payload this hook reads, on stdout.
Expand Down Expand Up @@ -539,6 +546,8 @@ assert_allow "an absolute path to a compliant body allowed" "$GATED" \

printf '%s\n' "$BAD" >"$GATED_YAML/body.md"
assert_block "a .yaml gate workflow enforces too" "$GATED_YAML" "gh pr create -t T --body-file body.md"
printf '%s\n' "$BAD" >"$GATED_COMPOSITE/body.md"
assert_block "the report-ci-status composite enforces too" "$GATED_COMPOSITE" "gh pr create -t T --body-file body.md"

# --- Locale independence -----------------------------------------------------
# `[[:space:]]` is locale-defined; JavaScript's `\s` is not. Each body below
Expand Down
18 changes: 12 additions & 6 deletions plugins/source-control/hooks/pr-linkage-mcp-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
# anywhere in the body, which GitHub's negation-blind parser would still close
# on merge, judged as the consuming repository's
# `.github/actions/pr-require-checks/check-contract` composite step
# (melodic-software/ci-workflows) judges it, after stripping HTML comments and
# (melodic-software/ci-workflows; `report-ci-status` runs it,
# https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-require-checks/report-ci-status/action.yml) judges it, after stripping HTML comments and
# masking Markdown code. The rest of that contract (a closing line
# and non-empty `## Summary`, `## Fix`, `## Verification` and `## Related`
# sections) is advisory in CI, so a body missing any of it is allowed.
#
# SCOPE GUARDS —
# - enforcement is keyed to the repository's OWN policy: the gate runs only
# when one of the repo's `.github/workflows/*.yml` / `*.yaml` files `uses:`
# the contract composite step `pr-require-checks/check-contract` (the
# the contract composite step `pr-require-checks/check-contract`, or the
# `pr-require-checks/report-ci-status` composite that runs it
# (https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-require-checks/report-ci-status/action.yml), in the
# SHA-pinned `melodic-software/ci-workflows/.github/actions/<path>@<sha>`
# form or ci-workflows' own local `./.github/actions/<path>`), so a consumer
# form or ci-workflows' own local `./.github/actions/<path>`, so a consumer
# without the step is never gated. This is deliberately NOT the
# `pr_body_required_sections` seam (docs/contracts/pr-body-convention/),
# whose portable default excludes `Related` on purpose;
Expand Down Expand Up @@ -152,9 +155,12 @@ GATE_FILE=""
# Both `uses:` forms the fleet writes: the SHA-pinned cross-repo reference
# (`melodic-software/ci-workflows/.github/actions/<path>@<sha>`) and
# ci-workflows' own local dogfood (`./.github/actions/<path>`), where <path> is
# `pr-require-checks/check-contract`. The trailing class keeps a longer sibling
# directory (`check-contract-foo`) out.
gate_re='\.github/actions/pr-require-checks/check-contract([@[:space:]]|$)'
# `pr-require-checks/check-contract` or the `pr-require-checks/report-ci-status`
# composite that runs it
# (https://github.com/melodic-software/ci-workflows/blob/main/.github/actions/pr-require-checks/report-ci-status/action.yml).
# The trailing class keeps a longer sibling directory
# (`check-contract-foo`) out.
gate_re='\.github/actions/pr-require-checks/(check-contract|report-ci-status)([@[:space:]]|$)'
for candidate in "$REPO_ROOT"/.github/workflows/*.yml "$REPO_ROOT"/.github/workflows/*.yaml; do
# An unmatched glob stays literal; skipped here rather than leaking
# `shopt -s nullglob` out of the hook.
Expand Down
6 changes: 6 additions & 0 deletions plugins/source-control/hooks/pr-linkage-mcp-gate.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ git -C "$GATED" init -q
git -C "$GATED" remote add origin https://github.com/acme-corp/widgets.git
git -C "$NOGATE" init -q
git -C "$NOORIGIN" init -q
COMPOSITE="$WORK/composite"
mkdir -p "$COMPOSITE/.github/workflows"
printf 'jobs:\n ci-status:\n steps:\n - uses: melodic-software/ci-workflows/.github/actions/pr-require-checks/report-ci-status@9c5bedfbfdbdfe733b9ce4cd7ca80c1574bd4cb8 # v0.76.3\n' >"$COMPOSITE/.github/workflows/pr-require-checks.yml"
git -C "$COMPOSITE" init -q
git -C "$COMPOSITE" remote add origin https://github.com/acme-corp/widgets.git

# run <expected-exit> <name> <payload-json>; the payload carries its own cwd.
run() {
Expand Down Expand Up @@ -118,6 +123,7 @@ run 0 "Refs: #N non-closing marker passes" "$(payload "$GATED" $CREATE $OWNER $R
run 0 "create with no body field passes (empty body)" "$(payload "$GATED" $CREATE $OWNER $REPO)"
run 0 "update with no body field passes" "$(payload "$GATED" $UPDATE $OWNER $REPO)"
run 2 "update with bad body blocks" "$(payload "$GATED" $UPDATE $OWNER $REPO "$BAD")"
run 2 "the report-ci-status composite enforces too" "$(payload "$COMPOSITE" $CREATE $OWNER $REPO "$BAD")"
run 0 "different target repo is out of scope" "$(payload "$GATED" $CREATE other-org other-repo "$BAD")"
run 0 "gated repo with no origin remote allows (undeterminable target)" "$(payload "$NOORIGIN" $CREATE $OWNER $REPO "$BAD")"
run 0 "repo without the gate file never blocks" "$(payload "$NOGATE" $CREATE $OWNER $REPO "$BAD")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ A PR that references an issue without closing it carries `Refs: #N` (or `Relates

Before creating the PR, run two independent checks against the body file `$BODY_FILE`: the closing-keyword check and the required-section check (generic: it reads `pr_body_required_sections`, never a hardcoded section list). Both must pass.

A PR create or edit command issued **outside** this skill meets the plugin's `pr-body-linkage-gate` PreToolUse hook instead, where the repository wires in its own contract check (a workflow that `uses:` the `pr-require-checks/check-contract` composite step). The hook blocks only a statically-readable body carrying a negated closing reference, since CI reports a missing closing line or section as advisory; [`../../../hooks/pr-body-linkage-gate.sh`](../../../hooks/pr-body-linkage-gate.sh) has its scope guard and coverage limits. On this skill's path its gate runs first, and the hook still blocks a drafted body carrying a negated closer.
A PR create or edit command issued **outside** this skill meets the plugin's `pr-body-linkage-gate` PreToolUse hook instead, where the repository wires in its own contract check (a workflow that `uses:` the `pr-require-checks/check-contract` composite step, or the `pr-require-checks/report-ci-status` composite that runs it). The hook blocks only a statically-readable body carrying a negated closing reference, since CI reports a missing closing line or section as advisory; [`../../../hooks/pr-body-linkage-gate.sh`](../../../hooks/pr-body-linkage-gate.sh) has its scope guard and coverage limits. On this skill's path its gate runs first, and the hook still blocks a drafted body carrying a negated closer.

#### 2.4.2.1 Verify closing-keyword line

Expand Down
Loading