Repository navigation
fix(policy): hold approve and merge on unlifted STOPP signals - #18
Conversation
A STOPP / "NICHT MERGEN" / "do not merge" / REQUEST_CHANGES text in a PR comment or review, or a CHANGES_REQUESTED review, now holds pr.merge and pr.review APPROVE regardless of the posting account. Only a later explicit release by the same account (or a policy.stop_release_accounts entry), or a later approve by the same account on another head, lifts it. Unreadable comments or reviews fail closed. Both typed actions route through one gate (stop_gate.hold_reason), so every core merge path passes it. Regression fixtures mirror the merge six minutes after a STOPP comment (2026-11-22) and the 2026-09-22 NICHT-MERGEN case. Ticket: T-20261122-473151443 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01THB2EyNYw5th8eXvfU8evh
Independent review, head
|
| Later comment | Why it matches _RELEASE |
|---|---|
weiterhin nicht fuer den Merge freigegeben, Tests rot. |
lookbehind only checks the word directly before |
Das ist nicht mehr freigegeben. |
same |
noch nicht freigegeben (two spaces) |
lookbehind is fixed to a single \s |
not yet freigegeben |
same |
freigegeben wird erst nach Retest |
bare word anywhere |
Ist der STOPP aufgehoben? |
a question counts as a release |
There is a seventh case. A stop comment without a SHA, followed by a same-account APPROVED on the same head, also lifts the stop. With no named prefix, any(...) over an empty set is False, so every later approve counts as "another head". The PR description says the release must come on a new head.
Why this matters here: during a bot-account fallback, the private instance wrapper acts as the owner account. That is the same account that posts the independent STOPP comments. "Same account" therefore does not mean "same instance". A routine bot comment that happens to contain "freigegeben" in any grammatical form would lift a human stop.
Suggested fix, kept small:
- Accept a release only as an explicit, unnegated line. For example
^\s*(?:STOPP?\s+(?:ist\s+)?aufgehoben|freigegeben|stop\s+lifted|cleared\s+to\s+merge)\b[^?\n]*$, matched per line withre.M. Reject the line if it containsnicht|kein|not|no|noch|erst|wirdbefore the keyword. - When a comment stop names no SHA, store the head that was current when the gate read the stop. If that is not known, require an explicit release and do not accept a later approve.
- Do not count the authenticated merge account as a releaser by comment. That account is the one writing.
- Add these probe rows as tests. The probe script is reproducible from the case table above.
Not part of this PR, but asked for: gh-CLI paths outside the core (private instance, reported separately)
- The base instance prompt still prescribes
gh pr merge … --match-head-commit. Only the full profile switches topr.merge. - The private instance wrapper passes
gh pr merge,gh pr review --approveandgh api -X PUT …/mergethrough. It refuses only auth, config, extension and alias. These paths skipstop_gateentirely. They need either a wrapper refusal or a prompt change. That cannot be fixed in this repository. --autois forbidden only by prompt text. If auto-merge was enabled on a PR earlier by someone else, GitHub merges without any gate. A pre-merge check ofautoMergeRequestis worth adding topr.merge, so that a HOLD also covers PRs where auto-merge is already armed.- STOPP text in inline review comments (
pulls/{n}/comments) is not read. A line comment saying "NICHT MERGEN" inside aCOMMENTEDreview with an empty body is missed.
No branch changes from my side; findings only.
Addresses the independent review STOPP on this PR (7 of 22 probes lifted a
stop wrongly):
- Release only by a line that is the formula alone (STOPP aufgehoben, STOP
lifted, Merge freigegeben, cleared to merge). Questions, negations and
extra words on that line never count; a release line next to a stop line
in the same comment keeps the stop.
- Approve of the stopping account lifts only on a head that GitHub compare
proves newer than every head the stop named. A stop without a head is
lifted only by the release line.
- The configured merge account never lifts a stop by approving.
- Inline review comments (pulls/{n}/comments) are read as stop sources.
- A held merge or approve reports armed auto-merge (auto_merge) so that it
can be disabled.
- All review probes are now parametrized tests.
Ticket: T-20261122-473151443
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01THB2EyNYw5th8eXvfU8evh
Independent re-review, head
|
| Mutation | Failed tests |
|---|---|
| Merge gate removed | 7 |
| Approve gate removed | 1 |
| List read error treated as fail-open | 3 |
| Unreadable comment skipped | 1 |
| Any account releases all | 1 |
| Approve lifts without compare proof | 3 |
| Merge account may lift by approve | 1 |
search instead of fullmatch |
1 |
| Inline comments ignored | 1 |
| Auto-merge note removed | 1 |
| No-SHA stop lifted by approve | 4 |
The 12th mutation, replacing the early non-dict check with pass, stays green. No test feeds a non-dict item.
Blocking residual: quoted or fenced formula lines count as a release
_lines() strips > and backticks before fullmatch. As a result, a quote-reply or a code block from the stopping account lifts its own stop:
| Later comment by the stopping account | Result |
|---|---|
> Merge freigegeben followed by Nein, noch nicht. |
lifted (expected HOLD) |
> STOPP aufgehoben (quote only) |
lifted (expected HOLD) |
a fenced code block whose only line is STOPP aufgehoben |
lifted (expected HOLD) |
GitHub's "Quote reply" produces exactly the first form. A reviewer who quotes the author's release line in order to contradict it would release their own stop.
Suggested fix:
- Do not strip
>or backticks. Skip blockquote lines (lstrip().startswith(">")) and lines inside fenced blocks before thefullmatch. - Add the three rows above as probe tests.
- Add one test with a non-dict item, so the early check is pinned.
Notes, not blocking
- Hex-like tokens of 7 or more characters in a stop comment, such as long issue or comment numbers or
20261122, become "named heads". Compare on them fails, so such a stop can then be lifted only by the formula. This fails closed, which is acceptable. - The auto-merge note appears only when a hold exists. That is fine, because the gate cannot stop GitHub's own auto-merge in any case.
No branch changes from my side; findings only.
Round-2 review residual: _lines() stripped ">" and backticks before the
fullmatch, so a quote-reply ("> Merge freigegeben" + "Nein, noch nicht."),
a quote alone or a fenced block containing only the formula lifted the
quoting account's own stop. ">" and backticks are no longer stripped and
lines inside ``` / ~~~ fences are skipped for releases; stop detection
still reads every line (fail closed).
Tests pin the three review rows, a tilde fence, a release after a closed
fence and the early non-dict check. Mutations "strip > and backticks",
"no fence tracking" and "drop non-dict check" each turn tests red.
Ticket: T-20261122-473151443
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01THB2EyNYw5th8eXvfU8evh
Independent re-review, head
|
| Mutation | Failed tests |
|---|---|
| Merge gate removed | 7 |
| Approve gate removed | 1 |
| List read error treated as fail-open | 3 |
| Unreadable comment skipped | 1 |
| Any account releases all | 1 |
| Approve lifts without compare proof | 3 |
| Merge account may lift by approve | 1 |
search instead of fullmatch |
4 |
| Inline comments ignored | 1 |
| Auto-merge note removed | 1 |
| No-SHA stop lifted by approve | 4 |
| Non-dict check removed | 1 |
| Fences not detected | 2 |
> and backticks stripped again |
2 |
Privacy scan of the diff: 0 hits.
Residual, not blocking: an indented code block (four leading spaces) whose only line is the formula still counts as a release. A reviewer's own comment would hardly contain that, so I leave it as a possible follow-up. Treating lines with 4 or more leading spaces after a blank line as code would close it.
Problem
Twice, a pull request was approved and merged minutes after a reviewing instance had posted a STOPP / "NICHT MERGEN" signal. Both times the signal stood under a different account than the merging bot (2026-09-22 and 2026-11-22, the latter merged six minutes after the STOPP comment). Nothing in the typed actions read PR comments or reviews before approving or merging.
Change
stop_gatemodule with one pureevaluate()and a fetchinghold_reason(). It reads all issue comments and reviews of the PR fresh, orders them by time and holds when an unlifted stop exists:STOPP,STOP(capitals),nicht mergen,do not merge,don't merge,REQUEST_CHANGESin a comment or review body, or aCHANGES_REQUESTEDreview. Negations ("kein STOPP") do not count. Dismissed reviews are ignored.STOPP aufgehoben,STOP lifted,Merge freigegeben,cleared to merge) by the same account or by an account in the newmulti_bot.policy.stop_release_accounts(default[]); questions, negations and extra words on that line never count. Or a later APPROVED review by the same account on a head that GitHub compare proves newer than every head the stop named; a stop without a head is lifted only by the formula; the configured merge account never lifts by approving.pr.mergeandpr.reviewwithAPPROVEboth call this one gate before writing, so every core merge path passes it. Merges in the instance go throughcore act pr.merge.Tests
tests/test_stop_gate.py:state,submitted_at).134 passed(stop_gate, typed_actions, pr_review_action, multibot_resources).493 passed, 2 skipped. The one failure was the prompt-documents-every-switch test, which this PR fixes.ruff checkandruff format --checkare clean.Not included
pr.readyis not gated. Readying a draft is not a merge, and the merge stays gated.Ticket: T-20261122-473151443
🤖 Generated with Claude Code
https://claude.ai/code/session_01THB2EyNYw5th8eXvfU8evh