Skip to main content

decide

Function decide 

Source
pub fn decide(
    pr: &PrState,
    round: usize,
    budget: usize,
    waited: Duration,
) -> Step
Expand description

Decide the next step. No I/O.

round counts the fix rounds already spent, so round == budget means the budget is gone. A wait never spends a round: waiting is free, and a slow CI must not consume the allowance meant for actual fixes.

The order of the tests is the policy:

  1. The pull request’s own state wins. A merge or a close that happened underneath us is the end of the story regardless of what the checks say.
  2. Pending beats red. A check that is still running may yet fail, and one fix round that addresses every failure is cheaper than two that each address half - the fix pushes and restarts the whole suite anyway.
  3. Comments outrank green. An unresolved comment holds the merge even when CI is happy; that is what a review is for.
  4. Unreadable is not absent. Checks that cannot be read yet are waited on for CHECKS_GRACE, because a pull request opened a moment ago has not been given its workflow runs yet. Past the grace they are treated as genuinely missing and magi stops rather than merge on a guess.