Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eval/daily-row.jq
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def over($limit; $what): if . == null then "\($what) was not measured" elif . >
| ([ ($l.ready_gaps_over_90 | if . == null then "waits of a ready head were not measured" elif . > 0 then "\(.) wait(s) over 90 minutes of a ready head with no landing" else empty end),
(if $repo == "basecamp/hey-native-apps" and ($l.landed // 0) > 0 then ($l.queue_added_p50_minutes | over(6; "minutes the queue adds at the median")) else empty end),
(if ($l.landed // 0) > 0 then ($l.builds_per_landing | over(if $repo == "basecamp/hey2" then 1.3 else 0.60 end; "builds per landing")) else empty end),
(if $repo == "basecamp/hey-native-apps" then ($l.passing_candidates_thrown_away | if . == null then "passing candidates thrown away were not measured" elif . > 3 then "\(.) passing candidates thrown away unlanded, over 3" else empty end) else empty end),
($l.wrong_ejections | if . == null then "wrong ejections were not measured" elif . > 0 then "\(.) wrong ejection(s)" else empty end),
(if $unjudged > 0 then "\($unjudged) landing(s) after an ejection could not be checked for a wrong one" else empty end),
(if ($t.twice // [] | length) > 0 then "\($t.twice | length) head(s) taken out twice" else empty end) ]) as $trips
Expand All @@ -32,6 +33,7 @@ def over($limit; $what): if . == null then "\($what) was not measured" elif . >
"| Longest wait of a ready head with no landing | \(if $l.ready_gaps == null then "not measured" elif $l.longest_ready_gap_minutes == null then "none" else "\($l.longest_ready_gap_minutes | n1) min, \($l.longest_ready_gap_from | hm) to \($l.longest_ready_gap_to | hm)" end) |",
"| Red candidates | \(if $l.red_candidates == null then "not measured" elif $l.red_candidates == 0 then "none" else "\($l.red_candidates), holding \($l.red_pull_requests | n1) pull requests; " + (if ($l.red_read_n // 0) > 0 then "failed job seen to read red \($l.red_read_median_minutes | n1) min at the median over \($l.red_read_n)" else "no failed job's time was recorded" end) end) |",
"| Trunk moves no recorded tick planned | \($l.unplanned_trunk_moves | n1)\(if ($l.unplanned_trunk_moves // 0) > 0 then " (a merge outside the queue, or a tick whose record is missing; its landings are not counted)" else "" end) |",
"| Passing candidates thrown away unlanded | \(if $l.passing_candidates_thrown_away == null then "not measured" elif $l.passing_candidates_thrown_away == 0 then "none" else "\($l.passing_candidates_thrown_away): \($l.thrown_away_head_moved) with a member's head moved, \($l.thrown_away_member_left) with a member gone from the queue" end) |",
(if ($l.unconfirmed_landing_plans // 0) > 0 then "| Landing plans in the window the records never confirm | \($l.unconfirmed_landing_plans) (a refused push, or a landing confirmed after the records end) |" else empty end),
"| Wrong ejections by the engine | \($l.wrong_ejections | n1)\(if $unjudged > 0 then ", with \($unjudged) landing(s) not checked" else "" end) |",
"| Take-outs | \($outs | length): \([classes[] as $k | "\($c[$k].count // 0) \($k)"] + [$others[] | "\(.count) \(.name)"] | join(", ")) |",
Expand Down
37 changes: 35 additions & 2 deletions eval/daily_row_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import (
// and returns its exit status and how often the post was called.
func dailyRow(t *testing.T, dir string, env ...string) (status, posts int) {
t.Helper()
cmd := exec.Command("bash", filepath.Join(dir, "daily-row"), "o/app", "2026-11-18")
return dailyRowOf(t, dir, "o/app", env...)
}

func dailyRowOf(t *testing.T, dir, repo string, env ...string) (status, posts int) {
t.Helper()
cmd := exec.Command("bash", filepath.Join(dir, "daily-row"), repo, "2026-11-18")
cmd.Env = append(append(os.Environ(), "T="+dir, "BANYAN_EVAL="+filepath.Join(dir, "eval"), "BANYAN_ROWS="+filepath.Join(dir, "state")), env...)
out, err := cmd.CombinedOutput()
if exit, ok := err.(*exec.ExitError); ok {
Expand Down Expand Up @@ -44,7 +49,7 @@ func standIns(t *testing.T) string {
for name, script := range map[string]string{
"fetch-ticks": "#!/bin/sh\nexit \"${FETCH_EXIT:-0}\"\n",
"eval": "#!/bin/sh\necho \"$*\" >> \"$T/asked\"\ncase \" $* \" in *\" -takeouts \"*) echo '{\"takeouts\":[],\"by_class\":{},\"comments_read\":0}' ;;\n" +
"*) echo \"{\\\"commit\\\":\\\"$COMMIT\\\",\\\"landed\\\":1,\\\"ticks\\\":2,\\\"red_candidates\\\":0,\\\"red_read_n\\\":0}\" ;; esac\n",
"*) echo \"{\\\"commit\\\":\\\"$COMMIT\\\",\\\"landed\\\":1,\\\"ticks\\\":2,\\\"red_candidates\\\":0,\\\"red_read_n\\\":0$LIVE}\" ;; esac\n",
"post": "#!/bin/sh\ncat > /dev/null; echo x >> \"$T/posts\"; [ \"${POST_EXIT:-0}\" = 0 ] || exit \"$POST_EXIT\"; echo posted\n",
} {
if err := os.WriteFile(filepath.Join(dir, name), []byte(script), 0o755); err != nil {
Expand Down Expand Up @@ -129,3 +134,31 @@ func TestDailyRowChecksEjectionsAgainstACloneAndSaysNoneForADayWithoutReds(t *te
t.Fatalf("a day without a red candidate reads:\n%s", row)
}
}

func TestDailyRowTripsOverThreePassingCandidatesThrownAwayInHeyNativeApps(t *testing.T) {
for _, c := range []struct {
repo, thrown, trip string
}{
{"basecamp/hey-native-apps", "3", ""},
{"basecamp/hey-native-apps", "4", "4 passing candidates thrown away unlanded, over 3"},
{"basecamp/hey2", "4", ""},
} {
dir := standIns(t)
live := `LIVE=,"passing_candidates_thrown_away":` + c.thrown + `,"thrown_away_head_moved":2,"thrown_away_member_left":1`
if status, _ := dailyRowOf(t, dir, c.repo, "COMMIT="+strings.Repeat("a", 40), live); status != 0 {
t.Fatalf("status %d", status)
}
data, _ := os.ReadFile(filepath.Join(dir, "state", filepath.Base(c.repo), "rows", "2026-11-18.md"))
row := string(data)
trips := ""
for _, line := range strings.Split(row, "\n") {
if strings.HasPrefix(line, "**Tripwires:** ") {
trips = line
}
}
line := "| Passing candidates thrown away unlanded | " + c.thrown + ": 2 with a member's head moved, 1 with a member gone from the queue |\n"
if !strings.Contains(row, line) || strings.Contains(trips, "thrown away") != (c.trip != "") || !strings.Contains(trips, c.trip) {
t.Fatalf("%s, %s thrown away reads:\n%s", c.repo, c.thrown, row)
}
}
}
56 changes: 50 additions & 6 deletions eval/live_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ type liveMeasures struct {
// UnplannedTrunkMoves counts the ticks in the window that read the trunk at a commit the tick
// before did not and no recorded plan landed: a merge made outside the queue, or a tick whose
// record is missing, whose landings the score cannot count.
UnplannedTrunkMoves int `json:"unplanned_trunk_moves"`
RedCandidates int `json:"red_candidates"`
RedReadN int `json:"red_read_n"`
RedReadMedianMinutes *float64 `json:"red_read_median_minutes"`
RedReadSumMinutes *float64 `json:"red_read_sum_minutes"`
RedPullRequests int `json:"red_pull_requests"`
UnplannedTrunkMoves int `json:"unplanned_trunk_moves"`
// PassingCandidatesThrownAway counts the candidates a tick in the window deleted while they
// had passed with members on them, and that no recorded plan landed, each once. Of those,
// ThrownAwayHeadMoved counts the ones with a member queued at another head by then, and
// ThrownAwayMemberLeft the ones with a member no longer queued; one can be both, or neither.
PassingCandidatesThrownAway int `json:"passing_candidates_thrown_away"`
ThrownAwayHeadMoved int `json:"thrown_away_head_moved"`
ThrownAwayMemberLeft int `json:"thrown_away_member_left"`
RedCandidates int `json:"red_candidates"`
RedReadN int `json:"red_read_n"`
RedReadMedianMinutes *float64 `json:"red_read_median_minutes"`
RedReadSumMinutes *float64 `json:"red_read_sum_minutes"`
RedPullRequests int `json:"red_pull_requests"`
}

type recordedHead struct {
Expand Down Expand Up @@ -233,6 +240,31 @@ func measureLive(recs []queue.Recording, opts liveOptions, landings []liveLandin
m.UnplannedTrunkMoves++
}
}
thrown := map[queue.SHA]bool{}
for _, rec := range recs {
if !opts.contains(rec.World.Now) {
continue
}
for _, a := range rec.Actions {
if a.Do != "delete" || planned[a.SHA] || thrown[a.SHA] {
continue
}
for _, b := range rec.World.Builds {
if b.SHA == a.SHA && b.Kind == queue.Candidate && b.Verdict == queue.Success && len(b.Chain) > 0 {
thrown[a.SHA] = true
m.PassingCandidatesThrownAway++
moved, left := throwReasons(rec.World.PRs, b.Chain)
if moved {
m.ThrownAwayHeadMoved++
}
if left {
m.ThrownAwayMemberLeft++
}
break
}
}
}
}
var added, build, total []float64
for _, r := range rows {
added, build, total = append(added, r.added), append(build, r.build), append(total, r.total)
Expand Down Expand Up @@ -360,6 +392,18 @@ func measureLive(recs []queue.Recording, opts liveOptions, landings []liveLandin
return m
}

func throwReasons(prs []queue.PR, chain []queue.Member) (moved, left bool) {
heads := map[int]queue.SHA{}
for _, pr := range prs {
heads[pr.Number] = pr.Head
}
for _, member := range chain {
head, queued := heads[member.Number]
moved, left = moved || queued && head != member.Head, left || !queued
}
return moved, left
}

// waitsOnTheQueue says a recorded pull request could be built: its own checks passed, nothing of
// its own holds it, and the queue's last note on it is not that it conflicts with the trunk, which
// only its author can change.
Expand Down
45 changes: 45 additions & 0 deletions eval/live_window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,48 @@ func TestLiveMarksWithoutPlansDoNotCount(t *testing.T) {
t.Fatalf("unplanned marks: %+v", row)
}
}

func TestLiveCountsPassingCandidatesThrownAwayUnlanded(t *testing.T) {
start := time.Date(2026, 11, 18, 12, 0, 0, 0, time.UTC)
at := func(m int) time.Time { return start.Add(time.Duration(m) * time.Minute) }
candidate := func(sha queue.SHA, verdict queue.Verdict, chain ...queue.Member) queue.Build {
return queue.Build{SHA: sha, Kind: queue.Candidate, Verdict: verdict, Chain: chain}
}
one, two := queue.Member{Number: 1, Head: "h1", Merge: "m1"}, queue.Member{Number: 2, Head: "h2", Merge: "m2"}
deleted := func(m int, prs []queue.PR, b queue.Build) queue.Recording {
return queue.Recording{World: queue.World{Now: at(m), Trunk: "t", PRs: prs, Builds: []queue.Build{b}}, Actions: []queue.Action{{Do: "delete", SHA: b.SHA}}}
}
both := []queue.PR{{Number: 1, Head: "h1"}, {Number: 2, Head: "h2"}}
moved := []queue.PR{{Number: 1, Head: "h1"}, {Number: 2, Head: "h2-pushed-again"}}
for _, c := range []struct {
name string
recs []queue.Recording
from, to int
thrown, headMoved, left int
}{
{"a member's head moved", []queue.Recording{deleted(1, moved, candidate("c", queue.Success, one, two))}, 0, 10, 1, 1, 0},
{"a member left", []queue.Recording{deleted(1, both[:1], candidate("c", queue.Success, one, two))}, 0, 10, 1, 0, 1},
{"one member moved and another left", []queue.Recording{deleted(1, moved[1:], candidate("c", queue.Success, one, two))}, 0, 10, 1, 1, 1},
{"deleted twice, counted once", []queue.Recording{deleted(1, both[:1], candidate("c", queue.Success, one, two)), deleted(2, both[:1], candidate("c", queue.Success, one, two))}, 0, 10, 1, 0, 1},
{"landed, then deleted", []queue.Recording{
{World: queue.World{Now: at(1), Trunk: "t", PRs: both, Builds: []queue.Build{candidate("c", queue.Success, one, two)}}, Actions: []queue.Action{{Do: "land", SHA: "c", Members: []queue.Member{one, two}}}},
deleted(2, nil, candidate("c", queue.Success, one, two))}, 0, 10, 0, 0, 0},
{"landed after the window", []queue.Recording{
deleted(1, both[:1], candidate("c", queue.Success, one, two)),
{World: queue.World{Now: at(20), Trunk: "t", PRs: both, Builds: []queue.Build{candidate("c", queue.Success, one, two)}}, Actions: []queue.Action{{Do: "land", SHA: "c", Members: []queue.Member{one, two}}}}}, 0, 10, 0, 0, 0},
{"failed", []queue.Recording{deleted(1, nil, candidate("c", queue.Failure, one, two))}, 0, 10, 0, 0, 0},
{"pending", []queue.Recording{deleted(1, nil, candidate("c", queue.Pending, one, two))}, 0, 10, 0, 0, 0},
{"passed with an empty chain", []queue.Recording{deleted(1, nil, candidate("c", queue.Success))}, 0, 10, 0, 0, 0},
{"a passing check, not a candidate", []queue.Recording{deleted(1, nil, queue.Build{SHA: "c", Kind: queue.Check, Verdict: queue.Success, Chain: []queue.Member{one}})}, 0, 10, 0, 0, 0},
{"deleted before the window", []queue.Recording{deleted(1, nil, candidate("c", queue.Success, one, two)), {World: queue.World{Now: at(5), Trunk: "t"}}}, 2, 10, 0, 0, 0},
{"deleted at the window's end", []queue.Recording{{World: queue.World{Now: at(1), Trunk: "t"}}, deleted(10, nil, candidate("c", queue.Success, one, two))}, 0, 10, 0, 0, 0},
} {
t.Run(c.name, func(t *testing.T) {
m := windowRow(t, c.recs, at(c.from), at(c.to)).liveMeasures
if m.PassingCandidatesThrownAway != c.thrown || m.ThrownAwayHeadMoved != c.headMoved || m.ThrownAwayMemberLeft != c.left {
t.Fatalf("thrown away %d, head moved %d, member left %d; want %d, %d, %d",
m.PassingCandidatesThrownAway, m.ThrownAwayHeadMoved, m.ThrownAwayMemberLeft, c.thrown, c.headMoved, c.left)
}
})
}
}