diff --git a/changelog.d/fixed-withheld-fix-exclusion-once.md b/changelog.d/fixed-withheld-fix-exclusion-once.md new file mode 100644 index 0000000000..5439f95f27 --- /dev/null +++ b/changelog.d/fixed-withheld-fix-exclusion-once.md @@ -0,0 +1 @@ +- review: a not-hive-authored head whose fix is withheld is now reported in `FixExclusions` only on the cycle that first withholds it, matching `auditWithheldReviewFixes`' doc instead of repeating every eval cycle (#14882, #14883). diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index 969fbe74c1..690a4f33a0 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -11647,8 +11647,10 @@ type reviewFixAuditor interface { // not get a bot commit — and silence is the one thing an operator cannot // investigate, so each one names the PR, who opened it, and the // review.fix_human_prs value at the time (on no longer permits the push: -// hivecommons/hive#12897). The planner reports each head once, so -// this does not repeat on every eval cycle. +// hivecommons/hive#12897). The planner records the exclusion and +// the withheld fix only on the cycle that first withholds a head (a persisted +// State.Withheld entry suppresses later cycles), so this does not repeat on +// every eval cycle. func auditWithheldReviewFixes(plan review.DispatchPlan, auditor reviewFixAuditor, logger *slog.Logger) { // One WARN per changes_requested head that ends the cycle without a fix // kick: a PR shown as "Fixing" that nobody is fixing must be loud diff --git a/src/pkg/review/dispatch.go b/src/pkg/review/dispatch.go index f5bf54e4f4..32ec1f8f5d 100644 --- a/src/pkg/review/dispatch.go +++ b/src/pkg/review/dispatch.go @@ -1417,11 +1417,6 @@ func fixPushAuthorOK(author string) bool { func (p *DispatchPlan) withholdFix(pr PullRequest, opts DispatchOptions, now time.Time) { for _, w := range p.State.Withheld { if samePRHead(w.Repo, w.Number, w.HeadSHA, pr.Repo, pr.Number, pr.HeadSHA) { - reason := FixDispatchExcludedNotHiveAuthored - if opts.FixHumanPRs { - reason = FixDispatchExcludedNotHiveAuthoredDCO - } - p.recordFixExclusion(pr, reason, 0) return } } diff --git a/src/pkg/review/fix_push_gate_test.go b/src/pkg/review/fix_push_gate_test.go index ad8e68ada6..70cbea4211 100644 --- a/src/pkg/review/fix_push_gate_test.go +++ b/src/pkg/review/fix_push_gate_test.go @@ -293,3 +293,22 @@ func TestFixPushAuthorOK(t *testing.T) { }) } } + +func TestWithheldFixExclusionReportedOncePerHead(t *testing.T) { + pr := humanPR("sha1") + pr.HiveAttributed = true + arts := Artifact{Items: []Aggregate{changesRequestedFor(pr)}} + + first := PlanDispatch([]PullRequest{pr}, arts, DispatchState{}, fixGateOpts(false)) + if len(first.FixExclusions) != 1 || len(first.WithheldFixes) != 1 { + t.Fatalf("first cycle: exclusions=%+v withheld=%+v, want one of each", first.FixExclusions, first.WithheldFixes) + } + + second := PlanDispatch([]PullRequest{pr}, arts, first.State, fixGateOpts(false)) + if len(second.FixExclusions) != 0 || len(second.WithheldFixes) != 0 { + t.Fatalf("second cycle re-reported the same head: exclusions=%+v withheld=%+v", second.FixExclusions, second.WithheldFixes) + } + if len(second.State.Withheld) != 1 { + t.Fatalf("withheld state = %+v, want the single entry kept", second.State.Withheld) + } +}