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-adopt-supersede-execution-feedback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- A delegated `adopt-supersede` decision no longer reports "done" when only the request label landed: the Activity Monitor βœ“ now reads "decided: adopt-supersede Β· executing…" until the adoption engine records the copy ("adopted as #N") or definitively cannot ("could not adopt: <reason>", with what a person can do). A PR that edits `.github/workflows` is decided as a capability gap and routed to the `capability:workflows-permission` blocker instead of flipping back to a bare Needs human decision; re-adoption after a closed copy surviving the mutation journal landed in [#15209](https://github.com/hivecommons/hive/pull/15209) ([#15188](https://github.com/hivecommons/hive/issues/15188)).
21 changes: 19 additions & 2 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -28354,12 +28354,27 @@
"applied",
"no-op",
"failed",
"superseded-by-state-change"
"superseded-by-state-change",
"executing",
"no-effect",
"blocked"
]
},
"detail": {
"type": "string"
},
"progress": {
"type": "string",
"description": "for an executing/blocked decision: what the worker has done so far or why it could not (e.g. \"adopted as #N\", \"could not adopt: …\")"
},
"blocker": {
"type": "string",
"description": "capability-blocker slug holding the decision (e.g. capability:workflows-permission)"
},
"human": {
"type": "string",
"description": "what, if anything, a person can do now"
},
"head_sha": {
"type": "string"
},
Expand All @@ -28373,7 +28388,9 @@
"addressed",
"stuck",
"pending",
"failed"
"failed",
"executing",
"blocked"
]
},
"stuck_after_seconds": {
Expand Down
16 changes: 15 additions & 1 deletion src/pkg/dashboard/api_repo_item_decide_delegated.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand All @@ -18,6 +18,7 @@
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/delegatedecision"
ghpkg "github.com/hivecommons/hive/pkg/github"
stageengineprstage "github.com/hivecommons/hive/pkg/stageengine/prstage"
"github.com/hivecommons/hive/pkg/stagelabels"
)

Expand Down Expand Up @@ -612,7 +613,9 @@
for _, f := range files {
if !delegatedLowRiskPath(f.GetFilename()) {
in.LowRiskPaths = false
break
}
if delegatedWorkflowPath(f.GetFilename()) {
in.WorkflowPath = true
}
}
}
Expand All @@ -637,6 +640,9 @@
if in.Kind == delegatedecision.KindPR && !in.HiveAuthored {
in.AdoptionGraceElapsed = s.delegatedAdoptionGraceElapsed(repoFull, number)
}
if strings.Contains(lowerReason, stageengineprstage.ContributorLaneReasonWorkflowPath) {
in.WorkflowPath = true
}
in.ReporterTrustHold = strings.Contains(lowerReason, "reporter-trust") || strings.Contains(lowerReason, "reporter trust")
in.DCOMissing = strings.Contains(lowerReason, "dco")
return in, nil
Expand Down Expand Up @@ -679,6 +685,14 @@
return len(summary.Red) == 0 && summary.Pending == 0 && summary.Green > 0, nil
}

// delegatedWorkflowPath reports a file under .github/workflows: the adoption
// fence refuses to publish such edits from the App (no `workflows`
// permission), so an adopt-supersede on the PR cannot execute
// (hivecommons/hive#15188).
func delegatedWorkflowPath(path string) bool {
return strings.HasPrefix(strings.ToLower(strings.TrimSpace(path)), ".github/workflows/")
}

// delegatedLowRiskPath reports a file whose change the policy calls low-risk:
// CI / workflow config, docs and text, changelog fragments.
func delegatedLowRiskPath(path string) bool {
Expand Down
93 changes: 93 additions & 0 deletions src/pkg/dashboard/api_repo_item_decide_delegated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/delegatedecision"
"github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/stagelabels"
)

func newDelegatedServer(t *testing.T, mock *repoItemDecisionMock) *Server {
Expand Down Expand Up @@ -684,3 +685,95 @@ func TestDelegatedAsyncFanOutSettlesOperatorAction(t *testing.T) {
}
}
}

