Repository navigation
π Adopt stuck contributor PRs automatically from the tracker's offer predicate - #15662
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
@clubanderson this PR is held at Why:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. |
|
stage 080-awaiting-merge-admission β 071-needs-author: conflicting |
There was a problem hiding this comment.
Docs-currency review (head 8802b3b). The new "When hive adopts automatically" paragraph matches AutoAdoption/cappedSince (automerge_adoption_clock.go:120-161) and the dashboard captions (stage_tracker_adoption.go:200-202, stage_tracker.go β "fork not editable by hive"). Two operator-facing passages this PR's behavior change makes stale were not updated:
-
src/docs/labels-and-control-signals.md:1852-1855β thereason=contributor-offlinemarker bullet still describes the old uncapped clock ("after the later of its last heartbeat and the first nudge"), which is exactly whatcappedSince(automerge_adoption_clock.go:151-160) replaces. It now contradicts the new paragraph 60 lines below it.- `reason=contributor-offline` β the author has a contributor profile here and no relay heartbeat within `governor.labels.stage.presence_window`: adopted `governor.labels.stage.adoption.after_offline` (default 15m) after the later of the first nudge and its last heartbeat, where a heartbeat after the nudge extends the wait by one window at most (see *When hive adopts automatically* below); -
src/docs/dashboard-sections.md:976and:1012enumerate the tracker'sadoption{β¦}andtakeover{β¦}JSON fields and the default-policy pill caption; this PR addsadoption.auto_adopt_at/adoption.auto_due(stage_tracker_adoption.go:58-59) andtakeover.auto_adopt_at(stage_tracker_takeover.go:48), and the 072 caption now readsβ¦ β hive adopts it in 3m unless a new head lands/β¦ β hive adopts it on the next sweep(stage_tracker_adoption.go:200-202). Neither list nor the caption example mentions them, and the:1020sentence "once the nudge grace has elapsed and the engine is not adopting on its own" describes the pre-fix split clock. Suggested edits:-carries `adoption{author, due, blocked_by, since, nudges, author_online, author_registered, author_last_seen, author_maintainer, policy, action, text}` +carries `adoption{author, due, blocked_by, since, nudges, author_online, author_registered, author_last_seen, author_maintainer, policy, action, text, auto_adopt_at, auto_due}` ... -`waiting on @zoe (offline 40m, 2 nudges)` while the default `adopt` policy's clock runs +`waiting on @zoe (offline 40m, 2 nudges) β hive adopts it in 3m unless a new head lands` while the default `adopt` policy's clock runs (`auto_adopt_at` is the same `automerge.AutoAdoption` verdict the sweep acts on; `β¦ β hive adopts it on the next sweep` once `auto_due`) ... -carries `takeover{author, author_online, adopt_now, adopt_now_reason, reroute, reroute_reason, clankers[], rerouted, forced_by, forced_at, fallback_at, grace_elapsed}` +carries `takeover{author, author_online, adopt_now, adopt_now_reason, reroute, reroute_reason, clankers[], rerouted, forced_by, forced_at, fallback_at, grace_elapsed, auto_adopt_at}`
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (style / maintainability) at 8802b3b β no blockers; two advisory notes, both about the PR's own "one clock, cannot drift" premise.
-
The defaults now live in three places.
src/pkg/github/automerge/automerge_adoption_clock.go:43-49introduces privatedefaultGraceOnlineβ¦defaultAdoptOfflineGrace"mirroring pkg/config", butpkg/configalready exports exactly these (src/pkg/config/config.go:3032-3034,:3070-3071) and this package already imports it (automerge_contributor_adopt.go:15). A second copy is the drift surfaceAdoptionClockwas written to remove.-// Defaults applied where the clock is zero (mirroring pkg/config). -const ( - defaultGraceOnline = 2 * time.Hour - defaultGraceOffline = 15 * time.Minute - defaultAdoptAfterOffline = 15 * time.Minute - defaultAdoptAfterUnregistered = 15 * time.Minute - defaultAdoptOfflineGrace = 30 * time.Minute -) - func (c AdoptionClock) graceOnline() time.Duration { - return durationOr(c.GraceOnline, defaultGraceOnline) + return durationOr(c.GraceOnline, config.DefaultContributorGraceOnline) }
(and likewise
config.DefaultContributorGraceOffline,config.DefaultAdoptAfterOffline,config.DefaultAdoptAfterUnregistered,config.DefaultAdoptOfflineGrace.) -
adoptionGracekept its own inlined 2h / 15m.automerge_contributor_adopt.go:72-83still hard-codes the nudge graces and is still called at:683for the supersede grace, so the!hasPresencebranch ofAutoAdoption(automerge_adoption_clock.go,case !hasPresence) andadoptionGracecompute the same value from two different sources.// adoptionGrace returns the grace that applies to the record's first nudge. func adoptionGrace(rec stagelabels.Record, policy StageLabelPolicy) time.Duration { clock := policy.AdoptionClock() if rec.NudgeOnline { return clock.graceOnline() } return clock.graceOffline() }
β hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (intent-alignment) β diff matches #15661: sliding heartbeat clock capped (automerge_adoption_clock.go:150-159), mode=queued no longer counts as online (automerge_contributor_nudge.go:302), sweep/offer/pill share AutoAdoption (automerge_contributor_adopt.go:162-168, stage_tracker_takeover.go:168-173, stage_tracker_presence.go:218-227), fork-not-editable humanised (stage_tracker.go:1430-1434). The sweep reaches adoptContributorPR for every 072 clanker PR regardless of lane reason (automerge_stage_labels.go:1284-1306), so the predicate fix is sufficient for the #15312 rows.
One advisory gap in the "one verdict" claim (low, in-scope):
stageTrackerAutoAdoption(stage_tracker_presence.go:93-107) does not read the PR's labels, so a 072 row carryinghold/do-not-mergewill now say "hive adopts it on the next sweep" (stage_tracker_adoption.go:199-202) while the engine refuses it atautomerge_contributor_adopt.go:640(adoptionBlocked(obs.Labels)). Before this PR the pill made no promise, so this is a new false positive, exactly the UI-vs-sweep drift the issue targets. Suggested fix:
--- a/src/pkg/dashboard/stage_tracker_presence.go
+++ b/src/pkg/dashboard/stage_tracker_presence.go
@@ func stageTrackerAutoAdoption(
if !hasRec || !clock.Enabled || it.Kind != "pr" || it.AuthorKind == authorKindHuman {
return automerge.AdoptionVerdict{}
}
+ // Mirrors the engine's adoptionBlocked(obs.Labels): a parked PR is
+ // never adopted, so the row must not promise it.
+ for _, l := range it.Labels {
+ switch strings.ToLower(strings.TrimSpace(l)) {
+ case "hold", "do-not-merge", "do-not-merge/hold":
+ return automerge.AdoptionVerdict{}
+ }
+ }β hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Correctness (read at head 8802b3b)
One in-scope gap between the predicate the sweep runs and the one the tracker now projects:
hold / do-not-merge rows still read "hive adopts it on the next sweep" β src/pkg/dashboard/stage_tracker_presence.go:97-110 (stageTrackerAutoAdoption) calls automerge.AutoAdoption with only the record/presence; it never looks at it.Labels. The sweep, however, stops after adoptionDue fires when a hold label is present (src/pkg/github/automerge/automerge_contributor_adopt.go:641-644, adoptionBlocked(obs.Labels) β "adoption due but blocked by label", return). So a nudged clanker PR carrying hold gets AutoDue=true / auto_adopt_at and the pill text at stage_tracker_adoption.go:199-202 promises an adoption the engine will log as blocked every sweep β the same UI/sweep disagreement #15661 is about, and the new docs paragraph (src/docs/labels-and-control-signals.md, "nothing holds it: no hold / do-not-merge") describes the gate as part of the offer predicate. The takeover's AutoAdoptAt/GraceElapsed (stage_tracker_takeover.go:168-173) inherits the same gap.
Suggested fix β gate the tracker verdict on the labels the sweep checks (export the label check or mirror it):
--- a/src/pkg/dashboard/stage_tracker_presence.go
+++ b/src/pkg/dashboard/stage_tracker_presence.go
@@ func stageTrackerAutoAdoption(
if !hasRec || !clock.Enabled || it.Kind != "pr" || it.AuthorKind == authorKindHuman {
return automerge.AdoptionVerdict{}
}
+ // Mirror adoptContributorPR: a hold label stops the sweep after the
+ // clock fires, so the row must not promise an adoption.
+ for _, l := range it.Labels {
+ switch strings.ToLower(strings.TrimSpace(l)) {
+ case "hold", "do-not-merge", "do-not-merge/hold":
+ return automerge.AdoptionVerdict{}
+ }
+ }
head := it.Head(plus a case in TestStageTrackerAutoAdoptionExampleCaptions with a hold label asserting no auto_adopt_at). Everything else checked out: the no-presence branch of AutoAdoption (automerge_adoption_clock.go:132-137) matches the removed adoptionGrace (automerge_contributor_adopt.go:73-84); cappedSince and adoptionRetryVerdict match the described one-window cap; the queued β offline change in MarkNudged only feeds NudgeOnline consumers that already expect "offline" (automerge_contributor_adopt.go:725,734, automerge_adoption_orphan.go:205).
β hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦predicate The engine, the tracker's takeover offer and its presence pill each kept their own adoption clock. The sweep counted the offline wait from the author's freshest heartbeat, so every reconnect or acknowledgement restarted the 15m window; a mode=queued nudge marked an offline clanker online (2h grace); the tracker offered Adopt at 072 with no clock at all. PRs by an offline clanker (conflicting, changes requested, optional check red, fork not editable) sat at 072 until a person pressed Adopt. One predicate, automerge.AutoAdoption, now drives the sweep, the offer and the adopt-at projection: a heartbeat after the nudge extends the wait by one window at most, queued nudges count as offline, the adoption log names its trigger, the row says when hive adopts, and fork-not-editable rows name their blocker. Adopt now remains the manual override. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
8802b3b to
ae4db06
Compare
|
hive/awaiting-ci: rebased onto v5 after #15574 split stage_tracker.go β re-applied the three hunks (ForkNotEditable caption, adoptionClock threading in buildStageTracker, AutoAdoptAt fields) onto the new files; no other changes. CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
@clubanderson this PR is back in your court (
Once the new head lands, CI and the review swarm re-run automatically and the PR returns to the normal path. |
There was a problem hiding this comment.
Intent-alignment (delta re-review at ae4db06). The delta is this PR's single commit rebased onto v5 (the other 49 files are #15410/#15639/#15634/#15655/#15574 already on v5). The core of #15661 β one predicate behind the sweep, the Adopt offer and the pill β is implemented (automerge.AutoAdoption, automerge_adoption_clock.go:139; adoptionDue at automerge_contributor_adopt.go:163 now wraps it). One previous finding is still present:
Still present β held PRs: the row promises an adoption the sweep refuses. stageTrackerAutoAdoption (src/pkg/dashboard/stage_tracker_presence.go:92-105) never looks at the row's hold / do-not-merge labels, so for a parked 072 PR stageTrackerAdoption emits AutoDue/AutoAdoptAt (stage_tracker_adoption.go:171-173) and the caption reads β¦ β hive adopts it on the next sweep (stage_tracker_adoption.go:217-220); the presence pill projects adopt_at the same way (stage_tracker_presence.go:221-230). The sweep refuses exactly that case after adoptionDue returns true (automerge_contributor_adopt.go:641-644 β adoptionBlocked, :216-224). That is the UI-says-X / sweep-does-Y gap #15661 is about, and the doc this PR adds lists "no hold / do-not-merge" as a condition of the automatic adoption (labels-and-control-signals.md:1926-1927) that the tracker projection does not honour. The hold modifier is already on the item (stage_tracker_build.go:95-99, stageTrackerOnHold at :517):
func stageTrackerAutoAdoption(it StageTrackerItem, rec stagelabels.Record, hasRec bool, presence func(string) (automerge.ContributorPresence, bool), clock stageTrackerAdoptionClock, now time.Time) automerge.AdoptionVerdict {
// A parked PR (hold / do-not-merge) is never adopted by the sweep
// (automerge adoptionBlocked), so the row must not say it will be.
if !hasRec || !clock.Enabled || it.Kind != "pr" || it.AuthorKind == authorKindHuman || stageTrackerOnHold(it) {
return automerge.AdoptionVerdict{}
}
With that, StageTrackerTakeover.AutoAdoptAt/GraceElapsed (stage_tracker_takeover.go:176-181) also stop advertising a clock for held rows, matching the "release the hold first" reason already set at :120-121. A one-row case in TestStageTrackerAutoAdoptionExampleCaptions with the hold label would pin it.
β hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Style re-review at ae4db06 (delta since 8802b3b; most of the 50-file compare is base-branch churn from the rebase β the PR itself touches 14 files).
Both previous style advisories are still present; neither blocks.
src/pkg/github/automerge/automerge_contributor_adopt.go:72-83βadoptionGracestill hard-codes2 * time.Hour/15 * time.Minutebeside the newAdoptionClockthat owns exactly those graces (automerge_adoption_clock.go:52-58), and is still called at :683. Two sources of truth for the same default:
// adoptionGrace returns the grace that applies to the record's first nudge.
func adoptionGrace(rec stagelabels.Record, policy StageLabelPolicy) time.Duration {
c := policy.AdoptionClock()
if rec.NudgeOnline {
return c.graceOnline()
}
return c.graceOffline()
}
src/pkg/github/automerge/automerge_adoption_clock.go:43-49β thedefault*constants are commented "mirroring pkg/config", butautomergealready importspkg/config(automerge_contributor_adopt.go:15) and the dashboard reads the same values asconfig.DefaultAdoptAfterOfflineetc. (stage_tracker_presence.go:145). Reference the exportedconfig.Default*constants instead of re-declaring them so the mirror cannot drift.
Minor, new in the delta: durationOr (automerge_adoption_clock.go:72) and orDefault (stage_tracker_presence.go:232) are the same helper; the dashboard one survives only for the 000-stage caption at :145.
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Correctness re-review at ae4db06 (delta vs 8802b3b is a rebase onto v5; the PR's own hunks are byte-identical, only relocated by the #15574 split). One finding from the previous round still stands.
Still present β tracker promises auto-adoption for hold / do-not-merge PRs the sweep refuses
src/pkg/github/automerge/automerge_contributor_adopt.go:639-642 β after adoptionDue fires, the sweep returns early when adoptionBlocked(obs.Labels) matches hold, do-not-merge, do-not-merge/hold (:217-225), logging "adoption due but blocked by label" every cycle. The tracker side of the "one predicate" never sees labels: stageTrackerAutoAdoption (src/pkg/dashboard/stage_tracker_presence.go:94-108) takes only rec/presence/clock, and StageTrackerItem carries no label slice. So for a held clanker PR at 072 the adoption pill reads "β hive adopts it in 3m unless a new head lands" and then "β hive adopts it on the next sweep" (stage_tracker_adoption.go:171-173, :217-220), presence.adopt_at is set (stage_tracker_presence.go:215-228), and takeover.grace_elapsed/auto_adopt_at flip true (stage_tracker_takeover.go:176-181) β none of which will happen. This is exactly the UI-vs-sweep divergence #15661 set out to remove, so it is in scope. finish already has labels in hand (stage_tracker_build.go:94), so the fix is small:
--- a/src/pkg/github/automerge/automerge_contributor_adopt.go
+++ b/src/pkg/github/automerge/automerge_contributor_adopt.go
@@ func adoptionBlocked(labels []string) string {
return ""
}
+
+// AdoptionHeldByLabel is the hold label that stops every adoption at this
+// head (hold / do-not-merge), "" when none β the tracker reads it so its
+// adopt-at projection never promises what adoptContributorPR refuses.
+func AdoptionHeldByLabel(labels []string) string { return adoptionBlocked(labels) }
--- a/src/pkg/dashboard/stage_tracker_presence.go
+++ b/src/pkg/dashboard/stage_tracker_presence.go
@@ type stageTrackerAdoptionClock struct {
Enabled bool
+ // Held is the row's hold label (automerge.AdoptionHeldByLabel): the
+ // sweep refuses adoption while it is set, so no clock is projected.
+ Held string
automerge.AdoptionClock
}
@@ func stageTrackerAutoAdoption(
- if !hasRec || !clock.Enabled || it.Kind != "pr" || it.AuthorKind == authorKindHuman {
+ if !hasRec || !clock.Enabled || clock.Held != "" || it.Kind != "pr" || it.AuthorKind == authorKindHuman {
return automerge.AdoptionVerdict{}
}
--- a/src/pkg/dashboard/stage_tracker_build.go
+++ b/src/pkg/dashboard/stage_tracker_build.go
@@ finish := func(it *StageTrackerItem, labels []string, ...
+ rowClock := adoptionClock
+ rowClock.Held = automerge.AdoptionHeldByLabel(labels)
...
- if it.Adoption = stageTrackerAdoption(*it, rec, hasRec, presence, maintainerPolicy, adoptionClock, now); it.Adoption != nil {
+ if it.Adoption = stageTrackerAdoption(*it, rec, hasRec, presence, maintainerPolicy, rowClock, now); it.Adoption != nil {
...
- it.Presence = stageTrackerPresenceFor(*it, login, stage, rec, hasRec, presence, adoptionClock, now)
+ it.Presence = stageTrackerPresenceFor(*it, login, stage, rec, hasRec, presence, rowClock, now)
...
- if it.Takeover = stageTrackerTakeover(*it, rec, hasRec, presence, rerouteCandidates, adoptionClock, now); it.Takeover != nil {
+ if it.Takeover = stageTrackerTakeover(*it, rec, hasRec, presence, rerouteCandidates, rowClock, now); it.Takeover != nil {Please add a hold-labelled row to TestStageTrackerAutoAdoptionExampleCaptions asserting no auto_adopt_at / "hive adopts" text.
Low, non-blocking: rec.AdoptionBlocked(head) for maintainer_policy: never is only written by the sweep once due fires (automerge_contributor_adopt.go:657-662), so a maintainer-authored row reads "hive adopts it in 3m" until the due moment, then flips to "not adopted: maintainer_policy is never". Acceptable, but worth a follow-up if the pill is meant to be exact.
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #15661
Root cause
The engine, the tracker's takeover offer and its presence pill each kept their own adoption clock. The sweep counted the offline wait from the author's freshest heartbeat (
Presence.LastSeen, bumped on every relay auth / task completion), so each reconnect or acknowledgement restarted the 15m window; amode=queuednudge marked an offline clanker online (2h grace); the tracker offered Adopt at 072 with no clock at all, so the operator clicked before the sweep's clock expired (hive#15565/#15566/#15609), andfork-not-editablerows (hive#15312 β¦) read "No stage recorded yet".Change
automerge.AutoAdoption(+AdoptionClock,AdoptionVerdict): the one predicate behind the sweep'sadoptionDue, the tracker's Adopt offer (stageTrackerTakeover), the adoption pill and the presenceadopt_atprojection. The clock runs only while the nudged head is unchanged β a pushing clanker is never adopted.cappedSince).MarkNudged:mode=queuedno longer counts as online.trigger=automatic:<reason>/operator-forced/operator-requested.adoption.auto_adopt_at/auto_due,takeover.auto_adopt_at; pill textβ¦ β hive adopts it in 3m unless a new head lands/β¦ β hive adopts it on the next sweep;fork-not-editableβ "fork not editable by hive". Adopt now stays as the manual override.labels-and-control-signals.md; changelog fragment.Tests
TestAutoAdoptionTriggerMatrix(automerge harness): conflicting / changes-requested / optional-check-failing / required-check-failing / fork-not-editable Γ online / offline / acknowledged Γ head moved / not.TestAutoAdoptionExampleRows: the π± refactor: split tracker words sourceΒ #15565/π± refactor: split stage tracker UI testsΒ #15566/π fix: select latest merged issue closerΒ #15609 clocks, heartbeat cap, head-moved reset, trigger strings.TestStageTrackerAutoAdoptionExampleCaptions(dashboard): the four live captions at 13m and at the due time.go test ./pkg/github/automerge/green;go test ./pkg/dashboard/ -run 'StageTracker|Adopt|Takeover|Presence|Delegated|Reroute|Tracker'green;go build ./...andgo vetclean.