Skip to content

✨ feat(automerge): the pin-only exception can be set from the dashboard and admin MCP - #17489

Merged
hivecommons-hive[bot] merged 5 commits into
hivecommons:v6from
Danathar:feat/automerge-pin-only-setting
Nov 10, 2026
Merged

hivecommons-hive[bot] merged 5 commits into
hivecommons:v6from
Danathar:feat/automerge-pin-only-setting

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

auto_merge.human_merge_pin_only is 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 editing hive.yaml, so a hosted hive had to edit its seed. This PR puts it on the auto-merge settings endpoint, extends the admin MCP auto_merge.update operation 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

  • Endpoint. PUT/PATCH /api/config/auto-merge takes human_merge_pin_only, and GET returns it plus pin_only_kinds. Like human_merge_paths, the map is replaced whole: {} clears it, and leaving it out changes nothing.
    • Keys must be in project.repos and are stored as owner/repo. Lists are trimmed and de-duplicated.
    • The map must pass ValidateHumanMergePinOnly, the same rule hive.yaml loads under. Anything invalid is a 400 and nothing changes.
    • It is owner only, like the rest of the endpoint.
  • One extra rule. An enabled entry the write adds or changes is refused when its repository has no 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 whose hive.yaml already holds one.
  • Applies live. The sweep lanes and /approve already 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.
  • Settings page. A "Pin bumps that skip the hand merge" block sits next to the human-merge paths. It has one row for each repository that has human-merge paths or already has an exception. Each row has on/off, paths, the three kinds and the trusted authors, and every label has a settingHelpMark.
  • Admin MCP. auto_merge.update takes human_merge_pin_only as {"owner/repo": {enabled, paths, kinds, trusted_authors}}, or null to remove a repository. Every other repository's entry is kept.
    • The preview shows the change before and after, and the stale-preview fingerprint covers it.
    • The old "not on this endpoint" refusal is gone.
    • Turning an exception on, or adding paths, kinds or trusted authors, is reported as widening. For example: "pin bumps (action-sha) to .github/workflows/*.yml in org/a by renovate[bot] will merge without a hand merge". Removing any of them is not.

Safety

  • What counts as pin-only does not change: intent.PinOnlySpec, the classifier, the commit-provenance checks and the sweep and /approve gates are untouched.
  • human_merge_paths still holds every change that is not a pin bump.
  • Only owners can write it, through the existing requireOwnerRole check. The MCP op goes through the same endpoint and still cannot merge anything.
  • An older hive that does not report human_merge_pin_only makes 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 (validate now 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.css and the same edits in static/index.html. The concatenated manifest matches index.html byte for byte (cmp); the generator was not run.
  • src/pkg/dashboard/settings_parity_allowlist.txt: the four human_merge_pin_only leaves are no longer yaml-only.
  • Docs: operator-reference/README.md, hive-merge.md, admin-mcp.md, design/admin-mcp.md, settings.md and 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 -l and node --check were 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_UnchangedEntryIsNotRechecked
  • TestAutoMergePinOnly_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_PersistsToSavedConfig
  • TestAutoMergePinOnlySettingsStaticWiring
  • TestAutoMergeUpdatePinOnlySetKeepsOtherRepos, TestAutoMergeUpdatePinOnlyWidening, TestAutoMergeUpdatePinOnlyRefusesStalePreview (ErrConfirmationStale), TestAutoMergeUpdatePinOnlyRefusals.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

Danathar and others added 5 commits November 9, 2026 19:36
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
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 10, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 10, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 59a3efe into hivecommons:v6 Nov 10, 2026
74 of 79 checks passed
@hivecommons-hive

hivecommons-hive Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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 reviewer-2 (folded here because this head already carries its hive review):

Read the diff against the v6 tree (dashboard endpoint, admin MCP op, relay sync and the callers). Looks correct to me; nothing blocking.

What I verified:

  • src/pkg/dashboard/api_config_automerge.go:695-704 builds the relay's PinOnlySpec map exactly as src/cmd/hive/notifywire.go:38-44 does on boot/reload, so a dashboard write and a restart leave the relay in the same state. Before this PR the dashboard sync never touched the relay's copy, so the "applies live" claim in the body is real.
  • The rollback at api_config_automerge.go:470-476 is safe: previousAutoMerge (:346) is captured before cfg.AutoMerge.HumanMergePinOnly is swapped for the new map, so the old map is restored intact.
  • autoMergeDedupeStrings goes through normalizeAutoMergeRepoList (:708-717), which only trims — it does not lowercase — so glob paths and logins keep their case.
  • autoMergeHumanMergePinOnly with an empty non-nil body map returns nil and the handler assigns it, so {} clears the key as the body says; absent leaves it untouched.
  • Admin MCP autoMergeCheckPinOnlyGuarded (tools_automerge_ops.go) applies the same "needs human_merge_paths after this change" rule as the endpoint, reading human_merge_paths from the planned body when the same call sets it. markDirtyAutoMergePinOnly is reachable through the generic data-change-action dispatcher (tooltips-dialogs.js:319-327) and is asserted in the static-wiring test.

One cosmetic difference, not a defect: the endpoint drops a {enabled:false, paths:[], kinds:[], trusted_authors:[]} entry (api_config_automerge.go, autoMergeHumanMergePinOnly), while autoMergeApplyPinOnly in the MCP op keeps it in the merged map it sends. The server discards it on write, so the only effect is that a preview can show a row the saved config will not contain.

Only tide is pending; every other check is green.

Review findings from adjudicator (folded here because this head already carries its hive review):

Correctness review (head 09bb1f5). Verified the "applies live" claim: sweep//approve read cfg through closures (src/cmd/hive/main_sweeps.go), and the new relay sync in api_config_automerge.go:692-702 mirrors src/cmd/hive/notifywire.go:38-44 exactly. Validation, rollback and the MCP merge/fingerprint paths look right. Two low-severity edge cases, neither blocking:

  1. Unchanged-entry bypass compares normalized vs raw lists — api_config_automerge.go:843-851. autoMergePinOnlyUnchanged does slices.Equal(was.Paths, policy.Paths) where policy has been trimmed/de-duplicated (:808-812) but was is the raw hive.yaml value. An entry whose yaml lists carry whitespace or a duplicate counts as "changed", so a full-map dashboard save on a hive whose yaml exception sits on a repo without human_merge_paths is refused — the case the PR body says the bypass exists for. Fix:

    			return was.Enabled == policy.Enabled && slices.Equal(autoMergeDedupeStrings(was.Paths), policy.Paths) &&
    				slices.Equal(autoMergeDedupeStrings(was.Kinds), policy.Kinds) && slices.Equal(autoMergeDedupeStrings(was.TrustedAuthors), policy.TrustedAuthors)
    
  2. UI echoes yaml-only repos the endpoint rejects — static-src/js/config-features.js:439-440 appends every human_merge_pin_only key not in project_repos as a row, and markDirtyAutoMergePinOnly (config-helpers.js:437-452) sends all rows whole. ValidateHumanMergePinOnly (config/automerge_pin_only.go:60-74) does not require keys to be in project.repos, but autoMergeWatchedRepo (api_config_automerge.go:746-748) does — so a hive with such a yaml entry gets a 400 on every pin-only save from the Settings page until yaml is edited. Simplest fix is to drop the .concat(...) so only project repos get rows (the human_merge_paths block already behaves that way), or skip the watchesRepo check for entries that are unchanged.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at 09bb1f5.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant