Skip to content

fix(mention): run setup before PR checkout so stale PRs don't drop mentions - #391

Merged
max-sixty merged 2 commits into
mainfrom
hourly/review-25452872657
May 8, 2026
Merged

max-sixty merged 2 commits into
mainfrom
hourly/review-25452872657

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Problem

tend-mention triggered from an issue_comment (or pull_request_review* event) on a PR whose head branch predates a local composite action referenced by setup fails before the agent boots. The current step order is:

  1. actions/checkout@v6 (default branch)
  2. Check out PR branch → gh pr checkout <N> switches HEAD to the PR branch
  3. uses: ./.github/actions/<setup> → resolves against the PR's tree

If the PR is old enough that its tree doesn't yet contain that action (a long-lived external PR opened before the action was added, or a stale PR never rebased), step 3 fails with Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/<repo>/<repo>/.github/actions/<name>'. Did you forget to run actions/checkout before running your local action?. The maintainer's @bot ... request drops silently with a red CI X; the agent never runs.

Repro

max-sixty/worktrunk run 25452024590 on PR #1256 (feat/add-az-support, opened 2026-03-04 by an external contributor). Comment: @worktrunk-bot yes, let's try a fresh implementation, push to this PR please. The local ./.github/actions/claude-setup was added 2026-03-05 in worktrunk PR #1273, one day after PR #1256 was opened. PR #1256 has not been rebased, so its head ref's tree lacks that action. gh pr checkout 1256 then uses: ./.github/actions/claude-setup → 404.

Fix

Run setup against the default branch (right after the initial actions/checkout@v6) and then gh pr checkout to switch to the PR branch. Local actions referenced by setup always resolve from default-branch state, regardless of how stale the PR is. The agent still sees the PR-branch tree because the PR-branch checkout follows setup; tools installed by setup (uv, bun, cargo crates, apt packages) persist in the runner env across the git switch and remain available to the agent and any post-checkout steps.

A short comment in the generated YAML calls out the constraint so future edits don't reverse the order.

Tradeoffs

