Skip to content

skills(notifications): add in-flight-run check to dedup gate - #322

Merged
max-sixty merged 3 commits into
mainfrom
notifications-inflight-dedup
Apr 22, 2026
Merged

max-sixty merged 3 commits into
mainfrom
notifications-inflight-dedup

Conversation

@max-sixty

@max-sixty max-sixty commented Apr 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Upstreams the fix from worktrunk PR max-sixty/worktrunk#2386 into the bundled notifications skill.

Step 4a of the dedup check currently finds completed bot activity (comments, reviews, timeline cross-references). It does not see a dedicated workflow that is still running. tend-mention sessions that involve real implementation routinely run past the 10-minute freshness gate — when the notifications bot proceeds, it re-implements in-progress work.

Evidence (from worktrunk, finding in #2386):

  • Run 24742688091 — ~79 min, ~$25, 279 turns. Re-implemented PR #2361 while tend-mention was still pushing; last-step dedup caught the collision and cleaned up, but the session cost had already been incurred.
  • Run 24519963858 — ~16 min, ~$9, 168 turns. Same pattern on PR #2263 / issue #2261.

Change

Adds an In-flight check sub-step to step 4a of plugins/tend-ci-runner/skills/notifications/SKILL.md, sitting between the freshness gate and the dedup check. It queries actions/runs?status=in_progress, filters to tend-* runs, excludes $GITHUB_RUN_ID, and matches on display_title (the workflow_run payload does not expose the triggering issue number for issue_comment / pull_request_review events without an extra API call per run). On hit, skip without marking read — same disposition as the freshness gate.

The two bash-tool caveats from the overlay are preserved inline: gh api --jq does not accept --arg/--argjson, and the Bash tool's bang rewriting can still bite outside heredocs, so the jq uses (X) | not rather than the not-equal operator.

Why this lives in tend, not as a per-repo overlay

The precedence rule codified in CLAUDE.md ("Skill precedence: repo > bundled") and in running-in-ci/SKILL.md (#306) says overlays are for repo-specific policy/convention/taste. This fix is generic: any tend consumer whose tend-mention runs can exceed 10 minutes will hit the same race. That makes it a bundled-skill defect, not an overlay.

Follow-up on worktrunk

Once this lands, worktrunk#2386 is redundant — the bundled skill now covers what its overlay added. A human should close #2386 and revert the overlay section it added to .claude/skills/running-tend/SKILL.md. I have not touched worktrunk.

Test plan

  • pre-commit run --all-files passes
  • jq query verified against worktrunk's actions/runs?status=in_progress (returns 0 when no concurrent tend run matches the subject title, which is the current state)
  • Next time a same-repo mention triggers a long tend-mention run, verify a concurrent notifications run sees IN_PROGRESS > 0 and exits cleanly

This was written by Claude Code on behalf of @max-sixty

max-sixty and others added 2 commits April 22, 2026 09:38
The bundled step 4a dedup check finds *completed* bot activity
(comments, reviews, timeline cross-references). It does not see a
dedicated workflow that is still running — and `tend-mention` sessions
that involve real implementation routinely run past the 10-minute
freshness gate. When the notifications bot proceeds, it duplicates
in-progress work.

Observed on worktrunk run 24742688091 (~79 min / ~$25 re-implementing
PR #2361 while tend-mention was still pushing) and historical run
24519963858 (~16 min / ~$9 duplicating PR #2263).

Add an in-flight check to step 4a that queries
`actions/runs?status=in_progress`, matching on `display_title` (the
workflow_run payload does not expose the triggering issue number for
issue_comment / pull_request_review events). On hit, skip without
marking read — same behavior as the freshness gate, so the next
scheduled poll picks it up when the dedicated run resolves.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The heredoc-specific ! rewriting was fixed in #317, but the Bash tool
can still rewrite bare bangs outside heredocs, so the overlay's
`(X) | not` form is still the safer construction when authoring jq
via bash. Revert to that and re-document the caveat.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Drop incident-specific references and over-qualified rationale.
Keep the check, the display_title note, and the two bash-tool
caveats — these are the only load-bearing pieces.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit dd48497 into main Apr 22, 2026
3 checks passed
@max-sixty
max-sixty deleted the notifications-inflight-dedup branch April 22, 2026 17:04
max-sixty added a commit that referenced this pull request Apr 23, 2026
## Summary

PR #322 relied on a precedence rule that CLAUDE.md stated but the skills
didn't fully cover: bundled-skill defects should go to tend (not to
per-repo overlays), but the rule didn't say *how* a bot should do that
across a trust boundary. This PR codifies the routing. When a correction
identifies a gap in a bundled skill (same root cause would fire in every
consumer), the bot opens a permission-request issue in the consuming
repo; on maintainer approval, the bot files the same issue in tend. The
maintainer, not the bot, authorizes cross-repo filings — consuming repos
may be private.

## Changes

- `plugins/tend-ci-runner/skills/running-in-ci/SKILL.md` — new
"Bundled-skill defects: ask permission to file in tend" subsection under
"Learning from Feedback," with signals and what to include in the
request.
- `plugins/tend-ci-runner/skills/review-runs/SKILL.md` — Step 6
exception covering the same routing when findings come from run review
rather than interactive feedback.
- `CLAUDE.md` — consolidated to development directions. Dropped the
"Skill precedence: repo > bundled" section (product-runtime content that
now lives in the skills). Added "Skill design: bundled for everyone,
overlay for one" — a directive for developers writing skills in this
repo about what belongs in each tier.

## Test plan

- [x] `pre-commit run --all-files`
- [ ] Next time a bundled-skill defect surfaces autonomously, verify the
bot opens a permission-request issue in the consuming repo rather than
patching the overlay or filing directly against tend.

Co-authored-by: Claude Opus 4.7 (1M context) <[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

Development

Successfully merging this pull request may close these issues.

2 participants