fix(code-tidying): route tidy's PR creation through the canonical gate#218
Merged
Conversation
`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
marked this pull request as ready for review
July 16, 2026 13:19
There was a problem hiding this comment.
💡 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".
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
code-tidying:tidy's Phase H ("Ship") told the agent to create the PR by callinggh pr createdirectly — a bare bypass ofsource-control:pull-request's canonical create flow, which resolves issue-linkage (with an issue-existence check before shipping aCloses #Nkeyword), 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 callinggh pr createitself.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):code-tidying:tidyandsource-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).What changed
Phase H now applies the same optional-plugin graceful-degrade pattern
tidyalready uses elsewhere in its own SKILL.md (Phase C fordiscovery, Phase D forwork-items):source-controlis 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.source-controlisn't installed: the same invariants apply inline — verify an issue exists before writingCloses #N, assemble the body via quoted heredoc + concat (never an unquoted<<EOF), and refusegh pr createuntil the body carries a valid closing keyword or an explicitRefs #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-pluginreference/artifact-protocol.mdprecedent, drift-checked byvalidate-plugin-contracts.mjsand this session's newscripts/check-cross-plugin-source-drift.sh). Rejected for now: every invariant worth stating is already authoritative inpull-request/reference/create.md, so a copied doc would be pure duplication with drift risk — and with exactly one non-source-controlconsumer 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 ifsource-controlis 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.gh pr createreferences remain underplugins/code-tidying/.tidy'sSKILL.mdprose directly (onlyopen-pr-count.test.sh, unrelated to Phase H) — nothing to update there.