feat(api): implement the documented v2 PR merge endpoint (closes #194) #3525
Cross-repo impact
See what breaks downstream if this PR merges.
Closing issues1
API docs advertise POST /api/v2/repos/:owner/:repo/pulls/:number/merge but no route implements it#194closed⮌ Merged
This pull request was merged into main.
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts
Closes #194.
POST /api/v2/repos/:owner/:repo/pulls/:number/mergewas documented at/docsbut never implemented � API callers (including AI agents when the MCP connector token expires) had no JSON merge path.Approach � one gating chain, two transports. The full pre-merge policy chain lived inline in the MCP
gluecron_merge_prhandler. It moves verbatim tosrc/lib/pr-merge-gated.ts(performGatedMerge) and both the MCP tool and the new REST endpoint delegate to it, so the two surfaces cannot drift:{"confirmHighRisk": true}in the body) ? GateTest + AI-review hard gates ? D5 branch protection + CODEOWNERS (fail-open) ? ref update or AI conflict auto-resolve ? DB flip, J7 close-keywords, audit + activity + webhooks.200 {merged:true, sha}/422 {merged:false, reason}(+riskScorewhen relevant). Auth:requireApiAuth+reposcope + repo write-ACL viaresolveRepoAccess.source: "api"vs"mcp"so incidents can tell the paths apart.confirmHighRisk.Tests:
mcp-write.test.ts(34/34) now exercises the shared chain through the MCP tool; new 401 test for the REST route;tsc --noEmitclean; adjacent suites (mcp-tools-expanded,auto-merge,connect-claude) green. The 13 pre-existingapi-v2.test.tsfailures in a no-DB environment are untouched.?? Generated with Claude Code