Repository navigation
✨ feat(automerge): the pin-only exception can be set from the dashboard and admin MCP - #17489
Conversation
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>
…pdate 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>
…rd and admin MCP auto_merge.human_merge_pin_only (hivecommons#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 hivecommons#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>
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>
…-setting Signed-off-by: Danathar <Danathar@users.noreply.github.com> # Conflicts: # changelog.d/added-adminmcp-auto-merge-update.md # src/docs/admin-mcp.md # src/docs/design/admin-mcp.md # src/pkg/adminmcp/tools_automerge_ops.go # src/pkg/adminmcp/tools_automerge_ops_test.go
|
[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. Evidence bundle `#1748909bb1f5` sha256:c4d87f53782616b7fad525355c3b41a175f56de5443258a24e66470d248229ec — download from the dashboard or `hivectl review evidence #17489`.Review findings from Read the diff against the What I verified:
One cosmetic difference, not a defect: the endpoint drops a Only Review findings from Correctness review (head
|
There was a problem hiding this comment.
Style/maintainability pass at 09bb1f5. No in-scope blocker; two advisory notes with fixes.
1. MCP "unchanged" detection depends on struct field order matching sorted JSON keys — src/pkg/adminmcp/tools_automerge_ops.go:688-697 documents that autoMergePinOnlyEntry's fields are ordered enabled, kinds, paths, trusted_authors so that compactJSON(before) == compactJSON(after) at tools_automerge_ops.go:409 (hive-reported map[string]any vs. the built map[string]autoMergePinOnlyEntry) compares equal. That works today, but a field reorder, a rename, or a hive that reports one extra key per entry silently turns "nothing would change" into a spurious change. Normalising both sides through autoMergePinOnlyValue removes the invariant:
--- a/src/pkg/adminmcp/tools_automerge_ops.go
+++ b/src/pkg/adminmcp/tools_automerge_ops.go
@@ func planAutoMergeUpdate(
- if compactJSON(before) == compactJSON(after) {
+ if f.same(before, after) {
plan.unchanged = append(plan.unchanged, f.key)
continue
}
@@
+// same reports whether before and after encode the same setting. Pin-only
+// entries are normalised first so the comparison does not depend on
+// autoMergePinOnlyEntry's field order matching the hive's JSON key order.
+func (f *amField) same(before, after any) bool {
+ if f.kind == amPinOnly {
+ return compactJSON(autoMergePinOnlyValue(before)) == compactJSON(autoMergePinOnlyValue(after))
+ }
+ return compactJSON(before) == compactJSON(after)
+}2. Relay-sync conversion duplicated — src/pkg/dashboard/api_config_automerge.go:698-704 is a verbatim copy of src/cmd/hive/notifywire.go:38-44 (the comment at :695-697 says as much). The two copies will drift the next time PinOnlySpec gains a field. A shared helper keeps one source of truth, e.g. in pkg/config:
// EnabledHumanMergePinOnly returns the enabled exceptions keyed as configured.
func (a AutoMergeConfig) EnabledHumanMergePinOnly() map[string]PinOnlyException {
out := map[string]PinOnlyException{}
for repo := range a.HumanMergePinOnly {
if ex, enabled := a.HumanMergePinOnlyFor(repo); enabled {
out[repo] = ex
}
}
return out
}so both call sites reduce to a one-line struct conversion. Related: static-src/js/config-features.js:432 hard-codes a third copy of config.PinOnlyKinds as a fallback; the server always sends pin_only_kinds, so an empty-list fallback (hide the kinds checkboxes) would avoid the duplicate.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Summary
auto_merge.human_merge_pin_onlyis the owner-approved exception that lets a pull request whose only change is a version or digest pin bump on a human-merge path merge without a hand merge (Refs #16377, Refs #16265). Until now it could only be set by editinghive.yaml, so a hosted hive had to edit its seed. This PR puts it on the auto-merge settings endpoint, extends the admin MCPauto_merge.updateoperation from #17486, and adds it to Settings → Features → Auto-merge. A change applies at once with no restart. What counts as a pin bump, and every other merge gate, stays the same.Why
Doug wants the exception on four projectbluefin repositories, and a hosted hive like knuckle has no easy way to edit its seed. Validation and the live engine wiring already exist (
ValidateHumanMergePinOnly,Engine.SetHumanMergePinOnly). Only the endpoint, the page and the MCP op were missing.What changes
PUT/PATCH /api/config/auto-mergetakeshuman_merge_pin_only, andGETreturns it pluspin_only_kinds. Likehuman_merge_paths, the map is replaced whole:{}clears it, and leaving it out changes nothing.project.reposand are stored asowner/repo. Lists are trimmed and de-duplicated.ValidateHumanMergePinOnly, the same rulehive.yamlloads under. Anything invalid is a 400 and nothing changes.human_merge_paths. The exception only ever lifts a human-merge-path hold, so on such a repository it would do nothing. An entry the write sends back unchanged is not re-checked, so a full-map save still works on a hive whosehive.yamlalready holds one./approvealready read the shared config on every evaluation. The merge-request relay keeps its own copy, and the dashboard's GitHub-client sync never refreshed it. It does now, so the relay sees a dashboard write with no restart. A pin-only write that cannot be saved is rolled back instead of staying live until the next restart.settingHelpMark.auto_merge.updatetakeshuman_merge_pin_onlyas{"owner/repo": {enabled, paths, kinds, trusted_authors}}, ornullto remove a repository. Every other repository's entry is kept.Safety
intent.PinOnlySpec, the classifier, the commit-provenance checks and the sweep and/approvegates are untouched.human_merge_pathsstill holds every change that is not a pin bump.requireOwnerRolecheck. The MCP op goes through the same endpoint and still cannot merge anything.human_merge_pin_onlymakes the MCP preview fail ("the hive may run an older build"), so the op never sends a field that hive would silently drop.Files
src/pkg/dashboard/api_config_automerge.go: the body field,autoMergeHumanMergePinOnly, the GET shape, the relay sync, the rollback.src/pkg/config/automerge_pin_only.go:PinOnlyKinds(validatenow uses it, same three kinds).src/pkg/github/human_merge_paths.go:Client.HumanMergePinOnlyFor, a read-only accessor for the relay copy.src/pkg/adminmcp/tools_automerge_ops.go,tools_settings.go: the MCP field, merge, rows, widening check and guard.src/pkg/dashboard/static-src/js/config-features.js,config-helpers.js,css/config-dialog.cssand the same edits instatic/index.html. The concatenated manifest matchesindex.htmlbyte for byte (cmp); the generator was not run.src/pkg/dashboard/settings_parity_allowlist.txt: the fourhuman_merge_pin_onlyleaves are no longer yaml-only.operator-reference/README.md,hive-merge.md,admin-mcp.md,design/admin-mcp.md,settings.mdand the API reference rows. Changelog:changelog.d/added-automerge-pin-only-setting.md. ✨ feat(adminmcp): change merge settings through preview and confirm #17486's fragment loses its "still set in the configuration file" clause.Tests
None were run locally (AGENTS.md:7). Only
gofmt -landnode --checkwere run. CI is the verdict.TestAutoMergePinOnly_PutGetRoundTrip: PUT, then GET, normalizing, absent leaves it,{}clears it.TestAutoMergePinOnly_InvalidIsRefusedWithNoChange: unknown repo, duplicate key, missing lists, unknown kind, no human-merge paths, and a mixed body. Each is a 400 and nothing changes.TestAutoMergePinOnly_UnchangedEntryIsNotRecheckedTestAutoMergePinOnly_NonOwnerIsForbidden: merger, unverified owner, no role, on PUT and PATCH.TestAutoMergePinOnly_ReachesRunningHiveWithoutRestart: the shared config and the relay client both see the write, and both lose it on clear.TestAutoMergePinOnly_PersistsToSavedConfigTestAutoMergePinOnlySettingsStaticWiringTestAutoMergeUpdatePinOnlySetKeepsOtherRepos,TestAutoMergeUpdatePinOnlyWidening,TestAutoMergeUpdatePinOnlyRefusesStalePreview(ErrConfirmationStale),TestAutoMergeUpdatePinOnlyRefusals.🤖 Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1