feat(hook): deny asking gh whether a pull request can merge - #156
Merged
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
CybotTM
force-pushed
the
feat/warn-on-handrolled-merge-readiness
branch
from
August 8, 2026 08:32
ddfd4f8 to
48b50e0
Compare
CybotTM
force-pushed
the
feat/warn-on-handrolled-merge-readiness
branch
from
August 8, 2026 08:34
48b50e0 to
f79926e
Compare
`gh pr view --json mergeStateStatus` and `gh api .../pulls/N --jq .mergeable_state` answer "blocked" and never say why. They are blind to the two states that usually cause it — an unresolved review thread and a failing check — so a pull request that needs work looks like one that is merely waiting. pr-status.sh reports both and ends with a NEXT: line naming the action, which is why the skill documents it as the status tool for the wait/merge cycle. Documenting it was not enough: one session issued 24 such queries despite the rule, and reported "waiting for your approval" while two review threads and two red CI jobs sat unattended. This gates the shape the same way the hand-rolled poll above it is gated. Only a segment that actually invokes gh counts, and shell keywords are skipped so a loop body — " do gh api ..." after splitting on separators — is caught too. Writing about the rule stays possible: a heredoc carrying test cases, an echo, a grep pattern. Commands already running pr-status.sh pass, as does the GraphQL query with `isRequired`, which names which required context is unmet and is the one thing pr-status.sh does not break down. The script had no tests. It has them now, standard library only, covering the new gate in both directions and the checks that were already here. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
lint.yml is governed by the skill template and has to stay byte-identical across skill repos, so the job gets its own workflow rather than an exception on a governed file. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
CybotTM
force-pushed
the
feat/warn-on-handrolled-merge-readiness
branch
from
August 8, 2026 08:38
f79926e to
2eeb8da
Compare
|
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.



The skill already documents
pr-status.shas the status tool for the wait/merge cycle, and the hook already gates the hand-rolled poll. The single-shot query was not gated:gh pr view --json mergeStateStatusandgh api .../pulls/N --jq .mergeable_stateanswer "blocked" and never say why, staying blind to the two states that usually cause it — an unresolved review thread and a failing check.Documenting it did not hold. In one session I issued 24 such queries despite the rule being in my own instructions, and told the operator a pull request was "waiting for your approval" while two CodeQL review threads and two red CI jobs sat unattended. They had to point it out. That is what this gate is for.
Scope is deliberately narrow. Only a segment that actually invokes
ghcounts, and shell keywords are skipped so a loop body (do gh api ...after splitting on separators) is caught as well — that was the exact shape I kept using. Writing about the rule stays possible: a heredoc carrying test cases, an echo, a grep pattern, this rule's own tests. Commands that already runpr-status.shpass, and so does the GraphQL query carryingisRequired— that one names which required context is unmet, which pr-status.sh does not break down, so it is a deliberate deep dive rather than a status check.scripts/validate_git_command.pyhad no tests at all. It has them now — standard library only, no dependency to install — covering the new gate in both directions plus the conventional-commit, force-push and hard-reset checks that were already there, and a CI job runs them. A PreToolUse hook decides whether commands run in every session that installs this plugin, so a silent regression there is expensive.