Skip to content

tools: add github_pr_merge, wait for CI then land a PR - #157

Merged
alpibrupa merged 1 commit into
mainfrom
feat/github-pr-merge
Sep 9, 2026
Merged

tools: add github_pr_merge, wait for CI then land a PR#157
alpibrupa merged 1 commit into
mainfrom
feat/github-pr-merge

Conversation

@alpibrupa

Copy link
Copy Markdown
Contributor

Summary

  • github_pr_create (tools: add github_pr_create, lex-code's first approval-gated tool #152) got a change as far as "a PR exists". Landing it always meant polling gh pr checks then gh pr merge by hand — exactly what this session did manually for six PRs in a row tonight, and the same pattern GitHub Copilot's "Agent Merge" and Codex's automatic pre-merge approval reviews both shipped this year.
  • Approval-gated, same reasoning as github_pr_create: merging is visible and irreversible. The approval prompt covers the conditional intent ("merge once checks pass"), asked before the outcome is known.
  • Verifies checks itself (gh pr checks --watch --fail-fast) rather than trusting the caller — refuses to merge unless that reports success, and returns the checks failure output as the error detail so it can actually be diagnosed.
  • pr accepts anything gh itself accepts (number, URL, branch name).

Test plan

  • lex check (full sweep), lex fmt --check, lex doc-sync --check, lex test all pass
  • Wired into refactor_permission's allowlist, all_tools_for_mode, and smoke.lex's skip list, mirroring github_pr_create exactly
  • Will use this exact tool to merge this exact PR once CI is green (dogfooding its own introduction)

🤖 Generated with Claude Code

github_pr_create (#152) got a change as far as "a PR exists". Landing
it always meant a human (or an agent driving `gh` by hand outside this
codebase) polling `gh pr checks`, then running `gh pr merge` once
green -- the exact pattern GitHub Copilot's "Agent Merge" and Codex's
automatic pre-merge approval reviews both shipped this year, and
exactly what a real dogfooding session did by hand for six PRs in a
row before this tool existed.

Approval-gated for the same reason github_pr_create is: merging is
visible to everyone with repo access and cannot be un-merged. The
approval prompt covers the whole conditional intent ("merge this once
checks pass"), asked before the outcome is known -- the same shape as
a human reviewer saying "LGTM, merge when CI is green".

Verifies checks itself (`gh pr checks --watch --fail-fast`) rather
than trusting the caller's own judgment, and refuses to call `gh pr
merge` at all unless that reports success -- a CI failure's own output
becomes the tool's error detail, so the failure can actually be
diagnosed rather than just reported as "didn't merge". `pr` accepts
anything `gh` itself accepts (number, URL, branch name).

Wired into refactor_permission's allowlist and all_tools_for_mode,
same as github_pr_create; added to smoke.lex's skip list (a smoke run
must never trigger a real merge).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@alpibrupa
alpibrupa merged commit 2588ef3 into main Sep 9, 2026
1 check passed
@alpibrupa
alpibrupa deleted the feat/github-pr-merge branch September 9, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant