Skip to content

After a poll prunes runs, a branch quiet for 30+ days shows an older run's Success (or a stuck Pending) instead of its newest run's Failure #418

Open

Description

@matt-edmondson

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-older at Now−40d (Success), rel-newest at 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 still rel-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

  1. matt-edmondson commented on Nov 12, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Recommended next step: apply the per-branch union in PruneRuns. Add the issue's two-variant repro (Success and Pending rel-older) to RunRetentionTests, and confirm the existing retention tests still pass.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions