From e065b40fd1fbae09631a8ab3797726d7c49d4a78 Mon Sep 17 00:00:00 2001 From: Danathar <6772335+Danathar@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:14:52 -0500 Subject: [PATCH] feat(dashboard): Settings toggle and MCP write for shared_ci_rerun.enabled shared_ci_rerun.enabled was yaml-only (settings_parity_allowlist.txt, TODO #11854). A hive whose App has no Actions write, an optional permission (src/docs/github-app-setup.md), gets a 403 on every rerun-failed-jobs and a note on each PR, and could only turn the sweep off by editing its config. - Features PUT/GET: sharedCiRerunEnabled. - Settings -> Features -> Quality loops & release health -> Shared-CI recovery: a toggle with a YAML hint and help, plus a search entry. - Admin MCP governor.feature_settings accepts it and discloses turning it on. - The key leaves the parity allowlist; docs updated. Refs #11854 Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 --- changelog.d/added-shared-ci-rerun-setting.md | 1 + src/docs/admin-mcp.md | 5 +++ src/docs/github-app-setup.md | 6 ++- .../sweeps-and-operations.md | 2 +- src/pkg/adminmcp/adminmcp_test.go | 18 +++++++++ src/pkg/adminmcp/tools_fleet_ops.go | 8 +++- .../dashboard/api_governor_features_ops.go | 16 +++++++- .../governor_settings_parity_test.go | 40 +++++++++++++++++++ .../dashboard/settings_parity_allowlist.txt | 1 - .../static-src/js/config-features.js | 8 ++++ .../dashboard/static-src/js/config-state.js | 1 + src/pkg/dashboard/static/index.html | 9 +++++ 12 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 changelog.d/added-shared-ci-rerun-setting.md diff --git a/changelog.d/added-shared-ci-rerun-setting.md b/changelog.d/added-shared-ci-rerun-setting.md new file mode 100644 index 0000000000..fa3869af61 --- /dev/null +++ b/changelog.d/added-shared-ci-rerun-setting.md @@ -0,0 +1 @@ +- `shared_ci_rerun.enabled` is now a Settings toggle (Features → Quality loops & release health → Shared-CI recovery) and an admin-MCP `governor.feature_settings` field (`sharedCiRerunEnabled`), so a hive whose App has no Actions write (an optional permission) can turn the shared-CI rerun attempts and their notes off without editing its config file. diff --git a/src/docs/admin-mcp.md b/src/docs/admin-mcp.md index d694dfdfe3..fe4d608ea2 100644 --- a/src/docs/admin-mcp.md +++ b/src/docs/admin-mcp.md @@ -1139,6 +1139,11 @@ refuses any other role. `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. +- `governor.feature_settings` also takes `sharedCiRerunEnabled` + (`shared_ci_rerun.enabled`, Settings → Features → Quality loops & release + health → Shared-CI recovery). Turning it off stops the shared-CI rerun + attempts and their notes, for example on a hive whose App has no Actions + write; turning it on is named in the preview's widening disclosure. - `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/github-app-setup.md b/src/docs/github-app-setup.md index 2caef7ed63..0a93539f4a 100644 --- a/src/docs/github-app-setup.md +++ b/src/docs/github-app-setup.md @@ -144,7 +144,11 @@ a source-code defect: Hive records `unauthorized:rerun-shared-ci`, posts one head-scoped actionable note using the existing unauthorized mechanism, and retries no more than once per repository per permission cooldown (one hour). An unchanged PR remains eligible after the cooldown; a successful rerun or -observing no failed runs clears the recovery block. +observing no failed runs clears the recovery block. A hive that does not grant +the permission can turn the sweep off with the **Re-run PRs after a shared-CI +incident** toggle (Settings → Features → Quality loops & release health → +Shared-CI recovery) or the admin MCP `governor.feature_settings` field +`sharedCiRerunEnabled`, which stops the attempts and their notes. The transient-CI re-run (a red hive or trusted-bot PR whose failing runs all carry `hive-ci-transient`, see ADR-0010) uses the same `rerun-failed-jobs` diff --git a/src/docs/operator-reference/sweeps-and-operations.md b/src/docs/operator-reference/sweeps-and-operations.md index 7703b9388a..44a301c14d 100644 --- a/src/docs/operator-reference/sweeps-and-operations.md +++ b/src/docs/operator-reference/sweeps-and-operations.md @@ -355,7 +355,7 @@ someone re-runs it. The shared-CI rerun sweep | Key | Default | Meaning | |---|---|---| -| `shared_ci_rerun.enabled` | `true` (unset) | Set `false` to stop re-running PRs when a `[shared-ci]` incident closes or its check passes on the base again. | +| `shared_ci_rerun.enabled` | `true` (unset) | Set `false` to stop re-running PRs when a `[shared-ci]` incident closes or its check passes on the base again. Settings → Features → Quality loops & release health → **Shared-CI recovery**, or the admin MCP `governor.feature_settings` field `sharedCiRerunEnabled`. | ## Shared-CI tracking issues (`shared_ci_issues`) diff --git a/src/pkg/adminmcp/adminmcp_test.go b/src/pkg/adminmcp/adminmcp_test.go index 0b6f044586..f86d9343d7 100644 --- a/src/pkg/adminmcp/adminmcp_test.go +++ b/src/pkg/adminmcp/adminmcp_test.go @@ -1090,6 +1090,24 @@ func TestFeatureSettingsWorkflowApproval(t *testing.T) { } } +// shared_ci_rerun.enabled is writable through governor.feature_settings; +// turning the sweep on is disclosed, turning it off is not. +func TestFeatureSettingsSharedCIRerun(t *testing.T) { + preview, err := featureSettingsOp{}.Preview(context.Background(), map[string]any{"sharedCiRerunEnabled": true}) + if err != nil { + t.Fatal(err) + } + if body := preview.Request.Body.(map[string]any); body["sharedCiRerunEnabled"] != true { + t.Fatalf("body = %#v", body) + } + if !strings.Contains(preview.WideningDisclosure, "sharedCiRerunEnabled") { + t.Fatalf("disclosure %q does not name sharedCiRerunEnabled", preview.WideningDisclosure) + } + if p, err := (featureSettingsOp{}).Preview(context.Background(), map[string]any{"sharedCiRerunEnabled": false}); err != nil || strings.Contains(p.WideningDisclosure, "sharedCiRerunEnabled") { + t.Fatalf("turning the rerun sweep off is no widening: %q, %v", p.WideningDisclosure, err) + } +} + // 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). diff --git a/src/pkg/adminmcp/tools_fleet_ops.go b/src/pkg/adminmcp/tools_fleet_ops.go index 2f1a03141f..d14286ba6f 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. This includes workflow-run approval (governor.ci: ciAutoApproveWorkflows, ciAutoApproveWorkflowActors) and write-back containment's unsolicited knobs (writeback.unsolicited: writebackMinLevel, writebackRequireLabels, writebackBackfill); the per-kind overrides have their own operation, writeback.kind_policy." + return "Update governor feature settings through PUT /api/config/governor/features. This includes workflow-run approval (governor.ci: ciAutoApproveWorkflows, ciAutoApproveWorkflowActors), the shared-CI rerun sweep (shared_ci_rerun.enabled: sharedCiRerunEnabled) and 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{} @@ -168,6 +168,7 @@ func (featureSettingsOp) InputSchema() map[string]any { // governor.ci (Settings → Features → Auto-merge → Workflow approval). props["ciAutoApproveWorkflows"] = map[string]any{"type": "boolean", "description": "governor.ci.auto_approve_workflows: approve the workflow runs GitHub holds behind \"Approve and run\" on trusted PR heads (default true)."} props["ciAutoApproveWorkflowActors"] = map[string]any{"type": "string", "description": "governor.ci.auto_approve_workflow_actors as a comma-separated list of GitHub logins trusted besides the hive's App and dashboard-approved heads; blank restores the default (dependabot[bot], renovate[bot]), \"none\" trusts neither."} + props["sharedCiRerunEnabled"] = map[string]any{"type": "boolean", "description": "shared_ci_rerun.enabled: re-run the failed jobs of PRs a [shared-ci] incident held red once it is over (default true; needs Actions write on the App, which is optional)."} props["otelHeaders"] = map[string]any{"type": "object", "additionalProperties": stringSchema()} props["rotationProviders"] = map[string]any{"type": "object"} props["rotationAgents"] = map[string]any{"type": "object", "additionalProperties": stringSchema()} @@ -226,6 +227,11 @@ func featureDisclosure(args map[string]any) string { if v, ok := args["ciAutoApproveWorkflowActors"].(string); ok && !strings.EqualFold(strings.TrimSpace(v), "none") { warnings = append(warnings, "ciAutoApproveWorkflowActors sets whose PRs get held workflow runs approved; a trusted author covers every run on the head, whoever pushed it") } + // The shared-CI rerun sweep re-runs failed jobs and comments on the PRs + // it re-ran (or, without Actions write, asks a maintainer to). + if v, ok := args["sharedCiRerunEnabled"].(bool); ok && v { + warnings = append(warnings, "sharedCiRerunEnabled lets the hive re-run failed jobs on PRs a shared-CI incident held red and leave a note on each") + } for _, key := range []string{"ioscanEnabled", "checkpointSpecEnabled", "checkpointPlanEnabled", "checkpointImplementEnabled", "claimsEnabled"} { if v, ok := args[key].(bool); ok && !v { warnings = append(warnings, key+" disables a protection or coordination gate") diff --git a/src/pkg/dashboard/api_governor_features_ops.go b/src/pkg/dashboard/api_governor_features_ops.go index 35956b8ab6..a6e8ac6e69 100644 --- a/src/pkg/dashboard/api_governor_features_ops.go +++ b/src/pkg/dashboard/api_governor_features_ops.go @@ -17,8 +17,9 @@ import ( // featuresOpsBody is the part of the Features PUT that covers the operational // hive.yaml blocks issues.*, jev.*, duplicate_sweep.*, policies.*, the // turn.pr_follow_up / turn.reentrant knobs, good_first_issue.*, the -// governor claim-mirroring and rotation headroom-source keys, and -// governor.ci's workflow-approval keys. Every field is a pointer so an +// governor claim-mirroring and rotation headroom-source keys, +// governor.ci's workflow-approval keys, and shared_ci_rerun.enabled. Every +// field is a pointer so an // absent key leaves the config untouched. Durations travel as Go duration // strings ("10m", "24h"); an empty string means the built-in default. type featuresOpsBody struct { @@ -86,6 +87,12 @@ type featuresOpsBody struct { // explicit empty list. The approval sweep reads both every cycle. CIAutoApproveWorkflows *bool `json:"ciAutoApproveWorkflows"` CIAutoApproveWorkflowActors *string `json:"ciAutoApproveWorkflowActors"` + // shared_ci_rerun.enabled: whether the shared-CI rerun sweep re-runs the + // failed jobs of PRs a [shared-ci] incident held red once it is over. A + // hive whose App has no Actions write (an optional permission, + // docs/github-app-setup.md) may turn it off to stop the attempts and + // their notes. The sweep reads it every pass. + SharedCIRerunEnabled *bool `json:"sharedCiRerunEnabled"` } // envVarNamePattern is the shape of a POSIX environment variable name. @@ -389,6 +396,10 @@ func (b featuresOpsBody) prepare(cur *config.Config) (func(*config.Config), erro c.Governor.CI.AutoApproveWorkflowActors = &v }) } + if b.SharedCIRerunEnabled != nil { + v := *b.SharedCIRerunEnabled + steps = append(steps, func(c *config.Config) { c.SharedCIRerun.Enabled = &v }) + } return func(c *config.Config) { for _, step := range steps { @@ -425,6 +436,7 @@ func featuresOpsResponse(cfg *config.Config) map[string]interface{} { "ciAutoApproveWorkflows": cfg.Governor.CI.AutoApproveWorkflowsEnabled(), "ciAutoApproveWorkflowActors": ciAutoApproveActorsResponse(cfg.Governor.CI), "ciAutoApproveActorsDefault": strings.Join(config.DefaultAutoApproveWorkflowActors, ", "), + "sharedCiRerunEnabled": cfg.SharedCIRerun.IsEnabled(), "issuesCloseOnMerge": cfg.Issues.CloseOnMergeEnabled(), "issuesCloseOnMergeInterval": settingsDurationString(cfg.Issues.CloseOnMergeInterval), diff --git a/src/pkg/dashboard/governor_settings_parity_test.go b/src/pkg/dashboard/governor_settings_parity_test.go index f33fa4eb25..50108cf18e 100644 --- a/src/pkg/dashboard/governor_settings_parity_test.go +++ b/src/pkg/dashboard/governor_settings_parity_test.go @@ -390,3 +390,43 @@ func TestWorkflowApprovalSettingsRender(t *testing.T) { } } } + +// shared_ci_rerun.enabled round-trips through the Features PUT and renders on +// Settings → Features → Quality with its YAML-key hint. A hive whose App has +// no Actions write (optional) turns it off to stop the rerun attempts. +func TestGovernorFeaturesSharedCIRerunRoundTrip(t *testing.T) { + s := covApiServer(t) + if !s.deps.Config.SharedCIRerun.IsEnabled() { + t.Fatal("shared_ci_rerun must default on") + } + if rec := doPut(s, opsFeaturesPath, map[string]any{"sharedCiRerunEnabled": false}); rec.Code != http.StatusOK { + t.Fatalf("features PUT: %d — %s", rec.Code, rec.Body.String()) + } + if s.deps.Config.SharedCIRerun.IsEnabled() { + t.Fatal("shared_ci_rerun.enabled not turned off") + } + rec := doGet(s, "/api/config/governor") + if rec.Code != http.StatusOK { + t.Fatalf("governor GET: %d", rec.Code) + } + var got struct { + Features map[string]any `json:"features"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &got); err != nil { + t.Fatal(err) + } + if got.Features["sharedCiRerunEnabled"] != false { + t.Fatalf("features response sharedCiRerunEnabled = %v", got.Features["sharedCiRerunEnabled"]) + } + if rec := doPut(s, opsFeaturesPath, map[string]any{"ciAutoApproveWorkflows": true}); rec.Code != http.StatusOK { + t.Fatalf("unrelated PUT: %d", rec.Code) + } + if s.deps.Config.SharedCIRerun.IsEnabled() { + t.Fatal("a PUT that did not carry the flag changed it") + } + + features := extractJSFunction(t, indexHTML(t), "renderGovFeatures") + if !strings.Contains(features, "yamlHint('shared_ci_rerun.enabled')") || !strings.Contains(features, `data-section="features" data-key="sharedCiRerunEnabled"`) { + t.Error("shared_ci_rerun.enabled has no Features control with its YAML-key hint") + } +} diff --git a/src/pkg/dashboard/settings_parity_allowlist.txt b/src/pkg/dashboard/settings_parity_allowlist.txt index fa69518577..1e9240a452 100644 --- a/src/pkg/dashboard/settings_parity_allowlist.txt +++ b/src/pkg/dashboard/settings_parity_allowlist.txt @@ -635,7 +635,6 @@ self_experiments.scheduler.interval_s # TODO #11854 self_experiments.scheduler.mode # TODO #11854 shared_ci_issues.enabled # shared-CI tracking issue sweep; yaml-only shared_ci_issues.min_prs # shared-CI tracking issue sweep; yaml-only -shared_ci_rerun.enabled # TODO #11854 swarm.themes..call_to_arms # TODO #11854 swarm.themes..event_name # TODO #11854 swarm.themes..leaderboard_title # TODO #11854 diff --git a/src/pkg/dashboard/static-src/js/config-features.js b/src/pkg/dashboard/static-src/js/config-features.js index 01d4f45432..6d65dd1c60 100644 --- a/src/pkg/dashboard/static-src/js/config-features.js +++ b/src/pkg/dashboard/static-src/js/config-features.js @@ -1424,6 +1424,14 @@
Applies on the next posture pass.
+ +
+
Shared-CI recovery ${settingHelpMark('settings', 'features', 'Shared-CI recovery', `When one check fails across many PRs at once, the hive files a [shared-ci] tracking issue. Once that incident is over (the issue is closed, or its check has passed on the PR's base branch again) the rerun sweep re-runs the failed jobs of each PR the incident held red, once per PR per incident, and leaves a short note on the PR.`)}
+
+
+ Re-run PRs after a shared-CI incident ${yamlHint('shared_ci_rerun.enabled')} ${settingHelpMark('settings', 'features', 'Re-run PRs after a shared-CI incident', `On by default. Re-running failed jobs needs Actions: Read and write on the App, which is optional. Without it GitHub refuses each re-run (403) and the PR gets a note asking a maintainer to re-run it; turn this off to stop those attempts and notes. Applies from the next sweep.`)} +
+
`)} ${featuresSectionHtml('integrations', ` diff --git a/src/pkg/dashboard/static-src/js/config-state.js b/src/pkg/dashboard/static-src/js/config-state.js index 139dbc2f8c..574da5c84a 100644 --- a/src/pkg/dashboard/static-src/js/config-state.js +++ b/src/pkg/dashboard/static-src/js/config-state.js @@ -130,6 +130,7 @@ { tab: 'Features', section: 'Autonomy & ACMM', label: 'Design-first planning', key: 'planning.design_approved_label', text: 'planning design approved label architect revisions concurrent designs plan from label planning.design_approved_label planning.max_concurrent_designs planning.max_design_revisions planning.plan_from_label' }, { tab: 'Features', section: 'Autonomy & ACMM', label: 'Write-back containment', key: 'writeback.unsolicited.min_level', text: 'write-back writeback containment unsolicited comments labels sentinel hold-gate stage labels opt-in label backfill per repo mode suppressed acmm level duplicate dedupe burst rate cap hourly writeback.unsolicited.min_level writeback.unsolicited.require_labels writeback.unsolicited.backfill writeback.per_repo writeback.kinds unlabeled_min_level own_only without label hive-authored only writeback.dedupe.enabled writeback.dedupe.same_item_ttl writeback.dedupe.burst_items writeback.dedupe.burst_window writeback.dedupe.hourly_cap' }, { tab: 'Features', section: 'Work intake & issue lifecycle', label: 'Superseded PR grace period', key: 'supersession_sweep.grace_period', text: 'supersession superseded grace period close contributor pr supersession_sweep.grace_period' }, + { tab: 'Features', section: 'Quality loops & release health', label: 'Shared-CI recovery', key: 'shared_ci_rerun.enabled', text: 'shared ci rerun re-run failed jobs incident recovery tracking issue outage actions write shared_ci_rerun.enabled' }, { tab: 'Features', section: 'Quality loops & release health', label: 'Compliance posture windows', key: 'compliance.posture_checks.window_days', text: 'compliance posture look-back window history retention compliance.posture_checks.window_days compliance.posture_checks.history_days' }, { tab: 'Features', section: 'Agents & tooling', label: 'Swarm banner wording', key: 'swarm.event_name', text: 'swarm event name call to arms leaderboard title banner swarm.event_name swarm.call_to_arms swarm.leaderboard_title' }, { tab: 'Features', section: 'Agents & tooling', label: 'Tool approval inbox path', key: 'tool_approval.inbox_path', text: 'tool approval inbox pending approvals path tool_approval.inbox_path' }, diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 391a104725..415c6d51f3 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -67229,6 +67229,7 @@

Configure LiteLLM

{ tab: 'Features', section: 'Autonomy & ACMM', label: 'Design-first planning', key: 'planning.design_approved_label', text: 'planning design approved label architect revisions concurrent designs plan from label planning.design_approved_label planning.max_concurrent_designs planning.max_design_revisions planning.plan_from_label' }, { tab: 'Features', section: 'Autonomy & ACMM', label: 'Write-back containment', key: 'writeback.unsolicited.min_level', text: 'write-back writeback containment unsolicited comments labels sentinel hold-gate stage labels opt-in label backfill per repo mode suppressed acmm level duplicate dedupe burst rate cap hourly writeback.unsolicited.min_level writeback.unsolicited.require_labels writeback.unsolicited.backfill writeback.per_repo writeback.kinds unlabeled_min_level own_only without label hive-authored only writeback.dedupe.enabled writeback.dedupe.same_item_ttl writeback.dedupe.burst_items writeback.dedupe.burst_window writeback.dedupe.hourly_cap' }, { tab: 'Features', section: 'Work intake & issue lifecycle', label: 'Superseded PR grace period', key: 'supersession_sweep.grace_period', text: 'supersession superseded grace period close contributor pr supersession_sweep.grace_period' }, + { tab: 'Features', section: 'Quality loops & release health', label: 'Shared-CI recovery', key: 'shared_ci_rerun.enabled', text: 'shared ci rerun re-run failed jobs incident recovery tracking issue outage actions write shared_ci_rerun.enabled' }, { tab: 'Features', section: 'Quality loops & release health', label: 'Compliance posture windows', key: 'compliance.posture_checks.window_days', text: 'compliance posture look-back window history retention compliance.posture_checks.window_days compliance.posture_checks.history_days' }, { tab: 'Features', section: 'Agents & tooling', label: 'Swarm banner wording', key: 'swarm.event_name', text: 'swarm event name call to arms leaderboard title banner swarm.event_name swarm.call_to_arms swarm.leaderboard_title' }, { tab: 'Features', section: 'Agents & tooling', label: 'Tool approval inbox path', key: 'tool_approval.inbox_path', text: 'tool approval inbox pending approvals path tool_approval.inbox_path' }, @@ -83131,6 +83132,14 @@

${esc(s.title)}

Applies on the next posture pass.
+ +
+
Shared-CI recovery ${settingHelpMark('settings', 'features', 'Shared-CI recovery', `When one check fails across many PRs at once, the hive files a [shared-ci] tracking issue. Once that incident is over (the issue is closed, or its check has passed on the PR's base branch again) the rerun sweep re-runs the failed jobs of each PR the incident held red, once per PR per incident, and leaves a short note on the PR.`)}
+
+
+ Re-run PRs after a shared-CI incident ${yamlHint('shared_ci_rerun.enabled')} ${settingHelpMark('settings', 'features', 'Re-run PRs after a shared-CI incident', `On by default. Re-running failed jobs needs Actions: Read and write on the App, which is optional. Without it GitHub refuses each re-run (403) and the PR gets a note asking a maintainer to re-run it; turn this off to stop those attempts and notes. Applies from the next sweep.`)} +
+
`)} ${featuresSectionHtml('integrations', `