Repository navigation
fix(running-in-ci): leave a review that lands mid-poll to tend-mention - #870
Conversation
tend-agent
left a comment
There was a problem hiding this comment.
The role-boundary cut is the right shape, and the three mechanical claims behind it check out — verify short-circuits to should_run=true on PR_AUTHOR == bot_name before the engagement heuristics, the pull_request_review prompt arm tells that run to make requested changes and push, and the relay's fork filter doesn't touch same-repo nightly PRs.
The one thing that doesn't hold is the backstop in "Why the handoff is safe": the notifications poll can't see this review, because GitHub raises no notification for an actor's own activity. The review is tend-agent's, on a tend-agent-authored PR, so no notification thread is ever created and the stale-unanswered-items path has nothing to find.
That matters because the dispatch can be lost without anything failing. tend-mention-handle-<PR#> runs at cancel-in-progress: false, and CLAUDE.md's "GHA queue depth = 1" note records that a third job arriving replaces the queued one — on a PR that's drawing several events, the review's handle job is exactly the one that gets replaced. Before this change the still-live session was the fallback; after it, the only residual is "name the outstanding review in your summary", and a session summary isn't maintainer-visible, so a dropped dispatch is silent rather than merely late.
Not arguing the trade-off goes the other way — the duplicated fix-and-verify cycle is the far more common outcome, and paying it every time to insure against a rare dropped dispatch is a bad deal. But the PR body should probably say the handoff is unbacked rather than backed, since that's the property a future reader will lean on.
How I checked the notification behaviour
gh api "notifications?all=true&per_page=100" (returns the newest 50, sorted updated_at desc; newest entry was 2026-08-06T04:23:44Z).
Absent entirely — each bot-authored, each with bot self-reviews and no other actor:
- #868 — opened today 08:52, self-reviews 08:57–08:59, i.e. newer than the newest row in the list, so it would sort first if it existed
- #837, #834, #821 — same shape
Present, and only for someone else's action:
|
Correct, and I re-confirmed it before changing anything: this PR's own review at Body updated. The section is now "What the handoff rests on — and what doesn't back it", and it states plainly that the dispatch is the only thing carrying the review, that a No change to the skill prose: it never claimed the backstop, so the inaccuracy was confined to the body. |
…eeps as siblings (#893) Two bot comments answering the same freshly-filed issue, 18 seconds apart, with independently-derived but substantively identical content. Every dedup guard in `running-in-ci` was followed; the guard for comments just doesn't say *when* to run the re-fetch, and the sibling guard for `gh pr create` 100 lines up does. ## The race, from the two session logs Issue opened 08:20:35Z by an outside consumer's bot. `tend-triage` fired on `issues: opened` and queued. The scheduled `tend-review-runs` run, already in session since 08:10:33Z, found the same issue in its survey at 08:22:24Z and started composing an answer to it. | Time (UTC) | Actor | Event | |---|---|---| | 08:20:35 | — | issue opened | | 08:20:37 | `tend-triage` | run created; job queued 5 m 08 s | | 08:22:24 | `tend-review-runs` | reads the issue during its survey | | 08:25:45 | `tend-triage` | job starts | | **08:29:03.977** | `tend-review-runs` | **dedup recheck** — `gh issue view … --json state,comments` → 0 bot comments. Correct at that instant. | | 08:29:07.764 | `tend-triage` | `gh issue comment` → first comment | | 08:29:20.818 | `tend-review-runs` | greps its composed body for placeholders, scans its URLs | | **08:29:26.006** | `tend-review-runs` | posts → second comment, 18 s after the first | The recheck was 22 seconds stale by the time the post went out, and the work that consumed those 22 seconds was the pre-post hygiene the same skill file asks for — compose the body, grep it for `PLACEHOLDER`/`<SHA>`/`<TODO>`, check every `github.com/` owner. Moving the recheck after that hygiene would have caught it: the triage comment existed from 08:29:08, a full 18 seconds before the post. ## Change Two sentences in **Recheck Before Posting**, no new section: - **Ordering.** Say the re-fetch runs as the last step before the post, and name the body-composition/placeholder-grep/link-check work as the gap it has to close. This is the rule the file already states for the sibling path — *"Re-run the check **as the last step before `gh pr create`**"* — applied to the comment path, which currently says only "before posting". - **Who the sibling can be.** The bullet listing pre-empting workflows names only `tend-mention`, `tend-triage`, `tend-review`. The run that duplicated here was a scheduled sweep, and a reader of the current list would reasonably conclude sweeps aren't in scope. Widen it to "every workflow posts as the same bot account", and call out the sharpest case: `tend-triage` owns `issues: opened`, so a sweep already in session that finds the same fresh issue is racing a run that already owns it. Not proposed here: a positive in-flight check (query `actions/runs` for a concurrent `tend-*` run on the same subject before posting) — the `notifications` skill has one and it would also have caught this. That's a new guard on every posting path rather than an ordering clause on an existing one, so it needs more than one occurrence behind it. Recorded in the evidence log instead. ## Gate assessment - **Confidence**: 1 occurrence, no prior instance of this shape in the evidence log for this target. **Structural** — no decision point anywhere in the chain: the skill text does not order the recheck relative to the post, so replaying the same two runs produces the same gap every time. - **Classification call, stated so it can be pushed back on.** I filed at 1 occurrence by reading the outcome as **Critical** rather than High — the wrong output shipped publicly, on an outside contributor's issue, and duplicate unsolicited comments are the specific thing the conduct rule names. The alternative reading is High (2–3 occurrences), which would mean recording this and waiting for a second one. - **Magnitude**: two sentences inside an existing guard, one of them restating a rule the same file already applies to `gh pr create`. Lowest bar on the Gate 2 table, and the reason I was willing to act on a single occurrence — the cost of being wrong here is one clause. Adjacent but distinct, checked for overlap: #865 / #870 cover a *review* landing while a session polls its own PR's CI; #867 covers `tend-ci-fix` not seeing a sibling's tracker. Neither touches this section or this race. Evidence log: https://gist.github.com/e08f6e62d6478163cb425a75648eb7e4 --------- Co-authored-by: tend-agent <[email protected]>
tend-agent
left a comment
There was a problem hiding this comment.
Two mechanical notes on the new head-SHA subsection, both inline. Self-authored, so this is a COMMENT rather than an approval.
…on altitude Two review fixes on the head-SHA subsection. The OID comparison alone passes on a merged or closed PR, since headRefOid freezes at its merge-time value — exactly the case the rule exists to avoid, so the expensive step ran on superseded work. Fetch `state` on the same call. Rename BASE_OID to HEAD_OID: the review skill uses BASE_SHA for baseRefOid, so a BASE_ name holding a head SHA reads as the wrong ref when copied. Move the "review that lands while you poll" subsection below the "pre-existing" paragraph — that paragraph is a general CI Monitoring rule and was reading as scoped to the new heading.
## Problem The gated CI poll in **CI Monitoring** caps at ~9 minutes, but nothing says the cap is the *whole* budget. Two `tend-review` sessions on `max-sixty/worktrunk` have now hit the cap and simply run the loop again — three full passes each, ~28 minutes of post-approval polling — because re-entering reads as diligence rather than as waiting on something that already proved it won't settle. It can't settle. `pending()` deliberately reads the whole `statusCheckRollup` rather than `--required`, so it counts advisory jobs too. worktrunk's `nightly` workflow runs `feature-powerset` and `benchmarks` for 80+ minutes on a PR head — the repo's own overlay documents the benchmark job's runtime — so on any PR that triggers them `pending()` structurally cannot return 0 inside a 9-minute cap, no matter how many times the loop is re-entered. ## Evidence | Run | PR | Approved | Poll passes | Ended | Still pending at exit | |---|---|---|---|---|---| | [31086241862](https://github.com/max-sixty/worktrunk/actions/runs/31086241862) | [#3748](max-sixty/worktrunk#3748) | 08:48:33Z | 3 × 9 min (08:48:41Z → 09:16:19Z) | 09:16:37Z | `feature-powerset` (started 08:49:11Z, still running an hour later) | | [30833412090](https://github.com/max-sixty/worktrunk/actions/runs/30833412090) | [#3721](max-sixty/worktrunk#3721) | 16:56:51Z | 3 passes, ~26 min beyond the first | 17:33Z | `feature-powerset`, `codecov/patch` (never registered) | In run 31086241862 every required check was terminal by 09:00:25Z; the remaining 16 minutes of polling watched one advisory job. The session's own log shows it saw `feature-powerset IN_PROGRESS` on all nine iterations of the final pass and then ended with the reasoning `"One non-required nightly job, feature-powerset, was still running when I hit the polling cap (~28 min) — I didn't wait it out; it's advisory and a failure there couldn't stem from a comment-only diff."` — a sound call, but it stayed in the session log. Step 4 asks for that as a comment; nothing was posted, so the PR carries an approval with no record of what went unverified. The 30833412090 session did post the comment, so the two runs resolved the same state differently. ## Change Step 4 now says the cap is terminal, gives the structural reason (`pending()` counts advisory jobs, so a long matrix can never reach 0), and specifies what the unverified-checks comment should carry — each pending check, marked required or advisory, with `gh pr checks --required` named as the source since the rollup the poll reads carries no required flag. An advisory-only tail becomes one cheap line rather than a judgment call about whether to say anything at all. ## Gate assessment - **Evidence level**: High — consistent across two independent sessions, both traced to the same structural cause. Occurrences: 2 (this run + prior evidence). The prior entry pre-registered exactly this escalation: *"Watch for a second, independent run showing the same re-entry before treating as High."* - **Structural**, not stochastic: `pending()` counts non-required checks by design (the recipe explains why it avoids `--required`), so any repo with a long advisory matrix reproduces this on every gated poll. - **Change type**: targeted fix — one numbered step, no new section. Normal bar, met. ## Not covered elsewhere [#821](#821) addresses the **pre-APPROVE** rollup guard in `review/SKILL.md` (provenance of a stale red when the cap expires); this is the **post-approve** dismiss-on-red poll in `running-in-ci`, where a terminal rule already exists and is being skipped rather than improvised. [#870](#870) adds a subsection after step 4 about reviews landing mid-poll and does not touch the step itself. Evidence log: https://gist.github.com/a88c03f4d0c3fb1791060ff3dd97d1c4 --------- Co-authored-by: tend-agent <[email protected]>
…t one by position (#899) A session verifying its own skill edit closed a live maintainer-facing issue and posted a false status comment. The bot caught it and self-healed within ~2.5 minutes, but the close/reopen is permanent in the timeline and the deleted comment had already fired a workflow run. The guidance that produced the behaviour is still unguarded, so the next session hits the same shape. ## What happened Run [31257558939](https://github.com/max-sixty/tend/actions/runs/31257558939) (`tend-mention`, `repository_dispatch`) was answering a review question on #898 — a change to `plugins/tend-ci-runner/skills/nightly/SKILL.md`. To verify the edit it extracted a code block from that file **by fence ordinal** and ran it: ````bash awk '/^```bash$/{n++} n==3 && !/^```/{print} /^```$/{if(n==3) exit}' \ plugins/tend-ci-runner/skills/nightly/SKILL.md > /tmp/step3.sh bash /tmp/step3.sh ```` The third `bash` fence in that file is not the step-3 recipe it was aiming at. It is the drift-issue closer: ```bash gh issue list --state open --author '@me' \ --search '"configuration drift" in:title' \ --json number --jq '.[].number' \ | xargs -r -I {} gh issue close {} --comment 'tend check now passes.' ``` Issue #822 (`tend check: configuration drift on max-sixty/tend`) matched. It was closed at `12:38:56Z` with the comment `tend check now passes.` — false; the check still fails. The session noticed, reopened at `12:39:04Z`, deleted the comment, and [left a correction on the thread](#822 (comment)) plus a flag in its PR reply. Its own words from the session log: *"My mistake — I ran an extracted block without reading it first."* What did not recover: `#822`'s timeline still shows `closed by tend-agent` / `reopened by tend-agent`, and the deleted comment had already fired `issue_comment`, so run [31257716552](https://github.com/max-sixty/tend/actions/runs/31257716552) exists and always will. ## Root cause Two things compose, and only the second is a slip: 1. **Structural — the verification mandate has no write carve-out.** [`running-in-ci`'s "Verifying external-tool behavior"](https://github.com/max-sixty/tend/blob/03f8e0d/plugins/tend-ci-runner/skills/running-in-ci/SKILL.md#L610) says *"verify by running the code"* and ranks running the tool above reading the source, with an example scolding a session for trusting docs instead of running the thing. That instruction is right, and the session was obeying it. Nothing anywhere says the recipes it points at include `gh issue close`, `gh pr comment`, and `git push`, or that "run it" needs to mean something different when the recipe writes. Every adopter's `nightly` skill ships that same closer, so this is a bundled gap, not a tend-local one. 2. **Stochastic — selecting the block by ordinal and not reading it.** A different session might have read it. But the ordinal is a trap independent of judgment: it moves with every edit to the file, so the block that runs is by construction not guaranteed to be the one under test. ## The change One paragraph plus a two-line example in the section that created the pressure. It names the write surface, kills positional extraction, and gives the read-half recipe. No new section, no reorganisation. ## Gate assessment - **Evidence level: Critical, 1 occurrence** — this is the gate table's own example, *"clearly wrong outcome (closed wrong issue)"*, which acts at 1. It is also genuinely new: every one of the 124 prior windows in the evidence log records `0 reopened issue` under negative signals, so there is no historical count to add to. - **Classification: structural pressure, stochastic trigger.** I'm not claiming the failure is fully structural — a session that read the block first would have avoided it. What is structural is the instruction that sent it there with no mention of side effects, and the ordinal extraction that makes "the block I meant" unknowable. - **Magnitude: targeted fix.** Gate 2 would put a *new* section at the 3+ bar. This is a guard attached to an existing instruction that demonstrably produced a public wrong write, held to one paragraph to stay proportionate. Flagging the tension rather than hiding it: if you read this as a new-paragraph change wanting 3 occurrences, the counter-argument is that the three occurrences would each be another wrongly-closed issue. - **Dedup:** no open or closed issue/PR covers it. The three open `running-in-ci` PRs (#837, #870, #876) are all the CI-monitor poll, a different section. ## Verified, not inferred - Both claims in the new text were checked against this incident rather than assumed: `#822`'s events API shows the close and the reopen both retained; run `31257716552` fired from the since-deleted comment and is still listed. - The extraction command and `bash /tmp/step3.sh` are read verbatim from the session log's `tool_use` entries, not reconstructed from the bot's summary. - The third-fence block is reproduced by re-running the same `awk` against `nightly/SKILL.md` at `03f8e0d`. Evidence log: https://gist.github.com/e08f6e62d6478163cb425a75648eb7e4 --------- Co-authored-by: tend-agent <[email protected]>
…PR (#944) ## 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 #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 --------- Co-authored-by: tend-agent <[email protected]>
Problem
When a session opens a PR and then stays alive polling its CI,
tend-reviewfires on that PR and posts findings — and two actors race to fix them: the still-live session that opened the PR, and thetend-mentionsession dispatched by thepull_request_reviewevent. Both make the same edits and run the same suite; the loser discovers the duplication atgit push, discards its commit, and a full fix-and-verify cycle is paid twice. No wrong output reaches the repo — every existing dedup guard fires — but every guard inrunning-in-ciis anchored at the output boundary (gh pr create,git push, comment posting), so the collision is only ever discovered after the cost is sunk.Solution
Two rules, one per commit — the first removes the common case, the second bounds what the first can't reach.
1. A role boundary: a review that lands mid-poll isn't yours to action
Per the second of the two options in #865. The API-based sibling-run check in the first option can't see which branch a nightly run is working on — that's only visible from its checkout — so it can't close the nightly-vs-mention case it was aimed at.
The rule goes in
running-in-ci's CI Monitoring section rather than the nightly skill: the mechanism is generic to any session that opens a PR and stays alive polling it (nightly, ci-fix, triage, weekly, the hourly review skills), and CI Monitoring is where that "stay alive and poll" instruction lives. The nightly skill's step 8 gets a one-line pointer to it, since its "poll CI" step named no section to read.The session that stands down has to be the one holding the PR: the mention dispatch fires whether or not the holder also responds, so it is the run that cannot be suppressed.
2. A cost bound: re-check the head SHA before the expensive verify
The role boundary cuts on who owns the review, and a recurrence on
max-sixty/worktrunkshows work colliding without the review being read at all. There, nightly never fetched the review;codecov/patch— a required gate on that repo — flagged the same new closure the reviewer had, so nightly added the missing test as the follow-up it was gated on (957358b46, 06:56) while the mention run independently built a near-identical one. The convergence isn't luck: a reviewer and a coverage tool reading the same new code ask for the same missing test. Rule 1 permits this by construction, since closing a red required gate is the carve-out it keeps.So the second commit puts a check on the writing side, where the cost is paid: record
headRefOidbefore editing, re-check it immediately before each expensive step (full suite, coverage/snapshot regeneration, long build) rather than only atgit push. On that occurrence it would have caught the sibling push at ~06:56 instead of ~07:01 — before the integration suite and the post-reset re-verify, which is where most of the wasted ~$2.14 went.It also records why the runs-API approach doesn't work, so it isn't re-derived: both writing runs report
head_branch: main(nightly runs onschedule, the mention handler onrepository_dispatch), so a live sibling is invisible there. Only thepull_request_targetreview run carries the PR branch — confirmed against runs 31465475753, 31466280614, and 31466624503.The other shape the report floats — making a PR-holding session read-only after
gh pr create— isn't taken here: that session is the only one gated on the PR's checks, and no dispatch fires for a red gate, so a redcodecov/patchwith no accompanying review would sit unfixed.What the handoff rests on — and what doesn't back it
tend-mention'sverifyjob short-circuits toshould_run=trueonPR_AUTHOR == bot_name, so every review on a bot-authored same-repo PR reaches the handle job, and the prompt forclient_payload.kind == 'pull_request_review'instructs the session to make requested changes and push. Nightly-opened PRs are same-repo, so the fork exclusion on the relay job doesn't apply to them.The handoff is unbacked — the dispatch is the only thing carrying the review, and if it's lost nothing recovers it. GitHub raises no notification for an actor's own activity, so a
tend-agentreview on atend-agent-authored PR creates no notification thread at all, and the notifications poll's "stale unanswered items" path has nothing to find. And the dispatch can be lost silently:tend-mention-handle-<PR#>runs atcancel-in-progress: false, and per CLAUDE.md's "GHA queue depth = 1" note a third job arriving replaces the queued one — on a PR drawing several events, the review's handle job is exactly the one that gets replaced. Before this change the still-live session was the fallback; after it, the only residual is "name the outstanding review in your summary", which lands in the session log rather than anywhere a maintainer sees.That is the accepted cost rather than an oversight: the duplicated fix-and-verify cycle is the common outcome and a dropped dispatch is rare, so paying the duplication on every review to insure against it is the worse deal. But the property a future reader will lean on is that the handoff has no second line of defence.
How the no-self-notification behaviour was checked
gh api "notifications?all=true&per_page=100"returns the newest 50 threads,updated_atdesc. The newest row is2026-08-06T04:23:44Z.Absent entirely — each bot-authored, each carrying bot self-reviews newer than that newest row, so they would sort first if a thread existed:
Present, but only keyed to another actor's action:
updated_at16:43:23, ~20s after the maintainer's merge at16:43:03updated_at16:44:47, after the merge at16:44:26Testing
None — the change is skill prose, and no test covers skill markdown. Verified against the mention template's
verifylogic and prompt text (generator/src/tend/templates/mention.yaml.j2) that the run being handed to actually receives and actions these reviews, and against the notifications API that no self-activity thread exists to back that dispatch up. The second commit's premises were checked against the public record onmax-sixty/worktrunk: the commit order and timing on #3799, and thehead_brancheach of the three runs reports.Closes #865 — automated triage