Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-writeback-kind-table-parity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Saving the write-back per-kind matrix under Settings → Features no longer wipes overrides it could not show. The table edited only `min_level` and `require_label` but rebuilt the whole `writeback.kinds` map on save, so any edit there silently dropped every kind's `unlabeled_min_level` and `own_only` (and an own-only kind's `min_level`), undoing what hive.yaml or the admin MCP `writeback.kind_policy` operation had set. The table now has *Without label* and *Hive-authored only* columns for those two fields, and saving sends each kind's override with every field nobody changed on the page kept as it was; the `writeback.kind_policy` preview no longer warns about the dashboard dropping them (#17555).
10 changes: 5 additions & 5 deletions src/docs/admin-mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -851,11 +851,11 @@ change between the preview and the confirm, the confirm is refused; preview
again. Neither operation kicks an agent, labels, approves or merges anything
itself.

The dashboard's write-back kind table edits only `min_level` and
`require_label`, and saving an edit there rewrites every kind's override from
the table, which drops `unlabeled_min_level` and `own_only`. The
`writeback.kind_policy` preview warns when an override it writes carries
either.
The dashboard's write-back kind table (Settings → Features → Write-back
containment) edits the same four fields. Saving there sends every kind's
override from the table, and a field nobody changed on the page is sent as
it was, so an override written by `writeback.kind_policy` survives a later
dashboard edit.

`auto_merge.update` changes merge settings, the same settings as the
dashboard's merge controls, through `PATCH /api/config/auto-merge`. It is owner
Expand Down
13 changes: 8 additions & 5 deletions src/docs/operator-reference/sweeps-and-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,14 @@ the foreign PR.
The gate is per write-back *kind*. Each kind has a minimum ACMM level and
whether the review opt-in label (`review.require_labels`, default
`hive-review`) is required on the PR; both are overridable per kind under
`writeback.kinds.<kind>.{min_level, require_label, unlabeled_min_level}`.
An owner changes these under Settings → Features, or with the admin MCP
operation `writeback.kind_policy`, which also sets `unlabeled_min_level` and
`own_only` and keeps the overrides of kinds it does not name
([admin-mcp.md](../admin-mcp.md#registered-operations)).
`writeback.kinds.<kind>.{min_level, require_label, unlabeled_min_level, own_only}`.
`unlabeled_min_level` is the level from which the kind also writes on an
item without the opt-in label; `own_only` keeps it to hive-authored items.
An owner changes all four in the per-kind matrix under Settings → Features
(columns *Min level*, *Opt-in label*, *Without label*, *Hive-authored only*;
saving keeps every field nobody changed on the page), or with the admin MCP
operation `writeback.kind_policy`, which keeps the overrides of kinds it
does not name ([admin-mcp.md](../admin-mcp.md#registered-operations)).
The rationale for each default is the same question: does the hive have, at
that level, the power the write-back exists to govern?

Expand Down
9 changes: 1 addition & 8 deletions src/pkg/adminmcp/tools_cadence_writeback_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func (writebackKindPolicyOp) PreviewWithProvider(ctx context.Context, args map[s
}

var changes []settingChange
var widen, narrow, changed, dashboardLossy []string
var widen, narrow, changed []string
for _, kind := range named {
cur, present := st.Kinds[kind]
next, err := applyWritebackKindChange(kind, cur, present, req[kind])
Expand Down Expand Up @@ -719,15 +719,11 @@ func (writebackKindPolicyOp) PreviewWithProvider(ctx context.Context, args map[s
var kept []string
for k, ov := range after {
kindsBody[k] = writebackKindOverrideBody(ov)
if ov.UnlabeledMinLevel != nil || ov.OwnOnly != nil {
dashboardLossy = append(dashboardLossy, k)
}
if _, isNamed := req[k]; !isNamed {
kept = append(kept, k)
}
}
sort.Strings(kept)
sort.Strings(dashboardLossy)

effects := make([]string, 0, len(changes)+5)
for _, c := range changes {
Expand All @@ -741,9 +737,6 @@ func (writebackKindPolicyOp) PreviewWithProvider(ctx context.Context, args map[s
"Hive saves it through Settings → Features (PUT /api/config/governor/features, writebackKinds), records a config_governor_features audit entry, and the write-back gate applies it from its next decision, with no restart. That endpoint replaces the whole override map, so this write sends every override with the change merged in. "+keptNote,
"The effective policy shown ignores writeback.unsolicited.min_level, which when set still raises every kind's level, and writeback.per_repo, which still sets each repository's mode.",
)
if len(dashboardLossy) > 0 {
effects = append(effects, "Settings → Features' write-back kind table edits only min_level and require_label, and saving an edit there rewrites every kind's override from that table: it would drop unlabeled_min_level and own_only from "+strings.Join(dashboardLossy, ", ")+". Change those through this operation or hive.yaml.")
}
effects = append(effects, "This write itself posts, labels, closes and merges nothing.")

narrowNote := ""
Expand Down
7 changes: 6 additions & 1 deletion src/pkg/adminmcp/tools_cadence_writeback_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,16 @@ func TestWritebackKindPolicyOpKeepsUntouchedKinds(t *testing.T) {
t.Fatalf("request = %s %s %s, want PUT /api/config/governor/features %s", preview.Request.Method, preview.Request.Path, bodyJSON(t, preview.Request.Body), want)
}
effects := strings.Join(preview.Effects, "\n")
for _, s := range []string{"writeback.kinds.base_refresh: no override → {unlabeled_min_level: 6}", "L6 with the opt-in label → L6, any item", "(stage_label) are sent unchanged", "would drop unlabeled_min_level and own_only from base_refresh"} {
for _, s := range []string{"writeback.kinds.base_refresh: no override → {unlabeled_min_level: 6}", "L6 with the opt-in label → L6, any item", "(stage_label) are sent unchanged"} {
if !strings.Contains(effects, s) {
t.Errorf("effects lack %q:\n%s", s, effects)
}
}
// Settings → Features' kind table now edits and keeps all four fields,
// so the preview no longer warns that a dashboard save would drop them.
if strings.Contains(effects, "would drop") {
t.Errorf("effects still warn that the dashboard drops fields:\n%s", effects)
}
if _, err := h.ConfirmWrite(context.Background(), map[string]any{"confirmation_id": id}); err != nil {
t.Fatalf("confirm: %v", err)
}
Expand Down
2 changes: 0 additions & 2 deletions src/pkg/dashboard/settings_parity_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,6 @@ runs.spektacular.interview # TODO #11854
task_mcp.launch_token_ttl # TODO #11854
task_mcp.lease_rate_limit_per_minute # TODO #11854
upstream_watch.repos.<key>.start_from # TODO #11854
writeback.kinds.<key>.own_only # policy-file knob; the Settings matrix shows it read-only as the kind's scope
writeback.kinds.<key>.unlabeled_min_level # policy-file knob; the Settings matrix shows it read-only in the kind's scope
governor.hotspot_enabled # merge-hotspot advisor; yaml-only
governor.hotspot_window_days # merge-hotspot advisor; yaml-only
governor.hotspot_min_prs # merge-hotspot advisor; yaml-only
Expand Down
36 changes: 29 additions & 7 deletions src/pkg/dashboard/static-src/js/config-sentinel.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,17 @@
const k = String(row.kind || ''); const p = row.policy || {}; const ov = overrides[k] || {};
const scope = p.own_only ? 'hive-authored only' : (p.require_label ? 'opt-in label' : 'any item');
const unl = p.unlabeled_min_level ? ` · without label L${esc(String(p.unlabeled_min_level))}` : '';
return `<tr data-wb-kind="${esc(k)}">
const unlOptions = [0, 1, 2, 3, 4, 5, 6].map(n => `<option value="${n}" ${ov.unlabeled_min_level === n ? 'selected' : ''}>${n ? 'L' + n : '0 (off)'}</option>`).join('');
// data-wb-override carries the override this row was rendered from,
// so markDirtyWritebackKinds keeps any field whose control is absent
// or disabled here (an own-only kind's level and label) on save.
return `<tr data-wb-kind="${esc(k)}" data-wb-override="${esc(JSON.stringify(ov))}">
<td><code>${esc(k)}</code></td>
<td>${esc(scope)}${unl}</td>
<td><input type="number" min="0" max="6" step="1" class="wb-kind-level" data-setting-key="writeback.kinds.<key>.min_level" value="${esc(ov.min_level != null ? String(ov.min_level) : '')}" placeholder="${esc(String(p.min_level || 0))}" ${p.own_only ? 'disabled title="hive-authored items only; the ACMM floor is the hold-gate level"' : ''} data-change-action="markDirtyWritebackKinds" aria-label="${esc(k)} minimum level"></td>
<td>${p.own_only ? '—' : `<select class="wb-kind-label" data-setting-key="writeback.kinds.<key>.require_label" data-change-action="markDirtyWritebackKinds" aria-label="${esc(k)} requires opt-in label"><option value="" ${ov.require_label == null ? 'selected' : ''}>default (${p.require_label ? 'yes' : 'no'})</option><option value="true" ${ov.require_label === true ? 'selected' : ''}>yes</option><option value="false" ${ov.require_label === false ? 'selected' : ''}>no</option></select>`}</td>
<td>${p.own_only ? '—' : `<select class="wb-kind-unlabeled" data-setting-key="writeback.kinds.<key>.unlabeled_min_level" data-change-action="markDirtyWritebackKinds" aria-label="${esc(k)} level without the opt-in label"><option value="" ${ov.unlabeled_min_level == null ? 'selected' : ''}>default (${p.unlabeled_min_level ? 'L' + esc(String(p.unlabeled_min_level)) : 'off'})</option>${unlOptions}</select>`}</td>
<td><select class="wb-kind-own" data-setting-key="writeback.kinds.<key>.own_only" data-change-action="markDirtyWritebackKinds" aria-label="${esc(k)} writes on hive-authored items only"><option value="" ${ov.own_only == null ? 'selected' : ''}>default (${p.own_only ? 'yes' : 'no'})</option><option value="true" ${ov.own_only === true ? 'selected' : ''}>yes</option><option value="false" ${ov.own_only === false ? 'selected' : ''}>no</option></select></td>
</tr>`;
}).join('');
return `
Expand All @@ -157,8 +163,8 @@
<div class="config-toggle" data-setting-key="writeback.unsolicited.require_labels"><div class="config-toggle-switch ${f.writebackRequireLabels !== false ? 'on' : ''}" data-action="toggleConfigSwitch" data-section="features" data-key="writebackRequireLabels"></div><span class="config-toggle-label">Only PRs carrying the review opt-in label ${settingHelpMark('settings', 'features', 'Write-back requires opt-in label', `When on (default), unsolicited write-backs on a foreign PR also need the review opt-in label (${esc(optIn)}, from review.require_labels). Turning it off lets each kind's level floor alone decide.`)}</span></div>
<div class="config-toggle" data-setting-key="writeback.unsolicited.backfill"><div class="config-toggle-switch ${f.writebackBackfill ? 'on' : ''}" data-action="toggleConfigSwitch" data-section="features" data-key="writebackBackfill"></div><span class="config-toggle-label">Backfill pre-existing items ${settingHelpMark('settings', 'features', 'Write-back backfill', `Off (default): when hive first sees a repo, or first gains write access to one, PRs and issues created before that moment are never written to unsolicited. On: process them like new items.`)}</span></div>
<div class="config-field"><label>Per-repo mode ${yamlHint('writeback.per_repo')} ${settingHelpMark('settings', 'features', 'Write-back per-repo mode', `One <code>owner/name=mode</code> per line. Modes: ${esc(modes.join(', '))}. <code>off</code> writes nothing unsolicited there; <code>issues-only</code> allows only hive-filed issues (e.g. a repo listed so the deps agent can file regressions); <code>labels-only</code> allows labels but no comments; <code>full</code> skips the level and label gates for that repo. Empty lines clear.`)}</label><textarea rows="3" spellcheck="false" data-setting-key="writeback.per_repo.<key>.mode" placeholder="torch-spyre/torch-spyre=issues-only" data-change-action="markDirtyWritebackPerRepo" data-arg-types="v">${esc(perRepoText)}</textarea></div>
<details class="config-field"><summary>Per-kind matrix ${yamlHint('writeback.kinds.<kind>.{min_level,require_label}')} ${settingHelpMark('settings', 'features', 'Write-back per-kind matrix', `What hive will say on GitHub at each ACMM level. Each kind has a minimum level and whether the opt-in label is required; leave a cell empty to keep the default shown as placeholder.`)}</summary>
<table class="qa-table" id="wb-kind-table"><thead><tr><th>Kind</th><th>Scope</th><th>Min level</th><th>Opt-in label</th></tr></thead><tbody>${rows}</tbody></table>
<details class="config-field"><summary>Per-kind matrix ${yamlHint('writeback.kinds.<kind>.{min_level,require_label,unlabeled_min_level,own_only}')} ${settingHelpMark('settings', 'features', 'Write-back per-kind matrix', `What hive will say on GitHub at each ACMM level. Each kind has a minimum level, whether the opt-in label is required, the level from which it also writes on items without that label, and whether it writes on hive-authored items only. Leave a cell empty or on default to keep the value shown. Saving sends every kind's override from this table; a field you did not change is kept.`)}</summary>
<table class="qa-table" id="wb-kind-table"><thead><tr><th>Kind</th><th>Scope</th><th>Min level</th><th>Opt-in label</th><th>Without label ${settingHelpMark('settings', 'features', 'Write-back level without the opt-in label', `<code>unlabeled_min_level</code>: from this ACMM level the kind also writes on items that do not carry the opt-in label (the sentinel's "L5 with the label, L6 without"). 0 (off) never admits an unlabelled item; default keeps the value shown. Only matters while the kind requires the label.`)}</th><th>Hive-authored only ${settingHelpMark('settings', 'features', 'Write-back hive-authored only', `<code>own_only</code>: yes means the kind writes only on PRs and issues hive opened, never on anyone else's at any level, and the level and label cells no longer apply. Default keeps the value shown.`)}</th></tr></thead><tbody>${rows}</tbody></table>
</details>
<div class="qa-schedule">
<div class="qa-schedule-label">Suppressed write-backs (last 24h): <span id="wb-suppressed-count">…</span></div>
Expand All @@ -179,13 +185,29 @@
markDirty('features', 'writebackPerRepo', out);
}

// The Features endpoint replaces the whole writeback.kinds map, so every
// row is rebuilt here. Each starts from the override it was rendered with
// (data-wb-override) and only a live control changes its field: a field
// with no control on the row, or a disabled one, is sent unchanged.
function markDirtyWritebackKinds() {
const out = {};
document.querySelectorAll('#wb-kind-table tr[data-wb-kind]').forEach(tr => {
const kind = tr.dataset.wbKind; const lvl = tr.querySelector('.wb-kind-level'); const lab = tr.querySelector('.wb-kind-label');
const ov = {};
if (lvl && !lvl.disabled && lvl.value !== '') ov.min_level = +lvl.value;
if (lab && lab.value !== '') ov.require_label = lab.value === 'true';
const kind = tr.dataset.wbKind;
let ov = {};
try { ov = Object.assign({}, JSON.parse(tr.dataset.wbOverride || '{}')); } catch (e) { ov = {}; }
const level = (el, field) => {
if (!el || el.disabled) return;
if (el.value === '') delete ov[field]; else ov[field] = +el.value;
};
const flag = (el, field) => {
if (!el || el.disabled) return;
if (el.value === '') delete ov[field]; else ov[field] = el.value === 'true';
};
level(tr.querySelector('.wb-kind-level'), 'min_level');
flag(tr.querySelector('.wb-kind-label'), 'require_label');
level(tr.querySelector('.wb-kind-unlabeled'), 'unlabeled_min_level');
flag(tr.querySelector('.wb-kind-own'), 'own_only');
Object.keys(ov).forEach(field => { if (ov[field] == null) delete ov[field]; });
out[kind] = Object.keys(ov).length ? ov : null;
});
markDirty('features', 'writebackKinds', out);
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/static-src/js/config-state.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading