Description
What's wrong
Build.PruneRuns (BuildMonitor/Build.cs:91-125, added in #398 and called from BuildSync.UpdateBuildAsync after every build poll) applies each keep-rule to runs one at a time, not per branch:
- "newest run on a branch" applies only to branches whose newest run is within
BranchRetention(30 days); - "ongoing" and "the estimator's newest successful runs" keep runs regardless of branch.
So for a branch outside the 30-day window, its newest run can be removed while an older run on the same branch survives through one of the other rules. RenderBuildTable (BuildMonitor.cs:620-625) groups the remaining runs by branch and shows the newest one left. That is now the older run. The status filter (ShouldShowBuildBranch), History and Errors read the same wrong run. ListByWorkflow only returns the newest runs, so the dropped run never comes back, and the result is persisted to the app data file.
The PruneRuns remarks and CLAUDE.md say "A branch none of whose runs is kept disappears from the table". Here the branch stays, showing a run that isn't its latest.
Repro (MSTest, in the style of RunRetentionTests, Now = 2026-06-01)
release/1.0:rel-olderat Now−40d (Success),rel-newestat Now−35d (Failure)- 60 Failure runs on branches
pr-0…pr-59, one hour apart, ending at Now build.PruneRuns(Now)
rel-older status |
removed | newest remaining release/1.0 run |
|---|---|---|
| Success | 1 | before rel-newest:Failure → after rel-older:Success |
| Pending | 1 | before rel-newest:Failure → after rel-older:Pending |
Why it matters
A failed release branch turns green in the monitor, with no new run, just because other branches were busy. A failure is hidden, which is the one thing a build monitor must not do. In the Pending case, the row shows a progress ring for a build that finished long ago.
Suggested fix
Decide per branch. After building kept from the existing rules, add each kept run's branch-newest run, so a branch either shows its true latest run or disappears:
HashSet<string> keptBranches = [.. runs.Where(r => kept.Contains(r.Id)).Select(r => r.Branch)];
kept.UnionWith(runs.Where(r => keptBranches.Contains(r.Branch))
.GroupBy(r => r.Branch)
.Select(g => g.MaxBy(r => r.Started)!.Id));Acceptance criteria
- With the repro above,
release/1.0's newest remaining run is stillrel-newest(Failure), in both the Success and the Pending variant. - A regression test is added to
RunRetentionTests, and the existing retention tests still pass.
Activity
matt-edmondson commentedon Nov 12, 2026
Triage
ListByWorkflownever brings the dropped run back, so the row doesn't heal itself.Build.PruneRuns(BuildMonitor/Build.cs:91-125, introduced by Prune old runs after each build poll so stale branches stop keeping rows [patch] #398) and its tests inRunRetentionTests. The fix is small and local: after buildingkept, add each kept branch's newest run, as the issue suggests. That makes the "a branch shows its latest run or disappears" contract in thePruneRunsremarks and CLAUDE.md true again.PruneRuns.Recommended next step: apply the per-branch union in
PruneRuns. Add the issue's two-variant repro (Success and Pendingrel-older) toRunRetentionTests, and confirm the existing retention tests still pass.Generated by Claude Code