diff --git a/changelog.d/fixed-15742-ask-policy-adoption-countdown.md b/changelog.d/fixed-15742-ask-policy-adoption-countdown.md new file mode 100644 index 0000000000..f6705d9ab7 --- /dev/null +++ b/changelog.d/fixed-15742-ask-policy-adoption-countdown.md @@ -0,0 +1 @@ +- A stage/072 row under `maintainer_policy: ask` no longer claims `hive adopts it in Nm` right up to the due moment for a maintainer's own PR, only to flip to `adopt?`: the engine does not read the author's repository permission until adoption is due, so the tracker names the exception (`unless the author maintains this repository, then it asks`), the same hedge `never` got in #15738. diff --git a/src/pkg/dashboard/stage_tracker_adoption.go b/src/pkg/dashboard/stage_tracker_adoption.go index 3fdfacf454..e3ead89f17 100644 --- a/src/pkg/dashboard/stage_tracker_adoption.go +++ b/src/pkg/dashboard/stage_tracker_adoption.go @@ -224,16 +224,21 @@ func stageTrackerAdoptionText(author string, a StageTrackerAdoption, now time.Ti } // stageTrackerAdoptionNeverHedge qualifies the auto-adopt countdown under -// maintainer_policy: never. The engine has not read the author's repository +// maintainer_policy: never and ask. The engine has not read the author's repository // permission yet (it only does so once due), so a maintainer's head never // reaches the promised moment at all and the row cannot promise adoption for // every author the way it does under adopt (hivecommons/hive#15692). lead is // the conjunction that joins the clause to the text before it. func stageTrackerAdoptionNeverHedge(a StageTrackerAdoption, lead string) string { - if a.Policy != config.AdoptionMaintainerPolicyNever { - return "" + switch a.Policy { + case config.AdoptionMaintainerPolicyNever: + return lead + " the author maintains this repository" + case config.AdoptionMaintainerPolicyAsk: + // ask reads the permission at the same due moment and then asks + // the maintainer instead of adopting (hivecommons/hive#15742). + return lead + " the author maintains this repository, then it asks" } - return lead + " the author maintains this repository" + return "" } // stageTrackerAdoptionOfflineFor renders " 26h" for the time the author's diff --git a/src/pkg/dashboard/stage_tracker_adoption_test.go b/src/pkg/dashboard/stage_tracker_adoption_test.go index 9a66a19cb3..b364b3a5e8 100644 --- a/src/pkg/dashboard/stage_tracker_adoption_test.go +++ b/src/pkg/dashboard/stage_tracker_adoption_test.go @@ -142,6 +142,42 @@ func TestStageTrackerAdoptionNeverHedgesBeforeDue(t *testing.T) { } } +// hivecommons/hive#15742: ask reads the author's permission at the same due +// moment as never, so its countdown hedges too, saying what ask does. +func TestStageTrackerAdoptionAskHedgesBeforeDue(t *testing.T) { + now := time.Date(2026, 10, 28, 16, 0, 0, 0, time.UTC) + s, store, status := adoptionFixture(t, now, config.AdoptionMaintainerPolicyAsk, offlinePresence(now.Add(-3*time.Hour))) + a := trackerItem(t, s.buildStageTracker(status, store, now), "pr", 14524).Adoption + if a == nil || a.Due || a.BlockedBy != "" || a.Action != "" || a.Policy != "ask" || !a.AutoDue { + t.Fatalf("adoption = %+v", a) + } + if a.Text != "waiting on @hanthor (offline 3h, 2 nudges) — hive adopts it on the next sweep unless the author maintains this repository, then it asks" { + t.Fatalf("text = %q", a.Text) + } + store2 := stagelabels.NewStore("", func() time.Time { return now }) + key := stagelabels.Key("hivecommons/hive", 14524) + store2.Observe(key, stagelabels.ReturnedToContributor, "conflicting") + store2.MarkNudged(key, "feed", 1, false, now.Add(-13*time.Minute)) + s.stageStore = store2 + s.presenceLookup = offlinePresence(now.Add(-13 * time.Minute)) + if a = trackerItem(t, s.buildStageTracker(status, store2, now), "pr", 14524).Adoption; a == nil || a.AutoDue || a.AutoAdoptAt == nil || !a.AutoAdoptAt.Equal(now.Add(2*time.Minute)) || a.Text != "waiting on @hanthor (offline 13m, 1 nudge) — hive adopts it in 2m unless a new head lands or the author maintains this repository, then it asks" { + t.Fatalf("pending text = %+v", a) + } +} + +// hivecommons/hive#15742: the hedge clause per maintainer policy. +func TestStageTrackerAdoptionHedgeByPolicy(t *testing.T) { + for _, tc := range []struct{ policy, want string }{ + {config.AdoptionMaintainerPolicyNever, " unless the author maintains this repository"}, + {config.AdoptionMaintainerPolicyAsk, " unless the author maintains this repository, then it asks"}, + {config.AdoptionMaintainerPolicyAdopt, ""}, + } { + if got := stageTrackerAdoptionNeverHedge(StageTrackerAdoption{Policy: tc.policy}, " unless"); got != tc.want { + t.Errorf("policy %q: hedge = %q, want %q", tc.policy, got, tc.want) + } + } +} + // adopt (default): nothing is held, so the row reports the wait, the // nudges, the presence and — since the engine's own predicate // (automerge.AutoAdoption) is what the row reads — that the hive adopts