Skip to content

fix(notifications): stop counting an abandoned run as a subject's owner - #1264

Merged
max-sixty merged 3 commits into
mainfrom
fix/abandoned-owning-runs
Sep 17, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/abandoned-owning-runs

Conversation

@tend-agent

@tend-agent tend-agent commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

active_subject_runs.py treats every non-terminal run as an owner of its subject, with no bound on how long it may stay one. That was the right fix for the case it was written for — a tend-mention run sitting queued for hours still owes the maintainer an answer — but GitHub also strands runs that never start: created, zero jobs, updated_at equal to created_at, and answering status=queued indefinitely. This repository is holding three of them right now:

Run Workflow Created Jobs
31164659276 tend-mention 2026-08-07 none
34748600612 tend-notifications 2026-09-13 none
34952625187 tend-mention 2026-09-15 none

A notification thread whose subject one of these names is deferred by the poll that finds it and by every poll after it, so nothing ever handles it. That is a hole in the recovery queue rather than wasted compute: the poll exists to catch what the event workflows missed, and a thread parked there is a maintainer request the bot never answers. The tend-mention run above pins PR #1248, which this poll found unread and had to reason past by hand.

Solution

owning_runs skips a run whose updated_at has not moved in 24h. GitHub advances updated_at on every job transition, so the bound measures how long a run's state has stood still rather than how long the run has existed — a run queued most of a day and then running out its job timeout (no timeout-minutes is set, so GitHub's 6h default applies) is over a day past created_at while it is still working the subject, and aging that one out would cost the second outward answer the ownership check exists to prevent. A stranded run reports updated_at equal to its created_at, so the bound still reaches exactly the three above.

An absent or unparsable updated_at still counts as an owner. The asymmetry is deliberate: deferring one extra poll costs a poll, while dropping a live owner costs a second outward answer from the same bot account — the failure #1235 closed.

The script moves to requires-python = ">=3.12", matching list_recent_runs.py and the other scripts that read timestamps, so datetime.fromisoformat parses GitHub's trailing Z directly and UTC is available. uv run --script provisions the interpreter, so this is not a deployment constraint.

Testing

Four tests in generator/tests/test_active_subject_runs.py, on a _run fixture that now carries both timestamps relative to the wall clock the script reads, defaulting updated_at to created_at — the shape GitHub reports for a queued run and for a stranded one:

  • a run untouched for 980h is not an owner — fails before the change, which reports it as one;
  • a run queued for 20h still is, pinning the bound above a real tend-mention queue rather than a fast one;
  • a run created 25h ago but touched 2h ago still is, pinning the measurement to the last state change rather than to creation;
  • a run with no updated_at still is, pinning the conservative fallback.

uv run pytest passes apart from the two test_refresh_consumers.py cases that need PyPI, which the sandbox has no DNS for. Every pre-commit hook passes.

`active_subject_runs.py` treats every non-terminal run as an owner, with no
bound on how long it may stay one. GitHub strands runs non-terminal — created,
no jobs, `updated_at` equal to `created_at`, never picked up — and the Actions
API keeps returning them from `status=queued` indefinitely. A thread whose
subject has one is deferred by the poll that finds it and by every poll after,
so nothing ever handles it.

`owning_runs` now skips a run created more than 24h ago: GitHub terminates a
job queued past that, and a Tend session's own timeout is hours short of it, so
no legitimate owner is still outstanding after a day. An absent or unparsable
`created_at` still counts as an owner — deferring one extra poll costs a poll,
while dropping a live owner costs a second outward answer from the same bot
account.

The script moves to `requires-python = ">=3.12"`, matching the other scripts
that read timestamps, so `datetime.fromisoformat` parses GitHub's trailing `Z`
directly and `UTC` is available; `uv run --script` provisions the interpreter,
so this is not a deployment constraint.

@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 bound keys on created_at, which covers the queue and the session, while the justification for 24h only covers them separately. No timeout-minutes is set on the generated workflows, so a job gets GitHub's 6h default: a tend-mention run queued ~19h — within the range this PR's own test pins as realistic — and then running is past 24h from creation while still live. abandoned() drops it, the poll reads the subject as unowned, and both sessions answer the maintainer as the same bot account. That is the failure #1235 closed, and the direction the description calls the expensive one.

updated_at measures the thing the bound is reaching for, and it is already in the same API response. All three stranded runs in the description report updated_at equal to created_at, so the check keeps catching exactly them; a live run's updated_at advances as its jobs transition — the in-progress tend-review run on this PR reports one 20 seconds after creation, so no live owner can age past the bound. Swapping the field is strictly narrower than raising it.

I'll push the full swap — the constant's comment, the docstring, the SKILL.md sentence, and the test fixture move with it — so the inline suggestion below is just the line the finding lands on.

created_at spans the queue and the session both, so a run queued most of a
day and then running out its job timeout is over 24h old while it is still
working the subject. Dropping it there reads the subject as unowned and
answers the maintainer a second time as the same bot account — the failure
the ownership check exists to prevent.

updated_at advances on every job transition, and a stranded run reports it
equal to its created_at, so the bound still reaches exactly the runs it
targets without aging out a live one.

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

ABANDONED_AFTER's comment justifies the bound with "GitHub terminates a job queued past 24h." That cancellation is a self-hosted-runner limit: content/actions/reference/limits.md lists Job queue time — 24 hours in the Self-hosted section, while the GitHub-hosted rows carry a 6h execution cap and no queue-time row at all. These workflows are runs-on: ubuntu-24.04, so nothing cancels a queued run of theirs at a day.

The value still holds on evidence — across the last 882 tend-* runs (6 days) the longest-lived is 0.78h, and all three stranded runs report updated_at equal to created_at. What the wrong premise costs is the next reader's reasoning: it reads as a guarantee, so the one shape that can outlast 24h stays invisible. tend-review holds its group with queue: max, which the same limits page caps at 100 runs per concurrency group, and a run parked there has no job transitions — the very thing the abandoned() docstring says advances updated_at — so its timestamp stays frozen at created_at for the whole wait. Around thirty queued sessions on one PR puts a live owner past the bound, and abandoned() drops it: the second outward answer this check exists to prevent.

I'm leaving the constant at 24h rather than widening it — that would trade a day's deferral on a genuinely stranded thread against a backlog depth this repo has never reached, and it's a knob to move if queue: max queues ever get deep. Pushing the comment correction below.

@max-sixty
max-sixty merged commit 642d1a9 into main Sep 17, 2026
11 checks passed
@max-sixty
max-sixty deleted the fix/abandoned-owning-runs branch September 17, 2026 08:12
@max-sixty max-sixty mentioned this pull request Sep 17, 2026
max-sixty added a commit that referenced this pull request Sep 17, 2026
Ships #1277. bubblewrap's CVE-2026-87766 fix reached the Ubuntu archive
this afternoon, and every consumer's sessions have died at sandbox
launch since — consumers pin an immutable tag, so the fix reaches them
only through a release.

Also carried: the `tend-notifications` conflict-gate and subject-owner
fixes (#1276, #1264), the outage-enrichment skip (#1248), the sandbox
Git identity seed (#1252), and the split of tend's own maintainer calls
out of the shipped skills (#1265, #1267, #1268, #1269, #1272).

`review` will fail on this PR for the same reason the release exists:
the reviewer runs `max-sixty/tend/[email protected]`, which is the broken
pin.

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

Co-authored-by: Claude Opus 5 (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