Skip to content

✨ [v6] workflows: owner toggle for model-based stage derivation from the dashboard - #17887

Merged
clubanderson merged 3 commits into
v6from
topup/v6-workflow-enabled-toggle
Nov 12, 2026
Merged

clubanderson merged 3 commits into
v6from
topup/v6-workflow-enabled-toggle

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Top-up of #17886 onto v6 (cherry-pick of 124a25e; conflicts in openapi.json, api-reference/configuration.md, hive.yaml.example resolved keeping v6 content plus the v5 additions).

Summary

workflow.enabled gates rules-based stage derivation (stageEngineWorkflowFor, stage_tracker_workflows.go) and bound-model label provisioning, but it could only be set by editing hive.yaml. Hosted hives have no YAML access, while binding (PUT /api/workflows/bindings) already works from the dashboard. This closes the gap.

Refs #17620

What changed

API — PUT /api/workflows/enabled {"enabled": bool} (pkg/dashboard/api_workflows.go)

  • requireOwnerRole; 400 on a non-boolean / missing body; 503 without config.
  • Sets Config.Workflow.Enabled, saveConfig() (reverts the flag if the save fails → 500).
  • Audits workflow_enabled / workflow_disabled (a no-op flip is not audited).
  • Returns {enabled, changed, bindings[], warnings?[]}.
  • Liveness: no reload hook needed. cmd/hive/stage_engine.go stageEngineWorkflowFor and the tracker read cfg.Workflow.Enabled on every call, and the hive.yaml reloader does *b.cfg = *newCfg in place, so the next derivation pass sees the new value.
  • Label provisioning on enable: new automerge.Engine.EnsureStageLabels(ctx, owner, repo) exposes the sweep's memoised ensureStageLabels path (built-in family + bound model LabelDefs, GC reconcile, shared tracker memo). cmd/hive/workflow_labels.go wires it as Dependencies.WorkflowProvisionLabels over the process-shared stage-engine options; the handler runs it for every binding when turning on, surfacing failures as warnings[] (the next sweep retries).

UI

  • Settings → Workflows → Library header: owner-only switch Derive stages from bound models (workflow.enabled) with a one-line explanation (off: columns only; on: stages derived by the bound model's rules and model labels provisioned). Confirms before turning on; reflects GET /api/workflows enabled; locked for non-owners and while a PUT is in flight.
  • Settings → Repos binding row: when a binding exists but the flag is off, the hint reads columns only — turn on derivation in Workflows.
  • static/index.html regenerated via go generate; tokens only (--sp-*, --status-warn).

Docs — dashboard/openapi.json (additive), docs/api-reference/configuration.md row (+ citations script passes), design doc note, hive.yaml.example workflow: block, changelog fragment.

Tests

  • TestWorkflowEnabledPut — owner gate, 400 on bad bodies, persist to hive.yaml, audit, provisioning fan-out + warnings, idempotency, save-failure revert, 503 without config.
  • TestWorkflowProvisionLabels* (cmd/hive), TestEnsureStageLabelsExportedUsesEngineTrackerAndPolicy (automerge).
  • TestWorkflowsEnabledToggleWiring / TestWorkflowsEnabledToggleNode (JS harness).
  • check-inline-js.js, check-api-reference-citations.sh, OpenAPI parity tests, gofmt/vet clean.

Flip it by hand

curl -sS -X PUT "$HIVE/api/workflows/enabled" \
  -H "Authorization: Bearer $HIVE_DASHBOARD_TOKEN" -H 'Content-Type: application/json' \
  -d '{"enabled": true}'

…ashboard

workflow.enabled gates rules-based stage derivation and bound-model label
provisioning, but could only be set by editing hive.yaml, which hosted
hives cannot do. Add PUT /api/workflows/enabled {enabled} (owner-gated,
persists hive.yaml, audited workflow_enabled / workflow_disabled) and a
"Derive stages from bound models" switch in Settings → Workflows → Library
that confirms before turning on. The stage engine and the tracker already
read cfg.Workflow.Enabled live and the reloader mutates the same *Config
in place, so no reload hook is needed. Turning on also provisions every
bound repository's model labels at once through the sweep's memoised
ensureStageLabels path (new automerge.Engine.EnsureStageLabels, wired as
Dependencies.WorkflowProvisionLabels); failures come back as warnings and
the next sweep retries. The Repos binding row says "columns only — turn
on derivation in Workflows" when a binding exists while the flag is off.

Refs #17620

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 12, 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

@github-actions

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible — a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking —
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly — that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 12, 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
#17861 ✨ [v6] claude auth: report long-lived-token vs dashboard-sign-in mode on auth status and surface 401 as token rejected same files src/docs/api-reference.md

Refs #17620

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive

hivecommons-hive Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • check-failure

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

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

Read the handler against the v6 tree and the callers it relies on; this looks correct to me.

What I verified

  • src/pkg/dashboard/api_workflows.go:260-300 — PUT /api/workflows/enabled follows the same shape as handleWorkflowBindingPut (owner gate → mutate deps.Config → saveConfig() → audit), and the revert on save failure restores the prior value before the 500.
  • Liveness claim holds: src/cmd/hive/stage_engine.go:71 reads cfg.Workflow.Enabled on every WorkflowFor call, and the reloader at main.go:4055 assigns *b.cfg = *newCfg in place, so the dashboard's deps.Config pointer and the stage engine's cfg are the same object.
  • Memo-sharing claim holds: no cmd/hive caller sets automerge.Options.StageTracker, so both the sweep and the new Engine.EnsureStageLabels (automerge_stage_labels_gc.go:191) fall through stageTrackerOrShared() to sharedStageTracker; a repo already provisioned for the current profile hash is a no-op at automerge_stage_labels.go:1935.
  • workflow_labels.go builds the engine over stageEngineOptions(cfg, logger), which is sync.Once-guarded, so workflowProfile() resolves bindings through the same WorkflowFor the sweep uses.
  • JS: hiveConfirm, wfLibRerender, data-arg-types="t" and _workflowState.enabled (set from GET /api/workflows in config-workflows.js:25) all exist on v6.

One observation, not a defect: provisionBoundWorkflowLabels runs sequentially inside the request under a single 60 s budget (api_workflows.go:246); a hive with many bound repos could see later repos time out and land in warnings[]. The sweep retries, and the UI surfaces the warning, so behaviour is still correct — just something to know when reading a slow toggle.

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

All three red checks (changelog-fragment-guard, relative links and anchors resolve, and native-queue-policy, which only re-reports the first) have a single cause in the cherry-pick conflict resolution of src/docs/api-reference/configuration.md.

The v6 table already contains the 13 rows for /api/config/convergence … /api/config/governor/inference-auth at lines 107-121, with v6-correct citations (api.go:276, :300, :315, :316, …). The resolution kept the v5 copies of the same rows as well, so they appear a second time at lines 122-134 with v5 line numbers (api.go:259, :261, :265 … :298). On v6 those lines don't register those routes — e.g. api.go:259 is PUT /api/config/governor/attribution — which is exactly the 13 DRIFT entries the citation guard prints.

Fix: delete lines 122-134 of configuration.md (keep the new PUT /api/workflows/enabled row at 135, which cites api_workflows.go:28 correctly). bash src/scripts/check-api-reference-citations.sh --fix will not do this for you — it rewrites line numbers, it does not de-duplicate rows.

The Go changes are the same as #17886 (I verified them against the v5 tree there, and the v6 cherry-pick of api_workflows.go, workflow_labels.go, and automerge_stage_labels_gc.go is identical to the v5 diff). No other findings.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

CI triage (hive scanner, comment-only on a contributor-authored branch): all three red checks share one root cause. changelog-fragment-guard fails on api-reference citation drift: src/docs/api-reference/configuration.md:123-134 cite pkg/dashboard/api.go:261-298 for the /api/config/convergence and /api/config/governor/* routes, and this PR's server.go/static edits shifted those lines. native-queue-policy only re-reports that guard (Error: changelog-fragment-guard: failure) and relative links and anchors resolve carries the same DRIFT lines. Fix: bash src/scripts/check-api-reference-citations.sh --fix (and python3 src/scripts/check-docs-citations.py --fix if it reports more), commit the result; if static pages under src/pkg/dashboard/ changed, lower the matching styleRatchetBaselines entry in src/pkg/dashboard/webstatic/style_ratchet_test.go in the same push. relative links and anchors resolve is green on v6, so this is PR-local.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

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

Refs #17620

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

Head 20ff603ba.

⏱️ The 900s mutation budget ran out, so 1 package(s) were not fully mutated and the results below do not cover them:

  • pkg/github/automerge: cut short (partial, no report)

1 mutant(s) in changed files are not reached by any test (NOT COVERED). A maintainer may apply the mutation/acknowledged label to accept this.

File Line Mutation
src/pkg/dashboard/api_workflows.go 246 ARITHMETIC_BASE

Verdict: uncovered (#17349).

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

One cherry-pick artifact to fix before this lands; the Go wiring checks out.

src/docs/api-reference/configuration.md:122-134 — the conflict resolution described in the body ("keeping v6 content plus the v5 additions") re-added 13 rows that already exist at :107-121: /api/config/convergence (GET/PUT), /api/config/governor/advisory, /replan, /work-source, /security, /project-observability, /inference-auth now each appear twice, byte-for-byte identical. Only the final PUT /api/workflows/enabled row (:135) is new. Dropping :122-134 leaves the intended +1 row; src/docs/api-reference.md:16 row count for this page should be re-checked after that.

What I verified in the tree at 20ff603:

  • src/cmd/hive/workflow_labels.go:36-40 builds a fresh automerge.Engine per call, but the memo it relies on is genuinely shared: stageEngineOptions is a sync.Once singleton (src/cmd/hive/stage_engine.go:37-55) and EnsureStageLabels (automerge_stage_labels_gc.go:192-197) goes through stageTrackerOrShared() → sharedStageTracker (automerge_stage_labels.go:461-466). So the "sweep's own memoised path" claim in the body holds.
  • api_workflows.go handler sets Config.Workflow.Enabled before provisioning, and stageEngineWorkflowFor (stage_engine.go:65-67) reads that flag per call, so the model's LabelDefs are included in the provisioning pass rather than only the built-in family.
  • Save failure reverts the flag before returning 500; provisioning failure is a warning, not a failure of the flip — matches the body.

Not a blocker, noting only: the 60s workflowProvisionTimeout is a single budget across all bindings (api_workflows.go provisionBoundWorkflowLabels), so with many bound repos the later ones can time out and land in warnings[]. The sweep retries, so that is acceptable; just expect it on large fleets.

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

@clubanderson
clubanderson merged commit b6ce953 into v6 Nov 12, 2026
81 of 82 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the topup/v6-workflow-enabled-toggle branch November 12, 2026 07:25
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant