Skip to content

fix(code-tidying): route tidy's PR creation through the canonical gate#218

Merged
kyle-sexton merged 3 commits into
mainfrom
feat/wp14-tidy-pr-decoupling
Jul 16, 2026
Merged

fix(code-tidying): route tidy's PR creation through the canonical gate#218
kyle-sexton merged 3 commits into
mainfrom
feat/wp14-tidy-pr-decoupling

Conversation

@kyle-sexton

Copy link
Copy Markdown
Contributor

Summary

code-tidying:tidy's Phase H ("Ship") told the agent to create the PR by calling gh pr create directly — a bare bypass of source-control:pull-request's canonical create flow, which resolves issue-linkage (with an issue-existence check before shipping a Closes #N keyword), assembles the PR body injection-safely (quoted heredoc + parameter-expansion concat, a defense against shell injection through prompt-derived text), and gates PR creation on a valid closing keyword or explicit opt-out before calling gh pr create itself.

Closes decisions #3 and #42 of the melodic-software issue/PR consistency initiative's Decisions Log (https://claude.ai/code/artifact/232ecdce-8316-4880-8c0a-dc3c7dcf3a63):

  • feat: markdown-formatter plugin (pilot migration) #3 (formatting-tidy-canonical-pr-gate-bypass) — "YES, fix — but not via direct skill-to-skill coupling... minimize coupling between code-tidying:tidy and source-control:pull-request... Likely shape: a shared script/check both skills call, or a convention-level requirement enforced by a common gate." This PR fixes the bypass without a hard cross-plugin dependency (below).
  • feat: add guardrails plugin (bundled safety hooks) #42 (crosscut-skill-content-sync-mechanism) — "Single shared reference doc, all authoring skills import it." Applied here for its first concrete instance (see Design rationale).

What changed

Phase H now applies the same optional-plugin graceful-degrade pattern tidy already uses elsewhere in its own SKILL.md (Phase C for discovery, Phase D for work-items):

  • If source-control is installed: invoke /pull-request create, supplying tidy's own title/body-section content. Its stage-and-commit step (§2.3) is a no-op here since Phase E already committed the tidyings atomically — the call goes straight to rebase-check, issue-linkage resolution, and gated PR creation.
  • If source-control isn't installed: the same invariants apply inline — verify an issue exists before writing Closes #N, assemble the body via quoted heredoc + concat (never an unquoted <<EOF), and refuse gh pr create until the body carries a valid closing keyword or an explicit Refs #N / No related issue: opt-out.

Design rationale (decision #42, recorded as an assumption — no user available to confirm interactively this session)

Considered extracting the safety invariants into a new shared reference doc (mirroring the docs/PLUGIN-ARTIFACT-PROTOCOL.md → per-plugin reference/artifact-protocol.md precedent, drift-checked by validate-plugin-contracts.mjs and this session's new scripts/check-cross-plugin-source-drift.sh). Rejected for now: every invariant worth stating is already authoritative in pull-request/reference/create.md, so a copied doc would be pure duplication with drift risk — and with exactly one non-source-control consumer today, it wouldn't even register as a cluster for the new drift checker (which requires 2+ plugin copies). A prose convention pointer is lighter, carries no duplication to drift, and degrades gracefully if source-control is absent — which a hard-copied doc wouldn't buy any safety over.

This is decision #42's design choice for its first application, not a retrofit of every authoring skill in the marketplace — no other skill is touched by this PR. Rolling the same pattern out to other PR-creating skills (if any surface a similar bypass) is deferred, unscoped follow-up work, tracked in the Decisions Log rather than guessed at here.

Test plan

  • bash scripts/validate-plugins.sh — all plugin manifests + strict catalog validation pass.
  • node scripts/validate-plugin-contracts.mjs — 16 setup skills + 1342 plugin files checked, clean.
  • npx markdownlint-cli2 plugins/code-tidying/skills/tidy/SKILL.md — 0 errors.
  • Confirmed no other stale bare-gh pr create references remain under plugins/code-tidying/.
  • No existing test file exercises tidy's SKILL.md prose directly (only open-pr-count.test.sh, unrelated to Phase H) — nothing to update there.

`tidy`'s Phase H told the agent to call `gh pr create` directly, bypassing
`source-control:pull-request`'s canonical create flow — issue-linkage
resolution with an issue-existence check, injection-safe PR-body assembly
(quoted heredoc + parameter-expansion concat), and a pre-create gate that
requires a valid closing keyword or explicit opt-out before the PR ships.

Phase H now applies the same optional-plugin graceful-degrade pattern
`tidy` already uses elsewhere (Phase C for `discovery`, Phase D for
`work-items`): invoke `/pull-request create` when `source-control` is
installed — its own stage-and-commit step is a no-op since Phase E already
committed the tidyings — falling back to the same invariants applied
inline when it isn't. This keeps `code-tidying` and `source-control`
decoupled (no cross-plugin runtime dependency; either plugin remains
independently installable) while closing the actual gap: an agent
following Phase H literally never bypasses the gate again, regardless of
which plugins happen to be present.

No related issue: closes decisions #3/#42 in the melodic-software
issue/PR consistency initiative's Decisions Log (an internal tracking
artifact, not a GitHub issue in this repo).
@kyle-sexton
kyle-sexton marked this pull request as ready for review July 16, 2026 13:19

@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: 64d2cdadc6

ℹ️ 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".

Comment thread plugins/code-tidying/skills/tidy/SKILL.md Outdated
…R body

The canonical /pull-request create body template is fixed to Summary +
Test plan with no slot for tidy-specific content; extending it would
reopen the bypass surface this PR exists to close. Post the Tidyings
applied / Deferred items sections as a follow-up PR comment instead
when source-control is installed, so the canonical gate stays the sole
body-owner while the audit trail still lands in the PR timeline.
The prior wording let an agent judge the Tidyings-applied table as
"nothing beyond what's already in the PR body" and skip the whole
comment -- but that table is never in the body anymore, so skipping
silently reproduces the exact bug this PR fixes. Only Deferred items
stays conditional.
@kyle-sexton
kyle-sexton merged commit 26ccaf0 into main Jul 16, 2026
14 checks passed
@kyle-sexton
kyle-sexton deleted the feat/wp14-tidy-pr-decoupling branch July 16, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant