Measure stale unmarking from the stale window, not just the label date - #180
Conversation
The unmark check asked whether there was activity since the stale label was applied, while the marking check asked whether there was activity in the last 90 days. When the label was older than the window both could be true at once, so an item was unmarked one night and marked again the next, posting a fresh stale comment each time. This happened to esphome/esphome#10867: labelled in December, commented on six days later, then closed and locked. Reopening it in August let the January comment clear the label, and the next run marked it stale again because that comment was long outside the 90 day window. Measure from whichever of the label date and the stale cutoff is later, so activity that is itself stale can no longer clear the label.
|
@esphbot review |
Reviewed. Clamp correct. No blockers. Three non-blocking notes. Close log still prints |
PR Review — Measure stale unmarking from the stale window, not just the label dateCorrect one-line fix for a real flip-flop bug, with a well-evidenced diagnosis. Merge-ready; three non-blocking notes. The root-cause analysis is the strongest part of this PR: naming that the mark and unmark paths were asking two different questions is exactly right, and the #10867 timeline (locked for seven months with a December label still attached, then reopened) is a genuinely non-obvious path to that state. The
🟢 Suggestions
1. Close log line now reports a date the check didn't use
|
esphbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
|
Thanks |
The unmark check asks whether there has been activity since the stale label was applied, while the marking check asks whether there has been activity in the last 90 days. Those are different questions, and once the label is older than the window both can be true at once — so an item is unmarked one night and marked again the next, posting a fresh stale comment every time.
esphome/esphome#10867 is a worked example:
The reporter replied 16 minutes after the auto-close, and the issue was locked a week later. Locked items are skipped, so it sat untouched for seven months with the December label still attached. Reopening it put it back in the loop: that January comment was activity since the label, so the label came off on the 14th, and on the 15th the marking check found nothing inside 90 days and put it straight back on.
Measuring from whichever of the label date and the stale cutoff is later fixes it — activity that is itself outside the stale window can no longer clear the label. Items labelled in the normal course are unaffected, since a label applied days ago is always newer than the cutoff.
One consequence worth knowing: an item that is reopened while still carrying an old stale label now reaches the close branch on the next run rather than flip-flopping, and that branch posts no comment before closing.
not-staleis the escape hatch, and removing the label when reopening also works. Counting a reopen as activity in its own right would handle that case properly, but it needslistEventsplumbed intohasRealActivitySinceand is left for a follow-up.