The previous test (test_setup_after_pr_checkout_in_mention) asserted the inverted contract — setup after PR checkout — to give setup steps PR-branch state (e.g. cache prefixes hashing PR's Cargo.lock). The cost of that contract is that any local-action-referencing setup breaks on long-lived stale PRs, and breaks them silently. Reversing the contract trades a minor cache-key miss (cargo/rust-cache handles this internally) for a workflow that always runs.

The renamed test (test_setup_before_pr_checkout_in_mention) carries the rationale in its docstring so the next reader understands why this ordering matters.

Scope

tend-mention only — tend-review (and the other workflows) check out the PR head directly via a single actions/checkout and don't have the two-step main-then-PR sequence. tend-review on a conflicting + stale PR could in principle hit a related shape, but tend-review is gated by pull_request_target events ([opened, synchronize, ready_for_review, reopened]) — a stale PR that hasn't been synchronized since the action was introduced won't fire the workflow. Out of scope here.

Tests

generator/: uv run pytest — 188 passed. Regtest snapshots regenerated for the two mention outputs.

Evidence

Evidence gist — first occurrence of this specific shape recorded in this run; classified Critical (1 occurrence sufficient — clearly wrong outcome dropping a maintainer's explicit request) + Structural (deterministic action-resolution against checked-out tree).

…ntions

When `tend-mention` fires from an `issue_comment` (or PR review event) on a
PR whose head branch predates a local composite action used by `setup` —
e.g. `./.github/actions/claude-setup` added after the PR was opened — the
prior order checked out the PR branch first, then `uses: ./...setup` 404s
with `Can't find 'action.yml'`. Net effect: the maintainer's "@bot please
push" silently fails before the agent boots.

Run setup against the default branch first, then `gh pr checkout` to switch
to the PR branch. Local actions referenced by setup always resolve from
default-branch state; PR-specific tree state remains visible to the agent
(claude-setup's installed tools persist in the runner env across the
branch switch).

Tests: rename + invert `test_setup_after_pr_checkout_in_mention` to assert
the new ordering, with the rationale captured in the docstring. Regtest
outputs for `mention` minimal + with-setup updated.

Observed: max-sixty/worktrunk run 25452024590 on PR #1256
("@worktrunk-bot ... push to this PR please") — `Check out PR branch`
switched HEAD to a 2026-03-04 branch, `claude-setup` was added 2026-03-05
(#1273), agent never ran.

Evidence: https://gist.github.com/9675d1510da32c68a68c1d45137b21e0
@max-sixty

Copy link
Copy Markdown
Owner

I don't think we need the comment here

Per maintainer feedback on PR #391 — the test docstring already captures
the rationale for setup-before-PR-checkout; the inline YAML comment is
redundant.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Removed in aefdb57 — regtest snapshots updated alongside.

@max-sixty
max-sixty merged commit f26b112 into main May 8, 2026
3 checks passed
@max-sixty
max-sixty deleted the hourly/review-25452872657 branch May 8, 2026 18:52
@max-sixty max-sixty mentioned this pull request May 13, 2026
max-sixty added a commit that referenced this pull request May 13, 2026
Bumps generator to 0.0.18.

## Headline

Expose the `__TEND_DELETE__` sentinel so TOML overrides can reach RFC
7396 delete-key semantics — useful for dropping a generator-injected key
(e.g. `on.schedule` from a scheduled workflow) while keeping the rest.
Closes #439, thanks @jrdncstr for reporting.

## Other changes since 0.0.17

- fix(action): sum usage and num_turns across all result entries (#437)
- diag(action): upload execution-output.json (#408)
- fix(mention): run setup before PR checkout so stale PRs don't drop
mentions (#391)
- fix(running-in-ci): base skill worktree on default branch (#401)
- install-tend: fix oauth-token.sh returning an invalid token on macOS
(#398)
- oauth-token.sh: don't tee the OAuth token to stderr (#421)
- Skill hardening: bang-escape guidance, review-reviewers corruption
scans, dedup rules, $GITHUB_RUN_ID requirement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 13, 2026
Brings tend's own deployed workflows in line with the 0.0.18 generator.

Notable propagation: `fix(mention)` (#391) — `setup-uv` now runs before
the PR checkout step, so stale-PR triggers no longer drop mentions.

Until this merges, tend's deployed workflows lag the released generator.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request Aug 13, 2026
…eck (#966)

Drops the `47 * * * *` cron from `review-reviewers`, leaving
`workflow_dispatch`. Its recent output had converged on maintaining its
own evidence machinery, at the fleet's highest per-run cost and a
seven-day quota ceiling that twice took the user-facing workflows down
with it; each adopter's daily `tend-review-runs` already reviews that
repo's runs from the inside and routes bundled-skill defects upstream,
so this removes the direct loop rather than the only one.

The skill is scoped to match: it described itself as hourly and told the
session to analyze "the past hour". It now states the window
`list-recent-runs.sh` actually hands it — floor at the previous
successful run of the workflow, clamped 6h back — which with no cron
makes the clamp the normal case rather than an outage signal, and scopes
its claims to that window. (An earlier revision of this PR described a
cron-payload branch; #965 replaced that logic while this branch was
open, and the text was rebased onto what merges.)

<details><summary>What the sweep caught, and when</summary>

Its unique catches — the ones no inside-out session would have found —
cluster in April–June: rubber-stamped APPROVEs over visibly failing
checks (#667), backslash-backtick corruption in already-published
comment bodies across repos (#359, #405, #424, #562), stale PRs silently
dropping mentions (#391), and the stale/re-anchored approval family
(#798, #821, #884).

The last two weeks are dominated by fixes to its own machinery —
evidence-gist plumbing, survey-window arithmetic, matrix branch naming,
run→output attribution — while per-run cost climbed from $5.31 to
$10.49. That is the shape the cost gate in #960 was written for.

</details>

Re-enable by dispatching it after a change that could move bot behavior
fleet-wide: a release, a harness switch, a model bump — within the hour
of that change, per the window note in the overlay.

> _This was written by Claude Code on behalf of max-sixty_

---------

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

Labels

claude-behavior Behavioral issues found by review-reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants