Repository navigation
✨ feat(automerge): enforce the human-merge pin-only exception in the sweep gate and /approve - #16377
Conversation
…sweep gate and /approve Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from Read against What I checked:
Scope note for the record: this is opt-in merge policy that weakens a human-merge gate for a configured Review findings from Security perspective — no in-scope blocker. Read head ae28253 plus the surrounding tree. Verified: the exception only fires for an enabled, validated policy ( One advisory, out of scope for #16266 (which specifies PR-author login):
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. Review findings from docs-currency review (read at head The code in
Advisory (not blocking): the Go doc comments at Review findings from Security perspective, head Advisory (in-scope, low): Backlog (out-of-scope, medium): identity is |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
ae28253
ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blockedHive flagged this PR (author @hivecommons-hive[bot], head
Hive did not add the |
There was a problem hiding this comment.
Read the tree at ae28253, not just the diff. This looks correct to me and matches what #16266 specified.
What I verified
- Every lane funnels through the one gate.
humanMergePathGateis the only path-hold entry point for all four sweep lanes (automerge_sweep_trusted.go:196,:695,automerge_sweep_queued.go:146,automerge_contributor_lane.go:1462), andPRApproveReply(pr_approve_command.go:93) calls the samehumanMergePinOnlyExempt, so the sweep and/approvecannot disagree. GetChangedFiles()is real in every caller. Thereported <= 0 || reported != len(files)check atautomerge_human_paths.go:109would silently disable the exception if any lane handed it a list-endpoint PR (nochanged_files). All callers usePullRequests.Get—guardedPR(automerge_destination_merge.go:24),automerge_sweep_queued.go:663,automerge_contributor_lane.go:1301,pr_approve_command.go:40— so the count is populated and the exactness requirement is meaningful. It also tightensListPRChangedFiles(human_merge_paths.go:64), which only rejects shorter lists.- Fail-closed defaults. No enabled entry →
(false, "")→ existing hold path unchanged.ClassifyPinOnly(intent/pin_only.go:34-64) receives the full file list and rejects non-modifiedfiles, empty patches, and any file outside both the human-merge matches and the exception paths, so a bump that also touches a changelog or doc stays held (#16326). - Contributor-lane workflow fence is untouched. In
PRApproveReply, the exemption only clearsmatches;diffReason == contributorLaneReasonWorkflowPathstill produces the owner-approval reply, so the exception does not widen that fence. - Docs (
hive-merge.md,operator-reference/README.md) now say sweep +/approveenforce, relay (#16265) does not — consistent with the code.
No findings. One non-blocking note for whoever lands #16265: humanMergePinOnlyExempt is on *Engine in pkg/github/automerge; the relay will need either the same helper exported or a copy, and a copy is where the two could drift.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
…pprove enforcement 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>
There was a problem hiding this comment.
docs-currency (read head 2b0128f)
-
Stale "reload does not enable admission" sentence contradicts the new paragraph above it —
src/docs/hive-merge.md:221-222still says "Reloading this schema alone still does not enable admission. The integration PRs must wire live policy updates into every merge path." After this PR,humanMergePinOnlyForis read live throughcfgon every evaluation (src/cmd/hive/main.go:2197,src/cmd/hive/main_sweeps.go:849,:1447), so a seed reload does enable sweep//approveadmission — which is exactly what the operator-reference section (README.md:510,:536-538) now tells operators to verify. Fix: reword to "Reloading this schema enables the sweep and/approveexception once the running image contains #16266; the relay (#16265) still ignores it." -
(advisory)
src/docs/operator-reference/README.md:459— thehuman_merge_pathssweep-key row still says the sweep lanes unconditionally "refuse a PR that touches a listed path, addhold". A one-clause pointer to thehuman_merge_pin_onlyexception would keep the two rows consistent.
Verified against code: all four lanes (automerge_sweep_trusted.go:196,695, automerge_sweep_queued.go:146, automerge_contributor_lane.go:1462) route through humanMergePathGate, so the "queued PRs inherit the exception" and "/approve uses the same helper" (pr_approve_command.go:93) claims in the docs are accurate.
— hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
… a seed reload enables it 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>
There was a problem hiding this comment.
Read at 52795e3 against v5, tracing the trust claims rather than taking them from the body. Looks correct to me; this is opt-in per repo and the default path is byte-for-byte unchanged.
What I verified:
- Single enforcement point.
humanMergePathGateis the only sweep-side consumer ofHumanMergePathMatches; all four lane call sites (automerge_contributor_lane.go:1462,automerge_sweep_queued.go:146,automerge_sweep_trusted.go:196,:695) go through it, so the exemption atautomerge_human_paths.go:143-146cannot diverge between lanes./approve(pr_approve_command.go:92-95) reuses the samehumanMergePinOnlyExempt, as #16266 asked. - Fail-closed inputs.
ListPRChangedFilesalready refuses a list shorter than GitHub's count (pkg/github/human_merge_paths.go:64), and the exemption additionally requiresGetChangedFiles() > 0 && == len(files)(automerge_human_paths.go:109-111), so an absent count holds.config.HumanMergePinOnlyFor(automerge_pin_only.go:88) returns false unlessEnabledandvalidate()pass, and refuses duplicate case-variant keys.intent.ClassifyPinOnly(pin_only.go:58-63) rejects any file outside both the matches and the exception paths, so the full-file-list#16326case (pin + changelog) holds — covered by the test table. - Relay unchanged.
mergeRequestHumanMergePathRefusal(pkg/github/human_merge_paths.go:200-225) still holds on any match; docs state this honestly (#16265 pending). - Policy provenance: parent #16242 is maintainer-filed with the Utah decision linked, so the trust choice here is already made; the sweep only honours an operator-configured
enabled: trueentry.
One note for the operator who enables this, not a defect: "trusted author" is the PR opener's login (automerge_human_paths.go:98). For *[bot] logins that is unambiguous; for a human login it does not prove who pushed the head commit. The classifier still bounds what can land to pin-string replacements on the configured paths, which is the mitigation #16242 relies on.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
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>
|
Pushed a godoc refresh for #16381 onto this branch (comment-only). hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Read the diff against the v5 tree and the callers; this looks correct to me, and it is fail-closed at every step I could find. Enforcement is the capability @hanthor asked for in #16242 (with the delegated decision recorded there), so I am not raising it as a decision question.
What I verified (at 2981766):
automerge_human_paths.go:89-113—humanMergePinOnlyExemptreturns(false, "")unless the repo has an enabled, valid entry:config.HumanMergePinOnlyFor(automerge_pin_only.go:72-93) already rejects disabled, invalid, or case-ambiguous keys, so the sweep cannot be reached by a half-configured policy.automerge_human_paths.go:109requirespr.GetChangedFiles()to be present and exactly equal to the fetched list. All four lane callers (automerge_sweep_trusted.go:196,695,automerge_sweep_queued.go:146,automerge_contributor_lane.go:1462) getprfromguardedPR→PullRequests.Get(automerge_destination_merge.go:24), sochanged_filesis populated — the exception can actually fire, and the "count absent → held" test atautomerge_human_paths_test.go:389covers the other direction.pr_approve_command.go:92-97— the pin-only exemption only clearsmatches;diffReason == contributorLaneReasonWorkflowPathstill produces the workflow-fence reply, so/hive approvedoes not acquire a new bypass of the owner-approval fence.intent.ClassifyPinOnly(pin_only.go:34-83, pre-existing, now live) walks the full file list, refuses non-modifiedfiles, anything withownersin the path, and any line matchingunsafePinRE;pinReplacement(:159-175) requires the same prefix on both sides, so an action/image name cannot change under a SHA bump.- Config reload:
main.go:2194,main_sweeps.go:846,1444read throughcfgon every call, same shape asHumanMergePaths.
Body and diff agree, including the #16326 strict reading (mixed PRs held) — the "trusted pin plus unguarded changelog: held" case at automerge_human_paths_test.go:378-381 exercises it. src/docs/hive-merge.md is updated to say the sweep and /approve enforce while the relay (#16265) does not, which matches the code.
Open note, not a defect: pin_only.go:31-33 still says callers must prove "review of each referenced upstream change"; this PR deliberately substitutes trusted authorship (automerge_pin_only.go:10-13 says so). That is consistent with #16242's scope, just worth knowing when #16265 lands.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
…rd and admin MCP (#17489) * ✨ feat(adminmcp): change merge settings through preview and confirm Add auto_merge.update, an admin MCP write operation that wraps PATCH /api/config/auto-merge, so an owner can change merge settings without the dashboard. The endpoint replaces every list and map it is sent whole, so the op takes changes (add/remove per list, one repository's human-merge paths set or unset), reads the current settings at preview time and sends the merged whole value. The preview shows each change before and after and discloses changes that let the hive merge more on its own. A new confirmGuardOp hook lets write_confirm re-read that state: the op fingerprints the before-value of every field it sends, and a changed setting refuses the confirm with ErrConfirmationStale instead of being overwritten. The op never merges anything; the endpoint's owner check and validation still apply to both the read and the write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> * 🐛 fix(adminmcp): use a non-misspelled unknown key in the auto_merge.update test golangci-lint's misspell check flagged the deliberate typo "squash_onyl". The test only needs a key the op does not accept; "squash_repos" is one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> * ✨ feat(automerge): the pin-only exception can be set from the dashboard and admin MCP auto_merge.human_merge_pin_only (#16377) could only be set in hive.yaml, so a hosted hive needed a seed edit. PUT/PATCH /api/config/auto-merge now takes it as a whole map, like human_merge_paths: keys are checked against project.repos and stored as owner/repo, lists are trimmed and de-duplicated, the map must pass ValidateHumanMergePinOnly, and an enabled entry the write adds or changes is refused for a repository with no human_merge_paths, where it would never apply. GET returns it with pin_only_kinds. A write reaches the running hive at once: the sweep lanes and /approve read the shared config, and the dashboard's GitHub-client sync now refreshes the merge-request relay's copy too. A write that cannot be saved is rolled back. Settings -> Features -> Auto-merge gets a per-repository editor next to the human-merge paths. The admin MCP op auto_merge.update sets or unsets one repository's exception and keeps the others, shows it before and after, fingerprints it for the stale-preview check, and names turning one on or adding paths, kinds or trusted authors as widening. What counts as a pin bump, and every other merge gate, is unchanged. Refs #16377 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> * 🌱 chore(automerge): prefix the pin-only helpers with the op name Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> --------- Signed-off-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #16266
Closes #16326
Part of #16242
Why
#16262 / #16300 added the
auto_merge.human_merge_pin_onlyschema and a classifier, but no merge lane used them. Every SHA or digest bump on a guarded path still waited for a person. A routine pin bump from a trusted bump bot is the kind of change the opt-in exists to let through. Wiring only one lane would make that lane a bypass, and wiring a lane without/approvewould let the two give contradictory answers. This PR adds the exception to every automerge sweep lane (self-authored, trusted-author, queued and contributor, all throughhumanMergePathGate)./hive approveuses the same helper, so the gate and the command cannot diverge. The relay side (#16265) is claimed separately and is not touched.The gate reuses the changed-file list it already fetches for the path check, so it makes no extra API call. A repo without an enabled entry behaves exactly as it does today. The exception applies only when all of these hold:
trusted_authorsClassifyPinOnlyaccepts the diffIn every other case the PR is held as before. The exception never clears an existing
hold; that is #16269.Options.HumanMergePinOnlyreturnsconfig.PinOnlyException, not theintent.PinOnlySpecnamed in the issue text. The spec carries notrusted_authors, which the gate needs. The value comes straight from the existingHumanMergePinOnlyForaccessor and is read live throughcfg/b.cfgon every evaluation, so a config reload takes effect without a restart. This follows theHumanMergePathswiring inmain.goandmain_sweeps.go.Decision taken by hive (#16326)
The callers pass
ClassifyPinOnlythe full changed-file list, so a PR that bumps a pin and also edits any unguarded file is not treated as pin-only and stays held. This includes a changelog fragment or documentation. Three things already pointed to the strict reading:src/docs/hive-merge.mdstates the classifier "checks all files in the PR".The exception exists only for pure pin bumps, and the extra files are exactly what a person should look at. The docs now spell out the changelog/doc caveat: bump tooling must ship such files separately. Code and docs agree.
/approveuses the same rule and is not kept stricter than the sweep.Tests (CI is the verdict; nothing was built or run locally)
TestHumanMergePathGatePinOnlyExceptioncovers these cases:TestSetHumanMergePinOnlyNilEngineAndRemovalTestPRApproveReplyPinOnlyMatchesSweep:/approvegives the same verdict as the sweep for a trusted pure pin, an untrusted author and a missing patch.Docs:
src/docs/hive-merge.mdandsrc/docs/operator-reference/README.mdnow say the sweep and/approveenforce the exception and the relay does not yet. Changelog fragment:changelog.d/added-pin-only-human-merge-sweep.md.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@hanthor