Skip to content

ci: base stale-assignment clock on human activity, not updated_at#823

Open
andreahlert wants to merge 1 commit into
apache:mainfrom
andreahlert:aex/fix-stale-assignment-clock
Open

ci: base stale-assignment clock on human activity, not updated_at#823
andreahlert wants to merge 1 commit into
apache:mainfrom
andreahlert:aex/fix-stale-assignment-clock

Conversation

@andreahlert

Copy link
Copy Markdown
Collaborator

Problem

The Stale Assignments workflow (.github/workflows/stale-assignments.yml) is supposed to warn at 14 days of inactivity and unassign at 21. It never unassigns.

It measures inactivity from issue.updated_at:

const updatedAt = new Date(issue.updated_at);
const daysSinceUpdate = Math.floor((now - updatedAt) / (1000 * 60 * 60 * 24));

updated_at is bumped by any change to the issue, including the bot's own warning comment and label edits. So each weekly warn resets the clock, capping daysSinceUpdate at the warn interval. The 21-day unassign branch is effectively dead code: the bot warns forever and never removes an assignee.

Evidence (#400)

Bot warning timestamps on #400:

Date Text
2026-04-15 inactive for 17 days
2026-04-29 inactive for 14 days
2026-06-03 inactive for 16 days
2026-06-24 inactive for 20 days

Apr 15 to Apr 29 is exactly 14 days. An honest counter would have read 31, not 14, the warning comment reset updated_at. The assignee was never removed despite four warnings.

Fix

Measure inactivity from the last human activity, taking the most recent of:

  • last non-bot comment (github-actions[bot] excluded),
  • the assigned timeline event for a current assignee (so a freshly assigned issue is not instantly stale),
  • issue creation time (fallback).

Bot comments no longer pollute the signal, so the clock accumulates past 14 and the 21-day unassign threshold becomes reachable. The paginated comments are reused for the existing recent-warn spam guard.

Notes

  • No behavior change to thresholds (14 warn / 21 unassign) or to the lifecycle/frozen exemption.
  • Security note in the header still holds: only numeric IDs and login names from the API are used; no untrusted input reaches a shell.
  • Validated locally: YAML parses, embedded script passes node --check.

The stale-assignment workflow measured inactivity from issue.updated_at.
That field is bumped by *any* change to the issue, including the bot's own
warning comment and label edits. Each weekly warn therefore reset the clock,
capping daysSinceUpdate at the warn interval so the 21-day unassign branch
was never reached: the bot warned forever and never removed an assignee.

Observed on apache#400: warnings at 17 then exactly 14 days later 14,
again 16 then 20 days, while the assignee was never unassigned.

Compute inactivity from the most recent of: last non-bot comment, the
assignment event for a current assignee (so a freshly assigned issue is not
instantly stale), and issue creation time. Bot comments no longer pollute the
signal, so the clock accumulates and the unassign threshold is reachable.
Reuse the paginated comments for the recent-warn spam guard.

Signed-off-by: André Ahlert <andre@aex.partners>
@github-actions github-actions Bot added the area/ci Workflows, build, release scripts label Jun 27, 2026
@andreahlert

Copy link
Copy Markdown
Collaborator Author

Superseding this. Rather than chase a correct activity signal, removing the stale-assignment bot entirely (it posted misleading inactivity numbers and never actually unassigned anyone). New PR removes the workflow.

@andreahlert andreahlert reopened this Jun 27, 2026
@andreahlert

Copy link
Copy Markdown
Collaborator Author

Reopened. Disregard the previous close note about removing the workflow, that was a misread. The bot stays; this PR is the intended fix: the bot's own warning comment no longer resets the inactivity clock. Excluding github-actions[bot] comments from the activity signal is the whole point, so warnings accumulate and the 21-day unassign threshold becomes reachable.

@andreahlert andreahlert self-assigned this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Workflows, build, release scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant