Skip to content

fix(scripts): don't let tend-review gate the poll - #1053

Merged
max-sixty merged 13 commits into
mainfrom
fix/issue-1050
Aug 28, 2026
Merged

max-sixty merged 13 commits into
mainfrom
fix/issue-1050

Conversation

@tend-agent

@tend-agent tend-agent commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

tend-review starts on every push to a PR and often outlives the poller's nine-minute budget, so waiting for it makes the poll time out after the repository checks have settled. This change adds one exact workflow exemption for tend-review; the existing own-run and same-workflow filters remain. A rollup with no gating checks stays unverified.

Verification: uv run pytest generator/tests/test_poll_scripts.py -q (27 passed), plus pre-commit on the changed files.

Closes #1050

poll-pr-checks.sh exempted the caller's own check run and sibling runs of
the same workflow, so a session that pushed to a PR blocked on
tend-review's agent job — created by the very push being verified, and
routinely longer than the 9-iteration cap.

Closes #1050

@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 mechanism is right and the diagnosis in #1050 holds up — tend-review is created by the very synchronize the poll verifies, so blocking on it is structural, not occasional. One clause in the same chain is the right depth, and keying it on the workflow rather than the check name is what keeps a repo's own review job gating. Two things below; the first is a concrete gap in the prefix match.

tend-install-test is a generated tend-* workflow that is a verdict on the code. generate_install_test in generator/src/tend/workflows.py stamps name: tend-install-test, and its one step runs uvx "tend@$TEND_VERSION" init --with-install-test then git diff --quiet .github/workflows/ — a deterministic drift check, not an agent session. The new clause drops it, so the rationale in the header ("No tend agent job is a verdict on the code") doesn't cover the one workflow it exempts that isn't an agent job. Confirmed against the script's own jq — a single failing install-test check from workflow tend-install-test reduces to {"pending":[],"failed":[]}, i.e. exit 0 green. The window is narrow but reachable: install-tend is the documented path for changing an installed repo's config, it generates the file with --with-install-test, and on an already-installed repo tend-review/tend-mention do run on that PR — so a session that pushes to it and polls reads green with the drift check red. Inline suggestion on the jq line and the header sentence.

Empty-after-filter now reads green where the header says UNVERIFIED. The exit-code block documents "a commit with zero checks and zero statuses … the rollup is null then too, so 'nothing to gate on' is indistinguishable from 'nothing answered'" as exit 2. After this change a commit whose rollup holds only tend-* entries filters to {"pending":[],"failed":[]} and takes the exit-0 path with green: every gating check on $SHA settled green — the same epistemic state, opposite verdict. The hole predates the PR (own-run plus same-workflow could already empty the list) but this widens it from tend-review-as-caller to every caller: tend-review's check run is guaranteed present on the commit within seconds of the push, so it's now the tend entry that keeps the rollup non-null while the repo's own checks may not have registered at the 60 s and 90 s samples. It fails toward a false green, which is the one direction this script is built not to fail in. Worth considering distinguishing "filtered to empty" from "nothing to filter" — if the pre-filter node list was non-empty and the post-filter list is empty, that's exit 2 rather than green. Not asking for it in this PR, but it's the case the new clause makes common.

Same pattern outside the diff: the pre-APPROVE rollup block in plugins/tend-ci-runner/skills/review/SKILL.md (the FAILED= jq under "Before APPROVE specifically") applies no own-run, own-workflow, or tend- filter at all, so a red tend-mention / handle sitting on the head commit withholds an approval for exactly the tend-outage-not-a-code-verdict reason this PR argues against. Different file, different failure (a withheld approval rather than a false green) — happy to push that as a follow-up if you want it tracked.

Testing looks right: test_a_repo_check_named_like_tend_still_gates is the pin that matters, since it's what stops the exemption drifting onto check-run names. uv run pytest is green here too (589 passed).

Two gaps in the `tend-*` exemption this PR adds, both false greens.

`tend-install-test` carries the prefix but runs no agent: it regenerates
the committed workflow files and diffs them against the tree, so a red one
is drift in the code under poll and is the one `tend-*` verdict that
counts. Exempt every generated workflow bar that one.

Filtering to empty is not green. A rollup holding only exempt entries
answers nothing about the commit — the state the header already documents
as exit 2 for a null rollup — and the exemption makes it routine, since
`tend-review` registers within seconds of the push while the repo's own
checks may not have. The reduction now emits nothing there, so the loop
keeps polling and the cap reports UNVERIFIED rather than green.

@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.

Both findings from the last review landed and I verified them rather than taking the commit message's word: tend-install-test now exits 1 with the check named on stdout (test_install_test_gates_despite_the_tend_prefix), and an all-exempt rollup reaches exit 2 instead of the byte-identical-to-green reduction (test_filtering_to_empty_never_reads_green). I confirmed against generate_install_test in generator/src/tend/workflows.py that it really is the only generated workflow with no agent step — every other name: in generator/src/tend/templates/ (tend-review, tend-mention, tend-triage, tend-ci-fix, tend-notifications, tend-<scheduled>) invokes the composite action. And the "read UNVERIFIED via the cap before" claim in the description checks out against the base: 483f274 has no tend- clause at all, so a tend-only rollup left tend-review pending and hit the cap. uv run pytest generator/tests/test_poll_scripts.py is green here (28 passed).

One simplification inline. Nothing blocking.

Two smaller notes:

Nothing pins tend-install-test as the only agentless generated workflow. The exception is correct today because the generator has exactly one such workflow, but that fact lives only in a comment. A second deterministic generated workflow — another drift or lint check — would silently inherit the tend- exemption and re-open exactly the false green this commit closes, with no test going red. A cheap pin would be a generator test asserting every tend-* name it stamps either invokes the composite action or is named in the script's exception. Not asking for it here; flagging it since the failure mode is a wrong outward verdict rather than wasted compute.

Textual overlap with #1055. Different fix, not a duplicate — it makes an OID that resolves to no object terminal instead of a retry. But it edits the same rollup() header block and the same exit-2 enumeration from a base that predates this PR, so whichever lands second will conflict there. Worth knowing before merge order is decided; no semantic collision that I can see, since its NOSUCHCOMMIT early-return sits above the filter chain this PR touches.

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Both review findings are applied in 35db26a and replied to inline; required checks are green on that commit.

I took the second one (empty-after-filter) into this PR rather than leaving it as a follow-up, despite the review not asking for it here. The reasoning: the exemption and the guard are one safety property, not two changes. Without the guard this PR converts a tend-only rollup from UNVERIFIED-via-the-cap into green — tend-review registers within seconds of the push and keeps the rollup non-null, so the existing exit-2 check stops firing in exactly the window it was written for. Shipping the exemption alone would have introduced a false green rather than merely leaving one in place, and that is the one direction this script exists not to fail in.

On the review/SKILL.md pre-APPROVE rollup: the gap is real — that FAILED= jq applies no own-run, own-workflow, or tend- filter, so a red tend-mention / handle on the head commit withholds an approval for the reason this PR argues against. I'm leaving it out of this PR to keep the change atomic: different file, opposite failure direction (a withheld approval is conservative; a false green is not), and it wants its own reasoning about whether an approval should be gated more strictly than a poll. Happy to open it as a separate PR — say the word rather than assuming, since it changes when the bot approves.

What the two clauses do now
| select($wf == "" or .workflow != $wf)
| select(.workflow == "tend-install-test"
         or (.workflow | startswith("tend-") | not))

tend-install-test is the one generated workflow with no agent step — generate_install_test in generator/src/tend/workflows.py stamps a job that runs uvx tend@$TEND_VERSION init --with-install-test and git diff --quiet .github/workflows/, so a red one is drift in the code under poll.

The reduction then emits nothing when the filtered group list is empty, so the loop keeps polling and the cap reports UNVERIFIED instead of {pending: [], failed: []}, which is byte-identical to settled green.

Four tests cover it, each verified failing against the pre-fix script: test_other_tend_workflows_do_not_gate, test_a_repo_check_named_like_tend_still_gates, test_install_test_gates_despite_the_tend_prefix, test_filtering_to_empty_never_reads_green.

… pin the exemption set

The guard reads the same and keeps the reduction at its original
indentation, so blame on those lines still points at the commit that
wrote them.

Adds test_poll_exemptions_match_the_agentless_generated_workflows: every
`tend-*` workflow the generator stamps either invokes the composite
action or is named back in as a gating check in poll-pr-checks.sh, never
both and never neither. A second agentless generated workflow would
otherwise inherit the `tend-` exemption and its red would read as green.
@tend-agent

