Skip to content

The Implementer's own subject pull request (review-feedback, merge-conflicts, abandoned-drafts, dequeued, failed-runs) is never checked for a mid-gap merge before the stage spends its own engagement

Id: TD-PPagop-26083004 · Status: resolved · Filed: 2026-08-30 · Resolved: 2026-10-02 · Ref: #2052

What: agent-ops#916’s escalation #922 settled a merge-mid-stage read at two call sites — “one state-read helper (pr_merge_state), at the handoff (fail-closed) and at the start of any stage handed a work order that already names a subject pull request (advisory)”. The Reviewer’s own stage-start read (agent-cycle.sh, just inside “— 8. Reviewer stage —”) and the handoff read (right after $rev_status is parsed) both landed in this pull request. The Implementer’s own stage-start read — named in the same decision for the five finishing sources whose work order already carries a pr_url before the Implementer ever runs (review-feedback, merge-conflicts, abandoned-drafts, dequeued, failed-runs) — did not.

Why it matters: it is a cost optimisation only, never a safety gap. Nothing about a merge caught here is irreversible the way a draft flip, an Approver review or a landing attempt is — the Reviewer’s own handoff-time read (requirement 31d) still runs after the Implementer, fail-closed, and would still catch a subject that merged before or during the Implementer’s own engagement, exactly as it catches one that merged during the Reviewer’s. The gap this record tracks is only that an Implementer can spend a whole engagement — a push, a review round answered, a rebase — against a pull request already merged out from under it, when one gh pr view call ahead of time would have caught it for the price the Reviewer’s own stage-start read already pays.

Where: agent-cycle.sh, the Implementer stage launch (the five finishing sources’ own branch/claim handling, “— 7. Implementer stage —” and its preceding claim logic) — the same pr_merge_state (lib/handoff.sh) and reviewer_merge_observed-shaped completion (lib/merge-observed.sh, requirement 32c) the Reviewer’s own two call sites already use, generalised past its current stage values ("reviewer"/"reviewer-stage-start") to cover an Implementer catch too.

Suggested fix: before launching the Implementer for one of the five finishing sources, read pr_merge_state against the work order’s own pr_url; on merged, skip the Implementer entirely and retire the item the same merge-observed way (no file_debt/file_issue to carry, since no stage ran yet to have found anything — the same shape the Reviewer’s own stage-start call site already takes with an empty verdict); on anything else (including unreadable), run the stage as normal — advisory only, exactly as the Reviewer’s own stage-start read already is, since the Reviewer’s later handoff-time read still guards whatever the Implementer produces regardless.

Noticed while working PR #1061, which lands the Reviewer-side halves of the same decision.

Migrated to https://github.com/Poetic-Poems/agent-ops/issues/1062 — the pw::type:tech-debt band is served from labelled issues now (scripts/gather-tech-debt.sh), so a record filed after the register migration is invisible to it without one (#1046).