Repository navigation
fix(pr-kit): make the force-push guard actually run, and cap the CI loop - #54
Merged
Merged
Conversation
A first audit of this plugin found four defects. Three are safety-relevant and all four are fixed here. make-pr-easy-to-review rewrites git history and force-pushes. Its only guard captured the pre-rewrite tree into a shell variable read back many tool calls later — and shell state does not survive between tool calls, so the byte-identical check compared two empty strings and the "do not push" rule never fired. The tree now lives in a git ref. Replacing that mechanism exposed a quieter version of the same bug, which review caught before it shipped: comparing two command substitutions passes when BOTH are empty, and command substitution discards git's exit code. A git that is absent, shimmed, broken, or run outside a repository produced exit 0 with no output — byte-identical to a genuine pass, in a harness that resets the working directory between calls. The check now uses --verify, chains with &&, and prints TREES MATCH <sha>; the instruction is to push only on seeing that token. Measured: dead git exits 1, absent git 127, outside a repository 128. The push states its lease explicitly against the recorded head. The bare --force-with-lease reads a remote-tracking ref a freshly added fork remote does not have, and is rejected as `stale info` even when nothing is wrong. An earlier version of this fix told the model to fetch and retry on that rejection — which refreshes the lease to include a collaborator's commit and then overwrites it. Measured on a fixture: their file gone, exit 0, output reading `forced update`. `stale info` now means stop. Also in that skill: the fork capture never checked out the commit it captured, so the section written for fork PRs could not be executed on one; the fork URL was built from headRepositoryOwner, an object; the fork remote is now named per PR with its URL confirmed, because `git remote add` exits 3 on a name clash and the push then goes to whatever repository the leftover name refers to; and the capture chains with && so a failed fetch cannot record a stale baseline. fix-ci stopped pointing at /review-cycle:accept, which is disable-model-invocation: true and exists for a human who reviewed the change themselves — instructing it both dead-ended the step and, if routed around, let the skill self-certify a fix it then pushed. This repo's own AGENTS.md forbids that verbatim. The loop gains a cap of three rounds, or two on the same check: the previous same-check heuristic could never fire when a fix for check A broke check B whose fix re-broke A. The merge-the-base guardrail names its commands and uses baseRefName instead of assuming main. The README no longer claims fix-ci stages and hands off; it commits and pushes each round by design, and now says so. Closes cpl-9uz Closes cpl-1yu Closes cpl-blp
Contributor
|
These packages will release:
|
jbabin91
added a commit
that referenced
this pull request
Sep 25, 2026
…onflict markers, and pin skill contracts (#94) Fixes two pr-kit skill defects from the 2026-09-17 audit and adds pr-kit's first tests. Every command claim below was measured in scratch repos or against live PRs. ## Changes - **`get-pr-comments` keeps open threads (cpl-0ye).** It skipped every outdated thread, but outdated means only that a later push changed the code the comment was left on. Outdated but unresolved threads now appear under **Possibly stale — verify**, located by `originalLine` (`line` is null on them — measured on vitejs/vite#15000, #11228, #2432 and cli/cli#14475). - **`get-pr-comments` pages for real (cpl-0ye).** The thread query declares `$endCursor`, which `gh api --paginate` requires; `--slurp` returns every page. A `node(id)` follow-up re-reads a thread with more than 50 comments. Measured with `first:2`: 5 pages, 9 threads; `--paginate` follows the thread cursor even when a nested comments page has more. - **`fix-merge-conflicts` checks the whole tree (cpl-r73).** `git diff --cached --check` missed a conflicted file left unstaged and failed on trailing whitespace. It is replaced by `git diff --name-only --diff-filter=U` plus two `git grep` marker searches with `-- ':/'`: one over the working tree, one over the index (`--cached`). The pattern covers diff3 `|||||||` and markers longer than 7; exit 128 is a failed search. - **`fix-merge-conflicts` states that a rebase swaps sides (cpl-r73).** A table and sentence: during `git rebase`, `ours` is the upstream and `theirs` is your commit; check `git status` for `rebase in progress` first. - **`fix-merge-conflicts` handles conflicts that leave no markers.** Binaries, symlinks, and paths one side deleted or both sides renamed pass every marker check once staged, with `git add` silently keeping the working-tree copy (the upstream, during a rebase). The skill now has the agent keep a side or `git rm` the path explicitly and report it. Submodule conflicts are out of scope: `git checkout --ours/--theirs` exits 0 on them and changes nothing. - **pr-kit prose-anchor tests (cpl-k3s).** `plugins/pr-kit/tests/skill-contracts.spec.ts`, 16 vitest tests, pinning the fixes above plus the earlier audit's contracts: the `make-pr-easy-to-review` tree guard, the `fix-ci` round cap, no skill invoking a model-disabled skill, every gh field a skill fills in being fetched, and the README's `gh` requirement matching the skills that call `gh`. Each of 42 literal mutations fails its own test. - **Release note:** `.changeset/pr-kit-audit-findings.md` (pr-kit patch). cpl-121 (README `gh` claim) was already fixed on main by #54 and is closed with no code change. ## Review `/review-cycle:review` converged in 5 iterations (Codex, code-reviewer, pr-test-analyzer, silent-failure-hunter; then spec conformance and a maintainability audit). Spec conformance found no missing or wrong requirements. ## Follow-ups - cpl-yxo — deferred anchor and marker-check gaps (CRLF `=======`, slashless skill references, `True` in frontmatter, a submodule cue, nine test-tightening suggestions). - cpl-crj — share anchor helpers across plugins and run the model-disabled-reference check repo-wide (3 unchecked references in review-cycle today). ## Test plan - `pnpm test` — 727 passed - `pnpm lint`, `pnpm format:check`, markdownlint — clean - `claude plugin validate ./plugins/pr-kit --strict` — passed - `pnpm exec oakum check --strict` — exit 0
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.
First audit of
pr-kitfound four defects. Three are safety-relevant; all four are fixed. Every claim below was measured in scratch git repos — commands and outputs are in the commit body and the changesets.The P0: a force-push guard that could not run
make-pr-easy-to-reviewrewrites history and force-pushes. Its only guard captured the pre-rewrite tree into a shell variable, read back many tool calls later. Shell state does not survive between tool calls, so the byte-identical check compared two empty strings and the "do not push" rule never fired.Replacing the mechanism exposed a quieter version of the same bug, caught in review before it shipped. Comparing two command substitutions —
— passes when both are empty, and command substitution discards git's exit code. A git that is absent, shimmed, broken, or run outside a repository gives
"" = "", exit 0, no output: byte-identical to a genuine pass, in a harness that resets the working directory between calls. That is the same class ascpl-ol6, reintroduced into the fix for it.The check now requires a token a dead git cannot fabricate:
TREES MATCH <sha>The lease: a fix that was briefly worse than the bug
The bare
--force-with-leasereads a remote-tracking ref a freshly added fork remote does not have, so it is rejected asstale infowhen nothing is wrong. An earlier version of this fix told the model to fetch and retry on that rejection — which refreshes the lease to include a collaborator's commit and then overwrites it. Measured: their file gone, exit 0, output readingforced update. That is--forceby another route, written into the section whose purpose is refusing it.The push now states its lease explicitly against the recorded head. Measured: succeeds with no tracking ref, and still refuses after a contributor push with their commit intact.
stale infonow means stop, with the reason stated so the shortcut is not reinvented.Also in that skill
git fetch <url> <ref>writesFETCH_HEADand moves nothing else, so the section written for fork PRs could not be executed on one — the model would rewrite the base branch and the guard would refuse with no explanation.headRepositoryOwner, which is an object — the URL was malformed. NowheadRepository.nameWithOwner.git remote addexits 3 on a name clash, and the push then goes to whatever repository the leftover name refers to.&&and use--verify, so a failed fetch cannot record a stale baseline.fix-ci
/review-cycle:accept, which isdisable-model-invocation: trueand exists for a human who reviewed the change themselves. Instructing it dead-ended the step, and routing around it would let the skill self-certify a fix it then pushed. This repo's ownAGENTS.mdforbids it verbatim.baseRefNameinstead of assumingmain.fix-cistages and hands off. It commits and pushes each round by design, and now says so.Verification
bin/run-batsclaude plugin validate ./plugins/pr-kit --strictoakum check --strictReviewed by three legs plus Codex. Nine findings fixed inline, four of which were defects introduced while fixing defects — the empty-comparison guard, the fetch-and-retry lease, and two changelog claims stronger than what was measured. Both changelog overstatements are corrected, which matters because under squash-merge the changelog is the surviving history.
Known limitation
pr-kithas notests/directory, so nothing mechanically prevents any of these from returning — every fix is prose a future edit can silently undo. Tracked ascpl-k3swith candidate invariants drawn from the defects actually found, two of which are mechanical and would have caught findings from this audit outright.Closes cpl-9uz
Closes cpl-1yu
Closes cpl-blp