Copy link
Copy Markdown
Collaborator Author

The inline simplification is applied in 86c9399, and I took the first note into this PR rather than leaving it flagged.

The pin now exists. test_poll_exemptions_match_the_agentless_generated_workflows in generator/tests/test_repo_pins.py generates every workflow (including --with-install-test), scrapes the .workflow == "tend-…" names back out of poll-pr-checks.sh, and asserts the two sets are complements: a stamped tend-* workflow either invokes max-sixty/tend/<harness> or is named back in as a gating check — never both, never neither. That is the invariant this PR's exemption rests on, so it belongs with the exemption rather than after it; a test is also about as cheap as machinery gets, and the failure it prevents is a wrong outward verdict.

I verified it goes red in both directions rather than trusting that it passes: renaming the tend-install-test exception fails with "runs no agent job, so the tend- exemption … drops it from the rollup and a red one reads as green", and adding tend-review to that list fails with the converse. uv run pytest is green here (592 passed), as is pre-commit run over both changed files.

On #1055: agreed it's a textual conflict and not a semantic one, and it looks one-directional — its NOSUCHCOMMIT early return sits above this filter chain, and this commit only touches the reduction at the bottom of rollup() plus the header paragraph. Whichever lands second rebases over the exit-2 enumeration and the rollup() header block by hand. No preference on order from here.

What the new test asserts, and why the invariant isn't self-evident

The exemption's rationale is "no tend agent job is a verdict on the code". That is a claim about what the generator stamps, not about the tend- prefix, and nothing enforced the two staying aligned — generate_install_test happens to be the only agentless generated workflow today, and that fact lived only in a comment. A second deterministic generated workflow (another drift check, a lint job) would inherit the prefix exemption silently, and the only symptom would be a caller reading green on a commit whose drift check was red.

Both operands are in-repo, so the test can only fail on a change to one of them — it never goes red on an upstream event.

@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 pin from the last review landed, and I checked it against the script rather than taking the commit message's word. test_poll_exemptions_match_the_agentless_generated_workflows goes red in both directions: naming tend-review back into the exemption list fails with "runs an agent job but poll-pr-checks.sh names it back in as a gating check", and dropping the tend-install-test clause fails with the converse. Both operands are in-repo, so it can only fail on a change to one of them — that is the invariant the prefix exemption rests on, and it now has something holding it.

select(length > 0) is the same filter as the if length == 0 then empty form on an array input, and the reduction below it is untouched. uv run pytest generator/tests/test_repo_pins.py generator/tests/test_poll_scripts.py green here (30 passed), pre-commit clean over both changed files.

Incidentally the rollup on 86c9399 is the shape this PR is about: every ci check terminal green, tend-review / review the sole pending entry.

No new findings on the increment; the two notes from the last review are both closed. Can't approve my own PR, so this is the verdict — nothing blocking.

# Conflicts:
#	generator/tests/test_repo_pins.py

@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 base merge resolved the test_repo_pins.py conflict with a single blank line between the end of test_poll_exemptions_match_the_agentless_generated_workflows and the ACTION_PATH_REF comment block that follows it. ruff-format wants two there, so lint will go red on this commit:

$ ruff 0.14.11 format --check --diff generator/tests/test_repo_pins.py
@@ -92,6 +92,7 @@
             "as green — name it back in alongside `tend-install-test`"
         )
 
+
 # Every `${{ github.action_path }}/…` reference in the two composite actions.
1 file would be reformatted

Inline suggestion below. Nothing else on the increment — the resolution kept both sides of the conflict, and the invariant the new test rests on survives main's shared/steps/ reorganisation (generate_all's signature is unchanged and every tend-* template still stamps uses: max-sixty/tend/).

Comment thread generator/tests/test_repo_pins.py Resolved
@max-sixty max-sixty changed the title fix(scripts): don't let another tend workflow's agent job gate the poll fix(scripts): don't let tend-review gate the poll Aug 28, 2026

@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.

Narrowing to the one workflow is right, and I checked the premise rather than the argument: across the twelve most recent PRs the only tend check runs that land on a PR head commit are tend-review / review and tend-mention's relay (one dispatch POST, seconds, 42 for 42 successful to date). tend-mention's verify and handle are always SKIPPED on a PR head, and structurally so — verify's if: admits only repository_dispatch, issues, and issue_comment, none of which carries the PR head as its run's head SHA, so the agent job that could outlive the cap never registers on the commit under poll. tend-review is the whole exposure, which makes the prefix rule, its hand-maintained exception, and the generator pin test machinery for a set of one. Deleting all three is the right depth. ci is green on e8fd471f, test included.

Two coverage holes, though, both provable by mutating the filter chain, and both closeable without adding a test.

The exemption's keying on the workflow rather than the check-run name is no longer observed. 2e9407b removed the only fixture pairing a check named review with a non-exempt workflow, and the failure coverage it defers to — test_red_names_the_failing_check_with_its_url — uses checks named tests and lint, which can never collide with the exemption. Rewriting the clause as select(.name != "review") now leaves the whole file green. This script ships to every adopter, and an adopter whose own CI job is called review would have its red silently exempted. The inline suggestion restores the pin in place: with the green companion renamed, a name-keyed filter drops both entries, the rollup filters to empty, and the test's returncode == 0 fails on exit 2.

The same-workflow ($wf) filter now has no test at all. test_own_run_and_same_workflow_are_filtered is the only test whose fixture holds an entry with .workflow equal to its env's GITHUB_WORKFLOW — _check_run("handle", status="QUEUED", workflow="tend-review", run_id=777) against the env fixture's "GITHUB_WORKFLOW": "tend-review". On main that entry was removed only by select($wf == "" or .workflow != $wf); this PR's new clause removes it too, so deleting the $wf clause outright leaves the suite green. That clause is what stops a session deadlocking on its own concurrency-queued sibling, which is the failure class #1050 is about. It's outside the diff, so two lines rather than an inline suggestion:

    env = env | {"GITHUB_WORKFLOW": "tend-nightly"}
    _serve(
        env,
        _resp(
            _check_run("tests"),
            _check_run("review", status="IN_PROGRESS", run_id=555, workflow="x"),
            _check_run("handle", status="QUEUED", workflow="tend-nightly", run_id=777),
        ),
    )

Your call on whether either is worth keeping — but a fixture edit is about as cheap as machinery gets, and CLAUDE.md's Development section puts preventing a wrong outward action above the cost of the mechanism that prevents it. Both holes fail toward a false green, which is the direction this script exists not to fail in.

How the two holes were verified

uv isn't on the sandbox's PATH, so this is not a pytest run: I extracted the reduction from rollup() and ran it under jq over each remaining fixture, mapping the output to the exit code the loop would take (pending non-empty then cap, exit 3; failed non-empty, exit 1; both empty, exit 0; no output, exit 2). M1 deletes select($wf == "" or .workflow != $wf); M2 replaces select(.workflow != "tend-review") with select(.name != "review").

fixture asserts base M1 M2
test_own_run_and_same_workflow_are_filtered exit 0 exit 0 exit 0 exit 0
test_tend_review_does_not_gate exit 0 exit 0 exit 0 exit 0
test_filtering_to_empty_never_reads_green exit 2 exit 2 exit 2 exit 2
test_red_names_the_failing_check_with_its_url exit 1 exit 1 exit 1 exit 1
test_superseded_failure_yields_to_its_replacement exit 1 exit 1 exit 1 exit 1

Every remaining fixture is verdict-identical under both mutations. With the two fixes applied, M1 moves test_own_run_and_same_workflow_are_filtered to exit 3 and M2 moves test_tend_review_does_not_gate to exit 2 — each fails its own assertion, which is the pin.

The tend-mention claim above comes from the rollups of the twelve most recent PRs plus verify's if: block in .github/workflows/tend-mention.yaml, and from the workflow's run history (42 pull_request_review runs, all success).

Comment thread generator/tests/test_poll_scripts.py Resolved
max-sixty and others added 4 commits August 27, 2026 19:26
The pin these fixtures carry was deleted once already because nothing in
the file recorded that the check names and workflows are load-bearing:
rename either back and the suite stays green while a false green becomes
reachable.
# Conflicts:
#	plugins/tend-ci-runner/scripts/poll-pr-checks.sh
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Both findings were already applied in 5254ce6 before this session's edits landed, so I dropped my duplicate and pushed only what was left: 276f643 adds a sentence to each of the two docstrings saying the fixture values are load-bearing. test_other_workflows_still_gate was deleted in 2e9407b for looking redundant, and after 5254ce6 the pin lives in a check name and a workflow string with nothing recording why — renaming either back leaves the suite green while a false green becomes reachable again. ci is green on 276f643; #1055 has since merged into the branch and left both docstrings intact.

How the two holes were re-verified

uv isn't on the sandbox PATH, so this isn't a pytest run — but it isn't the review's hand-extracted jq chain either: I ran the real poll-pr-checks.sh against a fake gh and sleep on PATH (the shape the pytest fixtures use) and read its actual exit codes.

fixture asserts base M1 (drop $wf clause) M2 (select(.name != "review"))
test_own_run_and_same_workflow_are_filtered — before 5254ce6 0 0 0 0
test_own_run_and_same_workflow_are_filtered — after 0 0 3 0
test_tend_review_does_not_gate — before 5254ce6 0 0 0 0
test_tend_review_does_not_gate — after 0 0 0 2

The bold cells are the holes; each is closed by the row below it. Deleting the own-run ($own) filter also still moves test_own_run_and_same_workflow_are_filtered to exit 3, so that pin survived the fixture edit.

@max-sixty
max-sixty merged commit 74b9467 into main Aug 28, 2026
7 checks passed
@max-sixty
max-sixty deleted the fix/issue-1050 branch August 28, 2026 02:33
@tend-agent tend-agent mentioned this pull request Aug 30, 2026
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Aug 30, 2026
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.20 → 0.1.22

## Notable changes

- **Notifications now run off a recovery queue** (max-sixty/tend#1074).
The pre-check drops the old layered inbox sweep (shadowed-run and
closed-bot-PR marking) in favour of a single paginated snapshot taken
before a 10-minute cutoff, passes that cutoff through to the agent, and
keeps repository watching enabled with an idempotent `PUT
.../subscription` on every cycle. The job also gains a serial
`tend-notifications` concurrency group.
- **`tend-review` re-targets instead of skipping**
(max-sixty/tend#1082). The "skip when the live HEAD is already examined"
gate step and its `if:` guards are gone; a live session now re-targets
when HEAD moves. The concurrency group adds `queue: max` so a push can't
evict a pending `ready_for_review` run.
- **Skills check the default branch for a landed fix before opening a
PR** (max-sixty/tend#1070), and `review-runs` gains the run census as a
second stranded-trigger drain input (max-sixty/tend#1073).
- **Poll/rerun script fixes** (max-sixty/tend#1053,
max-sixty/tend#1055): `tend-review` no longer gates the CI poll, and an
unresolvable commit fails fast rather than passing silently.
- **Generator fixes**: `watched_workflows` and `branches` are validated
as string lists (max-sixty/tend#1076), and block prompts no longer get
padded blank lines (max-sixty/tend#1090).

Full upstream diff:
max-sixty/tend@0.1.20...0.1.22

Co-authored-by: worktrunk-bot <[email protected]>
max-sixty pushed a commit to max-sixty/leaf that referenced this pull request Aug 30, 2026
Automated nightly regeneration of tend's workflow files.

**tend version:** 0.1.20 → 0.1.22

**Notable changes**

- Notifications recover work missed while the unread queue was stale,
and the job now runs under its own `tend-notifications` concurrency
group so overlapping schedules serialize instead of racing
(max-sixty/tend#1074).
- Skills check the default branch for a landed fix before opening a PR,
cutting duplicate PRs for work that already merged
(max-sixty/tend#1070).
- `review-runs` gains the run census as a second stranded-trigger drain
input (max-sixty/tend#1073), and reviews re-target when HEAD moves
rather than being discarded (max-sixty/tend#1082).
- The CI poll no longer lets `tend-review` gate it, and the
commit-resolution script fails fast instead of proceeding on an
unresolved SHA (max-sixty/tend#1053, max-sixty/tend#1055).
- The generator validates `watched_workflows` and `branches` as string
lists, and stops padding blank lines inside block prompts
(max-sixty/tend#1076, max-sixty/tend#1090).

max-sixty/tend@0.1.20...0.1.22


**Beyond the regeneration:** 0.1.22's `tend-review.yaml` sets
`concurrency.queue: max`, which GitHub accepts but the pinned
`actionlint` hook rejects, so this PR also adds a scoped `-ignore` for
that one schema message to `.pre-commit-config.yaml` — otherwise `lint`
is red and the PR can't merge on its own CI. Tracked upstream as
max-sixty/tend#1094.

---------

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants