fix(list-recent-runs): close the completion window at the cron tick - #850
Open
tend-agent wants to merge 1 commit into
Open
fix(list-recent-runs): close the completion window at the cron tick#850tend-agent wants to merge 1 commit into
tend-agent wants to merge 1 commit into
Conversation
The window's floor advances one cron period per cycle but had no ceiling, so each cycle listed floor..now — wider than a period by the scheduler's delay — and the next cycle re-listed that tail. With ticks landing 45-55 min late, 19 of 21 runs in a cycle had already been surveyed by the previous one. Close the window at the tick, exclusive, so consecutive cycles tile as the header already claims; runs finishing after the tick are the next cycle's first items, not dropped.
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
list-recent-runs.shanchors its completion window's floor to the intended cron tick, and advances that floor by exactly one period per cycle. It never sets a ceiling — the filter isupdatedAt >= cutoffand nothing more. So each cycle listsfloor .. now, which is wider than one period by however late the GHA scheduler was, and the next cycle — whose floor is exactly this cycle's tick — lists that tail a second time. The script's own header says the opposite: "Consecutive cycles then tile exactly: [intended-1h, intended], then [intended, intended+1h]." That property only holds with the ceiling this PR adds.The cost is a duplicated agent survey, on the workflow that is the fleet's dominant token consumer.
Measured on this repo's last two cycles
review-reviewersticks are landing 45–55 min late (09:41:26Z→10:41:41Z→11:32:14Z, against47 * * * *), so the redundant share is close to the whole period:19 of this cycle's 21 runs had already finished before the previous cycle began listing, so they were in that cycle's list too and were surveyed twice. Only two runs —
30998444312itself and30999831196— were new. Both cycles independently reached the same all-clear on the same runs.With the ceiling, this cycle's window closes at 10:47Z and the two post-tick runs move to the next cycle, whose floor is 10:47Z. Nothing is dropped, only deferred by one cycle: the deferral is bounded by the period, and the dropped-tick recovery below still reaches further back when a tick never fires.
Verification
New
generator/tests/test_list_recent_runs.pydrives the real script through a stubgh(no network), placing fixture runs either side of the tick:test_window_is_half_open_at_the_cron_tick— pre-floor, in-window, post-tick and still-running runs; asserts only the in-window pair is listed. Mutation-checked: fails onmainwith[2, 3, 4]vs the expected[2, 3].test_next_cycle_picks_up_what_the_ceiling_deferred— a run finishing just after the previous tick is listed by this cycle, i.e. deferred rather than dropped.test_non_periodic_cron_keeps_the_now_anchored_window_uncapped— off the cron path (*/15 * * * *,workflow_dispatch) there is no next cycle to hand a tail to, so no ceiling is applied.Each test derives the cron minute as
(now.minute + 30) % 60, putting the tick ~30 min from the clock in either direction so it can't race a rollover.shellcheck -S warningclean,bash -nclean, full generator suite 330 passed.Relationship to the other open PRs on this file
Neither of the two open PRs touching
list-recent-runs.shcloses this gap; both keep the floor-only filter and both restate the "tile exactly / no overlap" claim in comments.intended - period. It cuts the number of cycles, but the overlap per cycle stays equal to the scheduler delay — at a 3-hourly period that is ~30% of each window instead of ~90%. Its verification prints windows with both bounds, which is the behaviour this PR actually implements.The edits are textually adjacent to both (a new assignment after
COMPLETED_AFTER), so whichever lands second wants a small rebase; neither depends on the other.Gate assessment
Evidence log: https://gist.github.com/e08f6e62d6478163cb425a75648eb7e4