diff --git a/changelog.d/changed-automerge-require-current-base-default.md b/changelog.d/changed-automerge-require-current-base-default.md new file mode 100644 index 0000000000..0ff13a8c00 --- /dev/null +++ b/changelog.d/changed-automerge-require-current-base-default.md @@ -0,0 +1 @@ +- **Breaking (merge behaviour):** the auto-merge current-base gate (`auto_merge.require_current_base`) is now on for every repository by default. A green head whose base has moved is brought up to date with GitHub update-branch and merges once CI is green on the new head; a stale-green merge (#15236) had broken `v5` for every open PR for 20 minutes. Opt a repo out with `auto_merge.skip_current_base: [owner/repo]`, or set `auto_merge.require_current_base_default: false` to return to opt-in only. Repos listed explicitly in `require_current_base` are strict; repos gated only by the default merge a head the App cannot update (fork without maintainer edits, branch protection) as tested, with one WARN per PR ([#15335](https://github.com/hivecommons/hive/issues/15335)). diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index 87da7ae2bd..a24e6f37f1 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -2570,6 +2570,9 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) { // a reload of auto_merge.human_merge_paths applies without a restart. autoMergeOpts.HumanMergePaths = func(repo string) []string { return humanMergePathsFor(b.cfg, repo) } autoMergeOpts.RequireCurrentBase = func(repo string) bool { return b.cfg != nil && b.cfg.AutoMerge.RequireCurrentBaseFor(repo) } + autoMergeOpts.RequireCurrentBaseStrict = func(repo string) bool { + return b.cfg != nil && b.cfg.AutoMerge.RequireCurrentBaseStrictFor(repo) + } autoMergeOpts.MergeForwardTrustedHuman = func(repo string) bool { return b.cfg != nil && b.cfg.AutoMerge.MergeForwardTrustedHumanFor(repo) } @@ -9452,6 +9455,7 @@ func runAutoMergeSweepIfDue(ctx context.Context, ghClient *github.Client, cfg *c opts.RepoOnGitHub = func(repo string) bool { return cfg.RepoOnGitHub(repo) } opts.HumanMergePaths = func(repo string) []string { return humanMergePathsFor(cfg, repo) } opts.RequireCurrentBase = func(repo string) bool { return cfg.AutoMerge.RequireCurrentBaseFor(repo) } + opts.RequireCurrentBaseStrict = func(repo string) bool { return cfg.AutoMerge.RequireCurrentBaseStrictFor(repo) } opts.MergeForwardTrustedHuman = func(repo string) bool { return cfg.AutoMerge.MergeForwardTrustedHumanFor(repo) } opts.MergeTrain = func() automerge.MergeTrainPolicy { return automerge.MergeTrainPolicy{Enabled: cfg.AutoMerge.MergeTrain.IsEnabled(), MaxRebaseAttempts: cfg.AutoMerge.MergeTrain.EffectiveMaxRebaseAttempts()} diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index d4c7758a47..edd7112045 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -430,7 +430,9 @@ advanced into the merge path. | `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. | | `auto_merge.no_ci_ok` | unset (refuse) | **Merge-request watcher key, not a sweep key.** Per-repo opt-in that downgrades only the "unverified" CI verdict (zero statuses, check runs, and workflow runs) to green, for adopted repos with no CI by design. Red and pending verdicts are never downgraded (#6281). See [hive-merge.md](hive-merge.md). | | `auto_merge.human_merge_paths` | unset | Per-repo map of `owner/repo` to glob patterns (same syntax as `intent.guardrail_path_patterns`) for paths a person must merge, e.g. `Danathar/goodreads-mcp: [".claude/settings.json", ".claude/hooks/**"]`. Every App merge path honors it: the automerge sweep lanes (App self-merge, trusted-author, label-queued) and the agent merge-request relay refuse a PR that touches a listed path, add `hold`, and post one `` comment naming the path(s); a person must merge it. If the changed-file list cannot be fetched completely for a configured repo, the merge is withheld (#11038, #11039). | -| `auto_merge.require_current_base` | unset (off) | Repo list (`owner/repo`) whose App self-merge, trusted-author and contributor lanes only merge a head that contains the current base tip. A green head tested against an older base is updated with GitHub update-branch (a merge commit; no author commit is rewritten) and merges once CI is green on the new head, so a semantic conflict with work merged since turns that PR red instead of breaking the base (#13634). Costs one compare call per merge candidate. | +| `auto_merge.require_current_base` | unset | Repo list (`owner/repo`) explicitly opted into the current-base gate in its **strict** form. The gate itself is on for every repo by default (see `require_current_base_default`): the App self-merge, trusted-author and contributor lanes only merge a head that contains the current base tip. A green head tested against an older base is updated with GitHub update-branch (a merge commit; no author commit is rewritten) and merges once CI is green on the new head, so a semantic conflict with work merged since turns that PR red instead of breaking the base ([#13634](https://github.com/hivecommons/hive/issues/13634), [#15335](https://github.com/hivecommons/hive/issues/15335)). Costs one compare call per merge candidate. Listing a repo here additionally makes it strict: a behind head the App cannot update (fork without maintainer edits, branch protection or a missing `contents: write`) is parked (`fork-not-editable` / `update-branch`) rather than merged as tested. | +| `auto_merge.require_current_base_default` | `true` | Fleet-wide default of the current-base gate for repos in neither `require_current_base` nor `skip_current_base`. On a default-gated repo a behind head the App cannot update merges as it was tested, with one WARN per PR (`automerge current-base gate: … merging as tested`), so fork-heavy repos are not parked wholesale. Set `false` to return to opt-in only. | +| `auto_merge.skip_current_base` | unset | Repo list (`owner/repo`) opted **out** of the current-base gate: a green head there merges even if the base has moved (the pre-#15335 behaviour). An explicit `require_current_base` entry wins over this list. | | `auto_merge.merge_forward_trusted_human` | unset (off) | Repo list (`owner/repo`) where a `role/trusted` + `author/human` PR on a same-repo branch that GitHub reports as conflicting (`dirty`) gets the base merged into its head as one App-authored, signed-off merge commit via the GitHub merges API (no human commit is rewritten), then merges once CI is green on the new head. A real conflict pushes nothing and posts one `` note naming the files both sides changed. Fork heads are never written. Attempted once per head (#13636). | | `auto_merge.merge_train.enabled` | `true` | Conflict-aware merge train in every automerge lane (hive, trusted-author, contributor) ([#15117](https://github.com/hivecommons/hive/issues/15117)). Each sweep groups the open approved / mergeable-pending PRs of one repo+base by overlapping changed files (`GET /pulls/{n}/files`, cached per head SHA) and lets ONE front per group merge — the clean-mergeable PR approved earliest — while the others wait at stage/080 with lane reason `merge-train:queued-behind#:/:…` (tracker pill "In merge queue · 3 of 4 · ~4m", never a human stage, never `needs-rebase` as a human flag). The moment the front merges, every sibling whose branch is merely `behind` gets `PUT /pulls/{n}/update-branch`; a `dirty` one is handed to the fixer's rebase-resolve episode (`requested_by: merge-train`, the shared two-attempt guard of [#15104](https://github.com/hivecommons/hive/pull/15104); the fixer router still requires a head the hive can push to, so a fork without maintainer edits stays on the plain `conflicting` path for a person). A head the lane last saw blocked on its own (red required check, terminal hold, permanent merge refusal) never fronts, and a group whose best member is blocked imposes no ordering (fail-open) — nobody waits behind a PR that is not moving. One INFO line `merge train` per order change, not per cycle. The queue carries one PR per issue: when two open PRs declare the same `Fixes #N`, the sweep keeps one (green first, then the earlier-opened) and holds the other with lane reason `merge-train:duplicate-of#:/0:0/0:` (tracker pill "Duplicate of #15402 · needs a pick"; *Let hive decide* supersedes, [#15395](https://github.com/hivecommons/hive/issues/15395)). `false` restores independent per-PR evaluation. | | `auto_merge.merge_train.max_rebase_attempts` | `2` | Loop guard: how many rebase-resolve requests the train makes for one PR behind one front. Past it the PR moves to stage/085 with the pill "Needs human decision · rebase failed twice" and the decision option "Rebase, then merge as maintainer". | diff --git a/src/pkg/config/automerge_current_base_test.go b/src/pkg/config/automerge_current_base_test.go index 2de625be78..2213fc69c4 100644 --- a/src/pkg/config/automerge_current_base_test.go +++ b/src/pkg/config/automerge_current_base_test.go @@ -3,18 +3,27 @@ package config import "testing" func TestRequireCurrentBaseFor(t *testing.T) { - cfg := AutoMergeConfig{RequireCurrentBase: []string{" HiveCommons/Hive ", ""}} + off := false + listed := AutoMergeConfig{RequireCurrentBase: []string{" HiveCommons/Hive ", ""}} + skipped := AutoMergeConfig{SkipCurrentBase: []string{"Acme/Legacy"}} + defaultOff := AutoMergeConfig{RequireCurrentBaseDefault: &off, RequireCurrentBase: []string{"hivecommons/hive"}} + both := AutoMergeConfig{RequireCurrentBase: []string{"acme/widget"}, SkipCurrentBase: []string{"acme/widget"}} tests := []struct { name string cfg AutoMergeConfig repo string want bool }{ - {"unset", AutoMergeConfig{}, "hivecommons/hive", false}, - {"not listed", cfg, "acme/widget", false}, - {"listed case-insensitive", cfg, "hivecommons/hive", true}, - {"listed with spaces", cfg, " HIVECOMMONS/HIVE ", true}, - {"empty repo", cfg, "", false}, + {"unset defaults on", AutoMergeConfig{}, "hivecommons/hive", true}, + {"unlisted repo defaults on", listed, "acme/widget", true}, + {"listed case-insensitive", listed, "hivecommons/hive", true}, + {"listed with spaces", listed, " HIVECOMMONS/HIVE ", true}, + {"empty repo", listed, "", false}, + {"skip list opts out", skipped, "acme/legacy", false}, + {"skip list leaves others on", skipped, "acme/widget", true}, + {"default false turns unlisted off", defaultOff, "acme/widget", false}, + {"default false keeps listed on", defaultOff, "hivecommons/hive", true}, + {"explicit list beats skip list", both, "acme/widget", true}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { @@ -24,3 +33,16 @@ func TestRequireCurrentBaseFor(t *testing.T) { }) } } + +func TestRequireCurrentBaseStrictFor(t *testing.T) { + cfg := AutoMergeConfig{RequireCurrentBase: []string{"HiveCommons/Hive"}} + if !cfg.RequireCurrentBaseStrictFor("hivecommons/hive") { + t.Fatal("listed repo must be strict") + } + if cfg.RequireCurrentBaseStrictFor("acme/widget") { + t.Fatal("default-gated repo must not be strict") + } + if (AutoMergeConfig{}).RequireCurrentBaseStrictFor("hivecommons/hive") { + t.Fatal("unset list must not make any repo strict") + } +} diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 91630dff79..9d18c528bf 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -8037,9 +8037,27 @@ type AutoMergeConfig struct { // A head that is green but was tested against an older base is updated // (GitHub update-branch, a merge commit) and merged once CI is green on // the new head, so a semantic conflict with anything merged since shows - // up as red CI instead of a broken base. Empty (the default) keeps the - // previous behavior: a green head merges even if the base has moved. + // up as red CI instead of a broken base. + // + // Since hivecommons/hive#15335 the gate is ON for every repo by default + // (RequireCurrentBaseDefault); this list is the STRICT form: a listed + // repo never falls back to merging an un-updated head, even when the App + // cannot update the branch (fork head without maintainer edits, branch + // protection or a missing contents:write). Repos covered only by the + // default merge the green head as tested in that case, with one WARN per + // PR, so a fork-heavy repo is not parked wholesale by the default. RequireCurrentBase []string `yaml:"require_current_base,omitempty" json:"require_current_base,omitempty"` + // RequireCurrentBaseDefault is the fleet-wide default for the gate above + // on repos that appear in neither RequireCurrentBase nor + // SkipCurrentBase. nil/unset means true (hivecommons/hive#15335: a + // stale-green merge broke v5 for every open PR for 20 minutes because the + // repo was not listed). `false` restores the opt-in-only behaviour. + RequireCurrentBaseDefault *bool `yaml:"require_current_base_default,omitempty" json:"require_current_base_default,omitempty"` + // SkipCurrentBase lists owner/repo names opted OUT of the current-base + // gate: a green head there merges even if the base has moved (the + // pre-#15335 behaviour). An explicit RequireCurrentBase entry wins over + // this list. + SkipCurrentBase []string `yaml:"skip_current_base,omitempty" json:"skip_current_base,omitempty"` // MergeForwardTrustedHuman lists owner/repo names where a role/trusted // author/human PR that GitHub reports as conflicting ("dirty") gets the // base merged into its same-repo head branch as a new App-authored, @@ -8488,9 +8506,31 @@ func (a AutoMergeConfig) HumanMergePathsFor(repo string) []string { return nil } -// RequireCurrentBaseFor reports whether repo (owner/repo, matched -// case-insensitively) is listed in auto_merge.require_current_base. +// RequireCurrentBaseFor reports whether the automerge lanes must see a head +// that contains the current base tip before merging into repo (owner/repo, +// matched case-insensitively). Resolution order: an explicit +// auto_merge.require_current_base entry (on, strict), then +// auto_merge.skip_current_base (off), then +// auto_merge.require_current_base_default (unset means on). func (a AutoMergeConfig) RequireCurrentBaseFor(repo string) bool { + key := strings.ToLower(strings.TrimSpace(repo)) + if key == "" { + return false + } + if repoListSet(a.RequireCurrentBase)[key] { + return true + } + if repoListSet(a.SkipCurrentBase)[key] { + return false + } + return a.RequireCurrentBaseDefault == nil || *a.RequireCurrentBaseDefault +} + +// RequireCurrentBaseStrictFor reports whether repo is explicitly listed in +// auto_merge.require_current_base. A strict repo never merges a head the App +// could not bring up to date; a repo gated only by the default falls back to +// merging the green head as tested when update-branch is unavailable. +func (a AutoMergeConfig) RequireCurrentBaseStrictFor(repo string) bool { return repoListSet(a.RequireCurrentBase)[strings.ToLower(strings.TrimSpace(repo))] } diff --git a/src/pkg/dashboard/settings_parity_allowlist.txt b/src/pkg/dashboard/settings_parity_allowlist.txt index c5d535e3dc..e3b119b023 100644 --- a/src/pkg/dashboard/settings_parity_allowlist.txt +++ b/src/pkg/dashboard/settings_parity_allowlist.txt @@ -161,7 +161,9 @@ auto_merge.merge_train.max_rebase_attempts # merge train rebase loop guard (#151 auto_merge.no_ci_ok[] # TODO #11854 auto_merge.repos..required_checks[] # TODO #11854 auto_merge.require_current_base[] # TODO #11854 +auto_merge.require_current_base_default # current-base gate fleet default (#15335); yaml-only auto_merge.required_checks[] # TODO #11854 +auto_merge.skip_current_base[] # current-base gate per-repo opt-out (#15335); yaml-only auto_merge.squash_only[] # merge-method policy; yaml-only auto_merge.trusted_authors.exclude_labels[] # TODO #11854 auto_merge.trusted_authors.repos[] # TODO #11854 diff --git a/src/pkg/github/automerge/automerge_current_base.go b/src/pkg/github/automerge/automerge_current_base.go index 627e233f76..9e2024608b 100644 --- a/src/pkg/github/automerge/automerge_current_base.go +++ b/src/pkg/github/automerge/automerge_current_base.go @@ -2,6 +2,9 @@ package automerge import ( "context" + "errors" + "fmt" + "net/http" "strings" gh "github.com/google/go-github/v72/github" @@ -16,6 +19,10 @@ const ( // currentBaseUpdateReason is the update-branch claim reason recorded when // a green head is refreshed because the base moved under it. currentBaseUpdateReason = "base-moved" + // currentBaseFallbackMessage is the one-per-PR WARN emitted when a repo + // gated only by auto_merge.require_current_base_default has a behind head + // the App cannot update, so the head merges as it was tested. + currentBaseFallbackMessage = "automerge current-base gate: head is behind the base but the branch cannot be updated; merging as tested (list the repo in auto_merge.require_current_base to park it instead)" ) func (c *Engine) requireCurrentBaseFor(repo string) bool { @@ -25,6 +32,51 @@ func (c *Engine) requireCurrentBaseFor(repo string) bool { return c.requireCurrentBase(repo) } +func (c *Engine) requireCurrentBaseStrictFor(repo string) bool { + if c == nil || c.requireCurrentBaseStrict == nil { + return false + } + return c.requireCurrentBaseStrict(repo) +} + +// currentBaseUpdateUnavailable reports whether an update-branch attempt +// failed because the App may not write the head at all — a fork head without +// maintainer edits, or a same-repo 403 (branch protection or a missing +// contents:write) — as opposed to a transient or conflict failure. Only +// these outcomes let a default-gated repo fall back to merging as tested; +// a conflict or an unknown error still stops the merge. +func currentBaseUpdateUnavailable(reason string, err error) bool { + if reason == autoMergeReasonForkNotEditable { + return true + } + var ghErr *gh.ErrorResponse + return err != nil && errors.As(err, &ghErr) && ghErr.Response != nil && ghErr.Response.StatusCode == http.StatusForbidden +} + +// warnCurrentBaseFallbackOnce logs, once per repo#pr, that the default gate +// is letting a behind head merge as tested because the App cannot update it. +// Later ticks for the same PR log at Debug so a parked PR does not repeat +// the line every sweep. +func (c *Engine) warnCurrentBaseFallbackOnce(displayRepo string, number int, reason string, err error) { + if c == nil { + return + } + key := fmt.Sprintf("%s#%d", strings.ToLower(displayRepo), number) + c.currentBaseFallbackWarnedMu.Lock() + if c.currentBaseFallbackWarned == nil || len(c.currentBaseFallbackWarned) > 4096 { + c.currentBaseFallbackWarned = map[string]struct{}{} + } + _, seen := c.currentBaseFallbackWarned[key] + c.currentBaseFallbackWarned[key] = struct{}{} + c.currentBaseFallbackWarnedMu.Unlock() + args := []any{"repo", displayRepo, "pr", number, "reason", reason, "error", err, "opt_in_key", "auto_merge.require_current_base"} + if seen { + c.debug(currentBaseFallbackMessage, args...) + return + } + c.warn(currentBaseFallbackMessage, args...) +} + // currentBaseGate enforces auto_merge.require_current_base // (hivecommons/hive#13634). GitHub only reports mergeable_state "behind" when // branch protection requires up-to-date branches, so a head that was green @@ -57,5 +109,13 @@ func (c *Engine) currentBaseGate(ctx context.Context, displayRepo, owner, repo s } c.info("automerge head is behind the current base; updating before merge", "repo", displayRepo, "pr", number, "base", baseBranch, "behind_by", cmp.GetBehindBy()) event, reason, err := c.updateBranchAndSkip(ctx, displayRepo, owner, repo, number, headSHA, currentBaseUpdateReason, fork) + if currentBaseUpdateUnavailable(reason, err) && !c.requireCurrentBaseStrictFor(owner+"/"+repo) { + // Default-on gate (#15335) on a head the App may not write: parking + // it would turn every non-editable fork PR fleet-wide into a stall + // a human has to clear, so keep the pre-gate behaviour for this PR + // and say so once. Strict (explicitly listed) repos still park. + c.warnCurrentBaseFallbackOnce(displayRepo, number, reason, err) + return AutoMergeSweepEvent{}, "", false, nil + } return event, reason, true, err } diff --git a/src/pkg/github/automerge/automerge_current_base_test.go b/src/pkg/github/automerge/automerge_current_base_test.go index 2b2ed39427..8edf2eb257 100644 --- a/src/pkg/github/automerge/automerge_current_base_test.go +++ b/src/pkg/github/automerge/automerge_current_base_test.go @@ -3,6 +3,7 @@ package automerge import ( "context" "encoding/json" + "log/slog" "net/http" "net/http/httptest" "strings" @@ -86,6 +87,67 @@ func TestCurrentBaseGate(t *testing.T) { } } +// TestCurrentBaseGateUpdateUnavailableFallback pins the default-on guard +// (hivecommons/hive#15335): when the App cannot update a behind head — a fork +// without maintainer edits, or a same-repo 403 from branch protection — a +// repo gated only by the default merges the head as tested and WARNs once +// per PR; a repo explicitly listed in auto_merge.require_current_base still +// parks it. +func TestCurrentBaseGateUpdateUnavailableFallback(t *testing.T) { + const head = "sha-head" + cases := []struct { + name string + fork bool + updateStatus int + updateBody string + strict bool + wantStop bool + wantReason string + wantWarns int + }{ + {name: "fork not editable falls back", fork: true, updateStatus: http.StatusForbidden, updateBody: `{"message":"Resource not accessible by integration"}`, wantWarns: 1}, + {name: "fork maintainer edits off falls back", fork: true, updateStatus: http.StatusUnprocessableEntity, updateBody: `{"message":"Update is not a fast forward; maintainer edits disabled"}`, wantWarns: 1}, + {name: "same-repo forbidden falls back", fork: false, updateStatus: http.StatusForbidden, updateBody: `{"message":"Resource not accessible by integration"}`, wantWarns: 1}, + {name: "strict repo still parks fork", fork: true, strict: true, updateStatus: http.StatusForbidden, updateBody: `{"message":"Resource not accessible by integration"}`, wantStop: true, wantReason: autoMergeReasonForkNotEditable}, + {name: "conflict never falls back", fork: false, updateStatus: http.StatusUnprocessableEntity, updateBody: `{"message":"merge conflict between base and head"}`, wantStop: true, wantReason: "conflicting"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch { + case r.Method == http.MethodGet && r.URL.Path == "/repos/acme/widget/compare/main..."+head: + _ = json.NewEncoder(w).Encode(map[string]any{"behind_by": 2, "ahead_by": 1}) + case r.Method == http.MethodPut && r.URL.Path == "/repos/acme/widget/pulls/7/update-branch": + w.WriteHeader(tc.updateStatus) + _, _ = w.Write([]byte(tc.updateBody)) + default: + t.Errorf("unexpected request %s %s", r.Method, r.URL.Path) + w.WriteHeader(http.StatusNotFound) + } + })) + defer srv.Close() + + var logs strings.Builder + c := newAutoMergeSweepClient(srv.URL) + c.logger = slog.New(slog.NewTextHandler(&logs, &slog.HandlerOptions{Level: slog.LevelWarn})) + c.requireCurrentBase = func(string) bool { return true } + c.requireCurrentBaseStrict = func(string) bool { return tc.strict } + for tick := 0; tick < 2; tick++ { + _, reason, stop, err := c.currentBaseGate(context.Background(), "acme/widget", "acme", "widget", 7, "main", head, true, "behind", tc.fork) + if err != nil { + t.Fatalf("tick %d: err = %v", tick, err) + } + if stop != tc.wantStop || reason != tc.wantReason { + t.Fatalf("tick %d: stop, reason = %v, %q; want %v, %q", tick, stop, reason, tc.wantStop, tc.wantReason) + } + } + if got := strings.Count(logs.String(), currentBaseFallbackMessage); got != tc.wantWarns { + t.Fatalf("fallback WARN lines over two ticks = %d, want %d (one per PR, not per sweep):\n%s", got, tc.wantWarns, logs.String()) + } + }) + } +} + func TestCurrentBaseGateNilEngine(t *testing.T) { var c *Engine if c.requireCurrentBaseFor("acme/widget") { diff --git a/src/pkg/github/automerge/automerge_sweep.go b/src/pkg/github/automerge/automerge_sweep.go index 945b3fc056..29adabaf61 100644 --- a/src/pkg/github/automerge/automerge_sweep.go +++ b/src/pkg/github/automerge/automerge_sweep.go @@ -91,9 +91,16 @@ type Options struct { // for an owner/repo. Every sweep lane refuses a PR touching one (#11038). // nil means no repo has any. HumanMergePaths func(repo string) []string - // RequireCurrentBase returns the live auto_merge.require_current_base - // switch for an owner/repo (hivecommons/hive#13634). nil means off. + // RequireCurrentBase returns the live current-base gate switch for an + // owner/repo (hivecommons/hive#13634, default on since #15335 via + // config.AutoMergeConfig.RequireCurrentBaseFor). nil means off. RequireCurrentBase func(repo string) bool + // RequireCurrentBaseStrict reports whether owner/repo is explicitly + // listed in auto_merge.require_current_base. A strict repo parks a head + // the App cannot update; a repo gated only by the default merges the + // green head as tested in that case, with one WARN per PR. nil means no + // repo is strict. + RequireCurrentBaseStrict func(repo string) bool // MergeForwardTrustedHuman returns the live // auto_merge.merge_forward_trusted_human membership for owner/repo // (hivecommons/hive#13636); nil means off. @@ -243,8 +250,12 @@ type Engine struct { humanMergePaths func(repo string) []string requireCurrentBase func(repo string) bool + requireCurrentBaseStrict func(repo string) bool mergeForwardTrustedHuman func(repo string) bool + currentBaseFallbackWarnedMu sync.Mutex + currentBaseFallbackWarned map[string]struct{} + selfAuthorizationHoldEnabled func(repo string) bool selfAuthorizationHoldReleaseLimit int repoAutoMergeEnabled func(repo string) bool @@ -347,6 +358,7 @@ func New(transport Transport, opts Options) *Engine { humanChangeRequests: opts.HumanChangeRequests, humanMergePaths: opts.HumanMergePaths, requireCurrentBase: opts.RequireCurrentBase, + requireCurrentBaseStrict: opts.RequireCurrentBaseStrict, mergeForwardTrustedHuman: opts.MergeForwardTrustedHuman, selfAuthorizationHoldEnabled: opts.SelfAuthorizationHoldEnabled, selfAuthorizationHoldReleaseLimit: opts.SelfAuthorizationHoldReleaseLimit,