diff --git a/changelog.d/added-writeback-unsolicited-mcp-write.md b/changelog.d/added-writeback-unsolicited-mcp-write.md new file mode 100644 index 0000000000..43d8902e45 --- /dev/null +++ b/changelog.d/added-writeback-unsolicited-mcp-write.md @@ -0,0 +1 @@ +- The admin MCP `governor.feature_settings` operation now writes write-back containment's unsolicited knobs (`writebackMinLevel`, `writebackRequireLabels`, `writebackBackfill`), which until now only the dashboard's Settings → Features toggles could change. The preview discloses each change that lets the hive write to more items. diff --git a/src/docs/admin-mcp.md b/src/docs/admin-mcp.md index b8741a48e2..3f6a28e70a 100644 --- a/src/docs/admin-mcp.md +++ b/src/docs/admin-mcp.md @@ -1112,6 +1112,13 @@ refuses any other role. operator-owned (`governor.cadence_owners`), as a dashboard edit does, so a later ACMM level change (`fleet.autonomy_level`) or pack apply no longer resets it to the pack default. The preview says so. +- `governor.feature_settings` also takes write-back containment's unsolicited + knobs, the toggles above the per-kind table on Settings → Features: + `writebackMinLevel` (`writeback.unsolicited.min_level`, 0 restores the default), + `writebackRequireLabels` (`writeback.unsolicited.require_labels`) and + `writebackBackfill` (`writeback.unsolicited.backfill`). Its preview names + each one that lets the hive write to more items: backfill on, the opt-in + label requirement off, or any level change. - `writeback.kind_policy` changes the write-back gate's per-kind overrides (`writeback.kinds.`: `min_level`, `require_label`, `unlabeled_min_level` and `own_only`), through diff --git a/src/docs/design/admin-mcp.md b/src/docs/design/admin-mcp.md index d1f5c8ac43..f8dbd02e9d 100644 --- a/src/docs/design/admin-mcp.md +++ b/src/docs/design/admin-mcp.md @@ -621,7 +621,12 @@ Phase 5 registers the fleet-level write operations under that contract: released; rejection discloses the re-gating and lease reset. - `governor.feature_settings` wraps `PUT /api/config/governor/features`, preserves the endpoint's pointer-field partial update contract, and calls out protective toggles such as - ioscan, claims, checkpoint gates, and autonomy automation before confirmation. + ioscan, claims, checkpoint gates, and autonomy automation before confirmation. It also takes + write-back containment's three unsolicited knobs (`writebackMinLevel`, + `writebackRequireLabels`, `writebackBackfill` for `writeback.unsolicited.*`), and discloses + turning backfill on and turning the opt-in label requirement off, since each lets the hive + write to more items it was not asked to touch, and any change to the level floor (which + raises per-kind floors, never lowers them; 0 restores the default). - `governor.general_settings` wraps `PUT /api/config/governor/general-advanced` (Settings → General: the eval interval, the loop pacing knobs, `governor.api_budget_pacing`, the default explain mode and the attribution trailer). It sends only the fields that differ from the diff --git a/src/pkg/adminmcp/adminmcp_test.go b/src/pkg/adminmcp/adminmcp_test.go index 70ca24d706..bbf09e54d6 100644 --- a/src/pkg/adminmcp/adminmcp_test.go +++ b/src/pkg/adminmcp/adminmcp_test.go @@ -1067,3 +1067,25 @@ func mustJSON(t *testing.T, v any) string { } return string(b) } + +// Write-back containment's unsolicited knobs (Settings → Features → +// Write-back containment) are writable here too, and the preview names +// each change that lets the hive write to more items (#18846 follow-up). +func TestFeatureSettingsWritebackUnsolicited(t *testing.T) { + preview, err := featureSettingsOp{}.Preview(context.Background(), map[string]any{"writebackBackfill": true, "writebackRequireLabels": false, "writebackMinLevel": 3}) + if err != nil { + t.Fatal(err) + } + body := preview.Request.Body.(map[string]any) + if body["writebackBackfill"] != true || body["writebackRequireLabels"] != false || body["writebackMinLevel"] != 3 { + t.Fatalf("body = %#v", body) + } + for _, want := range []string{"writebackBackfill", "writebackRequireLabels", "writebackMinLevel"} { + if !strings.Contains(preview.WideningDisclosure, want) { + t.Fatalf("disclosure %q does not name %s", preview.WideningDisclosure, want) + } + } + if p, err := (featureSettingsOp{}).Preview(context.Background(), map[string]any{"writebackBackfill": false}); err != nil || strings.Contains(p.WideningDisclosure, "writebackBackfill") { + t.Fatalf("turning backfill off is no widening: %q, %v", p.WideningDisclosure, err) + } +} diff --git a/src/pkg/adminmcp/tools_fleet_ops.go b/src/pkg/adminmcp/tools_fleet_ops.go index 2ef4fb7a02..297f873f40 100644 --- a/src/pkg/adminmcp/tools_fleet_ops.go +++ b/src/pkg/adminmcp/tools_fleet_ops.go @@ -150,7 +150,7 @@ func (planRejectOp) Preview(_ context.Context, args map[string]any) (WritePrevie func (featureSettingsOp) Name() string { return WriteOpFeatureSettings } func (featureSettingsOp) Description() string { - return "Update governor feature settings through PUT /api/config/governor/features." + return "Update governor feature settings through PUT /api/config/governor/features. This includes write-back containment's unsolicited knobs (writeback.unsolicited: writebackMinLevel, writebackRequireLabels, writebackBackfill); the per-kind overrides have their own operation, writeback.kind_policy." } func (featureSettingsOp) InputSchema() map[string]any { props := map[string]any{} @@ -225,6 +225,18 @@ func featureDisclosure(args map[string]any) string { warnings = append(warnings, key+" enables additional fleet behavior") } } + // Write-back containment (writeback.unsolicited, Settings → Features → + // Write-back containment): each of these lets the hive write to more + // PRs and issues it was not asked to touch. + if v, ok := args["writebackBackfill"].(bool); ok && v { + warnings = append(warnings, "writebackBackfill lets the hive write unsolicited to PRs and issues created before it first saw the repository") + } + if v, ok := args["writebackRequireLabels"].(bool); ok && !v { + warnings = append(warnings, "writebackRequireLabels off drops the review opt-in label requirement for unsolicited write-backs on other people's PRs") + } + if _, ok := args["writebackMinLevel"]; ok { + warnings = append(warnings, "writebackMinLevel changes the ACMM floor for unsolicited write-backs (it raises per-kind floors, never lowers them; 0 restores the default)") + } if len(warnings) == 0 { return "No obvious authority widening detected from the provided feature fields." } @@ -290,11 +302,11 @@ func featureFieldSet(schema map[string]any) map[string]bool { } func boolFeatureFields() []string { - return []string{"ioscanEnabled", "tracingEnabled", "otelEnabled", "retroEnabled", "mintEnabled", "planFromLabel", "formalEnabled", "personaLearningEnabled", "checkpointSpecEnabled", "checkpointPlanEnabled", "checkpointImplementEnabled", "planMatchEnabled", "spektacularEnabled", "spektacularHubExecutor", "runStages", "triageEnabled", "triageClarifyComment", "publicationEnabled", "extFlueEnabled", "extOmpEnabled", "wavefrontEnabled", "claimsEnabled", "autonomyAutoPromote", "autonomyAutoDemote", "rotationEnabled", "otelInsecure"} + return []string{"ioscanEnabled", "tracingEnabled", "otelEnabled", "retroEnabled", "mintEnabled", "planFromLabel", "formalEnabled", "personaLearningEnabled", "checkpointSpecEnabled", "checkpointPlanEnabled", "checkpointImplementEnabled", "planMatchEnabled", "spektacularEnabled", "spektacularHubExecutor", "runStages", "triageEnabled", "triageClarifyComment", "publicationEnabled", "extFlueEnabled", "extOmpEnabled", "wavefrontEnabled", "claimsEnabled", "autonomyAutoPromote", "autonomyAutoDemote", "rotationEnabled", "otelInsecure", "writebackRequireLabels", "writebackBackfill"} } func intFeatureFields() []string { - return []string{"runWaitTimeoutSeconds", "spektacularPollS", "spektacularHubExecutorTimeoutS", "spektacularHubExecutorMaxConcurrent", "maxStageRetries", "triageMinBodyChars", "claimsTtlS", "autonomyPromoteAfter", "autonomyMaxLevel", "autonomyCooldownDays", "rotationThresholdPct", "rotationHighVolumeCadenceS"} + return []string{"runWaitTimeoutSeconds", "spektacularPollS", "spektacularHubExecutorTimeoutS", "spektacularHubExecutorMaxConcurrent", "maxStageRetries", "triageMinBodyChars", "claimsTtlS", "autonomyPromoteAfter", "autonomyMaxLevel", "autonomyCooldownDays", "rotationThresholdPct", "rotationHighVolumeCadenceS", "writebackMinLevel"} } func stringFeatureFields() []string {