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-adoption-superseded-close-and-note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- A PR superseded by a hive adoption now closes promptly and reads as one muted line in the Activity Monitor (hivecommons/hive#15511 listed hive's #15574 *Merge queued* and, under it, the still-open original #15526 whose greyed note "· Adopted → #15574 · superseded (hive re-authored with sign-off)" wrapped to two lines; the close-first close had been refused by the write-back gate with `needs-opt-in-label`). New `governor.labels.stage.adoption.close_superseded: on_adopt|on_merge` (default `on_adopt`): a clanker- or hive-authored original closes in the adopting pass by policy — the gate admits the close as `superseded-agent-pr` without the `contributor_adopt` opt-in label once the copy carries its commits and sign-off; a human-authored original still needs the label, else it closes when the copy merges. The tracker marks the original `superseded_by: M` (cleared when the copy dies, omitted for in-place adoptions) and the copy's `adopted_from.state` / `lineage.from_state`; the muted sub-row's note is now "superseded · hive adopted → #M" ("superseded · closed · hive adopted → #M" once closed) on one line — the title ellipsizes first, the hover carries "re-authored with the same commits and sign-off" and whether it closes when #M merges or is already closed — and the line stays only while #M is open and listed.
1 change: 1 addition & 0 deletions src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func stageLabelPolicyFunc(cfg *config.Config) func() automerge.StageLabelPolicy
AdoptionAutoMerge: stage.Adoption.AutoMergeEnabled(),
AdoptionMaintainerPolicy: stage.Adoption.EffectiveMaintainerPolicy(),
AdoptSupersedeCloseFirst: stage.Adoption.Supersede.CloseFirstEnabled(),
AdoptCloseSuperseded: stage.Adoption.EffectiveCloseSuperseded(),
HiveID: cfg.HiveID,
AuthorKindLabels: cfg.Governor.Labels.Author.Names(),
RelayKnown: contributorRelayKnown,
Expand Down
2 changes: 2 additions & 0 deletions src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@ An adopted pull request names the hive's superseding copy in its detour word (`a

If two copies are closed within an hour the hive stops (`adopted_by_state: "closed-twice"`, park reason `adoption-child-closed-twice`): the row reads "Adopted → #N (closed twice) · needs a person" and the popover question asks you to reopen the last copy, give direction, or close the PR. With close-first supersession (the default, hivecommons/hive#15135) the original is closed in the adopting pass and has **no row** while its copy is open — the copy is the one active PR for the issue, and the original's record is superseded (no chevron, no *Needs human decision*).

A superseded original keeps a muted, chevron-less sub-row under the issue while its superseder is open and listed (hivecommons/hive#15511 showed hive's #15574 *Merge queued* and, beneath it, the still-open #15526 as a greyed line whose note "· Adopted → #15574 · superseded (hive re-authored with sign-off)" wrapped to two lines). The note now reads **"superseded · hive adopted → #M"**, or **"superseded · closed · hive adopted → #M"** once the original is closed, and never wraps — the PR title ellipsizes first; the hover carries the long form ("Hive re-authored this PR as #M with the same commits and sign-off. This PR closes as superseded when #M merges." / "…This PR is closed as superseded."). The tracker sets `superseded_by: M` on the original (omitted for an in-place adoption, cleared when the copy is closed / closed-twice / copy-failed so the original counts again) and `adopted_from.state` / `lineage.from_state` on the copy (`"open"` or `"closed"`). A closed original is listed in this muted form only while #M is open and listed; it leaves the tracker once #M merges or closes. Agent-authored originals close in the adopting pass by policy (`governor.labels.stage.adoption.close_superseded`, default `on_adopt`); a person's PR closes then only with the write-back opt-in label, else when the copy merges — see [hive-merge.md](hive-merge.md).

A copy that then fails (closed unmerged, or red at two heads) reopens the original: `adopted_by_state: "copy-failed"` renders "Adopted → #N (copy failed) · reopened, needs a person" at 085 with the caption "The hive's copy #N failed; this PR was reopened and needs a person".

#### Presence indicator on the waiting-on pill
Expand Down
25 changes: 21 additions & 4 deletions src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,27 @@ then), so the issue list and the PR list read the same
([#12436](https://github.com/hivecommons/hive/issues/12436)).

An adoption pair is one logical PR everywhere a person might otherwise be
asked to pick between PRs (hivecommons/hive#15495). When the write-back gate
keeps the contributor's original open after supersession (`needs-opt-in-label`,
a fork the hive cannot edit), it sits at 072 "superseded by #N" and the
issue's caption, open-PR count, parked-PR check and "Let hive decide — all N
asked to pick between PRs (hivecommons/hive#15495). A clanker- or
hive-authored original closes in the adopting pass by policy
(`governor.labels.stage.adoption.close_superseded: on_adopt`, the default;
`on_merge` keeps it open until the copy merges): the write-back gate admits
the close as `superseded-agent-pr` without the repo opt-in label the
`contributor_adopt` kind otherwise wants, because the copy carries the same
commits and sign-off (hivecommons/hive#15526 sat open beside hive's #15574
as "Adopted → #15574 · superseded" with the gate saying
`needs-opt-in-label`). A human-authored original still needs that opt-in
label to close in the adopting pass; without it the gate keeps it open after
supersession (`needs-opt-in-label`, or a fork the hive cannot edit) and it
sits at 072 "superseded by #N" until the copy merges. Either way the
superseded original draws in the Activity Monitor as one muted,
chevron-less line under the issue (greyed title, no stage strip) whose
trailing note reads "superseded · hive adopted → #M" — or "superseded ·
closed · hive adopted → #M" once it is closed — on a single line (the title
ellipsizes first); the hover carries the long form ("Hive re-authored this
PR as #M with the same commits and sign-off. This PR closes as superseded
when #M merges." / "…is closed as superseded."). The tracker marks it
`superseded_by: M`; the line stays only while #M is open and listed and
drops once #M merges or closes. The issue's caption, open-PR count, parked-PR check and "Let hive decide — all N
PRs" fan-out all see only the hive's copy: the original's review verdict never
gates the issue, and the copy's body carries every `Fixes #N` / `Refs #N` line
of the original (an annotated `Refs #N — partial` travels as the bare
Expand Down
8 changes: 7 additions & 1 deletion src/docs/labels-and-control-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,13 @@ When a contributor-agent PR goes red the hive does not just relabel it (a human-
table in
[operator-reference.md](operator-reference.md#what-hive-writes-to-github-and-when)):
refused, nothing is written and the original stays open on the
keep-open path below until the copy merges. `close_first: false` restores the keep-open behaviour
keep-open path below until the copy merges. A clanker- or
hive-authored original does not need the label: the gate admits its
close as `superseded-agent-pr` by policy
(`governor.labels.stage.adoption.close_superseded`, `on_adopt` by
default, `on_merge` to keep it open until the copy merges), because
the copy carries the same commits and sign-off
(hivecommons/hive#15526). `close_first: false` restores the keep-open behaviour
below: the note has no `close_first` field, the original moves to
`stage/074-adopted-by-hive` (its linked issue mirrors the stage) and
closes only when the copy merges. The hub drops the PR from the
Expand Down
10 changes: 8 additions & 2 deletions src/docs/operator-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,13 @@ label, close and reopen are unsolicited writes on a contributor's PR, so each
first asks the write-back gate as kind `contributor_adopt` (L6 + opt-in label
by default; see [the write-back table](#what-hive-writes-to-github-and-when)):
refused, the original is not closed and stays open on the keep-open path
until the copy merges, and a due reopen waits for the next poll (a pause
until the copy merges, and a due reopen waits for the next poll. A clanker-
or hive-authored original is exempt from the opt-in label: with
`governor.labels.stage.adoption.close_superseded: on_adopt` (the default;
`on_merge` keeps it open until the copy merges) the gate admits its close
as `superseded-agent-pr` once the copy carries its commits and sign-off, so
an agent's PR never lingers open beside hive's copy
(hivecommons/hive#15526) (a pause
lifting lands it; a policy change after the close is warned in the log and
leaves the PR closed until a person reopens it). `close_first:
false` keeps the earlier behaviour: the original moves to 074 and closes
Expand Down Expand Up @@ -1073,7 +1079,7 @@ that level, the power the write-back exists to govern?
| PR↔issue linker (`pr_issue_link.go`, `pr_contributor_link.go`, `linked_prs.go`) | PR watcher | "covered by PR" label on the issue, link comments | issues referenced by any PR | `covered_by_pr_label` → L5 + label |
| Verdict / decision labels (`pr_decision_operator.go`, `human_decision_label.go`, `legacy_decision_labels.go`, `contribute_verdict_settle.go`) | review verdicts, dashboard decisions | `hive:verdict-*`, decision labels | reviewed PRs | `verdict_label` → L3 + label; dashboard-triggered decisions are solicited |
| Contributor adopt / nudge / bot takeover (`automerge/automerge_contributor_*.go`, `automerge_bot_takeover.go`) | auto-merge sweep | adopt comment, update-branch push, workflow approval, nudge comments | contributor PRs in the contributor lane | `contributor_adopt` → L6 + label |
| Adoption close-first (`automerge/automerge_adoption_close_first.go`) | auto-merge sweep, when a supersede adoption opens the hive's copy; close-first poll | close-first note, `hive/superseded` label and close on the original; reopen, copy-failed note and label removal when the copy fails | the contributor's original PR | `contributor_adopt` → L6 + label; refused: the original stays open until the copy merges, and a due reopen waits for the next poll |
| Adoption close-first (`automerge/automerge_adoption_close_first.go`) | auto-merge sweep, when a supersede adoption opens the hive's copy; close-first poll | close-first note, `hive/superseded` label and close on the original; reopen, copy-failed note and label removal when the copy fails | the contributor's original PR | `contributor_adopt` → L6 + label (an agent-authored original closes without the label, `adoption.close_superseded: on_adopt`); refused: the original stays open until the copy merges, and a due reopen waits for the next poll |
| Claims (`prclaims.go`, `claimed_by_label.go`, `cmd/hive/claimswire.go`, `claimescalation.go`) | claim ledger changes | `claimed-by:*` labels, claim/escalation comments | claimed issues | `claim_comment` → L4 + label (hive-claimed issues are own items) |
| Issue close / task-list / decomposed parents (`issue_close.go`, `task_list_sweep.go`, `decomposed_parents.go`, `close_on_merge.go`, `tracking_issue.go`) | merges, sweeps | close, body edits (checkbox ticks), `Refs` rewrites | issues linked from hive PRs | `issue_close`, `parent_issue_edit` → L5 + label; hive-filed issues are own items |
| Gate comments (`pkg/scheduler/clarity_gate.go`, `prior_art_gate.go`, `triage.go`, `issue_blocked.go`, `issue_recheck_soak.go`) | scheduler intake | clarity/prior-art/triage questions, `blocked` labels | issues admitted by the issue filter | `gate_comment` → L5 + label; items carrying the intake label are opted in |
Expand Down
24 changes: 24 additions & 0 deletions src/pkg/config/adoption_close_first_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,27 @@ func TestStageAdoptionSupersedeCloseFirst(t *testing.T) {
}
}
}

// governor.labels.stage.adoption.close_superseded (hivecommons/hive#15586):
// on_adopt by default; on_merge keeps an agent-authored original open until
// the copy merges; unknown or oddly-cased values read as the default.
func TestStageAdoptionCloseSuperseded(t *testing.T) {
if got := (StageAdoptionConfig{}).EffectiveCloseSuperseded(); got != AdoptionCloseSupersededOnAdopt {
t.Fatalf("close_superseded default = %q, want %q", got, AdoptionCloseSupersededOnAdopt)
}
for in, want := range map[string]string{
"{}\n": AdoptionCloseSupersededOnAdopt,
"close_superseded: on_adopt\n": AdoptionCloseSupersededOnAdopt,
"close_superseded: ' On_Merge '\n": AdoptionCloseSupersededOnMerge,
"close_superseded: on_merge\n": AdoptionCloseSupersededOnMerge,
"close_superseded: whenever\n": AdoptionCloseSupersededOnAdopt,
} {
var cfg StageAdoptionConfig
if err := yaml.NewDecoder(strings.NewReader(in)).Decode(&cfg); err != nil {
t.Fatalf("%q: %v", in, err)
}
if got := cfg.EffectiveCloseSuperseded(); got != want {
t.Errorf("%q: EffectiveCloseSuperseded = %q, want %q", in, got, want)
}
}
}
35 changes: 35 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2928,11 +2928,46 @@ type StageAdoptionConfig struct {
// AdoptionMaintainerPolicyNever is the pre-#14524 rule: the hive never
// takes a maintainer's PR over and releases any adoption of one.
MaintainerPolicy string `yaml:"maintainer_policy,omitempty"`
// CloseSuperseded says when a supersede adoption closes a clanker- or
// hive-authored original once the hive's copy carries its commits
// (hivecommons/hive#15526 sat open as "Adopted → #15574 · superseded"
// because the write-back gate wanted a repo opt-in label the
// contributor_adopt kind requires on items the hive did not author):
// AdoptionCloseSupersededOnAdopt (default) closes it in the adopting
// pass by policy — an agent's PR the hive re-authored is one logical PR,
// so no opt-in label is asked for; AdoptionCloseSupersededOnMerge keeps
// it open until the copy merges. Human-authored originals are not
// governed here: they close in the adopting pass only when they carry
// a writeback opt-in label (writeback.kinds.contributor_adopt), else
// when the copy merges.
CloseSuperseded string `yaml:"close_superseded,omitempty"`
// Supersede tunes supersede-mode adoption (the hive-authored copy from
// hive/adopt-<n>).
Supersede StageAdoptionSupersedeConfig `yaml:"supersede,omitempty"`
}

// Values for governor.labels.stage.adoption.close_superseded.
const (
AdoptionCloseSupersededOnAdopt = "on_adopt"
AdoptionCloseSupersededOnMerge = "on_merge"
DefaultAdoptionCloseSuperseded = AdoptionCloseSupersededOnAdopt
)

// AdoptionCloseSupersededValues lists the accepted close_superseded values.
var AdoptionCloseSupersededValues = []string{AdoptionCloseSupersededOnAdopt, AdoptionCloseSupersededOnMerge}

// EffectiveCloseSuperseded normalises CloseSuperseded; empty or unknown
// reads as the default (on_adopt).
func (c StageAdoptionConfig) EffectiveCloseSuperseded() string {
v := strings.ToLower(strings.TrimSpace(c.CloseSuperseded))
for _, p := range AdoptionCloseSupersededValues {
if v == p {
return p
}
}
return DefaultAdoptionCloseSuperseded
}

// StageAdoptionSupersedeConfig is governor.labels.stage.adoption.supersede.
type StageAdoptionSupersedeConfig struct {
// CloseFirst closes the original PR as soon as the hive's copy is open
Expand Down
1 change: 1 addition & 0 deletions src/pkg/config/testdata/agent_runtime_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"StrictAttribution": null,
"AutoMerge": null,
"MaintainerPolicy": "",
"CloseSuperseded": "",
"Supersede": {
"CloseFirst": null
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/api_repo_item_decision_reroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func repoItemAdoptNowResponse(repoFull string, number, superseding int) repoItem
}
out.Status = "adoption-forced"
out.Result.Outcome = "Adoption forced: hive opens its copy on the pass now running."
out.Result.Next = "The contributor PR closes when the hive's copy merges; the author's commits and sign-off are preserved. The row updates when the pass lands."
out.Result.Next = "The contributor PR closes as superseded (an agent's PR in the adopting pass, a person's when the hive's copy merges) and leaves the list; the author's commits and sign-off are preserved. The row updates when the pass lands."
return out
}

Expand Down
Loading
Loading