Skip to content

Limit the triage bot's PR edits to escalate, hold and release - #29

Open
computron wants to merge 1 commit into
mainfrom
bot-label-gate
Open

computron wants to merge 1 commit into
mainfrom
bot-label-gate

Conversation

@computron

@computron computron commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem: the triage bot may run any gh pr edit. It can remove review requested or do not merge, the labels that make mergatron_guard.sh refuse a merge, and then merge. It can also rewrite a PR's title, body or base branch.

Fix: new mergatron_label.sh <PR> escalate <login> | hold | release, which runs only those three edits. mergatron.yml allows it in place of gh pr edit, the rules name the verbs, and setup.sh installs it in every mode. Any other call is refused with the usage line. No other edit command is on either bot's list. This repo's own .github/ copy, which already differs from the template, is not changed.

Risk:

  • The triage bot can no longer edit a PR's title, body or base, even when a maintainer asks for it in an @claude comment. That request now fails with the script's usage line.
  • Repos that copy only the new mergatron.yml and not mergatron_label.sh lose labeling and escalation until they add the script. setup.sh copies both.
  • To undo, put Bash(gh pr edit:*) back in the allowed tools.

Tested: the new tests/label_gate.sh checks the exact gh arguments for each verb, and that an unknown verb, a missing login and a non-numeric PR are refused. The full suite passes. Not yet run in a live bot job.

Closes #28.

PR assisted by Claude Code.

The bot could run any gh pr edit, so it could remove the labels that hold
a merge, or rewrite a PR's text or base. mergatron_label.sh allows only the
three edits the rules call for: escalate, hold and release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@computron

Copy link
Copy Markdown
Contributor Author

@claude review this PR: is the change correct, and is it needed?

@claude
claude Bot requested a review from ardunn November 19, 2026 22:43
@claude

claude Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Correct and needed: gh pr edit:* lets the bot remove block labels, so the merge hold fails. @ardunn: review it, because it changes agent rules and tool permissions.

  • Hole is real: bot can remove review requested/do not merge, then guard merges.
  • Same tool also lets bot edit PR title, body, and base.
  • Script allows only escalate/hold/release. fail and $who exist in lib.
  • CI ran tests/label_gate.sh. It passed.
  • Gap: <login> is not validated. escalate "a,b" adds two reviewers.
    • Fix: [[ "$login" =~ ^@?[A-Za-z0-9-]+$ ]] || fail ...
  • Repo's own .github/ copy still allows gh pr edit:*. Port it after merge.
Why escalated
Rule Hit
1: agent instructions github-template/mergatron_rules.md
1: tool permissions allowedTools in github-template/workflows/mergatron.yml
Status Draft. Not merged by bot.

@computron
computron marked this pull request as ready for review November 19, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Triage bot can remove the labels that hold a merge

1 participant