Repository navigation
fix(notifications): stop counting an abandoned run as a subject's owner - #1264
Conversation
`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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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]>
Problem
active_subject_runs.pytreats 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 — atend-mentionrun sittingqueuedfor hours still owes the maintainer an answer — but GitHub also strands runs that never start: created, zero jobs,updated_atequal tocreated_at, and answeringstatus=queuedindefinitely. This repository is holding three of them right now:tend-mentiontend-notificationstend-mentionA 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-mentionrun above pins PR #1248, which this poll found unread and had to reason past by hand.Solution
owning_runsskips a run whoseupdated_athas not moved in 24h. GitHub advancesupdated_aton 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 (notimeout-minutesis set, so GitHub's 6h default applies) is over a day pastcreated_atwhile 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 reportsupdated_atequal to itscreated_at, so the bound still reaches exactly the three above.An absent or unparsable
updated_atstill 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", matchinglist_recent_runs.pyand the other scripts that read timestamps, sodatetime.fromisoformatparses GitHub's trailingZdirectly andUTCis available.uv run --scriptprovisions the interpreter, so this is not a deployment constraint.Testing
Four tests in
generator/tests/test_active_subject_runs.py, on a_runfixture that now carries both timestamps relative to the wall clock the script reads, defaultingupdated_attocreated_at— the shape GitHub reports for a queued run and for a stranded one:tend-mentionqueue rather than a fast one;updated_atstill is, pinning the conservative fallback.uv run pytestpasses apart from the twotest_refresh_consumers.pycases that need PyPI, which the sandbox has no DNS for. Everypre-commithook passes.