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
1 change: 1 addition & 0 deletions changelog.d/changed-ci-failure-nudge-cooldown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Contributor nudge: CI-failure nudges are keyed on the failing-check set, not the lane's reason prefix — the same set on a new head or a check joining the set on the same head edits the PR's one `hive:contributor-nudge` comment (no relay re-dispatch for the same head), and a changed set within `governor.labels.stage.contributor_nudge.ci_failure_cooldown` (default 6h) folds into it instead of counting as a fresh nudge. The ledger persists in the stage-label store across restarts.
1 change: 1 addition & 0 deletions src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func stageLabelPolicyFunc(cfg *config.Config) func() automerge.StageLabelPolicy
StalledRequireQuiet: stage.Stalled.IsRequireQuiet(),
ContributorNudge: stage.ContributorNudge.IsEnabled(),
RenudgeInterval: nudgeRepeatAfter(cfg),
CIFailureCooldown: stage.ContributorNudge.EffectiveCIFailureCooldown(),
Adoption: stage.Adoption.IsEnabled(),
GraceOnline: stage.EffectiveContributorGraceOnline(),
GraceOffline: stage.EffectiveContributorGraceOffline(),
Expand Down
10 changes: 10 additions & 0 deletions src/docs/labels-and-control-signals/stage-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,16 @@ When a contributor-agent PR goes red the hive does not just relabel it (a human-
agent get interrupted?".
`governor.labels.stage.contributor_nudge.enabled: false` turns the
comment and the relay task off; the stage label still moves.
Failing checks are one class whatever the lane's prefix
(`check-failing`, `required-check-failing`, `optional-check-failing`),
keyed on the failing-check set (hivecommons/hive#17328): the marker adds
`checks=<digest> attempt=<n>`, the same set red on another head or a
check joining the set on the same head edits the comment (the relay is
not re-dispatched for the same head), and a *changed* set on a new head
within `governor.labels.stage.contributor_nudge.ci_failure_cooldown`
(default 6h) is folded into the comment too; after the cooldown it
counts as a fresh nudge. The ledger lives in the stage-label store, so
a restart does not re-nudge.
2. Relay contributors (the author has a contributor profile and a live relay
connection) also receive the diagnosis in their relay session as a
`fix-pr` task with `priority: interrupt`. Presence = a relay heartbeat
Expand Down
1 change: 1 addition & 0 deletions src/docs/operator-reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ advanced into the merge path.
| `auto_merge.max_merges` | `3` (`DefaultAutoMergeSweepMaxMerges`) when 0/unset | Caps merges per sweep pass. |
| `auto_merge.min_head_age` | `3m` | Minimum PR head age before automerge trusts an unknown required-check set. A fresh head pushed more recently than this waits with `pending: head pushed ... ago (< min_head_age)` unless `auto_merge.required_checks` is declared and every required check is complete and successful. Head age is measured from the head commit's committer date (never earlier than the PR's creation), not the PR's `updated_at`, so label and comment activity — including the hive's own — does not restart it. When GitHub's head time is ahead of the host clock (clock skew), age is measured from when the hive first observed the head instead, so the hold lasts one window and then clears (`pending: head time ahead of host clock; head first seen ... ago (< min_head_age)`). |
| `auto_merge.nudge_repeat_after` | `72h` | How long a contributor nudge's condition must persist before the hive nudges once more. Nudges are one comment per PR and reason class, edited in place for a new head or changed reason; after this interval with the same condition the comment is re-posted once (cap 2 per reason), then never again. `governor.labels.stage.contributor_nudge.renudge_interval`, when set, overrides it. |
| `governor.labels.stage.contributor_nudge.ci_failure_cooldown` | `6h` | CI-failure nudges are keyed on the failing-check set: the same set red on a new head, or a check joining the set on the same head, edits the PR's one nudge comment. A *different* set on a new head inside this window is folded into that comment too (count unchanged); after it the hive counts a fresh nudge. |
| `auto_merge.required_checks` | unset | Default operator-declared status-check contexts / check-run names (e.g. `["build-gate"]`) that the sweep's green gate requires on repos without a per-repo override. See below. |
| `auto_merge.repos.<repo>.required_checks` | inherits default | Per-repo override for heterogeneous hives. `<repo>` may be the bare name from `project.repos` or `owner/repo`; an explicit empty list declares that GitHub has no required contexts, while Hive still requires positive CI evidence from at least one real successful check-run before merge. |
| `auto_merge.allow_unprotected_base` | deprecated no-op | Accepted for compatibility only. [`hive-merge`](../hive-merge.md) no longer refuses solely because a base branch has no GitHub branch protection; it may merge into any branch the App can write after positive CI evidence. |
Expand Down
1 change: 1 addition & 0 deletions src/hive.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ governor:
# contributor_nudge: # stage/072: one @-mention comment per head + relay fix-pr interrupt (#12436)
# enabled: true
# renudge_interval: 24h # second (and last) nudge; default = the stage dwell
# ci_failure_cooldown: 6h # a new head red on a different check set inside this window folds into the one nudge comment (#17328)
# presence_window: 15m # relay heartbeat this fresh = contributor online → relay interrupt, else comment only
# contributor_grace_online: 2h # nudge unanswered this long (online author) → stage/074 adoption
# contributor_grace_offline: 15m # same for offline / external authors (comment-only nudge)
Expand Down
14 changes: 14 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,20 @@ type ContributorNudgeConfig struct {
// more (the documented cap is 2 nudges per PR and reason class). Unset
// defers to auto_merge.nudge_repeat_after (default 72h).
RenudgeInterval string `yaml:"renudge_interval,omitempty"`
// CIFailureCooldown is how long after a CI-failure nudge a changed
// failing-check set on a new head is folded into the PR's one nudge
// comment instead of counting as a fresh nudge
// (hivecommons/hive#17328). Default DefaultContributorNudgeCIFailureCooldown (6h).
CIFailureCooldown string `yaml:"ci_failure_cooldown,omitempty"`
}

// DefaultContributorNudgeCIFailureCooldown is
// governor.labels.stage.contributor_nudge.ci_failure_cooldown's default.
const DefaultContributorNudgeCIFailureCooldown = 6 * time.Hour

// EffectiveCIFailureCooldown parses CIFailureCooldown with the 6h default.
func (c ContributorNudgeConfig) EffectiveCIFailureCooldown() time.Duration {
return parseDurationOr(c.CIFailureCooldown, DefaultContributorNudgeCIFailureCooldown)
}

// IsEnabled reports whether the contributor nudge runs (default on).
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/config/testdata/agent_runtime_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
"Dwell": null,
"ContributorNudge": {
"Enabled": null,
"RenudgeInterval": ""
"RenudgeInterval": "",
"CIFailureCooldown": ""
},
"PresenceWindow": "",
"ContributorGraceOnline": "",
Expand Down
26 changes: 19 additions & 7 deletions src/pkg/dashboard/api_governor.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ func (s *Server) handleGovernorConfigGet(w http.ResponseWriter, r *http.Request)
"stageNudgeRenudge": cfg.Governor.Labels.Stage.ContributorNudge.RenudgeInterval,
// auto_merge.nudge_repeat_after (hivecommons/hive#17067): the
// same-reason re-nudge window the legacy renudge_interval defers to.
"nudgeRepeatAfter": cfg.AutoMerge.NudgeRepeatAfter,
"stagePresenceWindow": cfg.Governor.Labels.Stage.PresenceWindow,
"nudgeRepeatAfter": cfg.AutoMerge.NudgeRepeatAfter,
// governor.labels.stage.contributor_nudge.ci_failure_cooldown
// (hivecommons/hive#17328): the fold window for a changed
// failing-check set.
"stageNudgeCICooldown": cfg.Governor.Labels.Stage.ContributorNudge.CIFailureCooldown,
"stagePresenceWindow": cfg.Governor.Labels.Stage.PresenceWindow,
// governor.labels.stage.adoption.enabled / contributor_grace_*: the
// stage-074 adoption of red contributor PRs.
"stageAdoptionEnabled": cfg.Governor.Labels.Stage.Adoption.IsEnabled(),
Expand Down Expand Up @@ -815,6 +819,10 @@ func (s *Server) handleGovernorLabels(w http.ResponseWriter, r *http.Request) {
// NudgeRepeatAfter is auto_merge.nudge_repeat_after
// (hivecommons/hive#17067); a Go duration, empty restores 72h.
NudgeRepeatAfter *string `json:"nudge_repeat_after"`
// StageNudgeCICooldown is
// governor.labels.stage.contributor_nudge.ci_failure_cooldown
// (hivecommons/hive#17328); a Go duration, empty restores 6h.
StageNudgeCICooldown *string `json:"stage_nudge_ci_failure_cooldown"`
// Stage-074 adoption: governor.labels.stage.adoption.enabled and
// governor.labels.stage.contributor_grace_online / _offline.
StageAdoptionEnabled *bool `json:"stage_adoption_enabled"`
Expand Down Expand Up @@ -922,11 +930,12 @@ func (s *Server) handleGovernorLabels(w http.ResponseWriter, r *http.Request) {
}
}
for name, v := range map[string]*string{
"stage_nudge_renudge_interval": body.StageNudgeRenudge,
"nudge_repeat_after": body.NudgeRepeatAfter,
"stage_presence_window": body.StagePresenceWindow,
"stage_grace_online": body.StageGraceOnline,
"stage_grace_offline": body.StageGraceOffline,
"stage_nudge_renudge_interval": body.StageNudgeRenudge,
"nudge_repeat_after": body.NudgeRepeatAfter,
"stage_nudge_ci_failure_cooldown": body.StageNudgeCICooldown,
"stage_presence_window": body.StagePresenceWindow,
"stage_grace_online": body.StageGraceOnline,
"stage_grace_offline": body.StageGraceOffline,
} {
if v == nil || strings.TrimSpace(*v) == "" {
continue
Expand Down Expand Up @@ -1037,6 +1046,9 @@ func (s *Server) handleGovernorLabels(w http.ResponseWriter, r *http.Request) {
if body.NudgeRepeatAfter != nil {
s.deps.Config.AutoMerge.NudgeRepeatAfter = strings.TrimSpace(*body.NudgeRepeatAfter)
}
if body.StageNudgeCICooldown != nil {
s.deps.Config.Governor.Labels.Stage.ContributorNudge.CIFailureCooldown = strings.TrimSpace(*body.StageNudgeCICooldown)
}
if body.StagePresenceWindow != nil {
s.deps.Config.Governor.Labels.Stage.PresenceWindow = strings.TrimSpace(*body.StagePresenceWindow)
}
Expand Down
35 changes: 35 additions & 0 deletions src/pkg/dashboard/nudge_repeat_after_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,38 @@ func TestHandleGovernorLabels_NudgeRepeatAfterRoundTrip(t *testing.T) {
t.Fatalf("empty must clear the override, got %q", got)
}
}

// governor.labels.stage.contributor_nudge.ci_failure_cooldown
// (hivecommons/hive#17328) sits beside the nudge intervals on the Labels tab.
func TestHandleGovernorLabels_CIFailureCooldownRoundTrip(t *testing.T) {
srv := newFullServer(t)
w := httptest.NewRecorder()
srv.handleGovernorLabels(w, ownerPUT(t, "/api/config/governor/labels", `{"stage_nudge_ci_failure_cooldown":" 2h "}`))
if w.Code != http.StatusOK {
t.Fatalf("code = %d, body = %s", w.Code, w.Body.String())
}
if got := srv.deps.Config.Governor.Labels.Stage.ContributorNudge.CIFailureCooldown; got != "2h" {
t.Fatalf("ci_failure_cooldown = %q, want trimmed 2h", got)
}
if got := decodeGovernorConfigGet(t, srv)["stageNudgeCICooldown"]; got != "2h" {
t.Fatalf("GET stageNudgeCICooldown = %v, want 2h", got)
}

w = httptest.NewRecorder()
srv.handleGovernorLabels(w, ownerPUT(t, "/api/config/governor/labels", `{"stage_nudge_ci_failure_cooldown":"-1h"}`))
if w.Code != http.StatusBadRequest {
t.Fatalf("negative duration: code = %d, want 400; body = %s", w.Code, w.Body.String())
}
if got := srv.deps.Config.Governor.Labels.Stage.ContributorNudge.CIFailureCooldown; got != "2h" {
t.Fatalf("rejected save mutated ci_failure_cooldown to %q", got)
}

w = httptest.NewRecorder()
srv.handleGovernorLabels(w, ownerPUT(t, "/api/config/governor/labels", `{"stage_nudge_ci_failure_cooldown":""}`))
if w.Code != http.StatusOK {
t.Fatalf("clear: code = %d, body = %s", w.Code, w.Body.String())
}
if got := srv.deps.Config.Governor.Labels.Stage.ContributorNudge.CIFailureCooldown; got != "" {
t.Fatalf("empty must restore the default, got %q", got)
}
}
8 changes: 8 additions & 0 deletions src/pkg/dashboard/static-src/js/config-governor.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,9 @@
const nudgeRepeatAfter = (_configState.dirty.labels && _configState.dirty.labels.nudge_repeat_after !== undefined)
? _configState.dirty.labels.nudge_repeat_after
: (_configState.data.nudgeRepeatAfter || '');
const stageNudgeCICooldown = (_configState.dirty.labels && _configState.dirty.labels.stage_nudge_ci_failure_cooldown !== undefined)
? _configState.dirty.labels.stage_nudge_ci_failure_cooldown
: (_configState.data.stageNudgeCICooldown || '');
const stagePresenceWindow = (_configState.dirty.labels && _configState.dirty.labels.stage_presence_window !== undefined)
? _configState.dirty.labels.stage_presence_window
: (_configState.data.stagePresenceWindow || '');
Expand Down Expand Up @@ -788,6 +791,11 @@
<input type="text" id="cfg-nudge-repeat-after" value="${esc(nudgeRepeatAfter)}" placeholder="72h" data-change-action="markDirty" data-arg0="labels" data-arg1="nudge_repeat_after" data-arg-types="s,s,w">
<div class="config-help">How long a contributor PR must stay red for the same reason before its one <code>hive:contributor-nudge</code> comment is rewritten a second (and last) time; empty = 72h.</div>
</div>
<div class="config-field">
<label for="cfg-stage-nudge-ci-cooldown">CI-failure nudge cooldown ${yamlHint('governor.labels.stage.contributor_nudge.ci_failure_cooldown')}</label>
<input type="text" id="cfg-stage-nudge-ci-cooldown" value="${esc(stageNudgeCICooldown)}" placeholder="6h" data-change-action="markDirty" data-arg0="labels" data-arg1="stage_nudge_ci_failure_cooldown" data-arg-types="s,s,w">
<div class="config-help">After a CI-failure nudge, a new head failing a different set of checks within this window is folded into the PR's existing <code>hive:contributor-nudge</code> comment instead of counting as a fresh nudge; empty = 6h.</div>
</div>
<div class="config-field">
<label for="cfg-stage-presence-window">Contributor presence window ${yamlHint('governor.labels.stage.presence_window')}</label>
<input type="text" id="cfg-stage-presence-window" value="${esc(stagePresenceWindow)}" placeholder="15m" data-change-action="markDirty" data-arg0="labels" data-arg1="stage_presence_window" data-arg-types="s,s,w">
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/static-src/js/config-state.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading