Skip to content

fix(running-in-ci): re-read the branch before a terminal action on a PR - #944

Merged
max-sixty merged 3 commits into
mainfrom
fix/issue-943
Aug 11, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/issue-943

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

#943 reports a tend-nightly session closing (with --delete-branch) a PR it had opened, seconds after a tend-mention session had pushed the review's remedy to that same PR and polled its checks green. The branch ref is gone; the commit survives only through the PR ref.

The blind spot is structural, not bad luck. Every recheck a session runs before a terminal action looks at the thread: Recheck Before Posting counts comments and reviews, Re-check PR state before pushing a follow-up commit asserts state == OPEN (true here), and the closing session's own re-read was gh pr view --json reviews. A close collides with commits and branch state, which none of those queries return — so the sibling's pushed, CI-green work was invisible by construction, and the same query replays identically every time.

The second, separable half from the report: the mention session's closing summary — "PR is open and awaiting a maintainer" — was false 71 seconds after it was written, and it is the only durable record that session leaves.

Solution

Two rules, one per commit, both in running-in-ci.

  1. A terminal action collides with branch state, not comments — a new subsection under Recheck Before Posting, where the rule it extends already lives. Before gh pr close, a revert, or a force-push, re-read headRefOid,commits rather than the thread. If the head moved past the SHA the session last pushed, read the sibling's commits before deciding. Deliberately not a stand-down: withdrawing a PR whose premise a review invalidated is the PR-holder's call and it was the right call in nightly closes a PR out from under the mention session that just fixed it — divergent dispositions on the same review (#865 sibling) #943 — what changes is that the close comment says what the sibling landed and why it stands anyway, and drops --delete-branch so that work stays reachable.
  2. Don't close on a state claim you can't hold — one paragraph under End the turn only when work is shipped. Re-check state claims in the closing summary as they are written, and prefer reporting what the session did ("pushed the fix; its checks went green at that head") over a state it doesn't control.

Relationship to #870

Complementary, and deliberately not the same rule. #870 makes a PR-holding session stand down from a review that lands mid-poll — applied to #943 that would have prevented the destructive close, but only by making nobody withdraw a PR that should have been withdrawn, since the mention session held author role and had no standing to conclude the PR shouldn't exist. This PR keeps the withdraw authority and puts the check on the terminal action itself, so it holds whether or not #870 lands. The two touch different sections of running-in-ci (this one is under Recheck Before Posting and End the turn…; #870 is under Pushing to PR Branches and CI Monitoring), so they don't conflict textually either.

Testing

Skill prose — no test surface. Verified the file has no bang-backtick preprocessor poison, no trailing whitespace, and a trailing newline (the three local hooks that apply to it), and re-read both edits in place.


Closes #943 — automated triage

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule lands where the blind spot is, and the scoping — keep the withdraw authority, put the check on the terminal action — reads right against #943. One nit on the recipe.

…the thread

A session that opened a PR and stayed alive polling it can take a
terminal action — close, revert, force-push — on a head a sibling
session has already moved. Every existing recheck counts comments and
reviews or asserts state == OPEN, all of which pass while a pushed,
CI-green sibling commit sits on the branch; --delete-branch then makes
the loss destructive.

Refs #943
…hold

A closing summary is the only durable record a session leaves, and a
claim about the PR's state can be false seconds after it is written.
Re-check the claim as it is written, and prefer reporting what the
session did over reporting a state it doesn't control.

Closes #943
@max-sixty
max-sixty merged commit a0f9b1c into main Aug 11, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-943 branch August 11, 2026 23:36
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.

nightly closes a PR out from under the mention session that just fixed it — divergent dispositions on the same review (#865 sibling)

2 participants