Repository navigation
fix(review): bind preflight to the outward action - #1107
Conversation
…cript
`#### Posting mechanics` was ~40 lines of shell inside the review skill —
prose the agent retyped every review session, in every adopter repo,
with no test over it. Each of its three checks decides an outward action
and none of them fails loudly when it goes wrong: an approval lands on a
closed PR, a review claims code the session never read, or a second
review duplicates one already on the commit.
`plugins/tend-ci-runner/scripts/review-preflight.sh` now owns them and
returns one JSON object (`verdict`, `reason`, `head`, `retargeted`,
`delta`), mirroring `bot-review-state.sh`, which it calls for the dedup.
The skill keeps what is genuinely a skill: how to read the delta, and
the pin-file contract on either side of the call. Per `running-in-ci`,
"put the logic in a tested script and leave the skill a one-line
invocation with the intent".
Extracting it fixed five things the inline version got wrong:
- `FORCE_FULL_REVIEW` was read as `${FORCE_FULL_REVIEW:-false}` in a
Bash call that never set it — shell state does not survive a tool
call, so a `ready_for_review` pass could never replace the draft
COMMENT it exists to replace. The script derives it from the event.
- `read -r … < <(gh …)` succeeded with empty fields when `gh` failed,
and an empty state is not `OPEN` — an API blip came back as a
considered decision to post nothing.
- The delta went through `jq --arg`, which Linux caps at 131072 bytes
per argv string. A push regenerating a large file killed the script
*after* the pin file had advanced, leaving an unreviewed head looking
reviewed. It goes through `--rawfile` now.
- `set -e` does not reach inside `$( … )`, so a failing scoped `git log`
vanished and left a delta of base merges alone — the author's push
reading as an "Update branch" click. The logs run in a brace group.
- A `bot-review-state.sh` failure left the dedup empty and fell through
to posting; it now aborts.
`generator/tests/test_review_preflight.py` drives the script against a
real git repository and a fake `gh`: base merges, force-pushes, closed
PRs, draft replacement, an oversized delta, and each way the pin file
can be unusable. The skill-text assertions in
`test_cross_file_contracts.py` and `test_bot_review_state.py` move to
the script side, so the pair still cannot drift.
# Conflicts: # plugins/tend-ci-runner/skills/review/SKILL.md
tend-agent
left a comment
There was a problem hiding this comment.
Two findings, both on the skill side of the boundary this PR draws.
The approve recipe now reports success on every skip. review-preflight.sh exits 0 when it declines to run the command — test_a_wrapped_outward_action_does_not_retarget pins exactly that — so && echo "✓ approved", which used to be gated on the POST itself, is now gated on the preflight instead and fires on the closed-PR, moved-head, already-reviewed and stale-state paths alike. The session then reads skip: HEAD moved to … before the outward action followed by ✓ approved, believes it approved, and carries that into step 6's dismissal-on-failure gate and its closing summary. It's the one place the diff turns a real skip into a claimed outward action, which is the class of thing the rest of the PR exists to prevent.
Separately, the exit-code contract at the top of Posting mechanics no longer holds in command mode: a failed gh api POST now propagates out of the preflight, so a non-zero exit can mean the review was attempted and failed. That's the 422 case, and the sentence directly above the new paragraph sends the reader to re-run the preflight instead — which on case (a) reports the persisted body as already carries a COMMENTED review N and finishes, stranding the failed inline comments outside the body.
The rest reads clean. Wrapping all four write paths (POST, body-only retry, orphan PUT, approve) is complete — there's no unwrapped review write left in the skill. The STATE_HEAD check isn't redundant with the final re-read as it first looks, since at_head/orphan_id are keyed on the head bot-review-state.sh saw, so an unstable head there would evaluate the duplicate-guard against the wrong commit. And requiring at_head.id == orphan_id == $edit for --edit-review means a moved head can no longer authorize an orphan edit at all, since at_head goes null — conservative, but consistent with treating the edit as an outward action.
Verification
uv run pytest— 823 passed- Reproduced the
✓ approvedbehaviour directly with a stub that printsskip:and exits 0
Automated nightly regeneration of tend's workflow files. **tend version:** 0.1.22 → 0.1.24 ## Notable changes - **Conflicted bot PRs are now repaired on the frequent poll** (max-sixty/tend#1108). `tend-notifications` gains a `conflict_count` boot gate: it runs a GraphQL scan for open bot PRs whose `mergeable` is not `MERGEABLE`, skips ones already carrying a `tend-conflict-deferred` marker for the current head, and boots the agent when either notifications or conflicts are outstanding. This is the bulk of the workflow-body diff. - **A multi-line adopter prompt now survives generation** (max-sixty/tend#1103). Block scalars gain explicit indentation indicators — `prompt: |` becomes `prompt: |2`, likewise `sandbox_setup:` — so a prompt or setup script whose first line is itself indented no longer changes meaning. This repo's `sandbox_setup:` (the Playwright headless-shell install) is regenerated under the new form. - **Review gating tightened** (max-sixty/tend#1087, max-sixty/tend#1107, max-sixty/tend#1080). `APPROVE` is gated on the author stating merge readiness rather than on the draft flag alone; the posting preflight is bound to the outward action; and the code-review pass becomes its own step, gated at submit. - **`uv` is provisioned for agent sessions** (max-sixty/tend#1109), and pre-check setup guards are preserved through regeneration (max-sixty/tend#1106). - Experimental Gist-backed Claude memory (max-sixty/tend#1110) — off unless configured. Full upstream range: max-sixty/tend@0.1.22...0.1.24 ## Also in this PR `tend init` now writes `.github/actionlint.yaml` — a `concurrency.queue` ignore scoped by glob to `**/.github/workflows/tend-*.yaml`. This repo carried the same accommodation as a blanket `-ignore` arg on the actionlint pre-commit hook, which suppressed that schema error everywhere, including in workflows this repo owns. The generated file replaces it, so the false positive stays ignored on the generated workflows and a real one in `ci.yaml` or `publish-site.yaml` now fails. Verified by running `pre-commit run actionlint --all-files` in the regeneration worktree with the blanket arg removed and the generated config in place: passed. --------- Co-authored-by: leaf-agent <[email protected]>
Nightly regeneration of tend's workflow files, picking up two upstream releases. **tend version:** 0.1.22 → 0.1.24 ### Notable changes - **The frequent poll now repairs conflicted bot PRs**, not just unread notifications — the `tend-notifications` boot gate gained a GraphQL query that test-merges open bot PRs and looks for deferral markers in recent comments, so a conflicted PR wakes the queue instead of waiting for the nightly sweep ([max-sixty/tend#1108](max-sixty/tend#1108)). - **Review gating tightened**: `APPROVE` is now conditioned on the author stating merge readiness rather than the draft flag alone, the posting preflight is bound to the outward action, and the code-review pass became its own step gated at submit ([max-sixty/tend#1087](max-sixty/tend#1087), [max-sixty/tend#1107](max-sixty/tend#1107), [max-sixty/tend#1080](max-sixty/tend#1080)). - **Generator fixes that change this repo's YAML**: an adopter's `prompt:` may now span more than one line (the `|2` block-indent markers in the diff), pre-check setup guards are preserved, and the `concurrency.queue` actionlint ignore is written out ([max-sixty/tend#1103](max-sixty/tend#1103), [max-sixty/tend#1106](max-sixty/tend#1106), [max-sixty/tend#1095](max-sixty/tend#1095)). - **`uv` is provisioned for agent sessions**, and Gist-backed Claude memory ships as experimental ([max-sixty/tend#1109](max-sixty/tend#1109), [max-sixty/tend#1110](max-sixty/tend#1110)). - Pinned harness versions moved with the releases: Claude 2.1.251, Codex 0.151.0, uv 0.12.7. ### A second commit, outside the usual regen `tend init` now also writes `.github/actionlint.yaml` (the `concurrency.queue` ignore from max-sixty/tend#1095). The nightly recipe stages only `.github/workflows` and `.config`, so it landed untracked and would be re-created on every future run — the second commit tracks it. This repo runs no actionlint job or pre-commit hook, so the file is inert here; it only suppresses a false positive for anyone linting these workflows locally. Full compare: max-sixty/tend@0.1.22...0.1.24 --------- Co-authored-by: worktrunk-bot <[email protected]>
Summary
Follow up #1104 by making its preflight the actual boundary around every
review write:
after a final stable head/state check
orphan review
PENDINGreviews in canonical review stateThis also supersedes #1083's separate suggestion-recomposition change.
Verification
wt testafter merging currentmain(833 Python tests, 32 worker tests,TypeScript typecheck)
pre-commit run --all-filesprobes