Skip to content

A branch's duration estimate falls back to the all-branch figure once 20+ newer runs exist on other branches #373

Open

Description

@matt-edmondson

What's wrong

DurationEstimator.EstimateDuration (BuildMonitor/DurationEstimator.cs ~L41-64) takes the 20 most recent successful runs across all branches first. Only then does it filter that sample by branch:

List<Run> allSuccessfulRuns = [.. build.Runs.Values
    .Where(r => r.Status == RunStatus.Success && !r.IsOngoing)
    .OrderByDescending(r => r.Started)
    .Take(MaxSamplesToConsider)];
...
List<Run> branchRuns = [.. allSuccessfulRuns.Where(r => r.Branch == branch)];

So a branch only gets its own estimate when at least MinSamplesForEstimate of its successes are among the 20 newest successes of the whole workflow.

Failure scenario

  1. A repository's CI workflow has frequent PR and dependabot runs.
  2. Within the last 20 successful runs, main has fewer than three. Runs are never pruned and every poll adds more, so this is common on an active repository.
  3. build.CalculateEstimatedDuration("main") (BuildMonitor.cs:889) finds too few main runs in that sample and silently falls back to the all-branch estimate.
  4. If main runs take a different length of time, for example because they also pack and release, everything derived from that estimate is wrong for main:
    • the shown estimate
    • the ETA
    • the progress ring
    • the RunSync poll interval (Run.CalculateETA → RunSync.cs)

This happens even though main may have plenty of history just outside the window.

The existing test ABranchWithEnoughHistoryUsesItsOwnEstimate uses only a handful of runs, so it never reaches the 20-run cap.

Suggested fix

  • Filter by branch before Take(MaxSamplesToConsider), so the branch estimate uses that branch's own 20 most recent successes.
  • Keep a separate top-20 across all branches for the fallback.
  • GetEstimationStats (~L205-212) does the same thing; fix it the same way or remove it if it is unused.
  • Add a test: 5 older main successes of one duration, then 20+ newer successes on another branch of a very different duration. The main estimate must reflect the main runs.

Activity

  1. added
    bug
    on Oct 19, 2026
  2. matt-edmondson commented on Oct 19, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions