Repository navigation
fix(review): ignore synthetic reply containers in all three review-record guards - #835
Conversation
…IEW_SHA
Replying to a review thread via POST /pulls/{n}/comments/{id}/replies makes
GitHub wrap the reply in a zero-body COMMENTED review anchored at the
then-current HEAD. The pre-flight took the newest bot review record, so after
any tend-mention run answered threads inline the next review computed its
incremental against a commit nothing had reviewed and skipped it as trivial.
Count a review record only when it carries a body or owns at least one
top-level (non-reply) inline comment.
Closes #828
tend-agent
left a comment
There was a problem hiding this comment.
The diagnosis is right and the repro reproduces exactly — I re-ran the old and new recipes against max-sixty/cargo-affected #54 and got 551e059 vs 1ffcde2, matching the table in the description. Two paginated calls are worth it here, and jq -s | add is correct against gh api --paginate, which merges pages into a single array (verified).
One gap: the filter's premise is that "body-empty and no top-level inline comment" uniquely identifies a reply container, but this skill's own primary success path produces exactly that shape. gh pr review --approve -b "" — "silence means correct" from step 5, and the trivial-skip path's "submit an APPROVE with an empty body so the PR isn't left in limbo" — writes a review with a zero-length body and no inline comments at all, so the new select drops it.
Across the last 25 tend PRs, 10 bot review records are state=APPROVED body_len=0, and every one is discarded:
| PR | records | as-written anchors at | head |
|---|---|---|---|
| #812 | one empty-body APPROVE only | (empty) | 02f8dce |
| #820 | COMMENT+body, empty APPROVE, reply container | e8d3e7c (older) |
3a5621c |
For #812 that isn't a widened incremental, it's the loss of the anchor entirely: LAST_REVIEW_SHA is empty, so LAST_REVIEW_SHA == HEAD_SHA never fires and a re-trigger on an already-approved commit takes the first review path — a full re-read of the whole PR, re-deriving findings on code that was already reviewed and approved. Step 5's ALREADY_POSTED check is unfiltered, so it still blocks the duplicate post at the last step, but only after the run has done all the work. Since a clean approve is the most common outcome, this is the common case rather than an edge one.
The description already supplies the fix: reply containers are always COMMENTED (the same fact the weekly audit leans on). Adding or .state == "APPROVED" readmits empty-body approvals and no containers — every reply container I sampled, bot- and human-authored, is COMMENTED. Re-running with that clause: cargo-affected #54 still yields 1ffcde2 (fix preserved), #820 moves to 3a5621c, #812 to 02f8dce, #825 unchanged.
Suggestions inline. Skipping the /code-review second pass — that skill isn't available yet; #819 is the PR porting it in.
An empty-body `gh pr review --approve` — the skill's own primary success path — has no body and no top-level inline comment, so the reply-container filter dropped it too. Reply containers are always COMMENTED, so an APPROVED clause readmits approvals without readmitting any container.
…s guards Step 1's derivation was fixed, but the two step-5 guards that key on `commit_id == $HEAD_SHA` were left unfiltered, so a reply container anchored at the current HEAD still reads as a review: - `ALREADY_POSTED` becomes a false positive and the run exits without posting, discarding a full review at the last gate. Same lost-signal symptom as #828, just moved from the pre-flight to the close-out — and it fires whenever a `tend-mention` run answers threads on the commit under review. - `ORPHAN_ID` resolves to the container, so the 422 recovery path would PUT the review body over an unrelated reply. `ALREADY_POSTED` reuses step 1's predicate verbatim; `ORPHAN_ID` only needs the body test, since a case-(a) orphan always persisted a body and a container never has one.
tend-agent
left a comment
There was a problem hiding this comment.
The APPROVED clause is right and the filter now behaves on every shape I could find: across the last 25 PRs here, every zero-body non-APPROVED bot review record is a reply container (no top-level inline comment), so the three-way predicate discards containers and nothing else. Re-ran it on this PR as a self-test — SUBSTANTIVE resolves to [4860021420] and LAST_REVIEW_SHA to b75b165, not the 8699228 the old recipe would have returned.
The gap is that the same defect survives, unfixed, in the two step-5 guards under Posting mechanics and Recovering from inline comment 422 errors. Both select on .commit_id == "$HEAD_SHA" with no substantive filter, so a reply container anchored at the current HEAD reads as a review there too:
ALREADY_POSTEDbecomes a false positive and the run exits atAlready reviewed — skipping. That is the same lost-review-signal symptom #828 describes, just relocated from the pre-flight to the close-out — and it costs more, because the run has already read the diff and formed the verdict before throwing it away. Step 1's fix does not cover it: fixing the derivation routes the run into a full review, and this guard then discards the result.ORPHAN_IDresolves to the container, so the case-(a) recovery wouldPUTthe review body over an unrelated inline reply.
This run reproduced it live rather than hypothetically. tend-mention answered both threads from the previous review at 00:32:18/19, after the 00:32:05 push, so the containers landed on the current HEAD:
| record | commit_id |
body | inline comments |
|---|---|---|---|
| 4860021420 | b75b165 |
2286 | 2 top-level |
| 4860032792 | 8699228 |
0 | 1 reply (in_reply_to_id 3717103568) |
| 4860032847 | 8699228 |
0 | 1 reply (in_reply_to_id 3717103574) |
Run as written against 8699228, ALREADY_POSTED returns 2026-08-05T00:32:19Z and ORPHAN_ID returns 4860032847. Neither is a review. Following the skill literally, this review would not exist.
Pushed the fix in the same commit-scope rather than opening a follow-up, since it is the same root cause in the same file and the PR only half-closes #828 without it. ALREADY_POSTED reuses step 1's predicate verbatim (re-deriving SUBSTANTIVE, since shell state does not carry between tool calls); ORPHAN_ID needs only the body test, because a case-(a) orphan always persisted a body and a container never has one. Verified against four shapes: containers-only on this PR at 8699228 returns empty, the real review at b75b165 returns its timestamp, and the empty-body approvals on #812 (02f8dce) and #820 (3a5621c, alongside a container) both still return theirs.
The push cancels this session — tend-review is cancel-in-progress: true on a per-PR group — so that commit ships CI-unverified.
`gh api --paginate` runs `--jq` against each page separately, so the `| last` inside the filter emits one id per page. Past the first page of reviews — which reply containers make reachable — ORPHAN_ID would hold several ids and the recovery PUT would 404. Pipe to `jq -rs 'add | …'` like the step-1 and ALREADY_POSTED derivations already do.
|
Both step-5 guards are fixed in The CI-unverified caveat is closed — run 30964152146 is green on
The two containers at Description updated — it described only the first commit, and the PR now covers all three record consumers. |
tend-agent
left a comment
There was a problem hiding this comment.
No findings in the diff — I re-derived all three guards independently and got the same anchors, and --slurp (the obvious alternative to piping out) turns out to be unusable here anyway: gh api rejects it with the --slurp option is not supported with --jq or --template, so | jq -rs 'add | …' is the only shape available for a cross-page reduction.
The same-pattern sweep did turn up one live instance outside the diff, in the generated mention workflow rather than a skill. generator/src/tend/templates/mention.yaml.j2 reduces inside --jq under --paginate in three places — both BOT_COMMENTS= assignments and BOT_REVIEWS=, each --jq '[.[] | select(.user.login == "<<cfg.bot_name>>")] | length'. That is the shape cdbf065 just fixed in ORPHAN_ID: --jq is applied per page, so the reduction returns one count per page rather than one overall.
gh api --paginate sets per_page=100, so it takes >100 reviews or >100 issue comments on a single thread to cross. Past that the variable holds e.g. 100\n7, and the guard immediately below it — if [ "$BOT_COMMENTS" -gt "0" ] — errors with integer expression expected and returns 2 instead of matching. The if swallows the failure, so the step falls through to should_run=false: the bot stops answering participants on exactly the threads where it has engaged the most, silently and without going red. These render into every adopter's tend-mention.yaml, not just ours.
Cheaper to fix than this PR's guards, since none of the three needs --argjson — moving the count outside jq keeps the filter a per-element stream, which paginates fine:
BOT_REVIEWS=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" \
--jq '.[] | select(.user.login == "<<cfg.bot_name>>") | .id' | wc -l)Separate file and separate concern from the reply-container fix, so I'd rather not fold it in here — happy to open it as its own PR if you want it.
Verification
Per-page application, forced with per_page=1 on this PR's 4 review records:
$ gh api --paginate "repos/max-sixty/tend/pulls/835/reviews?per_page=1" --jq '[.[]] | last | .id'
4860021420
4860032792
4860032847
4860059883
The stream form above returns 4 on the same input. Default page size confirmed at 100 (gh api --paginate repos/max-sixty/tend/commits --jq 'length' → 100 per page).
Fall-through, reproduced directly:
$ BOT_REVIEWS=$(printf '30\n12\n'); if [ "$BOT_REVIEWS" -gt "0" ]; then echo run; else echo "rc=$?"; fi
bash: [: 30
12: integer expression expected
rc=2
Live in the generated workflow at .github/workflows/tend-mention.yaml lines 264, 283, 290. Template call sites: BOT_COMMENTS (issue path), BOT_REVIEWS, BOT_COMMENTS (PR path). The fourth --paginate in that step, the review-comment body scan piped to grep -qF, is a per-element stream and is unaffected.
|
Opened the out-of-diff finding as #840 rather than leaving the offer hanging — same shape ( |
…it it (#840) ## Problem `tend-mention`'s verify step derives three engagement counts by reducing inside a `--paginate`d `--jq`: ```bash BOT_REVIEWS=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" \ --jq '[.[] | select(.user.login == "<<cfg.bot_name>>")] | length') ``` `gh` applies `--jq` once per page, so the reduction emits one count *per page* rather than one overall. `--paginate` requests `per_page=100`, so it takes more than 100 reviews or more than 100 issue comments on a single thread to cross — past that the variable holds e.g. `100\n7`, and the guard immediately below it errors: ``` $ BOT_REVIEWS=$(printf '100\n7\n'); if [ "$BOT_REVIEWS" -gt "0" ]; then echo run; else echo "rc=$?"; fi bash: [: 100 7: integer expression expected rc=2 ``` `test` returning 2 makes the `if` false, so the step falls through to `should_run=false`. The bot stops answering participants on exactly the threads where it has engaged the most — silently, with nothing going red. All three sites are on the engagement path that decides whether a non-mention comment gets a session at all: the issue-comment count, the PR-review count, and the PR-comment count. These render into every adopter's `tend-mention.yaml`, not just ours. ## Solution Keep the filter a per-element stream — which paginates fine — capture it bare, and test it for emptiness. The values are only ever compared against zero, so no count is needed: ```bash BOT_REVIEWS=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" \ --jq '.[] | select(.user.login == "<<cfg.bot_name>>") | .id') if [ -n "$BOT_REVIEWS" ]; then ``` Reducing through a pipe (`| wc -l`) would fix the count but move the substitution's exit status off `gh` and onto `wc`. The step declares no `shell:`, so it runs under GHA's default `bash -e {0}` — errexit on, pipefail off — and a failing `gh api` would then read as "no engagement" on a green job rather than aborting the step: ``` $ bash -e -c 'X=$(false | wc -l); echo "survived, X=[$X]"' survived, X=[0] $ bash -e -c 'X=$(false); echo survived'; echo "rc=$?" rc=1 ``` `set -o pipefail` is not a safe alternative in this step: `grep -qF` on the review-comment scan exits on first match, `gh` takes SIGPIPE, and the pipeline resolves 141 — under pipefail that `if` goes false and a first-contact mention inside an inline comment is missed. `--slurp` is not available either: `gh api` rejects it with `the --slurp option is not supported with --jq or --template`. The fourth `--paginate` in that step — the review-comment body scan piped to `grep -qF` — is already a per-element stream and is unchanged. ## Testing New `test_mention_verify_engagement_lookups_survive_pagination` asserts no `--paginate`d `--jq` in the verify step carries a `| length` reduction, that the three lookups capture the raw stream, and that no `-gt "0" ]` numeric comparison remains. It fails against the old template. Regtest snapshots for the mention workflow are updated; `uv run pytest` is green (328 passed). Mechanism verified live, forcing multiple pages with `per_page=1` against this repo's PR #835 (4 bot review records): ``` $ gh api --paginate "repos/max-sixty/tend/pulls/835/reviews?per_page=1" \ --jq '[.[] | select(.user.login == "tend-agent")] | length' 1 1 1 1 1 $ gh api --paginate "repos/max-sixty/tend/pulls/835/reviews?per_page=1" \ --jq '.[] | select(.user.login == "tend-agent") | .id' | wc -l 5 ``` The empty case is unchanged: no matching records means an empty stream, so `[ -n ... ]` is correctly false. Only the template is touched — `.github/workflows/tend-mention.yaml` picks this up from `uvx tend@latest init` after the next release, per the generated-workflow rule in `CLAUDE.md`. Found while reviewing #835, which fixed the same per-page-`--jq` shape in the `review` skill's `ORPHAN_ID` guard. Separate file and separate concern, so it lands separately. --------- Co-authored-by: tend-agent <[email protected]>
Bumps the generator to 0.1.14, syncs the lockfile, and adds the CHANGELOG section the release workflow publishes verbatim as the GitHub Release notes.
12 commits since 0.1.13. The release's substance is the deployment-record fix and the environment checks around it. Generated workflows now name the environment as `{name: tend, deployment: false}`, so a job stops filing a deployment record against whatever run it belongs to — under `pull_request_target` that record landed on the PR's own head, so every push to every PR grew a `<bot> deployed to tend` line in its timeline. The branch policy that gates the operational secrets is untouched, and `tend check` grows an `environment-deployments` check that refuses a job naming the environment without the property (#852, #853). Separately, `tend check` widens its environment sweep from secret-holding to credential-holding: an environment counts if it stores a secret or a job requesting `id-token: write` deploys to it, and a ref policy no longer counts as a gate under a trigger a write-scoped actor can steer (#815).
Four silent failures on the agent's own paths are fixed. `tend-mention` reduced its engagement counts inside a `--paginate`d `--jq`, so past one page the numeric guard errored and the bot went quiet on the threads it had engaged with most (#840). The `review` skill counted synthetic reply containers as reviews, which advanced the incremental past unreviewed commits and discarded formed reviews at the close-out (#835). The review's second pass returned a tool-use error because the built-in `/code-review` carries `disable-model-invocation`, and now runs a tend-owned skill that the Codex harness resolves too (#819). And `mark-notification-read` turned a successful run red on a transient API error (#843).
After this tags, adopters pick the changes up on their next nightly regen; tend's own workflows are regenerated in the follow-up PR the release runbook's last step calls for.
Testing: 336 tests pass, `pre-commit run --all-files` is clean, and the release workflow's `awk` extraction was run against the new `## 0.1.14` section locally to confirm the GitHub Release job will find its notes.
> _This was written by Claude Code on behalf of max-sixty_
Automated nightly regeneration of tend's workflow files. **tend version:** 0.1.13 → 0.1.14 ## Notable changes - **Jobs now name the `tend` environment with `deployment: false`** (max-sixty/tend#852), so GitHub stops filing a deployment record per run and posting it on the pull request. This is what the current `tend check` flags as `environment-deployments` (#3729) — regenerating clears it, and max-sixty/tend#853 makes `check` refuse the old shape going forward. - **`id-token: write` dropped from every tend job** — a side effect of removing the claude-smoke workflow and its `tend-manual` environment (max-sixty/tend#820). None of the remaining jobs use OIDC, so the permission was unused. - **`tend-mention` counts bot engagement outside `jq`** (max-sixty/tend#840). `gh api --paginate` applies `--jq` once per page, so `| length` emitted one count per page; past 100 comments the shell variable held `100\n7`, the numeric test errored, and the bot fell through to `should_run=false` — going quiet on exactly its most-engaged threads. - **Review and triage skill fixes** — the review-record guards now ignore synthetic reply containers (max-sixty/tend#835), `/code-review` is ported into a tend-owned skill (max-sixty/tend#819), and triage substitutes the real issue number into its PR-body templates instead of leaving a placeholder (max-sixty/tend#844). - **Outage reporting is more robust** — a stranded outage row now names the trigger it points at (max-sixty/tend#823), and marking a notification read tolerates a transient run-metadata fetch failure (max-sixty/tend#843). Full compare: max-sixty/tend@0.1.13...0.1.14 Co-authored-by: worktrunk-bot <[email protected]>
… reply creates (#849) ## Problem `tend-mention`'s verify gate skips the bot's own comments — `issue_comment` and `pull_request_review_comment` where the comment author is the bot — because the bot never needs to respond to itself. The `pull_request_review` submission kind is deliberately left out of that skip, since a review the bot leaves on its own PR is its reviewer role. But replying to a review thread (`POST /pulls/{n}/comments/{id}/replies`) wraps the reply in a **synthetic zero-body `COMMENTED` review** — the same artifact #828 documents. So the bot's own inline reply arrives twice: once as the `pull_request_review_comment` the skip already drops, and once as a `pull_request_review` submission it doesn't. The container isn't a review; it's the same comment on a second event path. Nothing downstream catches it. The empty-body gate one block up requires `REVIEW_STATE = approved`, and a reply container is `commented`. The inline `@`-mention scan finds nothing (the bot doesn't summon itself). The engagement heuristic then sees a bot-authored PR — or `BOT_REVIEWS > 0` from the container itself — and returns `should_run=true, reason=participation`, spinning up a full `handle` job that the prompt's self-loop guard exits with nothing posted. ## Evidence Three occurrences on `PRQL/prql`, recorded across two windows in the [evidence gist](https://gist.github.com/192514ea2c36586f9b7f842a482d62ab), all on bot-authored PRs where the bot answered its own review threads inline: | Dispatched handle | PR | Cost | | --- | --- | --- | | [30894437460](https://github.com/PRQL/prql/actions/runs/30894437460) | #6141 | agent ran 9 m 16 s, posted nothing | | [30894732823](https://github.com/PRQL/prql/actions/runs/30894732823) | #6141 | agent ran 7 m 35 s, posted nothing | | [30991732962](https://github.com/PRQL/prql/actions/runs/30991732962) | [#6144](PRQL/prql#6144) | queued 20 m, then cancelled | The third is this run's window. Its container ([review 4862824760](PRQL/prql#6144 (review))) has `body: ""`, `state: COMMENTED`, and exactly one inline comment — a reply: ``` $ gh api repos/PRQL/prql/pulls/6144/reviews/4862824760/comments \ --jq '.[] | {id, in_reply_to_id, user: .user.login}' {"id":3719317911,"in_reply_to_id":3719296566,"user":"prql-bot"} ``` Its `handle` job sat pending behind a live sibling for 20 minutes and was then evicted by GHA's queue-depth-1 replacement when a real dispatch arrived. That is the harm beyond wasted agent minutes: a container carrying no work occupies the one queue slot `cancel-in-progress: false` leaves, and the next event has to displace it. ## Fix Reuse the inline-comment fetch the gate already makes, and skip when the review is bot-authored, has an empty body, and **every** inline comment is a reply: ``` if [ "$REVIEW_AUTHOR" = "<<cfg.bot_name>>" ] \ && [ -z "$COMMENT_BODY" ] \ && [ "$(printf '%s\n' "$INLINE" | jq -s '[.[] | select(.in_reply_to_id == null)] | length')" = "0" ]; then echo "should_run=false" >> "$GITHUB_OUTPUT" exit 0 fi ``` Deliberately narrower than the own-comment skip. The reason the `pull_request_review` path was left unguarded still holds — a real review the bot submits with inline comments and no body carries actionable signal — so the guard requires that no inline comment be a *fresh* one. Any container with a single non-reply comment still fires, and the `@`-mention scan runs first, so a mention inside a reply still wins. The fetch changes from a piped `--jq '.[].body'` to a variable holding `{body, in_reply_to_id}` objects, one per line, so `--paginate` concatenates pages rather than reducing within each — the hazard #839 describes. The object form is load-bearing for a second reason: `in_reply_to_id` is an *optional* property, absent rather than null on a fresh comment, and constructing the object normalizes absent to null so `select(.in_reply_to_id == null)` counts fresh comments at all. A bare `.in_reply_to_id` stream emits nothing for them, and the gate would skip every container — including the real bot reviews it is written to spare. A structural test (`test_mention_skips_bot_reply_container`) pins the four shapes above plus the three properties the regtest snapshots don't hold: the skip landing before the engagement heuristic, the inline `@`-mention scan running first, and the `REVIEW_AUTHOR` conjunction. That last is the load-bearing half — `pull_request_review_comment` subscribes to `edited` only, so this container is the sole path by which a human's freshly created inline reply reaches the bot, and an authorship-agnostic gate would silence the bot on every human reply to its own review threads with no test failing. Verified the discriminator against the shapes it has to separate: | Inline comments | non-reply count | Result | | --- | --- | --- | | one reply | 0 | skip | | one fresh comment | 1 | fires | | one reply + one fresh | 1 | fires | | none | 0 | skip | ## Gate assessment - **Evidence level**: High — 3 occurrences across two PRs and two windows, deterministic in each. - **Structural**: yes. The event shape always passes the existing gate; there is no decision point where the bot could have behaved differently. - **Change type**: targeted fix — one condition added beside the adjacent empty-body-APPROVED guard, no new mechanism. - **Both gates pass** (High needs 2–3; a targeted fix carries the normal bar). Distinct from #835, which fixes the same underlying artifact in the `review` skill's three review-record guards. That PR does not touch `mention.yaml.j2`; this is the second surface the container reaches. `generator/` tests pass (327), with the four `mention` regtest snapshots regenerated. `bash -n` clean on every rendered `run:` step. --------- Co-authored-by: tend-agent <[email protected]>
…anchored review SHA (#884) A force-push doesn't just move a PR's head — GitHub also re-points the prior review's `.commit_id` at the **new** head. `tend-review`'s pre-flight guard compares that field against `HEAD_SHA` to decide whether the current commit has already been reviewed, so after a rewrite it reads `LAST_REVIEW_SHA == HEAD_SHA`, exits silently, and leaves a stale APPROVE standing as the active verdict on code the bot never read. ## Observed [`PRQL/prql#6158`](PRQL/prql#6158) (dependabot, `js-yaml` bump). `prql-bot` submitted an empty-body APPROVE at 06:09:36Z; the head at that moment was `abb3853a` — confirmed by the `tend-mention` run the review itself triggered six seconds later, which carries `headSha=abb3853a`. Dependabot then rebased at 07:40:18Z (`head_ref_force_pushed` → `cc020720`), which re-triggered [`tend-review` 31158576591](https://github.com/PRQL/prql/actions/runs/31158576591). The agent ran the full 1 m 47 s and posted nothing. The reviews endpoint now reports that 06:09:36Z review against a commit created at 07:40:16Z: ``` {"id":4880377370,"state":"APPROVED","submitted_at":"2026-08-07T06:09:36Z", "commit_id":"cc0207205f99c5481b8404c805a16a43c91fb3af","body":""} ``` The session log shows the guard firing on exactly that, and the reasoning is correct given what it was told to read: > The current HEAD has already been reviewed and approved. There are no conversation comments, no unanswered questions directed at the bot, and no unresolved bot review threads to resolve. The triggering event was `synchronize`, not `ready_for_review`, so no exception applies. Exiting silently without posting — the existing approval stands as the active verdict. ## Control An ordinary push leaves the old anchor intact, so `.commit_id` alone cannot distinguish the two cases. On [`PRQL/prql#6159`](PRQL/prql#6159), a review submitted at 06:58:45Z still reports `commit_id=779b096d` after `177c1997` landed on top — the guard works there, which is why this has stayed invisible. ## Fix Probe the timeline for a `head_ref_force_pushed` newer than the last substantive bot review. Non-zero ⇒ the reviewed commit was rewritten away, so ignore `LAST_REVIEW_SHA` and review the head in full. The incremental path has to be skipped too: after a rewrite `LAST_REVIEW_SHA` names the current head, so `LAST_REVIEW_SHA..HEAD_SHA` is empty and every trivial-skip heuristic keyed on it under-reports the change. The existing `LAST_REVIEW_SHA` extraction is refactored to keep the whole review record rather than just `.commit_id`, so `submitted_at` comes from the same substantive-filtered pick — no second query, no risk of the two fields resolving to different reviews. Verified live against three shapes: `#6158` (force-pushed after approval) → 1; `#6159` (ordinary push) → 0; `#6161` (no prior bot review) → empty anchor, 0. ## Gates - **Evidence level**: High, **structural** — no decision point. Every force-push after a bot review re-points the anchor and defeats the comparison identically. - **Occurrences**: 2 for the failure class. This one, plus [#828](#828) — the same `LAST_REVIEW_SHA == HEAD_SHA` guard skipping a real commit because the anchor had moved to something the bot never reviewed (fixed for the reply-container mechanism in [#835](#835); the force-push mechanism is untouched by that fix). - **Magnitude**: targeted fix — one probe plus one condition, no new section. Normal bar. - Wrong-outcome shape, beyond the skipped work: the review record reads "approved `cc020720`" for a commit the bot never fetched, and the sequence generalizes to approve-then-rewrite. Evidence log: https://gist.github.com/192514ea2c36586f9b7f842a482d62ab --------- Co-authored-by: tend-agent <[email protected]>
Problem
reviewderives three separate signals from the bot's own review records, and all three counted any record the bot owns. GitHub creates the same record shape for something that is not a review: replying to a review thread viaPOST /pulls/{n}/comments/{id}/replieswraps the reply in a synthetic zero-bodyCOMMENTEDreview anchored at whatever HEAD was when the reply posted. So after anytend-mentionrun answers review threads inline — its normal response path — containers sit on the current HEAD, and every guard that asks "did the bot review this commit?" answers yes:LAST_REVIEW_SHA(step 1) advances to a commit nothing reviewed, so the nexttend-reviewrun computes its incremental against code it never read and skips everything before it under the trivial-change heuristic. This is review: LAST_REVIEW_SHA anchors on the empty review container GitHub creates for an inline reply, so the next run skips a real commit #828.ALREADY_POSTED(step 5, Posting mechanics) becomes a false positive and the run exits atAlready reviewed — skipping. Same lost-review-signal symptom, relocated to the close-out — and it costs more, because the run has already read the diff and formed the verdict before throwing it away. Fixing the derivation doesn't cover it: that routes the run into a full review, and this guard then discards the result.ORPHAN_ID(Recovering from inline comment 422 errors) resolves to the container, so the case-(a) recovery wouldPUTthe review body over an unrelated inline reply.Nothing goes red in any of the three; the run reports a well-reasoned decision to stay silent. On a repo where the bot both authors and reviews its own PRs, that removes the PR's only review signal. It is deterministic — no decision point — so it recurs on every reply-then-push flow.
Solution
Count a review record only when it carries a body, owns at least one top-level (non-reply) inline comment, or is
APPROVED. Reply containers have none of the three; an empty-body review carrying real inline findings still anchors, and so does an empty-body approval.LAST_REVIEW_SHAandALREADY_POSTEDuse the full predicate (the latter re-derivesSUBSTANTIVE, since shell state doesn't carry between tool calls);ORPHAN_IDneeds only the body test, because a case-(a) orphan always persisted a body and a container never has one. The review and comment calls are--paginated — container churn is exactly what pushes a PR past one page of reviews — and each reduction runs over the merged array viajq -rs 'add | …', not inside--jq:ghapplies--jqper page, so a| lastthere yields one record per page rather than one overall.Where the two shapes are genuinely indistinguishable (a UI review whose only content is thread replies), the filter skips it — that moves
LAST_REVIEW_SHAearlier, widening the incremental. The failure direction is more review, not less.Testing
No test file covers skill prompt text, so the reproduction is a live API comparison rather than a committed test.
Step 1, against
max-sixty/cargo-affectedPR #54 — the case in #828:commit_id1ffcde2551e059in_reply_to_id3710403279)551e059in_reply_to_id3710403291)The old recipe returns
551e059— a commit with no review, and the one whose refactor got skipped. The new recipe returns1ffcde2, the real review.Steps 5 and the 422 recovery, against this PR's own records.
tend-mentionanswered both threads from the first review after the8699228push, so the containers landed on the then-current HEAD:commit_idb75b1658699228in_reply_to_id3717103568)8699228in_reply_to_id3717103574)8699228Evaluated against
8699228as the reviewing run saw it — that is, before its own record 4860059883 existed — the oldALREADY_POSTEDreturns2026-08-05T00:32:19Zand the oldORPHAN_IDreturns4860032847. Neither is a review; following the skill literally, that review would not have been posted at all. The new guards discard both containers: at8699228they return2026-08-05T00:39:33Zand4860059883, the one real review at that SHA, and at7a11332andcdbf065both return empty, where no review exists yet. The zero-bodyAPPROVEDrecords on #812 (02f8dce) and #820 (3a5621c, alongside two containers) both still anchor, which is what theAPPROVEDclause is for.Other consumers of the same records were checked and left alone:
weeklyfilters onstate == "APPROVED"(reply containers are alwaysCOMMENTED), andnotificationscounts recent bot reviews for dedup, where a reply container legitimately means the bot responded.Closes #828 — automated triage