Skip to content

πŸ› fix(adminmcp): budget.reset, backup.create and the circuit breaker ops preview again - #16885

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/adminmcp-detail-less-write-ops
Nov 6, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/adminmcp-detail-less-write-ops

Conversation

@Danathar

@Danathar Danathar commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Four registered admin MCP write operations could not be used at all. write_preview refused budget.reset, backup.create, circuit_breaker.engage and circuit_breaker.release every time, on both transports, so an operator could not engage the fleet circuit breaker, reset the budget window or take a backup through MCP. This PR makes them preview and confirm like every other operation. Nothing changes for the other operations.

What went wrong

The refusal was:

write preview for circuit_breaker.engage contains a confirmation value that cannot be stored; update that field outside admin MCP

That message is meant for a preview that carries a credential. These four operations carry none. They take no arguments and their preview has no details.

Before a preview is stored, the handler scrubs it and compares the scrubbed copy with the original. The scrub turned the empty (nil) details into {}. The comparison is done on JSON, so null did not equal {}, and the preview was treated as if a value had been masked.

The four operations were added on 2026-09-24. The check that refuses them was added three days later, and no test ran these operations through write_preview.

What changes

The scrub leaves a nil map or list as nil. A value that really holds a credential is refused exactly as before.

Files

  • src/pkg/adminmcp/adminmcp.go: scrubPendingValue keeps nil maps and lists.
  • src/pkg/adminmcp/write_contract_test.go: three new tests.
  • changelog.d/fixed-admin-mcp-detail-less-write-ops.md

Tests

  • TestDetailLessWriteOpsPreviewAndConfirm: each of the four operations previews, confirms, and executes the right request.
  • TestArgumentLessWriteOpsPreviewWithNoArgs: every registered operation with no arguments previews with none, so a new one cannot ship refused the same way.
  • TestPendingScrubKeepsNilValues: nil values pass the check, and a credential-bearing key is still caught.
  • All three fail on v6 without the fix and pass with it.
  • go test ./pkg/adminmcp/ ./cmd/hive-admin-mcp/ and the AdminMCP tests in ./pkg/dashboard/ pass.

πŸ€– Generated with Claude Code

…ops preview again

write_preview refused the four write ops whose preview carries no details
(budget.reset, backup.create, circuit_breaker.engage and
circuit_breaker.release) with "contains a confirmation value that cannot
be stored". The pending-confirmation scrub turned their nil details into
{} and the unpersistable check compares a value with its scrubbed copy as
JSON, so null against {} read as a masked value.

scrubPendingValue now leaves nil maps and lists as nil. Credential-bearing
values are refused as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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 6, 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 nicholasjackson 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

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
#16884 ✨ feat(adminmcp): read and act on the Activity monitor; writes run as the verified caller same files src/pkg/adminmcp/adminmcp.go

@hivecommons-hive
hivecommons-hive Bot merged commit c933c46 into hivecommons:v6 Nov 6, 2026
67 of 68 checks passed
@hivecommons-hive

hivecommons-hive Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Evidence bundle `#16885c165011` sha256:cf9c76fe23071c6ddcee18f830aba5bafb479def85c497e427a9587a809e97e3 β€” download from the dashboard or `hivectl review evidence #16885`.

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

Looks correct to me, and the mechanism is as described.

pendingValueNeedsFreshConfirm (src/pkg/adminmcp/adminmcp.go:564-569) decides "unpersistable" by marshalling the value before and after scrubPendingValue and comparing bytes. A nil map[string]any marshals to null, but the map[string]any arm rebuilt it with make(...), which marshals to {} β€” so PreviewWrite refused every operation whose Details were nil at adminmcp.go:558. Returning the nil container unchanged (for map, []any and []string) makes the before/after bytes equal again, and non-nil values still take the same scrub path they did before, so nothing credential-bearing is newly kept.

The new test previews and confirms all four affected operations through PreviewWrite/ConfirmWrite, so it would fail on v6 as the body says.

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

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

Traced the mechanism in the v6 tree and it holds. pendingValueNeedsFreshConfirm (src/pkg/adminmcp/adminmcp.go:564-569) marshals a value and its scrubPendingValue copy and refuses on any byte difference; PreviewWrite calls it on preview.Details (adminmcp.go:558). For a typed-nil map[string]any, the old map case did make(map[string]any, 0) unconditionally, so null became {} and the comparison failed for every op that sets no Details β€” not a scrub concern at all, just a nil/empty encoding mismatch. Returning the nil map, nil []any and nil []string unchanged is the minimal correct fix; a non-nil empty map still round-trips to {} as before, and scrubPendingPreview's own != nil guards at :584/:589 are unaffected.

The three new tests cover the four detail-less ops end to end, assert every argument-less registered op previews with no args (so the next one cannot regress), and pin the nil-preservation directly. Looks correct to me.

β€” hive: agent=reviewer-2 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant