Skip to content

✨ feat(adminmcp): change agent cadences and write-back kinds through preview and confirm - #17555

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:feat/adminmcp-cadence-writeback
Nov 10, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:feat/adminmcp-cadence-writeback

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary: An owner who runs the hive from an assistant through admin MCP can now change two settings that only the dashboard could change before: an agent's cadence in each governor mode, and the write-back gate's per-kind overrides. Both go through preview and confirm and use the same endpoints the dashboard saves with. Nothing that exists today changes: these are two new operations.


What went wrong

On the knuckle hive (projectbluefin, build e86dd26) the operator needed two changes and neither was reachable through admin MCP:

  • Scanner cadence. knuckle's scanner runs every 4h in every mode (governor.modes.{surge,busy,quiet,idle}.scanner: 4h, operator-owned). On 2026-11-10 that left the scanner idle for about 7 hours with actionable work queued. The L6 default is 1h. There is no cadence operation, and governor.feature_settings takes a fixed field list.
  • Branch refresh reach. The stale-red branch refresh (✨ feat(github): merge the base into a red PR whose failing checks are now green on the base tip #17544) writes as the base_refresh kind, which by default reaches only PRs carrying the hive-review opt-in label. writeback.kinds.base_refresh.unlabeled_min_level: 6 lets it reach contributor PRs at L6, but the write-back kinds are not in governor.feature_settings either.

What changes

  • agent.cadences wraps PUT /api/config/agent/{name}/cadences. Arguments: agent and modes (surge, busy, quiet, idle, each a duration such as 1h, or pause). It sends only the modes that change. A mode the hive does not configure is refused, because the endpoint would silently skip it. The preview says each mode it sets becomes operator-owned (governor.cadence_owners, which the endpoint claims), so a later level change or pack apply no longer resets it. A shorter cadence is named as widening: "scanner runs more often in surge: more spend".
  • writeback.kind_policy wraps PUT /api/config/governor/features. Arguments: kinds, mapping a kind to {min_level, require_label, unlabeled_min_level, own_only}. null drops one field, and a kind set to null loses its override. Unknown kinds (checked against the writeback kind registry) and unknown fields are refused, and levels must be 0 to 6, as the endpoint checks.
  • Merge, not replace. The Features endpoint replaces the whole writebackKinds map it is sent (api_governor_features_platform.go, c.Writeback.Kinds = kinds). So the op reads the current overrides and sends all of them with the change merged in. knuckle's existing stage_label: {require_label: false} survives a base_refresh change.
  • Widening disclosure for write-back. The preview compares each kind's resolved policy (writeback.Config.Policy) before and after. It names any kind that would write at a lower level, without the opt-in label, or on items the hive did not author.
  • Both ops record a state fingerprint, so write_confirm refuses with ErrConfirmationStale if the cadences or overrides changed after the preview (the ✨ feat(adminmcp): change merge settings through preview and confirm #17486 hook). Neither op merges, approves, labels or kicks anything. Owner-only is the endpoints' own check.

The optional third item, per-repository repo_policies overrides for sentinel_sensitive_paths and workflow_fence_scope (#17547), is not included. No dashboard endpoint writes project.repo_policies for those fields (they are set in hive.yaml and only read back), so it would need a new endpoint. That follow-up is on hold.

One thing found along the way and left alone: the dashboard's write-back kind table edits only min_level and require_label, and saving an edit there rebuilds every kind's override from the table, which drops unlabeled_min_level and own_only. The writeback.kind_policy preview warns about this when it writes either field. Fixing the table is a separate change.

Files

  • src/pkg/adminmcp/tools_cadence_writeback_ops.go: the two operations (new)
  • src/pkg/adminmcp/tools_agent_ops.go: registers them (one line)
  • src/pkg/adminmcp/tools_cadence_writeback_ops_test.go, src/pkg/dashboard/admin_mcp_cadence_writeback_test.go: tests
  • src/docs/admin-mcp.md (op table and a Writes section), src/docs/design/admin-mcp.md, src/docs/operator-reference/sweeps-and-operations.md, src/docs/api-reference.md, src/docs/api-reference/configuration.md
  • changelog.d/added-adminmcp-cadences-writeback-kinds.md

Tests

None were run locally; per AGENTS.md, CI is the verdict (gofmt -l is clean). On the v6 tip every new test fails, because neither operation is registered and write_preview answers "unknown write operation".

  • TestAdminMCPCadenceAndWritebackKindOpsAreOwnerOnlyAndMerge (dashboard, end to end through the real endpoints): a read-write member's confirm gets "owner access required" and changes nothing. The owner's confirm sets surge to 1h and makes it operator-owned, while busy, quiet and idle keep 4h and their ownership. stage_label's override survives the base_refresh change.
  • TestAgentCadencesOpRejectsUnknownFields, TestWritebackKindPolicyOpRejectsUnknownFields: refuse unknown fields, modes and kinds, bad durations and levels, modes the hive lacks, and no-op changes.
  • TestAgentCadencesOpKeepsUntouchedModes, TestWritebackKindPolicyOpKeepsUntouchedKinds: only the changed modes are sent, and every other override is sent unchanged. This includes knuckle's exact settings, null removing one field or one kind, and an empty map when the last override goes.
  • TestAgentCadencesOpFlagsWidening, TestWritebackKindPolicyOpFlagsWidening: a shorter or new cadence and a lower, unlabeled or no-longer-own-only kind are named as widening. Longer, paused or stricter changes are not.
  • TestAgentCadencesOpRefusesStalePreview, TestWritebackKindPolicyOpRefusesStalePreview: a change made between preview and confirm refuses the confirm and writes nothing.
  • TestAgentCadencesOpRefusesNonOwner, TestWritebackKindPolicyOpRefusesNonOwner: a refused read mints no confirmation, and a 403 from the endpoint writes nothing.

Refs #17544, #17543, #17547

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…eview and confirm

Two dashboard settings had no admin MCP operation, so an operator running
the hive from an assistant could not change them: an agent's per-mode
cadences and the write-back gate's per-kind overrides.

agent.cadences wraps PUT /api/config/agent/{name}/cadences. It takes a
duration or pause per governor mode, sends only the modes that change,
refuses a mode the hive does not configure (the endpoint would skip it),
says each mode becomes operator-owned, and discloses a shorter cadence as
more spend.

writeback.kind_policy wraps PUT /api/config/governor/features. That
endpoint replaces the whole writebackKinds map, so the op reads the current
overrides and sends them all with the change merged in; null removes one
field or one kind's override, unknown kinds and fields are refused. The
preview discloses a kind that would write at a lower level, without the
opt-in label, or on items the hive did not author.

Both record a state fingerprint so write_confirm refuses a stale preview.
No existing endpoint or operation changes.

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>
@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 clubanderson 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
@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#17506 🌱 Top up v6 with v5 (durable hosted hive.yaml, shared-CI deferral naming and 118 more) same files src/docs/operator-reference/sweeps-and-operations.md

@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.

Read both ops against the endpoints they wrap at 8b3acdd; this looks correct to me.

What I verified in the tree (not from the description):

  • Features whole-map replace is handled. api_governor_features_platform.go:265-287 only touches c.Writeback.Kinds when b.WritebackKinds != nil, and every other field in that body struct is a pointer, so a body carrying only writebackKinds leaves the rest of Features untouched. Sending the full merged map (tools_cadence_writeback_ops.go:712-716) is the right shape; an empty {} maps to c.Writeback.Kinds = nil on the server side, matching the "last override removed" case.
  • Cadence body shape matches the handler. api_agent_config.go:995-1023 accepts {mode: seconds}, maps <=0 to pause, skips unknown modes silently and claims cadence_owners. The op refuses an unconfigured mode before the PUT (tools_cadence_writeback_ops.go:265-267), which is the right call given the handler's silent skip. agentCadenceSecondsLabel mirrors formatCadenceDuration, so Cadence.Validate() runs on the same string the server will store.
  • Reach calculation matches the gate. writebackKindReach (:548-564) agrees with Gate.Allowed at writeback/gate.go:491-509: no label → MinLevel; label required → MinLevel with label, UnlabeledMinLevel without when >0, never otherwise; own_only → never. Config.Policy (writeback/config.go:185-213) is what both sides use.
  • settings_read section agent returns cadences as seconds / 0 / schedule string and models keyed per configured mode (api_agent_config.go:99-116, 211-212), which is what readAgentCadenceCell and the configured-mode check consume.
  • numberArg rejects negatives and returns int, so the v.(int) assertions in applyWritebackKindChange cannot panic.

One optional note, not a defect: writebackKindState fingerprints only Kinds; requireLabels/optInLabels are unexported, so a writebackRequireLabels flip between preview and confirm would not trip ErrConfirmationStale. The write itself would still be correct (it only sends writebackKinds), only the widening text shown at preview could be stale. Fine to leave as is.

CI was still running when I read this; I did not wait on it.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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.

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

Read the two new ops against the endpoints they wrap at beb7a83; this looks correct to me.

What I verified in the tree (not from the description):

  • Features body is patch-shaped. featuresPlatformBody (src/pkg/dashboard/api_governor_features_platform.go:40-68) is all pointer/map fields, so sending only {"writebackKinds": …} leaves every other feature untouched. The kinds branch at :265-288 does replace the whole c.Writeback.Kinds map, so the merge-then-send in PreviewWithProvider (tools_cadence_writeback_ops.go:635-655, kindsBody built from after) is the right shape, and the fingerprint over st.Kinds plus ConfirmGuard re-read closes the preview→confirm window the same way issueFilterOp/sentinelSettingsOp already do.
  • Reach calculation matches the gate. writebackKindReach (:550-565) — own_only → never; !RequireLabel → MinLevel both ways; else MinLevel with label and UnlabeledMinLevel-or-never without — is exactly the branch order in Gate.Allowed (src/pkg/writeback/gate.go:475-510), and policyOf feeds writeback.Config.Policy the same RequireLabels the GET reports (writebackRequireLabels, api_governor_features_platform.go:417).
  • Cadence op matches handleAgentConfigCadences. The handler (api_agent_config.go:995-998) silently continues on a mode not in Governor.Modes; the op refuses that case first (:265-267) using the models keys, which the GET builds from the same Governor.Modes range (api_agent_config.go:114-117). Seconds are sent as int64 and 0 → "pause" on both sides (:1004-1009).
  • numberArg (tools_github_cap_ops.go:276) already rejects negatives and fractions, so the > MaxACMMLevel check at :390 is a complete 0–6 range check, and the v.(int) assertions in applyWritebackKindChange are safe.
  • The dashboard end-to-end test exercises the real handlers with RoleReadWrite vs owner and checks stage_label survives the base_refresh write; on v6 it fails because write_preview returns "unknown write operation", so it does pin the behaviour.

Not a defect, one note for whoever merges: the body cites Refs #17544, #17543, #17547 and explains #17547 is deferred; if #17543 is fully resolved by this PR a Closes would let it auto-close rather than stay open. I have not changed anything.

stage 080-awaiting-merge-admission → 072-returned-to-contributor: fork-not-editable

Evidence bundle `#17555beb7a83` sha256:b9be5d6f42f947f05a11ea1b369345cce95e184930c95dc7195e80466a582213 — download from the dashboard or `hivectl review evidence #17555`.

@hivecommons-hive

hivecommons-hive Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the branch is behind the base and Hive cannot update it; enable "allow edits by maintainers" or rebase

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (2 waiting): fixes are handed out before new work as soon as you have capacity.

…abeled items at L6

With min_level 6 and unlabeled_min_level 6 the labelled and unlabelled
reach are the same, and writebackKindPolicyLabel words that as 'L6, any
item'.

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>

@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.

Read the two new ops against the v6 tree (merge-base e86dd26) and the endpoints they wrap. Looks correct to me; nothing blocking.

What I verified:

  • Cadences endpoint contract. pkg/dashboard/api_agent_config.go:978-1026 takes map[mode]seconds, treats <= 0 as pause, continues on a mode not in Governor.Modes, and calls ClaimCadenceOwnership per mode. The op's "refuse a mode this hive lacks" check (tools_cadence_writeback_ops.go:261) is the right guard for that silent skip, and readAgentCadenceState derives configured modes from models, which the GET builds with one key per mode (api_agent_config.go:112-115). Cadence value shapes (int seconds / 0 / Cadence string or object, api_agent_config.go:99-110) match readAgentCadenceCell.
  • Features endpoint is partial-update, full-map replace. api_governor_features_platform.go:265-289 applies only non-nil fields, but when writebackKinds is present it rebuilds c.Writeback.Kinds from scratch (and sets it nil for an empty map). So sending only {"writebackKinds": <merged map>} is the correct way to change one kind without disturbing other feature settings, and an empty map correctly clears the last override.
  • Type safety of the v.(int) casts in applyWritebackKindChange: numberArg (tools_github_cap_ops.go:276) returns a non-negative int, so the 0..MaxACMMLevel bound is fully enforced before the cast.
  • Effective-policy preview uses writeback.Config.Policy (pkg/writeback/config.go:185) with the current writebackRequireLabels, which is what the gate itself resolves; the governor read exposes writebackKinds/writebackRequireLabels/writebackOptInLabels (api_governor_features_platform.go:417-423).
  • Label formatting (agentCadenceSecondsLabel) mirrors formatCadenceDuration (status_builder.go:2072), so the fingerprinted "before" label and the stored value agree.

The dashboard test goes through the real handlers with owner vs read-write roles and checks the untouched modes keep both cadence and ownership, which is the regression I'd have worried about.

Refs (not Closes) for #17543/#17544/#17547 reads right: those issues describe separate changes; this PR only adds the knobs they need.

Checks were still running when I read this; CI remains the verdict on the tests.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit b312a3b into hivecommons:v6 Nov 10, 2026
68 of 69 checks passed
Danathar added a commit to Danathar/hive that referenced this pull request Nov 10, 2026
Keep both admin-mcp design notes: sentinel.settings' repo_sensitive_paths
and hivecommons#17555's agent.cadences / writeback.kind_policy bullet.

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>
hivecommons-hive Bot pushed a commit that referenced this pull request Nov 10, 2026
…rride field (#17559)

* 🐛 fix(dashboard): the write-back kind table edits and keeps every override field

Settings → Features' write-back per-kind matrix edited only min_level and
require_label, but PUT /api/config/governor/features replaces the whole
writeback.kinds map and markDirtyWritebackKinds rebuilt it from those two
cells. Any edit there dropped every kind's unlabeled_min_level and own_only
(and an own-only kind's min_level, whose cell is disabled), undoing what
hive.yaml or the admin MCP writeback.kind_policy operation had set.

- The table gains "Without label" (unlabeled_min_level: default, 0 (off),
  L1-L6) and "Hive-authored only" (own_only: default/yes/no) columns, each
  with a settingHelpMark; the matrix's one yamlHint names all four fields.
- Each row carries the override it was rendered from (data-wb-override);
  the save handler starts from it and only a live, enabled control changes
  its field, so nothing the operator did not touch is dropped.
- writeback.kind_policy's preview no longer warns that a dashboard save
  drops those fields; its test now asserts the warning is gone.
- The two fields leave the settings parity allowlist, since the Settings UI
  now references them.

No endpoint change: the GET already returns every override field.

Refs #17555

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>

* 🐛 test(dashboard): parse the write-back level input quote-aware

The input's data-setting-key value contains "<key>", so the fixture's
[^>]* tag match ended at that '>' and never saw value="3" or disabled on
the own-only row; a browser parses the quoted attribute fine. The handler
was right; the fixture misread the row.

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>
hivecommons-hive Bot pushed a commit that referenced this pull request Nov 10, 2026
…ge (#17560)

The admin MCP could change these settings, but the dashboard could not show
or change them:

- Settings → Features → Auto-merge → Per-repository merge policy gets
  "Merge with no CI" (auto_merge.no_ci_ok) and, only while it is set, the
  deprecated auto_merge.allow_unprotected_base list, marked as having no
  effect so an owner can clear it. Both stage the full selection only when
  changed; an untouched save still omits them, so the server keeps them.
  A bare repository name from hive.yaml now selects that repository.
- Settings → Features → Let hive decide gets a per-repository
  on / off / hive-wide table (decisions.delegate.repos) and an Effect
  timeout (decisions.delegate.effect_timeout). The PUT replaces the repos
  map whole, so a table edit sends every saved override plus the edits.
  The timeout is checked like the server checks it before sending.
- Agent → Operating Mode lists NO_GITHUB (a legacy alias for ADVISORY)
  for an agent that has it, instead of showing "use level default".
- Fix the adminmcp comment that said decisions.delegate had no dashboard
  write endpoint.

No endpoint or server behaviour changes. static/index.html regenerated by
the manifest concatenation (cmp-identical).

Refs #17555 #17556


Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

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>
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