// hivecommons/hive#15188: a delegated adopt-supersede is not "done" when
// the request label lands. The ledger reads `executing` until the adoption
// engine records a copy, then "adopted as #N"; a workflow-path PR is a
// capability gap and routes to the workflows blocker instead of a bare
// Needs human decision.
func TestDelegatedAdoptSupersedeReportsExecutingUntilAdopted(t *testing.T) {
pinDelegatedClock(t, "2026-10-28T14:23:00Z")
now := time.Date(2026, 10, 28, 14, 23, 0, 0, time.UTC)
mock := &repoItemDecisionMock{prForeign: true, prRedCI: true, prMergeState: "blocked", prLabels: []string{"stage/085-needs-decision", "needs-human"}}
srv := newDelegatedServer(t, mock)
srv.deps.Config.Governor.Labels.Stage.Adoption.Enabled = boolPtr(true)
srv.operatorActionStore = newOperatorActionStore("")
srv.stageStore = stagelabels.NewStore("", func() time.Time { return now })
key := stagelabels.Key("testorg/testrepo", 8)
srv.stageStore.Observe(key, stagelabels.NeedsDecision, "adoption-stalled:contributor-lane:ci-red")

w := postDelegated(t, srv, 8, "writer", `{"type":"pr","reason":"adoption-stalled:contributor-lane:ci-red","caption":"adoption stalled"}`, nil)
if w.Code != http.StatusOK {
t.Fatalf("code=%d body=%s", w.Code, w.Body.String())
}
job := decodeDelegatedJob(t, w)
if job.Decision == nil || job.Decision.Verdict != delegatedecision.VerdictAdoptSupersede {
t.Fatalf("decision = %+v err=%s", job.Decision, job.Error)
}
if !strings.Contains(strings.Join(mock.added, ","), delegatedecision.LabelAdoptSupersede) {
t.Fatalf("request label not queued: %v", mock.added)
}
acts := srv.operatorActions().List("testorg/testrepo", 8)
if len(acts) != 1 || acts[0].Outcome != operatorActionOutcomeExecuting || !strings.Contains(acts[0].Detail, "executing") {
t.Fatalf("ledger after decision = %+v", acts)
}

// Before the engine runs: the row says the hive is carrying it out.
items := []StageTrackerItem{{Repo: "testorg/testrepo", Number: 8, Stage: 85, Head: "aaa"}}
srv.applyOperatorActions(items, now.Add(time.Minute))
last := items[0].LastOperatorAction
if last == nil || last.State != operatorActionStateExecuting || last.Progress == "" || last.Human != "" {
t.Fatalf("row before adoption = %+v", last)
}

// The adoption engine opened the copy: the same record now reads
// "adopted as #91" and is addressed, whatever stage the row sits at.
srv.stageStore.MarkAdopted(key, "aaa", 91, now.Add(2*time.Minute))
srv.invalidateStageTrackerCache()
items = []StageTrackerItem{{Repo: "testorg/testrepo", Number: 8, Stage: 85, Head: "aaa"}}
srv.applyOperatorActions(items, now.Add(3*time.Minute))
last = items[0].LastOperatorAction
if last == nil || last.State != operatorActionStateAddressed || last.Outcome != operatorActionOutcomeApplied || !strings.Contains(last.Progress, "adopted as #91") {
t.Fatalf("row after adoption = %+v", last)
}

// The engine refused the head instead (workflow path): blocked on the
// workflows capability, with what a person can do.
srv.stageStore.ClearAdoption(key)
srv.stageStore.MarkAdoptionEscalated(key, "aaa", "adoption-stalled:contributor-lane:workflow-path")
srv.invalidateStageTrackerCache()
items = []StageTrackerItem{{Repo: "testorg/testrepo", Number: 8, Stage: 85, Head: "aaa"}}
srv.applyOperatorActions(items, now.Add(3*time.Minute))
last = items[0].LastOperatorAction
if last == nil || last.State != operatorActionStateBlocked || last.Blocker != operatorActionBlockerWorkflows || last.Human == "" || !strings.Contains(last.Progress, "could not adopt") {
t.Fatalf("row after refusal = %+v", last)
}
}

// A PR that edits .github/workflows gets a capability-gap recommendation,
// not an adopt-supersede the engine would refuse; the ledger is `blocked`.
func TestDelegatedWorkflowPathIsCapabilityGap(t *testing.T) {
pinDelegatedClock(t, "2026-10-28T14:23:00Z")
mock := &repoItemDecisionMock{prForeign: true, prRedCI: true, prMergeState: "blocked", prLabels: []string{"stage/085-needs-decision", "needs-human"}}
srv := newDelegatedServer(t, mock)
srv.deps.Config.Governor.Labels.Stage.Adoption.Enabled = boolPtr(true)
srv.operatorActionStore = newOperatorActionStore("")
w := postDelegated(t, srv, 8, "writer", `{"type":"pr","reason":"adoption-stalled:contributor-lane:workflow-path","caption":"adoption stalled: contributor lane: workflow path"}`, nil)
if w.Code != http.StatusOK {
t.Fatalf("code=%d body=%s", w.Code, w.Body.String())
}
job := decodeDelegatedJob(t, w)
if job.Decision == nil || job.Decision.Rule != delegatedecision.RuleCapabilityGap || !job.Decision.KeepsPark {
t.Fatalf("decision = %+v err=%s", job.Decision, job.Error)
}
if strings.Contains(strings.Join(mock.added, ","), delegatedecision.LabelAdoptSupersede) {
t.Fatalf("adoption queued despite the capability gap: %v", mock.added)
}
acts := srv.operatorActions().List("testorg/testrepo", 8)
if len(acts) != 1 || acts[0].Outcome != operatorActionOutcomeBlocked {
t.Fatalf("ledger = %+v", acts)
}
if got := srv.delegatedStuckWhy(delegatedecision.Input{Kind: delegatedecision.KindPR, WorkflowPath: true}, delegatedecision.Decision{Verdict: delegatedecision.VerdictAdoptSupersede}, delegatedDecisionRequest{}, delegatedPriorState{Found: true}); got != delegatedecision.GlossaryWorkflowPath {
t.Fatalf("stuck why = %q", got)
}
}
3 changes: 3 additions & 0 deletions src/pkg/dashboard/delegated_decision_effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (s *Server) delegatedStuckWhy(in delegatedecision.Input, d delegatedecision
return false
}
if d.Verdict == delegatedecision.VerdictAdoptSupersede {
if in.WorkflowPath {
return delegatedecision.GlossaryWorkflowPath
}
if in.ContributorOnline {
return delegatedecision.GlossaryAuthorOnline
}
Expand Down
Loading
Loading