From 5806a234f8178364a6eadeac86724b0372eb1e3a Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 20:15:06 -0400 Subject: [PATCH 1/5] adoption: close agent-authored superseded originals on adopt by policy The write-back gate refused the close-first of #15526 (odttlnt's clanker PR, re-authored as #15574) with needs-opt-in-label: contributor_adopt requires a repo opt-in label on items the hive did not author. An agent's PR the hive has re-authored is one logical PR of the hive's own, so the gate now allows the adoption kind on an agent-authored item whose copy is on record (superseded-agent-pr). governor.labels.stage.adoption. close_superseded: on_adopt (default) | on_merge chooses when; a person's original keeps needing the label. Signed-off-by: Andrew Anderson --- src/cmd/hive/merge_eligibility.go | 1 + src/pkg/config/config.go | 35 +++++++ .../automerge_adoption_close_first.go | 38 +++++++- .../automerge_adoption_close_first_test.go | 96 ++++++++++++++++++- .../automerge/automerge_stage_labels.go | 8 ++ src/pkg/writeback/gate.go | 24 +++++ src/pkg/writeback/writeback_test.go | 17 ++++ 7 files changed, 216 insertions(+), 3 deletions(-) diff --git a/src/cmd/hive/merge_eligibility.go b/src/cmd/hive/merge_eligibility.go index 73b2ad6941..ea4e33ede1 100644 --- a/src/cmd/hive/merge_eligibility.go +++ b/src/cmd/hive/merge_eligibility.go @@ -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, diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 3a19be1bf2..026fe86b08 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -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-). 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 diff --git a/src/pkg/github/automerge/automerge_adoption_close_first.go b/src/pkg/github/automerge/automerge_adoption_close_first.go index 0f711eea45..d3efdeaba8 100644 --- a/src/pkg/github/automerge/automerge_adoption_close_first.go +++ b/src/pkg/github/automerge/automerge_adoption_close_first.go @@ -10,6 +10,8 @@ import ( "time" gh "github.com/google/go-github/v72/github" + "github.com/hivecommons/hive/pkg/authorkind" + "github.com/hivecommons/hive/pkg/config" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/stagelabels" "github.com/hivecommons/hive/pkg/writeback" @@ -41,6 +43,16 @@ import ( // the original open on the keep-open path; a refused reopen leaves the // record due its next poll, so the reopen lands once the gate allows it // (e.g. when an operator lifts a repo pause). +// +// An agent-authored original (a contributor's clanker or another hive, +// hivecommons/hive#15526) is the exception: under +// governor.labels.stage.adoption.close_superseded: on_adopt (default) the +// gate item names the copy that carries its commits and the gate allows the +// close by policy (writeback.ReasonSupersededAgentPR) — no repo opt-in +// label is asked for, because the pair is one logical PR of the hive's own. +// on_merge skips close-first for those and lets settleSuperseder close them +// when the copy merges. A human's original is never closed on adopt without +// the opt-in label. // AdoptionCopyFailedMarker opens the note posted when the hive reopens (or, // past the reopen guard, declines to reopen) a close-first original. @@ -112,6 +124,25 @@ func AdoptionCopyFailedHeldComment(copy int, head, why string, redHeads int, reo AdoptionCopyFailedMarker, copy, head, why, copy, adoptionCopyFailedWhy(why, redHeads), ago) } +// closeFirstGateItem is the write-back gate's view of an original about to +// be closed in favour of its copy `superseding`. An agent-authored +// original (author/clanker, author/hive) under close_superseded on_adopt +// (the default) names the copy so the gate allows the close by policy +// (writeback.ReasonSupersededAgentPR); under on_merge it reports onMerge +// and the caller leaves the original to settleSuperseder. A person's +// original is the plain gated item whatever the policy says. +func closeFirstGateItem(obs stageObservation, policy StageLabelPolicy, superseding int) (item writeback.Item, onMerge bool) { + item = writebackItemForObservation(obs) + if obs.AuthorKind != authorkind.Clanker && obs.AuthorKind != authorkind.Hive { + return item, false + } + if policy.AdoptCloseSuperseded == config.AdoptionCloseSupersededOnMerge { + return item, true + } + item.AgentAuthored, item.SupersededBy = true, superseding + return item, false +} + // closeSupersededOriginalFirst closes the original right after its copy // opened. The comment goes first so GitHub shows why before the close; // the record is marked as soon as the note is out so nothing re-posts it. @@ -123,7 +154,12 @@ func (c *Engine) closeSupersededOriginalFirst(ctx context.Context, store *stagel owner, repo, number := obs.Owner, obs.Repo, obs.Number logArgs := []any{"repo", obs.Display, "pr", number, "head", obs.HeadSHA, "superseded_by", superseding, "reason", reason} body := AdoptionCloseFirstComment(obs, policy.HiveID, superseding, reason) + adoptionFenceNote(fence) - if d := c.writebackAllowed(obs.Display, writebackItemForObservation(obs), writeback.KindContributorAdopt, body); !d.Allowed { + item, onMerge := closeFirstGateItem(obs, policy, superseding) + if onMerge { + c.info("stage labels: agent-authored original left open until the copy merges (close_superseded: on_merge)", logArgs...) + return 0, nil + } + if d := c.writebackAllowed(obs.Display, item, writeback.KindContributorAdopt, body); !d.Allowed { c.info("stage labels: close-first adoption suppressed by the write-back gate; original left open on the keep-open path", append(logArgs, "writeback_reason", d.Reason, "writeback_detail", d.Detail)...) return 0, nil } diff --git a/src/pkg/github/automerge/automerge_adoption_close_first_test.go b/src/pkg/github/automerge/automerge_adoption_close_first_test.go index 723a5f44db..310d708e56 100644 --- a/src/pkg/github/automerge/automerge_adoption_close_first_test.go +++ b/src/pkg/github/automerge/automerge_adoption_close_first_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + "github.com/hivecommons/hive/pkg/authorkind" + "github.com/hivecommons/hive/pkg/config" "github.com/hivecommons/hive/pkg/delegatedecision" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/stagelabels" @@ -341,6 +343,9 @@ func TestAdoptionCloseFirstReopenPingPongGuard(t *testing.T) { type closeFirstGateState struct { adoptOff bool paused bool + // requireLabel keeps the contributor_adopt kind's default opt-in label + // requirement (the live hive's needs-opt-in-label refusal on #15526). + requireLabel bool } // installWritebackGate puts a write-back gate on the harness's client at @@ -355,12 +360,12 @@ func (h *closeFirstHarness) installWritebackGate(st *closeFirstGateState) *write return writeback.RepoPauseInfo{By: "ops", Reason: "freeze"}, st.paused }, Config: func() writeback.Config { - one, no, yes, ownOnly := 1, false, true, st.adoptOff + one, no, yes, ownOnly, adoptLabel := 1, false, true, st.adoptOff, st.requireLabel return writeback.Config{ Unsolicited: writeback.UnsolicitedConfig{Backfill: &yes}, Kinds: map[string]writeback.KindPolicyOverride{ string(writeback.KindStageLabel): {MinLevel: &one, RequireLabel: &no}, - string(writeback.KindContributorAdopt): {MinLevel: &one, RequireLabel: &no, OwnOnly: &ownOnly}, + string(writeback.KindContributorAdopt): {MinLevel: &one, RequireLabel: &adoptLabel, OwnOnly: &ownOnly}, }, } }, @@ -436,6 +441,93 @@ func TestAdoptionCloseFirstWritebackGate(t *testing.T) { }) } +// hivecommons/hive#15526: with the contributor_adopt kind requiring a repo +// opt-in label (the default), an agent-authored original the hive has +// re-authored closes on adopt by policy (close_superseded: on_adopt, +// writeback.ReasonSupersededAgentPR); on_merge leaves it to the merge-time +// close. A person's original still needs the label (TestCloseFirstGateItem +// and the gate's own decision table). +func TestAdoptionCloseFirstSupersededAgentPolicy(t *testing.T) { + run := func(t *testing.T, policy StageLabelPolicy) (*closeFirstHarness, *writeback.Gate, func()) { + t.Helper() + h, done := newCloseFirstHarness(t, policy) + gate := h.installWritebackGate(&closeFirstGateState{requireLabel: true}) + h.adoptCloseFirst() + return h, gate, done + } + t.Run("clanker original closes on adopt without the label", func(t *testing.T) { + h, gate, done := run(t, closeFirstPolicy()) + defer done() + if len(h.adopt.pulls) != 1 { + t.Fatalf("copy not opened: pulls=%d", len(h.adopt.pulls)) + } + if len(h.adopt.prEdits) != 1 || h.adopt.prEdits[0] != "7:closed" { + t.Fatalf("original not closed: %v", h.adopt.prEdits) + } + if c := adoptionComments(h.api); len(c) != 1 || !strings.Contains(c[0], "close_first=true") || !strings.Contains(c[0], "same commits and sign-off") { + t.Fatalf("comments: %v", h.api.comments) + } + if rec := h.record(); !rec.SupersededClosedFirst || rec.SupersededBy != 90 || rec.SupersededOpen { + t.Fatalf("record = %+v", rec) + } + if s := suppressedFor(gate, 7, writeback.KindContributorAdopt); len(s) != 0 { + t.Fatalf("suppressed = %+v", s) + } + }) + t.Run("on_merge leaves a clanker original open until the copy merges", func(t *testing.T) { + p := closeFirstPolicy() + p.AdoptCloseSuperseded = config.AdoptionCloseSupersededOnMerge + h, gate, done := run(t, p) + defer done() + if len(h.adopt.pulls) != 1 || len(h.adopt.prEdits) != 0 { + t.Fatalf("pulls=%d edits=%v", len(h.adopt.pulls), h.adopt.prEdits) + } + if c := adoptionComments(h.api); len(c) != 0 { + t.Fatalf("close-first note posted under on_merge: %v", c) + } + rec := h.record() + if rec.SupersededClosedFirst || rec.AdoptedBy != 90 { + t.Fatalf("record = %+v", rec) + } + // Not a gate refusal: nothing was asked of the gate. + if s := suppressedFor(gate, 7, writeback.KindContributorAdopt); len(s) != 0 { + t.Fatalf("suppressed = %+v", s) + } + }) +} + +// closeFirstGateItem: only an agent-authored original names the copy for the +// gate; a person's never does, whatever close_superseded says. +func TestCloseFirstGateItem(t *testing.T) { + obs := func(kind authorkind.Kind) stageObservation { + return stageObservation{Number: 7, Author: "odttlnt", AuthorKind: kind, Labels: []string{"stage/072-returned-to-contributor"}} + } + onAdopt, onMerge := closeFirstPolicy(), closeFirstPolicy() + onMerge.AdoptCloseSuperseded = config.AdoptionCloseSupersededOnMerge + for _, tc := range []struct { + name string + kind authorkind.Kind + policy StageLabelPolicy + agent bool + by int + onMerge bool + }{ + {"clanker default", authorkind.Clanker, onAdopt, true, 90, false}, + {"hive default", authorkind.Hive, onAdopt, true, 90, false}, + {"clanker on_merge", authorkind.Clanker, onMerge, false, 0, true}, + {"human default", authorkind.Human, onAdopt, false, 0, false}, + {"human on_merge", authorkind.Human, onMerge, false, 0, false}, + {"unknown default", authorkind.Unknown, onAdopt, false, 0, false}, + } { + t.Run(tc.name, func(t *testing.T) { + item, onMerge := closeFirstGateItem(obs(tc.kind), tc.policy, 90) + if item.AgentAuthored != tc.agent || item.SupersededBy != tc.by || onMerge != tc.onMerge || item.Number != 7 || item.Author != "odttlnt" || !item.IsPR { + t.Fatalf("item=%+v onMerge=%v", item, onMerge) + } + }) + } +} + // A paused repo gets no reopen while paused; the record stays due its poll // and the reopen lands once the pause lifts. func TestAdoptionCloseFirstReopenWaitsForWritebackGate(t *testing.T) { diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index f9cedf20a6..73acfa5582 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -106,6 +106,14 @@ type StageLabelPolicy struct { // hivecommons/hive#15135). Off, the original stays open at 074 until // the copy merges. AdoptSupersedeCloseFirst bool + // AdoptCloseSuperseded is governor.labels.stage.adoption.close_superseded + // (config.AdoptionCloseSuperseded*): when an agent-authored original + // (author/clanker, author/hive) closes once the hive's copy exists. + // "" or on_adopt closes it in the adopting pass by policy, without the + // write-back opt-in label the contributor_adopt kind otherwise needs; + // on_merge leaves it open until the copy merges. Human-authored + // originals always take the gated path. + AdoptCloseSuperseded string // DCORequired resolves the per-repo `governor.labels.stage.dco.required` // override for "owner/repo"; ok false means "detect" (a DCO context in // the branch's required checks or on the head). nil = always detect. diff --git a/src/pkg/writeback/gate.go b/src/pkg/writeback/gate.go index 1a74b8bd34..9349fd9cf4 100644 --- a/src/pkg/writeback/gate.go +++ b/src/pkg/writeback/gate.go @@ -27,6 +27,16 @@ type Item struct { // an attributed relay PR, or an issue the hive filed. Own items are // never gated (except per-repo mode off). HiveAuthored bool + // AgentAuthored is true when the author is an agent rather than a + // person: a contributor's clanker (author/clanker) or another hive. + // With SupersededBy it lets the adoption kind close the item by + // policy (ReasonSupersededAgentPR). + AgentAuthored bool + // SupersededBy is the hive's own pull request that carries this item's + // commits (the supersede adoption's copy), 0 when none. Set only by a + // caller whose policy closes superseded originals on adopt + // (governor.labels.stage.adoption.close_superseded: on_adopt). + SupersededBy int // Labels is the item's current label set. Labels []string // CreatedAt is the item's creation time; the backfill guard compares it @@ -65,6 +75,13 @@ const ( // quiet on the repo, and the advisory digest edit that kept landing on // a paused torch-spyre showed that "unsolicited only" was not enough. ReasonRepoPaused = "repo-paused" + // ReasonSupersededAgentPR allows the adoption kind on an agent-authored + // PR the hive has re-authored as its own copy (hivecommons/hive#15526 + // stayed open at "superseded" for want of an opt-in label): the pair + // is one logical PR and the copy carries the author's commits and + // sign-off, so the close is the hive's own housekeeping, not an + // unsolicited write on a person's work. + ReasonSupersededAgentPR = "superseded-agent-pr" ) // RepoPauseInfo is the provenance of an operator pause, as config records @@ -425,6 +442,13 @@ func (g *Gate) decideLocked(repo string, item Item, kind Kind) Decision { if p.OwnOnly { return Decision{Reason: ReasonOwnOnly, Detail: fmt.Sprintf("%s only ever writes on hive-authored items; #%d is by %s", kind, item.Number, item.Author)} } + // An agent's PR the hive re-authored as its own copy: the close is + // housekeeping on one logical PR of the hive's, so neither the level + // nor the opt-in label applies (an operator's own_only / repo mode / + // pause above still do). + if kind == KindContributorAdopt && item.AgentAuthored && item.SupersededBy > 0 { + return Decision{Allowed: true, Reason: ReasonSupersededAgentPR, Detail: fmt.Sprintf("#%d is agent-authored and the hive's copy #%d carries its commits; close_superseded is on_adopt", item.Number, item.SupersededBy)} + } level := 0 if g.deps.LevelFor != nil { level = g.deps.LevelFor(repo) diff --git a/src/pkg/writeback/writeback_test.go b/src/pkg/writeback/writeback_test.go index 328f78ffa5..66c71aa97b 100644 --- a/src/pkg/writeback/writeback_test.go +++ b/src/pkg/writeback/writeback_test.go @@ -18,6 +18,12 @@ var ( humanPR = Item{Number: 10, IsPR: true, Author: "maintainer", CreatedAt: t0.Add(time.Hour)} optedPR = Item{Number: 11, IsPR: true, Author: "maintainer", Labels: []string{"Hive-Review"}, CreatedAt: t0.Add(time.Hour)} ownPR = Item{Number: 12, IsPR: true, Author: "hive[bot]", HiveAuthored: true, CreatedAt: t0.Add(time.Hour)} + // clankerSuperseded is a contributor's clanker PR the hive re-authored + // as its copy #90 (hivecommons/hive#15526); humanSuperseded the same + // for a person's PR. + clankerSuperseded = Item{Number: 13, IsPR: true, Author: "odttlnt", AgentAuthored: true, SupersededBy: 90, CreatedAt: t0.Add(time.Hour)} + humanSuperseded = Item{Number: 14, IsPR: true, Author: "maintainer", SupersededBy: 90, CreatedAt: t0.Add(time.Hour)} + clankerAdopting = Item{Number: 15, IsPR: true, Author: "odttlnt", AgentAuthored: true, CreatedAt: t0.Add(time.Hour)} ) func newGate(t *testing.T, cfg Config, level int) (*Gate, *bytes.Buffer) { @@ -169,6 +175,16 @@ func TestDecisionTable(t *testing.T) { {"no-label kind by level", Config{Kinds: map[string]KindPolicyOverride{"claim_comment": {RequireLabel: boolp(false)}}}, 4, humanPR, KindClaimComment, true, ReasonLevel}, {"no-label kind below", Config{Kinds: map[string]KindPolicyOverride{"claim_comment": {RequireLabel: boolp(false)}}}, 3, humanPR, KindClaimComment, false, ReasonBelowLevel}, {"unknown kind fails closed", Config{}, 6, optedPR, Kind("mystery"), false, ReasonOwnOnly}, + // Adoption close of a superseded original (hivecommons/hive#15526): + // agent-authored with the hive's copy on record closes by policy, + // no opt-in label needed; a person's PR, or an agent PR before its + // copy exists, still needs the label; other kinds are unchanged. + {"adopt close superseded clanker L6", Config{}, 6, clankerSuperseded, KindContributorAdopt, true, ReasonSupersededAgentPR}, + {"adopt close superseded clanker L1", Config{}, 1, clankerSuperseded, KindContributorAdopt, true, ReasonSupersededAgentPR}, + {"adopt close superseded human L6", Config{}, 6, humanSuperseded, KindContributorAdopt, false, ReasonNeedsLabel}, + {"adopt clanker no copy yet L6", Config{}, 6, clankerAdopting, KindContributorAdopt, false, ReasonNeedsLabel}, + {"sentinel on superseded clanker", Config{}, 5, clankerSuperseded, KindSentinel, false, ReasonNeedsLabel}, + {"adopt close superseded repo off", Config{PerRepo: map[string]RepoOverride{"org/repo": {Mode: RepoModeOff}}}, 6, clankerSuperseded, KindContributorAdopt, false, ReasonRepoOff}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -340,6 +356,7 @@ func TestRepoPausedRefusesEveryKind(t *testing.T) { {"issue file", "org/repo", Item{}, KindIssueFile}, {"stage label opted", "org/repo", optedPR, KindStageLabel}, {"case-insensitive repo", "org/repo", ownPR, KindClaimComment}, + {"superseded agent PR close", "org/repo", clankerSuperseded, KindContributorAdopt}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { From f72ec35e376cafd2ea4751a5a209708e7df0be25 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 20:34:04 -0400 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=90=9B=20tracker:=20fold=20a=20supers?= =?UTF-8?q?eded=20original=20into=20its=20copy's=20adopted-from=20chip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A PR superseded by a hive adoption is no longer drawn as its own sub-row while its superseder is listed: the server marks it superseded_by (cleared when the copy dies, omitted for in-place adoptions) and the copy's adopted_from.state / lineage.from_state; the SPA folds it into the copy's 'adopted from' chip whose hover says closed, or open and closing when the copy merges. Docs, changelog, Go + Node tests and a fold ratchet. Signed-off-by: Andrew Anderson --- ...ixed-adoption-superseded-close-and-fold.md | 1 + src/docs/dashboard-sections.md | 2 + src/docs/hive-merge.md | 19 +- src/docs/labels-and-control-signals.md | 8 +- src/docs/operator-reference.md | 10 +- .../api_repo_item_decision_reroute.go | 2 +- src/pkg/dashboard/stage_tracker.go | 27 +++ .../stage_tracker_attention_order_test.go | 1 + src/pkg/dashboard/stage_tracker_decided.go | 10 +- .../stage_tracker_decided_ui_test.go | 93 ++++++--- src/pkg/dashboard/stage_tracker_lineage.go | 24 ++- .../dashboard/stage_tracker_lineage_test.go | 1 + .../dashboard/stage_tracker_motion_test.go | 3 + .../stage_tracker_repo_grouping_test.go | 2 + .../stage_tracker_superseded_fold_test.go | 195 ++++++++++++++++++ src/pkg/dashboard/stage_tracker_ui_test.go | 5 + .../dashboard/static-src/js/tracker-filter.js | 17 +- .../dashboard/static-src/js/tracker-row.js | 33 ++- .../dashboard/static-src/js/tracker-words.js | 12 +- src/pkg/dashboard/static/index.html | 62 ++++-- 20 files changed, 458 insertions(+), 69 deletions(-) create mode 100644 changelog.d/fixed-adoption-superseded-close-and-fold.md create mode 100644 src/pkg/dashboard/stage_tracker_superseded_fold_test.go diff --git a/changelog.d/fixed-adoption-superseded-close-and-fold.md b/changelog.d/fixed-adoption-superseded-close-and-fold.md new file mode 100644 index 0000000000..aec187527a --- /dev/null +++ b/changelog.d/fixed-adoption-superseded-close-and-fold.md @@ -0,0 +1 @@ +- A PR superseded by a hive adoption now closes promptly and leaves the Activity Monitor (hivecommons/hive#15511 listed hive's #15574 *Merge queued* and, under it, the still-open original #15526 as a greyed "Adopted → #15574 · superseded" row; 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 SPA folds the original into the copy's "↳ adopted from #N" chip, whose hover says "#N is superseded and still open; it closes when this merges." or "#N is closed as superseded." — a superseded PR whose superseder is listed is never a row of its own. diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 7e9f8be812..2aa2e87d13 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -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 is never its own sub-row while its superseder is listed (hivecommons/hive#15511 showed hive's #15574 *Merge queued* and, beneath it, the still-open #15526 as a greyed "Adopted → #15574 · superseded" line). 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), `adopted_from.state` and `lineage.from_state` on the copy (`"open"` or `"closed"`), and the SPA folds the original into the copy's **↳ adopted from #N** chip — the hover ends "#N is superseded and still open; it closes when this merges." or "#N is closed as superseded." A closed original whose copy is not in the list still draws as one dimmed line. 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 diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index 54ca0ead4c..675cc9457a 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -775,9 +775,22 @@ 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 +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 is **not a row of its own** in the Activity Monitor +while its copy is listed: the tracker marks it `superseded_by: M` and the +SPA folds it into the copy's "adopted from @x's #N" chip, whose hover says +whether #N is closed or still open and closing when the copy merges. 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 diff --git a/src/docs/labels-and-control-signals.md b/src/docs/labels-and-control-signals.md index ec0c9da4fa..360176392a 100644 --- a/src/docs/labels-and-control-signals.md +++ b/src/docs/labels-and-control-signals.md @@ -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 diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 0dec23abf4..e0fa5d0fcd 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -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 @@ -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 | diff --git a/src/pkg/dashboard/api_repo_item_decision_reroute.go b/src/pkg/dashboard/api_repo_item_decision_reroute.go index 41e63c33c8..4f54a0675c 100644 --- a/src/pkg/dashboard/api_repo_item_decision_reroute.go +++ b/src/pkg/dashboard/api_repo_item_decision_reroute.go @@ -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 } diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 85d897fafc..31f8cb5296 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -460,6 +460,14 @@ type StageTrackerItem struct { // "copy-failed" — a close-first copy failed and the original was // reopened for a person (hivecommons/hive#15135). AdoptedByState string `json:"adopted_by_state,omitempty"` + // SupersededBy is, on an adopted original still open while the hive's + // copy is live (AdoptedBy with no failed / closed state), that copy: + // the SPA folds such a row into the copy's "adopted from" chip instead + // of listing it — a superseded PR is closed and not listed, never a + // second row for one logical PR (hivecommons/hive#15526 under #15511 + // read as two PRs). 0 when the copy is gone and the original is live + // work again. + SupersededBy int `json:"superseded_by,omitempty"` // Supersedes names the closed original this PR replaced (the hive's // close-first supersession, hivecommons/hive#15135). The original is // closed, unmerged, and never a tracker row; this is the only trace of @@ -1919,6 +1927,21 @@ func stageTrackerAdoptedByState(rec stagelabels.Record) string { return "" } +// stageTrackerSupersededBy is the live copy that supersedes an adopted +// original, 0 when the adoption was in place or the copy is closed, failed +// or being replaced (then the original is live work again). A copy still +// resolving conflicts is live: the pair stays one logical PR. +func stageTrackerSupersededBy(rec stagelabels.Record) int { + if rec.AdoptedBy <= 0 || rec.AdoptMode == stagelabels.AdoptModeInPlace { + return 0 + } + switch stageTrackerAdoptedByState(rec) { + case "", stageTrackerAdoptedResolving: + return rec.AdoptedBy + } + return 0 +} + // stageTrackerAdoptionLoopCaption is the 085 caption for the loop guard. func stageTrackerAdoptionLoopCaption(rec stagelabels.Record) string { return "The hive's copies of this PR (last #" + strconv.Itoa(rec.AdoptedBy) + ") were closed without merging twice within an hour; the hive stopped opening copies and a person must decide" @@ -2057,6 +2080,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } it.AdoptedBy = rec.AdoptedBy it.AdoptedByState = stageTrackerAdoptedByState(rec) + it.SupersededBy = stageTrackerSupersededBy(rec) it.SoakRemainingSeconds = int64(stageTrackerSoakRemaining(rec, now) / time.Second) it.AdmittedBy = rec.Admission(it.Head) if total, unsigned, ok := rec.DCOFor(it.Head); ok { @@ -3148,6 +3172,9 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin lp.LastOperatorAction, lp.OperatorActionCount = pr.LastOperatorAction, pr.OperatorActionCount lp.Decided, lp.AdoptedFrom = pr.Decided, pr.AdoptedFrom lp.AdoptedBy, lp.AdoptedByState = pr.AdoptedBy, pr.AdoptedByState + if lp.SupersededBy == 0 { + lp.SupersededBy = pr.SupersededBy + } lp.Hold = pr.Hold if len(pr.Modifiers) > 0 { lp.Modifiers = append([]string(nil), pr.Modifiers...) diff --git a/src/pkg/dashboard/stage_tracker_attention_order_test.go b/src/pkg/dashboard/stage_tracker_attention_order_test.go index 05d45d4fd6..c456dc0157 100644 --- a/src/pkg/dashboard/stage_tracker_attention_order_test.go +++ b/src/pkg/dashboard/stage_tracker_attention_order_test.go @@ -115,6 +115,7 @@ func TestStageTrackerAttentionOrderJS(t *testing.T) { "var _stageTrackerFilter = stageTrackerDefaultFilter();", jsFunc(t, html, "stageTrackerAnchor"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), + jsFunc(t, html, "stageTrackerLinkedFoldedInto"), jsFunc(t, html, "stageTrackerLinkedSorted"), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "stageTrackerRegressionHandled"), diff --git a/src/pkg/dashboard/stage_tracker_decided.go b/src/pkg/dashboard/stage_tracker_decided.go index 11a86e7a45..4c3396397b 100644 --- a/src/pkg/dashboard/stage_tracker_decided.go +++ b/src/pkg/dashboard/stage_tracker_decided.go @@ -91,7 +91,12 @@ type StageTrackerAdoptedFrom struct { DecidedAt *time.Time `json:"decided_at,omitempty"` DecidedAction string `json:"decided_action,omitempty"` Verdict string `json:"verdict,omitempty"` - Text string `json:"text"` + // State is the original's state: "open" (still open; closes when the + // copy merges) or "closed" (closed as superseded). The chip's hover + // says which, since the original is not listed as a row of its own + // (hivecommons/hive#15526). + State string `json:"state,omitempty"` + Text string `json:"text"` } const ( @@ -354,7 +359,7 @@ func stageTrackerFollowAdoption(issue, orig, copy *StageTrackerItem) { // stageTrackerAdoptedFrom builds the copy's adopted_from from the original // PR and its recorded decision. func stageTrackerAdoptedFrom(orig *StageTrackerItem, now time.Time) *StageTrackerAdoptedFrom { - af := &StageTrackerAdoptedFrom{Number: orig.Number, URL: orig.URL, Author: orig.Author} + af := &StageTrackerAdoptedFrom{Number: orig.Number, URL: orig.URL, Author: orig.Author, State: lineageFromStateOpen} text := "↳ adopted from #" + strconv.Itoa(orig.Number) if a := orig.LastOperatorAction; a != nil && stageTrackerDecidedVerdict(a) != "" { t := a.At @@ -398,6 +403,7 @@ func (s *Server) stageTrackerClosedOriginal(issue *StageTrackerItem, prs map[str } else if copy.AdoptedFrom == nil { copy.AdoptedFrom = &StageTrackerAdoptedFrom{Number: issue.LinkedPR, Text: "↳ adopted from #" + strconv.Itoa(issue.LinkedPR)} } + copy.AdoptedFrom.State = lineageFromStateClosed stageTrackerFollowAdoption(issue, &StageTrackerItem{Number: issue.LinkedPR}, copy) issue.LinkedPRs = slices.DeleteFunc(issue.LinkedPRs, func(lp StageTrackerLinkedPR) bool { return lp.Number == orig.Number }) issue.LinkedPRs = append(issue.LinkedPRs, orig) diff --git a/src/pkg/dashboard/stage_tracker_decided_ui_test.go b/src/pkg/dashboard/stage_tracker_decided_ui_test.go index 90e4df91c9..f9196af653 100644 --- a/src/pkg/dashboard/stage_tracker_decided_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_decided_ui_test.go @@ -34,6 +34,7 @@ func stageTrackerDecidedUIJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerDecidedActing"), jsFunc(t, html, "stageTrackerDecidedLead"), jsFunc(t, html, "stageTrackerLinkedSupersededText"), + jsFunc(t, html, "stageTrackerSupersededOriginalClause"), jsFunc(t, html, "stageTrackerAdoptedFromChipHtml"), // Pending entries as stageTrackerRowDeciding reads them. "var _stageTrackerPending = [];", @@ -165,59 +166,85 @@ for (const a of ['adopted', 'directed', 'closed', 'merged', 'queued-for-merge', } // ── 3. landed: the adoption pair ──────────────────────────────────────── -// The original is dimmed "Adopted → #15123 · superseded (hive re-authored -// with sign-off)" with no chevron track, no row tools and no needs-human -// styling; the copy carries the single active chevron and the chip -// "↳ adopted from #15029 · you let hive decide 11:57 UTC"; the issue row's -// pill follows the copy. +// A superseded PR is closed and not listed (owner, #15526 under #15511): +// the original is NOT its own sub-row — it lives only in the copy's +// "↳ adopted from #15029 · you let hive decide 11:57 UTC" chip, whose +// tooltip names its state; the copy carries the single active chevron +// and the issue row's pill follows the copy. { const landed = Object.assign({}, decidedPending, { effect: 'landed', superseded_by: 15123, next_at: undefined }); - const orig = original({ stage: 74, modifiers: [], manual_merge: false, human_merge_reason_text: '', adopted_by: 15123, adopted_by_state: 'open', decided: landed, last_operator_action: Object.assign({}, acted, { state: 'addressed' }), operator_action_count: 1 }); - const copy = { number: 15123, title: 'fix: tracker pill', url: 'u123', stage: 50, author: 'hivecommons-hive[bot]', author_kind: 'hive', modifiers: [], adopted_from: { number: 15029, url: 'u29', author: 'Karibhou', decided_by: 'clubanderson', decided_at: at, decided_action: 'let-hive-decide', verdict: 'adopt-supersede', text: '↳ adopted from #15029 · you let hive decide 11:57 UTC' } }; + const orig = original({ stage: 74, modifiers: [], manual_merge: false, human_merge_reason_text: '', adopted_by: 15123, adopted_by_state: 'open', superseded_by: 15123, decided: landed, last_operator_action: Object.assign({}, acted, { state: 'addressed' }), operator_action_count: 1 }); + const copy = { number: 15123, title: 'fix: tracker pill', url: 'u123', stage: 50, author: 'hivecommons-hive[bot]', author_kind: 'hive', modifiers: [], adopted_from: { number: 15029, url: 'u29', author: 'Karibhou', state: 'open', decided_by: 'clubanderson', decided_at: at, decided_action: 'let-hive-decide', verdict: 'adopt-supersede', text: '↳ adopted from #15029 · you let hive decide 11:57 UTC' } }; const issue = issueOf([orig, copy], { stage: 50 }); const row = stageTrackerRowHtml(issue, stages, ctx); - assert.strictEqual(subs(row).length, 1, 'one full sub-row: the copy; the original is a dimmed line'); - const dim = (/
\s*<\/div>/.exec(row) || [''])[0]; - assert.ok(dim, 'the original renders as a superseded line: ' + row); - assert.ok(dim.includes('data-ham-superseded-by="15123"')); - assert.ok(text(dim).includes('#15029') && text(dim).includes('Adopted → #15123 · superseded (hive re-authored with sign-off)'), text(dim)); - assert.ok(!dim.includes('aria-label="Pipeline progress"') && !dim.includes('ham-seg active'), 'no chevron track on the superseded original'); - assert.ok(!dim.includes('ham-row-tools') && !dim.includes('needs-human') && !dim.includes('Ready for human merge'), 'no action chevron, no needs-human styling'); - const sub = subHtml(row, 15123); - assert.ok(sub.includes('aria-current="step"'), 'the copy carries the active chevron'); - assert.ok(sub.includes('class="ham-badge ham-adopted-from"') && /↳ adopted from #15029 · you let hive decide 11:57( AM)? UTC/.test(text(sub)), 'the adopted-from chip: ' + text(sub)); - assert.ok(!text(sub).includes('untrusted author'), 'the copy is hive-authored'); - // With several PRs the issue strip ends at Claimed, unlit: the copy's - // chevron is the row's single active one; the original has none. + assert.strictEqual(stageTrackerLinkedFoldedInto(orig, issue), 15123, 'the original folds into the listed open copy'); + assert.strictEqual(stageTrackerLinkedFoldedInto(copy, issue), 0, 'the copy is never folded'); + // One drawn PR left: the issue row carries the copy inline, no sub-rows. + assert.strictEqual(subs(row).length, 0, 'the superseded original is not a sub-row; the copy rides the issue row: ' + row); + assert.ok(!row.includes('ham-sub-superseded'), 'no dimmed superseded line while the copy is listed: ' + row); + assert.ok(!row.includes('data-ham-superseded-by="15123"')); + assert.ok(!text(row).includes('Adopted → #15123'), 'the superseded caption is not a row: ' + text(row)); + assert.ok(!row.includes('#15029'), 'the original is never a PR ref of its own, only the chip: ' + row); + assert.ok(row.includes('aria-current="step"'), 'the copy carries the active chevron'); + assert.ok(row.includes('class="ham-badge ham-adopted-from"') && /↳ adopted from #15029 · you let hive decide 11:57( AM)? UTC/.test(text(row)), 'the adopted-from chip: ' + text(row)); + const chipTip = (/class="ham-badge ham-adopted-from"[^>]*title="([^"]*)"/.exec(row) || [])[1] || ''; + assert.ok(chipTip.includes('#15029 is superseded and still open; it closes when this merges.'), 'the chip tooltip names the superseded state: ' + chipTip); + assert.ok(!text(row).includes('untrusted author'), 'the copy is hive-authored'); assert.strictEqual((row.match(/aria-current="step"/g) || []).length, 1, 'exactly one active chevron: the copy'); - assert.ok(pill(sub).includes('CI / Review'), 'the active pill follows the copy: ' + pill(sub)); + assert.ok(pill(row).includes('CI / Review'), 'the active pill follows the copy: ' + pill(row)); + // With a third, unrelated PR the copy is a sub-row and the original still is not. + const third = { number: 15200, title: 'docs: note', url: 'u200', stage: 70, author: 'pat', author_kind: 'human', modifiers: [] }; + const row3 = stageTrackerRowHtml(issueOf([orig, copy, third], { stage: 50 }), stages, ctx); + assert.deepStrictEqual(subs(row3).map(s => (/pr#(\d+)"/.exec(s) || [])[1]), ['15123', '15200'], 'sub-rows: the copy and the unrelated PR, never the original'); + assert.ok(!row3.includes('ham-sub-superseded') && !row3.includes('#15029'), 'the original lives only in the chip'); assert.ok(!/Approving/.test(row)); + // The same fold without superseded_by (a pre-roll payload): adopted_by + // plus a live copy folds too. + const legacy = issueOf([original({ stage: 74, modifiers: [], adopted_by: 15123, adopted_by_state: 'open', decided: landed }), copy], { stage: 50 }); + assert.ok(!stageTrackerRowHtml(legacy, stages, ctx).includes('ham-sub-superseded'), 'adopted_by + live copy folds without superseded_by'); + // The copy closed (copy-failed / recovering): the original is live again. + const recovering = issueOf([original({ stage: 70, modifiers: [], adopted_by: 15123, adopted_by_state: 'closed', superseded_by: 15123 }), Object.assign({}, copy, { state: 'closed' })], { stage: 70 }); + assert.strictEqual(stageTrackerLinkedFoldedInto(recovering.linked_prs[0], recovering), 0, 'a closed copy never folds its original'); } // ── 4. closed original ────────────────────────────────────────────────── -// A closed-superseded original (closed PRs drop out of the open-PR -// projection; only the back-link remains) is one dimmed line with the +// A closed-superseded original whose copy is listed folds away too — the +// chip says "#15029 is closed as superseded." Only when the copy is not +// in the list does the closed original draw as one dimmed line with the // cached title: "#15029 fix: tracker pill · closed · superseded by #15123". { const closed = { number: 15029, title: 'fix: tracker pill', url: 'u29', stage: 74, state: 'closed', superseded_by: 15123, adopted_by: 15123, adopted_by_state: 'open', caption: 'closed · superseded by #15123', modifiers: [] }; - const copy = { number: 15123, title: 'fix: tracker pill', url: 'u123', stage: 50, author: 'hivecommons-hive[bot]', author_kind: 'hive', modifiers: [], adopted_from: { number: 15029, url: 'u29', author: 'Karibhou', text: '↳ adopted from #15029' } }; + const copy = { number: 15123, title: 'fix: tracker pill', url: 'u123', stage: 50, author: 'hivecommons-hive[bot]', author_kind: 'hive', modifiers: [], adopted_from: { number: 15029, url: 'u29', author: 'Karibhou', state: 'closed', text: '↳ adopted from #15029' } }; const row = stageTrackerRowHtml(issueOf([closed, copy], { stage: 50 }), stages, ctx); - const dim = (/
\s*<\/div>/.exec(row) || [''])[0]; - assert.ok(dim, 'the closed original renders as a line, not a bare number: ' + row); - assert.ok(text(dim).includes('#15029 fix: tracker pill') || (text(dim).includes('#15029') && text(dim).includes('fix: tracker pill')), 'cached title, no live fetch: ' + text(dim)); + assert.ok(!row.includes('ham-sub-superseded'), 'the closed original folds into the listed copy: ' + row); + assert.strictEqual(subs(row).length, 0, 'the copy rides the issue row alone'); + assert.ok(!row.includes('#15029'), 'the closed original is not a PR ref of its own'); + const chipTip = (/class="ham-badge ham-adopted-from"[^>]*title="([^"]*)"/.exec(row) || [])[1] || ''; + assert.ok(chipTip.includes('#15029 is closed as superseded.'), 'the chip tooltip says closed: ' + chipTip); + assert.ok(!stageTrackerLinkedPROpen(stageTrackerLinkedPRItem(issueOf([closed]), closed)), 'a closed PR is not an open linked PR'); + // Copy not listed under this issue: the closed original is still shown + // (inline when it is the only PR, a dimmed line beside other PRs). + const alone = stageTrackerRowHtml(issueOf([closed], { stage: 74 }), stages, ctx); + assert.ok(alone.includes('#15029'), 'the orphaned closed original stays visible: ' + text(alone)); + const other = { number: 15200, title: 'docs: note', url: 'u200', stage: 70, author: 'pat', author_kind: 'human', modifiers: [] }; + const beside = stageTrackerRowHtml(issueOf([closed, other], { stage: 50 }), stages, ctx); + const dim = (/
\s*<\/div>/.exec(beside) || [''])[0]; + assert.ok(dim, 'the closed original renders as a line, not a bare number: ' + beside); + assert.ok(text(dim).includes('#15029') && text(dim).includes('fix: tracker pill'), 'cached title, no live fetch: ' + text(dim)); assert.ok(text(dim).includes('closed · superseded by #15123'), text(dim)); assert.ok(!dim.includes('aria-label="Pipeline progress"'), 'no hollow chevrons'); - assert.ok(!stageTrackerLinkedPROpen(stageTrackerLinkedPRItem(issueOf([closed]), closed)), 'a closed PR is not an open linked PR'); - assert.strictEqual(subs(row).length, 1, 'only the copy is a full sub-row'); - // The issue row never shows a blank numbered sub-row. - for (const s of row.split('
Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'pr', title: 'fix: tracker', url: 'https://x/' + n, stage: 74, stage_since: since, caption: 'Adopted', author: 'odttlnt', author_kind: 'clanker', modifiers: [] }, extra || {}); +const issue = (n, prs, extra) => Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'issue', title: 'Issue ' + n, url: 'https://x/i' + n, stage: 40, stage_since: since, linked_prs: prs }, extra || {}); +const copy = (n, from, extra) => pr(n, Object.assign({ author: 'hivecommons-hive[bot]', author_kind: 'hive', stage: 80, caption: 'Merge queued', adopted_from: { number: from, url: 'https://x/' + from, author: 'odttlnt', state: 'open', text: '↳ adopted from #' + from } }, extra || {})); + +// Nested: the issue lists both; only the copy is drawn. +{ + const orig = pr(15526, { adopted_by: 15574, adopted_by_state: '', superseded_by: 15574, nested_under: 15511 }); + const cp = copy(15574, 15526, { nested_under: 15511 }); + const items = [issue(15511, [orig, cp]), orig, cp]; + const rows = stageTrackerVisible(items, { kind: 'all', repo: '' }); + assert.deepStrictEqual(rows.map(r => r.kind + '#' + r.number), ['issue#15511'], 'the nested pair draws under the issue only'); + const subs = stageTrackerLinkedSorted(rows[0]).map(lp => lp.number); + assert.deepStrictEqual(subs, [15574], 'the superseded original is not a sub-row'); + const prs = stageTrackerVisible(items, { kind: 'pr', repo: '' }).map(r => r.number); + assert.deepStrictEqual(prs, [15574], 'the Pull requests filter never lists the superseded original'); +} +// Top level: the pair without an issue; the original folds. +{ + const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574 }); + const cp = copy(15574, 15526); + assert.deepStrictEqual(stageTrackerVisible([orig, cp], { kind: 'all', repo: '' }).map(r => r.number), [15574]); + assert.deepStrictEqual(stageTrackerFoldSuperseded([orig, cp]).map(r => r.number), [15574]); +} +// The superseder not drawn (closed / merged / absent): the original stays. +{ + const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574 }); + assert.deepStrictEqual(stageTrackerFoldSuperseded([orig]).map(r => r.number), [15526], 'no superseder listed: keep'); + assert.deepStrictEqual(stageTrackerFoldSuperseded([orig, copy(15574, 15526, { state: 'closed' })]).map(r => r.number), [15526, 15574], 'closed superseder: keep'); + assert.deepStrictEqual(stageTrackerFoldSuperseded([orig, copy(15574, 15526, { modifiers: ['merged'] })]).length, 1, 'a merged copy still drops the original: the fold only asks that the copy be drawn'); + const other = pr(15526, { repo: 'hivecommons/docs', adopted_by: 15574, superseded_by: 15574 }); + assert.deepStrictEqual(stageTrackerFoldSuperseded([other, copy(15574, 15526)]).map(r => r.repo + '#' + r.number), ['hivecommons/docs#15526', 'hivecommons/hive#15574'], 'repo-scoped: a same-numbered PR elsewhere is not the superseder'); +} +// Ratchet over a mixed fixture: no drawn row's superseded_by names a drawn open PR. +{ + const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574, nested_under: 15511 }); + const cp = copy(15574, 15526, { nested_under: 15511 }); + const loose = pr(15561, { adopted_by: 15567, superseded_by: 15567 }); + const looseCopy = copy(15567, 15561); + const items = [issue(15511, [orig, cp]), orig, cp, loose, looseCopy, pr(15600, { stage: 70, caption: 'Fixing' })]; + for (const f of [{ kind: 'all', repo: '' }, { kind: 'pr', repo: '' }]) { + const rows = stageTrackerVisible(items, f); + const drawn = new Set(); + for (const r of rows) { + if (r.kind === 'pr') drawn.add(r.repo + '#' + r.number); + if (r.kind === 'issue') for (const lp of stageTrackerLinkedSorted(r)) drawn.add(r.repo + '#' + lp.number); + } + for (const r of rows) { + if (r.kind === 'pr') assert.ok(!(Number(r.superseded_by) > 0 && drawn.has(r.repo + '#' + r.superseded_by)), 'ratchet: superseded row drawn beside its open superseder: ' + r.number); + if (r.kind === 'issue') for (const lp of stageTrackerLinkedSorted(r)) assert.ok(!(Number(lp.superseded_by) > 0 && drawn.has(r.repo + '#' + lp.superseded_by)), 'ratchet: superseded sub-row drawn beside its superseder: ' + lp.number); + } + assert.ok(drawn.has('hivecommons/hive#15574') && drawn.has('hivecommons/hive#15567') && drawn.has('hivecommons/hive#15600'), 'the copies and the unrelated PR draw: ' + [...drawn].join(',')); + } +} +`) +} diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 337cb3f876..8e058ad890 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -181,6 +181,7 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerAgoText"), jsConstBlock(t, html, "STAGE_TRACKER_LINEAGE_REASON_TIP"), jsFunc(t, html, "stageTrackerLineageText"), + jsFunc(t, html, "stageTrackerSupersededOriginalClause"), jsFunc(t, html, "stageTrackerLineageTip"), jsFunc(t, html, "stageTrackerLineageChipHtml"), jsFunc(t, html, "stageTrackerLinkedPRItem"), @@ -191,6 +192,7 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), + jsFunc(t, html, "stageTrackerLinkedFoldedInto"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), @@ -217,6 +219,7 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerItemKey"), jsFunc(t, html, "stageTrackerMoveAttrs"), jsFunc(t, html, "stageTrackerNeedsAttention"), + jsFunc(t, html, "stageTrackerFoldSuperseded"), jsFunc(t, html, "stageTrackerVisible"), stageTrackerCuesJS(t, html), }, "\n") @@ -940,6 +943,7 @@ func TestStageTrackerFilterSortPage(t *testing.T) { "var _stageTrackerFilter = stageTrackerDefaultFilter();", jsFunc(t, html, "stageTrackerAnchor"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), + jsFunc(t, html, "stageTrackerLinkedFoldedInto"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), @@ -962,6 +966,7 @@ func TestStageTrackerFilterSortPage(t *testing.T) { jsFunc(t, html, "stageTrackerNormalizeFilter"), jsFunc(t, html, "stageTrackerFilterActive"), jsFunc(t, html, "stageTrackerMatches"), + jsFunc(t, html, "stageTrackerFoldSuperseded"), jsFunc(t, html, "stageTrackerVisible"), jsFunc(t, html, "stageTrackerRowCount"), jsFunc(t, html, "stageTrackerSort"), diff --git a/src/pkg/dashboard/static-src/js/tracker-filter.js b/src/pkg/dashboard/static-src/js/tracker-filter.js index 740cf4fc0a..14f82b1ee5 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter.js @@ -206,11 +206,26 @@ // is nested under a listed issue is drawn as that issue's sub-row only. function stageTrackerVisible(items, filter, ctx) { const f = stageTrackerNormalizeFilter(filter || _stageTrackerFilter); - const rows = (items || []).filter(it => stageTrackerMatches(it, f, ctx)); + const rows = stageTrackerFoldSuperseded((items || []).filter(it => stageTrackerMatches(it, f, ctx))); if (f.kind === 'pr') return rows; const issues = new Set(rows.filter(it => it.kind === 'issue').map(it => it.repo + '#' + it.number)); return rows.filter(it => !(it.kind === 'pr' && it.nested_under && issues.has(it.repo + '#' + it.nested_under))); } + // Pure: drop every PR row whose `superseded_by` names a PR that is + // itself drawn open on this page — as a row or as a listed issue's + // open sub-row. A superseded PR is closed and not listed (owner, + // hivecommons/hive#15526); the copy's "adopted from" chip is its one + // trace. A superseder that is not drawn (filtered out, another page, + // closed) leaves the original a row of its own. + function stageTrackerFoldSuperseded(rows) { + const drawn = new Set(); + for (const it of rows) { + if (!it) continue; + if (it.kind === 'pr' && String(it.state || '') !== 'closed') drawn.add(it.repo + '#' + it.number); + if (it.kind === 'issue' && Array.isArray(it.linked_prs)) for (const lp of it.linked_prs) if (lp && String(lp.state || '') !== 'closed' && (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') < 0) drawn.add(it.repo + '#' + lp.number); + } + return rows.filter(it => !(it && it.kind === 'pr' && Number(it.superseded_by) > 0 && Number(it.superseded_by) !== Number(it.number) && drawn.has(it.repo + '#' + Number(it.superseded_by)))); + } // The canonical tracker count (owner): rows of the default view — every // item on its own row except a PR drawn on a listed issue's row. diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index d67145a284..fa0f4f8ca2 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -943,6 +943,22 @@ } return true; } + // Pure: the listed, open PR a nested original is folded into — its + // superseder (`superseded_by` from the server; `adopted_by` while the + // copy is live, for a payload without it) when that copy is itself + // listed under the issue and not closed — else 0. A superseded PR is + // closed and not listed (owner, hivecommons/hive#15526 under #15511 + // drew the original as a dimmed second row beside hive's #15574): it + // lives only in the copy's "adopted from" chip. A closed original + // whose copy is not in the list still draws as one dimmed line. + function stageTrackerLinkedFoldedInto(lp, issue) { + if (!lp) return 0; + const live = lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed'; + const by = Number(lp.superseded_by) || (live ? Number(lp.adopted_by) || 0 : 0); + if (!(by > 0) || by === Number(lp.number)) return 0; + const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; + return linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed' && (Array.isArray(x.modifiers) ? x.modifiers : []).indexOf('merged') < 0) ? by : 0; + } // Pure: an issue's open nested PRs as row items. function stageTrackerNestedOpenPRs(issue) { if (!issue || issue.kind === 'pr') return []; @@ -984,7 +1000,16 @@ if (l.kind === 'superseded') return 'Hive took this PR over as #' + Number(l.to_number) + '; this original is closed when that merges.'; const who = l.from_author ? '@' + l.from_author : 'the contributor'; const tip = STAGE_TRACKER_LINEAGE_REASON_TIP[l.reason] || STAGE_TRACKER_LINEAGE_REASON_TIP['ci-red-contributor-offline']; - return tip.split('@AUTHOR').join(who); + return tip.split('@AUTHOR').join(who) + stageTrackerSupersededOriginalClause(Number(l.from_number), l.from_state); + } + // Pure: the hover clause that says what became of the superseded + // original the chip stands in for — closed, or still open and closing + // when the copy merges; '' when the server does not say. + function stageTrackerSupersededOriginalClause(number, state) { + if (!(number > 0)) return ''; + if (state === 'closed') return ' #' + number + ' is closed as superseded.'; + if (state === 'open') return ' #' + number + ' is superseded and still open; it closes when this merges.'; + return ''; } function stageTrackerLineageChipHtml(item, nowMs) { const text = stageTrackerLineageText(item, nowMs); @@ -1015,7 +1040,7 @@ const what = af.decided_action === 'let-hive-decide' ? 'you let hive decide' : 'you approved'; text += ' · ' + what + ' ' + agentNowClockTime(Date.parse(af.decided_at), typeof nowMs === 'number' ? nowMs : Date.now()); } - const tip = 'Hive re-authored #' + af.number + (af.author ? ' (by @' + af.author + ')' : '') + ' as this PR with the same commits and sign-off' + (af.decided_by ? '; the decision on #' + af.number + ' was ' + (af.decided_action || 'yours') + ' by @' + af.decided_by : '') + '. #' + af.number + ' is closed as superseded when this merges.'; + const tip = 'Hive re-authored #' + af.number + (af.author ? ' (by @' + af.author + ')' : '') + ' as this PR with the same commits and sign-off' + (af.decided_by ? '; the decision on #' + af.number + ' was ' + (af.decided_action || 'yours') + ' by @' + af.decided_by : '') + '.' + (stageTrackerSupersededOriginalClause(Number(af.number), af.state) || ' #' + af.number + ' is closed as superseded when this merges.'); return `${esc(text)}`; } // The row's inline lead action (tracker-actions.js @@ -1086,7 +1111,7 @@ return stageTrackerLinkedElsewhere(item).map(lp => `↳ #${Number(lp.number) || 0} · under #${Number(lp.drawn_under)}`).join(' '); } function stageTrackerLinkedSorted(item, stages) { - const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); + const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item) && !stageTrackerLinkedFoldedInto(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); const sinceOf = lp => Date.parse(lp.stage_since || '') || Infinity; return linked.sort((x, y) => (stageTrackerAnchor(y.stage, stages, 'pr', y) - stageTrackerAnchor(x.stage, stages, 'pr', x)) || (stageTrackerAttentionTier(x) - stageTrackerAttentionTier(y)) || (sinceOf(x) - sinceOf(y)) || ((x.number || 0) - (y.number || 0))); } @@ -1267,7 +1292,7 @@ // One covering PR: a single entry whose strip the PR's stage drives. const lp = linked[0]; const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); - prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? (stageTrackerLineageChipHtml(lp, nowMs) || null) : null, lp.base_ref)]; + prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: lp.stage || 40, stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index 38967d5f6b..f7197b9abe 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -736,17 +736,15 @@ const lead = who + ' · ' + chose + ', ' + agentNowClockTime(atMs, nowMs); return lead + (d.title ? '\n' + d.title : ''); } - // Pure: an adopted original listed under its issue — closed, or still - // open with the hive's copy already in the list — draws as one dimmed - // line without a chevron track (hivecommons/hive#15126). + // Pure: a closed adopted original listed under its issue draws as one + // dimmed line without a chevron track (hivecommons/hive#15126) — only + // when its copy is not in the list; with the copy listed the original + // is folded into the copy's chip and not drawn at all + // (stageTrackerLinkedFoldedInto, hivecommons/hive#15526). function stageTrackerLinkedSupersededText(lp, issue) { if (!lp) return ''; const by = Number(lp.superseded_by || lp.adopted_by) || 0; if (String(lp.state || '') === 'closed') return 'closed · superseded by #' + by; - if (by > 0 && lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice') { - const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; - if (linked.some(x => Number(x.number) === by)) return 'Adopted → #' + by + ' · superseded (hive re-authored with sign-off)'; - } return ''; } function stageTrackerCoveringPR(item) { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 3ea99ff4c2..fc7ad0a4e3 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -14986,17 +14986,15 @@

Where to get help

const lead = who + ' · ' + chose + ', ' + agentNowClockTime(atMs, nowMs); return lead + (d.title ? '\n' + d.title : ''); } - // Pure: an adopted original listed under its issue — closed, or still - // open with the hive's copy already in the list — draws as one dimmed - // line without a chevron track (hivecommons/hive#15126). + // Pure: a closed adopted original listed under its issue draws as one + // dimmed line without a chevron track (hivecommons/hive#15126) — only + // when its copy is not in the list; with the copy listed the original + // is folded into the copy's chip and not drawn at all + // (stageTrackerLinkedFoldedInto, hivecommons/hive#15526). function stageTrackerLinkedSupersededText(lp, issue) { if (!lp) return ''; const by = Number(lp.superseded_by || lp.adopted_by) || 0; if (String(lp.state || '') === 'closed') return 'closed · superseded by #' + by; - if (by > 0 && lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice') { - const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; - if (linked.some(x => Number(x.number) === by)) return 'Adopted → #' + by + ' · superseded (hive re-authored with sign-off)'; - } return ''; } function stageTrackerCoveringPR(item) { @@ -16620,6 +16618,22 @@

Where to get help

} return true; } + // Pure: the listed, open PR a nested original is folded into — its + // superseder (`superseded_by` from the server; `adopted_by` while the + // copy is live, for a payload without it) when that copy is itself + // listed under the issue and not closed — else 0. A superseded PR is + // closed and not listed (owner, hivecommons/hive#15526 under #15511 + // drew the original as a dimmed second row beside hive's #15574): it + // lives only in the copy's "adopted from" chip. A closed original + // whose copy is not in the list still draws as one dimmed line. + function stageTrackerLinkedFoldedInto(lp, issue) { + if (!lp) return 0; + const live = lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed'; + const by = Number(lp.superseded_by) || (live ? Number(lp.adopted_by) || 0 : 0); + if (!(by > 0) || by === Number(lp.number)) return 0; + const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; + return linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed' && (Array.isArray(x.modifiers) ? x.modifiers : []).indexOf('merged') < 0) ? by : 0; + } // Pure: an issue's open nested PRs as row items. function stageTrackerNestedOpenPRs(issue) { if (!issue || issue.kind === 'pr') return []; @@ -16661,7 +16675,16 @@

Where to get help

if (l.kind === 'superseded') return 'Hive took this PR over as #' + Number(l.to_number) + '; this original is closed when that merges.'; const who = l.from_author ? '@' + l.from_author : 'the contributor'; const tip = STAGE_TRACKER_LINEAGE_REASON_TIP[l.reason] || STAGE_TRACKER_LINEAGE_REASON_TIP['ci-red-contributor-offline']; - return tip.split('@AUTHOR').join(who); + return tip.split('@AUTHOR').join(who) + stageTrackerSupersededOriginalClause(Number(l.from_number), l.from_state); + } + // Pure: the hover clause that says what became of the superseded + // original the chip stands in for — closed, or still open and closing + // when the copy merges; '' when the server does not say. + function stageTrackerSupersededOriginalClause(number, state) { + if (!(number > 0)) return ''; + if (state === 'closed') return ' #' + number + ' is closed as superseded.'; + if (state === 'open') return ' #' + number + ' is superseded and still open; it closes when this merges.'; + return ''; } function stageTrackerLineageChipHtml(item, nowMs) { const text = stageTrackerLineageText(item, nowMs); @@ -16692,7 +16715,7 @@

Where to get help

const what = af.decided_action === 'let-hive-decide' ? 'you let hive decide' : 'you approved'; text += ' · ' + what + ' ' + agentNowClockTime(Date.parse(af.decided_at), typeof nowMs === 'number' ? nowMs : Date.now()); } - const tip = 'Hive re-authored #' + af.number + (af.author ? ' (by @' + af.author + ')' : '') + ' as this PR with the same commits and sign-off' + (af.decided_by ? '; the decision on #' + af.number + ' was ' + (af.decided_action || 'yours') + ' by @' + af.decided_by : '') + '. #' + af.number + ' is closed as superseded when this merges.'; + const tip = 'Hive re-authored #' + af.number + (af.author ? ' (by @' + af.author + ')' : '') + ' as this PR with the same commits and sign-off' + (af.decided_by ? '; the decision on #' + af.number + ' was ' + (af.decided_action || 'yours') + ' by @' + af.decided_by : '') + '.' + (stageTrackerSupersededOriginalClause(Number(af.number), af.state) || ' #' + af.number + ' is closed as superseded when this merges.'); return `${esc(text)}`; } // The row's inline lead action (tracker-actions.js @@ -16763,7 +16786,7 @@

Where to get help

return stageTrackerLinkedElsewhere(item).map(lp => `↳ #${Number(lp.number) || 0} · under #${Number(lp.drawn_under)}`).join(' '); } function stageTrackerLinkedSorted(item, stages) { - const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); + const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item) && !stageTrackerLinkedFoldedInto(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); const sinceOf = lp => Date.parse(lp.stage_since || '') || Infinity; return linked.sort((x, y) => (stageTrackerAnchor(y.stage, stages, 'pr', y) - stageTrackerAnchor(x.stage, stages, 'pr', x)) || (stageTrackerAttentionTier(x) - stageTrackerAttentionTier(y)) || (sinceOf(x) - sinceOf(y)) || ((x.number || 0) - (y.number || 0))); } @@ -16944,7 +16967,7 @@

Where to get help

// One covering PR: a single entry whose strip the PR's stage drives. const lp = linked[0]; const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); - prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? (stageTrackerLineageChipHtml(lp, nowMs) || null) : null, lp.base_ref)]; + prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: lp.stage || 40, stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { @@ -17795,11 +17818,26 @@

Where to get help

// is nested under a listed issue is drawn as that issue's sub-row only. function stageTrackerVisible(items, filter, ctx) { const f = stageTrackerNormalizeFilter(filter || _stageTrackerFilter); - const rows = (items || []).filter(it => stageTrackerMatches(it, f, ctx)); + const rows = stageTrackerFoldSuperseded((items || []).filter(it => stageTrackerMatches(it, f, ctx))); if (f.kind === 'pr') return rows; const issues = new Set(rows.filter(it => it.kind === 'issue').map(it => it.repo + '#' + it.number)); return rows.filter(it => !(it.kind === 'pr' && it.nested_under && issues.has(it.repo + '#' + it.nested_under))); } + // Pure: drop every PR row whose `superseded_by` names a PR that is + // itself drawn open on this page — as a row or as a listed issue's + // open sub-row. A superseded PR is closed and not listed (owner, + // hivecommons/hive#15526); the copy's "adopted from" chip is its one + // trace. A superseder that is not drawn (filtered out, another page, + // closed) leaves the original a row of its own. + function stageTrackerFoldSuperseded(rows) { + const drawn = new Set(); + for (const it of rows) { + if (!it) continue; + if (it.kind === 'pr' && String(it.state || '') !== 'closed') drawn.add(it.repo + '#' + it.number); + if (it.kind === 'issue' && Array.isArray(it.linked_prs)) for (const lp of it.linked_prs) if (lp && String(lp.state || '') !== 'closed' && (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') < 0) drawn.add(it.repo + '#' + lp.number); + } + return rows.filter(it => !(it && it.kind === 'pr' && Number(it.superseded_by) > 0 && Number(it.superseded_by) !== Number(it.number) && drawn.has(it.repo + '#' + Number(it.superseded_by)))); + } // The canonical tracker count (owner): rows of the default view — every // item on its own row except a PR drawn on a listed issue's row. From 09984098c243670a286cc60d981599c31db384c0 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 20:47:20 -0400 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=90=9B=20tracker:=20superseded=20orig?= =?UTF-8?q?inal=20reads=20'superseded=20=C2=B7=20hive=20adopted=20?= =?UTF-8?q?=E2=86=92=20#N'=20on=20one=20muted=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the fold from the previous commit per owner feedback: the muted, chevron-less sub-row under the issue stays; only the trailing note changes to the short one-liner ("superseded · closed · hive adopted → #N" once the original is closed), never wrapping — the title ellipsizes first — with "re-authored with the same commits and sign-off" moved to the hover. A closed original is listed in this muted form only while its superseder is open and listed, and leaves when the superseder merges or closes. Signed-off-by: Andrew Anderson --- ...ixed-adoption-superseded-close-and-fold.md | 1 - ...ixed-adoption-superseded-close-and-note.md | 1 + src/docs/dashboard-sections.md | 2 +- src/docs/hive-merge.md | 14 +- src/pkg/dashboard/stage_tracker.go | 19 +- ...stage_tracker_adoption_close_first_test.go | 13 +- .../stage_tracker_attention_order_test.go | 4 +- src/pkg/dashboard/stage_tracker_decided.go | 51 +++- .../dashboard/stage_tracker_decided_test.go | 4 +- .../stage_tracker_decided_ui_test.go | 121 ++++---- .../dashboard/stage_tracker_motion_test.go | 12 +- .../stage_tracker_repo_grouping_test.go | 5 +- .../stage_tracker_superseded_fold_test.go | 195 ------------- .../stage_tracker_superseded_row_test.go | 258 ++++++++++++++++++ src/pkg/dashboard/stage_tracker_ui_test.go | 10 +- src/pkg/dashboard/static-src/css/tracker.css | 2 +- .../dashboard/static-src/js/tracker-filter.js | 17 +- .../dashboard/static-src/js/tracker-row.js | 28 +- .../dashboard/static-src/js/tracker-words.js | 41 ++- src/pkg/dashboard/static/index.html | 88 +++--- 20 files changed, 517 insertions(+), 369 deletions(-) delete mode 100644 changelog.d/fixed-adoption-superseded-close-and-fold.md create mode 100644 changelog.d/fixed-adoption-superseded-close-and-note.md delete mode 100644 src/pkg/dashboard/stage_tracker_superseded_fold_test.go create mode 100644 src/pkg/dashboard/stage_tracker_superseded_row_test.go diff --git a/changelog.d/fixed-adoption-superseded-close-and-fold.md b/changelog.d/fixed-adoption-superseded-close-and-fold.md deleted file mode 100644 index aec187527a..0000000000 --- a/changelog.d/fixed-adoption-superseded-close-and-fold.md +++ /dev/null @@ -1 +0,0 @@ -- A PR superseded by a hive adoption now closes promptly and leaves the Activity Monitor (hivecommons/hive#15511 listed hive's #15574 *Merge queued* and, under it, the still-open original #15526 as a greyed "Adopted → #15574 · superseded" row; 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 SPA folds the original into the copy's "↳ adopted from #N" chip, whose hover says "#N is superseded and still open; it closes when this merges." or "#N is closed as superseded." — a superseded PR whose superseder is listed is never a row of its own. diff --git a/changelog.d/fixed-adoption-superseded-close-and-note.md b/changelog.d/fixed-adoption-superseded-close-and-note.md new file mode 100644 index 0000000000..1d96bf7649 --- /dev/null +++ b/changelog.d/fixed-adoption-superseded-close-and-note.md @@ -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. diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 2aa2e87d13..bcc51718ff 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -977,7 +977,7 @@ 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 is never its own sub-row while its superseder is listed (hivecommons/hive#15511 showed hive's #15574 *Merge queued* and, beneath it, the still-open #15526 as a greyed "Adopted → #15574 · superseded" line). 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), `adopted_from.state` and `lineage.from_state` on the copy (`"open"` or `"closed"`), and the SPA folds the original into the copy's **↳ adopted from #N** chip — the hover ends "#N is superseded and still open; it closes when this merges." or "#N is closed as superseded." A closed original whose copy is not in the list still draws as one dimmed line. 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 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". diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index 675cc9457a..9c75c5dd5f 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -787,11 +787,15 @@ as "Adopted → #15574 · superseded" with the gate saying 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 is **not a row of its own** in the Activity Monitor -while its copy is listed: the tracker marks it `superseded_by: M` and the -SPA folds it into the copy's "adopted from @x's #N" chip, whose hover says -whether #N is closed or still open and closing when the copy merges. The -issue's caption, open-PR count, parked-PR check and "Let hive decide — all N +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 diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 31f8cb5296..0f9eb56a66 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -649,9 +649,11 @@ type StageTrackerLinkedPR struct { Lineage *StageTrackerLineage `json:"lineage,omitempty"` // State is "closed" for an adopted original the hive (or a person) // closed once its copy existed (hivecommons/hive#15126): the sub-row - // is one dimmed line "#N · closed · superseded by #M" with no - // chevron track. SupersededBy is the copy; Title is cached from the - // copy (same commits, same title), never fetched live. + // is one muted line "#N <title> superseded · closed · hive adopted → + // #M" with no chevron track, listed only while the copy is listed open + // (hivecommons/hive#15511). SupersededBy is the copy (set on an open + // original too, once the copy exists); Title is cached from the copy + // (same commits, same title), never fetched live. State string `json:"state,omitempty"` SupersededBy int `json:"superseded_by,omitempty"` // Hold mirrors the nested PR's own row field (hivecommons/hive#15020). @@ -3147,7 +3149,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin } seen[lp.Number] = true pr := prs[it.Repo+"#"+strconv.Itoa(lp.Number)] - if pr == nil && (open == nil || !open(it.Repo, lp.Number)) { + if pr == nil && (open == nil || !open(it.Repo, lp.Number)) && !stageTrackerClosedOriginalListed(it, lp, prs) { return } if pr != nil { @@ -3280,6 +3282,15 @@ func stageTrackerLinkedPRProgress(it *StageTrackerItem) { it.Actor = "its PR" } +// stageTrackerClosedOriginalListed keeps a closed adopted original in its +// issue's list while the hive copy that superseded it is itself listed +// open there: it draws as one muted "superseded · closed · hive adopted → +// #M" line (hivecommons/hive#15511). Once the copy merges or closes the +// original leaves with it. +func stageTrackerClosedOriginalListed(issue *StageTrackerItem, lp StageTrackerLinkedPR, prs map[string]*StageTrackerItem) bool { + return lp.State == "closed" && lp.SupersededBy > 0 && prs[issue.Repo+"#"+strconv.Itoa(lp.SupersededBy)] != nil +} + // stageTrackerLinkedPRSupersededByListed reports whether lp is the // original of an adoption pair whose hive copy is itself listed open under // the same issue (or a closed original the copy replaced): the pair is one diff --git a/src/pkg/dashboard/stage_tracker_adoption_close_first_test.go b/src/pkg/dashboard/stage_tracker_adoption_close_first_test.go index 207125f35c..71dad03c45 100644 --- a/src/pkg/dashboard/stage_tracker_adoption_close_first_test.go +++ b/src/pkg/dashboard/stage_tracker_adoption_close_first_test.go @@ -66,8 +66,10 @@ func TestStageTrackerCloseFirstCopyFailedSaysWhy(t *testing.T) { // A closed original (#15184, closed first when its copy #15247 opened) // must not ride under its issue as a bare sub-row with an empty ladder: // the claims index still names it "open" for a while, and the status -// enumeration's bucket reason still names it. The live copy keeps the -// trace as `supersedes` metadata only (hivecommons/hive#15135 follow-up). +// enumeration's bucket reason still names it. It rides as the muted +// "superseded · closed · hive adopted → #15247" line while the copy is +// open (hivecommons/hive#15511), and the live copy keeps the trace as +// `supersedes` metadata (hivecommons/hive#15135 follow-up). func TestStageTrackerClosedSupersededPRNotASubRow(t *testing.T) { now := time.Date(2026, 10, 29, 2, 30, 0, 0, time.UTC) s := newTestServer() @@ -100,8 +102,11 @@ func TestStageTrackerClosedSupersededPRNotASubRow(t *testing.T) { } } issue := trackerItem(t, resp, "issue", 15183) - if len(issue.LinkedPRs) != 1 || issue.LinkedPRs[0].Number != 15247 { - t.Fatalf("issue 15183 linked_prs = %+v (want only the live copy #15247)", issue.LinkedPRs) + if len(issue.LinkedPRs) != 2 || issue.LinkedPRs[0].Number != 15247 || issue.LinkedPRs[1].Number != 15184 { + t.Fatalf("issue 15183 linked_prs = %+v (want the live copy #15247 and the muted closed original)", issue.LinkedPRs) + } + if c := issue.LinkedPRs[1]; c.State != "closed" || c.SupersededBy != 15247 || c.Caption != "superseded · closed · hive adopted → #15247" || c.Title == "" || c.Stage != 0 { + t.Fatalf("closed original must be the muted line, never a bare numbered row: %+v", c) } lp := issue.LinkedPRs[0] if lp.Stage != 70 || lp.Title == "" { diff --git a/src/pkg/dashboard/stage_tracker_attention_order_test.go b/src/pkg/dashboard/stage_tracker_attention_order_test.go index c456dc0157..5738eae1dc 100644 --- a/src/pkg/dashboard/stage_tracker_attention_order_test.go +++ b/src/pkg/dashboard/stage_tracker_attention_order_test.go @@ -115,7 +115,9 @@ func TestStageTrackerAttentionOrderJS(t *testing.T) { "var _stageTrackerFilter = stageTrackerDefaultFilter();", jsFunc(t, html, "stageTrackerAnchor"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), jsFunc(t, html, "stageTrackerSortKey"), jsFunc(t, html, "stageTrackerRegressionHandled"), diff --git a/src/pkg/dashboard/stage_tracker_decided.go b/src/pkg/dashboard/stage_tracker_decided.go index 4c3396397b..7c011b28a7 100644 --- a/src/pkg/dashboard/stage_tracker_decided.go +++ b/src/pkg/dashboard/stage_tracker_decided.go @@ -168,7 +168,7 @@ func stageTrackerDecided(it StageTrackerItem, sweep automerge.SweepState, now ti switch { case it.AdoptedBy > 0 && verdict == string(delegatedecision.VerdictAdoptSupersede): d.Effect, d.SupersededBy = decidedEffectLanded, it.AdoptedBy - d.Text = "Adopted → #" + strconv.Itoa(it.AdoptedBy) + " · superseded (hive re-authored with sign-off)" + d.Text = stageTrackerSupersededNote(it.AdoptedBy, false) case moved || a.State == operatorActionStateAddressed: d.Effect = decidedEffectLanded case !a.At.IsZero() && now.Sub(a.At) >= timeout: @@ -311,8 +311,10 @@ func (s *Server) applyDecidedProjection(items []StageTrackerItem, now time.Time) pr := prs[it.Repo+"#"+strconv.Itoa(it.LinkedPR)] if pr == nil { s.stageTrackerClosedOriginal(it, prs, store) + stageTrackerListClosedOriginals(it, prs) continue } + stageTrackerListClosedOriginals(it, prs) if copy := prs[it.Repo+"#"+strconv.Itoa(pr.AdoptedBy)]; pr.AdoptedBy > 0 && copy != nil { stageTrackerFollowAdoption(it, pr, copy) continue @@ -396,7 +398,7 @@ func (s *Server) stageTrackerClosedOriginal(issue *StageTrackerItem, prs map[str return } orig := StageTrackerLinkedPR{Number: issue.LinkedPR, State: "closed", SupersededBy: copy.Number, Title: copy.Title, - Caption: "closed · superseded by #" + strconv.Itoa(copy.Number)} + Caption: stageTrackerSupersededNote(copy.Number, true)} if a := s.stageTrackerLatestDecision(issue.Repo, issue.LinkedPR); a != nil { orig.LastOperatorAction = a copy.AdoptedFrom = stageTrackerAdoptedFrom(&StageTrackerItem{Number: issue.LinkedPR, LastOperatorAction: a}, time.Time{}) @@ -409,6 +411,51 @@ func (s *Server) stageTrackerClosedOriginal(issue *StageTrackerItem, prs map[str issue.LinkedPRs = append(issue.LinkedPRs, orig) } +// stageTrackerSupersededNote is the muted sub-row's trailing note for an +// adopted original (owner, hivecommons/hive#15511: one short line, +// "superseded · hive adopted → #15574"; "superseded · closed · hive adopted +// → #15574" once the close landed — the "re-authored with sign-off" part +// lives in the hover). +func stageTrackerSupersededNote(copy int, closed bool) string { + if closed { + return "superseded · closed · hive adopted → #" + strconv.Itoa(copy) + } + return "superseded · hive adopted → #" + strconv.Itoa(copy) +} + +// stageTrackerListClosedOriginals lists, under an issue, the closed +// original of every hive copy the issue carries (the copy's lineage names +// it: from_number, from_state closed), as a muted "superseded · closed · +// hive adopted → #M" line. Closed PRs are not in the open-PR projection, so +// without this the original vanished the moment the close-first close +// landed; the owner wants it visible in that muted form while its +// superseder is open (hivecommons/hive#15511). A copy that merged or closed +// is not listed, so its original goes with it. +func stageTrackerListClosedOriginals(issue *StageTrackerItem, prs map[string]*StageTrackerItem) { + for _, lp := range slices.Clone(issue.LinkedPRs) { + copy := prs[issue.Repo+"#"+strconv.Itoa(lp.Number)] + if copy == nil || copy.Lineage == nil || copy.Lineage.Kind != lineageAdopted || copy.Lineage.FromState != lineageFromStateClosed || copy.Lineage.FromNumber <= 0 { + continue + } + n := copy.Lineage.FromNumber + if n == issue.LinkedPR || prs[issue.Repo+"#"+strconv.Itoa(n)] != nil { + continue + } + closed := StageTrackerLinkedPR{Number: n, URL: copy.Lineage.FromURL, State: "closed", SupersededBy: copy.Number, + Title: copy.Title, Author: copy.Lineage.FromAuthor, AuthorKind: copy.Lineage.FromAuthorKind, Caption: stageTrackerSupersededNote(copy.Number, true)} + // The claims index may still list the original as open for a while + // after the close: that bare entry becomes the muted line. + if k := slices.IndexFunc(issue.LinkedPRs, func(x StageTrackerLinkedPR) bool { return x.Number == n }); k >= 0 { + if issue.LinkedPRs[k].URL != "" { + closed.URL = issue.LinkedPRs[k].URL + } + issue.LinkedPRs[k] = closed + continue + } + issue.LinkedPRs = append(issue.LinkedPRs, closed) + } +} + // stageTrackerLatestDecision reads the ledger for the newest decision // recorded on repo#number, or nil. func (s *Server) stageTrackerLatestDecision(repo string, number int) *StageTrackerOperatorAction { diff --git a/src/pkg/dashboard/stage_tracker_decided_test.go b/src/pkg/dashboard/stage_tracker_decided_test.go index 3bcbfe1047..f7c2471d9c 100644 --- a/src/pkg/dashboard/stage_tracker_decided_test.go +++ b/src/pkg/dashboard/stage_tracker_decided_test.go @@ -80,7 +80,7 @@ func TestStageTrackerDecidedProjection(t *testing.T) { if o.Decided == nil || o.Decided.Effect != decidedEffectLanded || o.Decided.SupersededBy != 15123 || o.Stage != stagelabels.AdoptedByHive.Number() { t.Fatalf("original: %+v", o.Decided) } - if !strings.HasPrefix(o.Decided.Text, "Adopted → #15123 · superseded") { + if o.Decided.Text != "superseded · hive adopted → #15123" { t.Fatalf("original text %q", o.Decided.Text) } if c.AdoptedFrom == nil || c.AdoptedFrom.Number != 15029 || c.AdoptedFrom.DecidedBy != "clubanderson" || c.AdoptedFrom.Text != "↳ adopted from #15029 · you let hive decide 17:51 UTC" { @@ -113,7 +113,7 @@ func TestStageTrackerDecidedProjection(t *testing.T) { t.Fatalf("linked_prs = %+v", is.LinkedPRs) } orig := is.LinkedPRs[0] - if orig.Number != 15029 || orig.State != "closed" || orig.SupersededBy != 15123 || orig.Title != "fix: decided state" || orig.Caption != "closed · superseded by #15123" { + if orig.Number != 15029 || orig.State != "closed" || orig.SupersededBy != 15123 || orig.Title != "fix: decided state" || orig.Caption != "superseded · closed · hive adopted → #15123" { t.Fatalf("closed original = %+v", orig) } if c.AdoptedFrom == nil || c.AdoptedFrom.Number != 15029 { diff --git a/src/pkg/dashboard/stage_tracker_decided_ui_test.go b/src/pkg/dashboard/stage_tracker_decided_ui_test.go index f9196af653..e13bde72ad 100644 --- a/src/pkg/dashboard/stage_tracker_decided_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_decided_ui_test.go @@ -34,6 +34,7 @@ func stageTrackerDecidedUIJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerDecidedActing"), jsFunc(t, html, "stageTrackerDecidedLead"), jsFunc(t, html, "stageTrackerLinkedSupersededText"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerSupersededOriginalClause"), jsFunc(t, html, "stageTrackerAdoptedFromChipHtml"), // Pending entries as stageTrackerRowDeciding reads them. @@ -166,82 +167,100 @@ for (const a of ['adopted', 'directed', 'closed', 'merged', 'queued-for-merge', } // ── 3. landed: the adoption pair ──────────────────────────────────────── -// A superseded PR is closed and not listed (owner, #15526 under #15511): -// the original is NOT its own sub-row — it lives only in the copy's -// "↳ adopted from #15029 · you let hive decide 11:57 UTC" chip, whose -// tooltip names its state; the copy carries the single active chevron -// and the issue row's pill follows the copy. +// The superseded original stays listed under the issue as one muted, +// chevron-less sub-row (owner likes the look, hivecommons/hive#15511) whose +// trailing note is short and never wraps: "superseded · hive adopted → +// #15123" — the "re-authored with sign-off" part moved into the hover. The +// copy carries the single active chevron and its "↳ adopted from #15029 · +// you let hive decide 11:57 UTC" chip; the issue row's pill follows the copy. { const landed = Object.assign({}, decidedPending, { effect: 'landed', superseded_by: 15123, next_at: undefined }); const orig = original({ stage: 74, modifiers: [], manual_merge: false, human_merge_reason_text: '', adopted_by: 15123, adopted_by_state: 'open', superseded_by: 15123, decided: landed, last_operator_action: Object.assign({}, acted, { state: 'addressed' }), operator_action_count: 1 }); const copy = { number: 15123, title: 'fix: tracker pill', url: 'u123', stage: 50, author: 'hivecommons-hive[bot]', author_kind: 'hive', modifiers: [], adopted_from: { number: 15029, url: 'u29', author: 'Karibhou', state: 'open', decided_by: 'clubanderson', decided_at: at, decided_action: 'let-hive-decide', verdict: 'adopt-supersede', text: '↳ adopted from #15029 · you let hive decide 11:57 UTC' } }; const issue = issueOf([orig, copy], { stage: 50 }); const row = stageTrackerRowHtml(issue, stages, ctx); - assert.strictEqual(stageTrackerLinkedFoldedInto(orig, issue), 15123, 'the original folds into the listed open copy'); - assert.strictEqual(stageTrackerLinkedFoldedInto(copy, issue), 0, 'the copy is never folded'); - // One drawn PR left: the issue row carries the copy inline, no sub-rows. - assert.strictEqual(subs(row).length, 0, 'the superseded original is not a sub-row; the copy rides the issue row: ' + row); - assert.ok(!row.includes('ham-sub-superseded'), 'no dimmed superseded line while the copy is listed: ' + row); - assert.ok(!row.includes('data-ham-superseded-by="15123"')); - assert.ok(!text(row).includes('Adopted → #15123'), 'the superseded caption is not a row: ' + text(row)); - assert.ok(!row.includes('<span class="ham-pr-num">#15029</span>'), 'the original is never a PR ref of its own, only the chip: ' + row); - assert.ok(row.includes('aria-current="step"'), 'the copy carries the active chevron'); - assert.ok(row.includes('class="ham-badge ham-adopted-from"') && /↳ adopted from #15029 · you let hive decide 11:57( AM)? UTC/.test(text(row)), 'the adopted-from chip: ' + text(row)); - const chipTip = (/class="ham-badge ham-adopted-from"[^>]*title="([^"]*)"/.exec(row) || [])[1] || ''; + // subs() counts full sub-rows only; the muted line is a "ham-sub ham-sub-superseded". + const parts = (r) => r.split('<div class="ham-sub').slice(1); + const part = (r, n) => parts(r).find(s => s.includes('pr#' + n + '"')) || ''; + assert.deepStrictEqual(parts(row).map(s => (/pr#(\d+)"/.exec(s) || [])[1]), ['15029', '15123'], 'two sub-rows, the original muted: ' + row); + assert.strictEqual(subs(row).length, 1, 'one full sub-row: the copy'); + const dim = part(row, 15029); + assert.ok(dim.startsWith(' ham-sub-superseded"'), 'the original is the muted line: ' + dim); + assert.ok(dim.includes('data-ham-superseded-by="15123"')); + const note = (/<span class="ham-superseded-note"[^>]*>([^<]*)<\/span>/.exec(dim) || [])[1] || ''; + assert.strictEqual(note, 'superseded · hive adopted → #15123', 'the note is short, one line, no parenthetical: ' + note); + assert.ok(!note.includes('re-authored') && !note.includes('(') && !text(dim).includes('(hive re-authored'), 'no parenthetical in the row: ' + text(dim)); + const noteTip = (/<span class="ham-superseded-note" title="([^"]*)"/.exec(dim) || [])[1] || ''; + assert.strictEqual(noteTip, 'Hive re-authored this PR as #15123 with the same commits and sign-off. This PR closes as superseded when #15123 merges.', noteTip); + assert.ok(!dim.includes('aria-label="Pipeline progress"') && !dim.includes('aria-current="step"'), 'no chevron track on the muted line'); + assert.ok(!dim.includes('ham-kebab') && !dim.includes('ham-sel'), 'no row tools on the muted line'); + assert.ok(text(dim).includes('#15029') && text(dim).includes('fix: tracker pill'), 'greyed title stays: ' + text(dim)); + const cp = part(row, 15123); + assert.ok(cp.includes('aria-current="step"'), 'the copy carries the active chevron'); + assert.ok(cp.includes('class="ham-badge ham-adopted-from"') && /↳ adopted from #15029 · you let hive decide 11:57( AM)? UTC/.test(text(cp)), 'the adopted-from chip on the copy: ' + text(cp)); + const chipTip = (/class="ham-badge ham-adopted-from"[^>]*title="([^"]*)"/.exec(cp) || [])[1] || ''; assert.ok(chipTip.includes('#15029 is superseded and still open; it closes when this merges.'), 'the chip tooltip names the superseded state: ' + chipTip); - assert.ok(!text(row).includes('untrusted author'), 'the copy is hive-authored'); + assert.ok(!text(cp).includes('untrusted author'), 'the copy is hive-authored'); assert.strictEqual((row.match(/aria-current="step"/g) || []).length, 1, 'exactly one active chevron: the copy'); assert.ok(pill(row).includes('CI / Review'), 'the active pill follows the copy: ' + pill(row)); - // With a third, unrelated PR the copy is a sub-row and the original still is not. - const third = { number: 15200, title: 'docs: note', url: 'u200', stage: 70, author: 'pat', author_kind: 'human', modifiers: [] }; - const row3 = stageTrackerRowHtml(issueOf([orig, copy, third], { stage: 50 }), stages, ctx); - assert.deepStrictEqual(subs(row3).map(s => (/pr#(\d+)"/.exec(s) || [])[1]), ['15123', '15200'], 'sub-rows: the copy and the unrelated PR, never the original'); - assert.ok(!row3.includes('ham-sub-superseded') && !row3.includes('<span class="ham-pr-num">#15029</span>'), 'the original lives only in the chip'); assert.ok(!/Approving/.test(row)); - // The same fold without superseded_by (a pre-roll payload): adopted_by - // plus a live copy folds too. - const legacy = issueOf([original({ stage: 74, modifiers: [], adopted_by: 15123, adopted_by_state: 'open', decided: landed }), copy], { stage: 50 }); - assert.ok(!stageTrackerRowHtml(legacy, stages, ctx).includes('ham-sub-superseded'), 'adopted_by + live copy folds without superseded_by'); - // The copy closed (copy-failed / recovering): the original is live again. - const recovering = issueOf([original({ stage: 70, modifiers: [], adopted_by: 15123, adopted_by_state: 'closed', superseded_by: 15123 }), Object.assign({}, copy, { state: 'closed' })], { stage: 70 }); - assert.strictEqual(stageTrackerLinkedFoldedInto(recovering.linked_prs[0], recovering), 0, 'a closed copy never folds its original'); + // The same muted line without superseded_by (an older payload): adopted_by + // with a live copy in the list is enough. + const legacy = stageTrackerRowHtml(issueOf([original({ stage: 74, modifiers: [], manual_merge: false, human_merge_reason_text: '', adopted_by: 15123, adopted_by_state: 'open' }), copy], { stage: 50 }), stages, ctx); + assert.ok(part(legacy, 15029).startsWith(' ham-sub-superseded"') && text(part(legacy, 15029)).includes('superseded · hive adopted → #15123'), 'legacy payload: ' + text(legacy)); + // A copy that was closed (recovering): the original is a live PR again + // — a full sub-row with a chevron, no muted line. + const recovering = issueOf([original({ stage: 85, modifiers: [], adopted_by: 15123, adopted_by_state: 'closed', superseded_by: 0 }), Object.assign({}, copy, { state: 'closed' })], { stage: 85 }); + assert.strictEqual(stageTrackerLinkedSuperseder(recovering.linked_prs[0], recovering), 0, 'a closed copy never supersedes its original'); + const rrow = stageTrackerRowHtml(recovering, stages, ctx); + assert.ok(!rrow.includes('ham-sub-superseded') && rrow.includes('aria-label="Pipeline progress"'), 'recovering: the original is a live row: ' + rrow); } // ── 4. closed original ────────────────────────────────────────────────── -// A closed-superseded original whose copy is listed folds away too — the -// chip says "#15029 is closed as superseded." Only when the copy is not -// in the list does the closed original draw as one dimmed line with the -// cached title: "#15029 fix: tracker pill · closed · superseded by #15123". +// Once the close-first close landed the original is still listed, in the +// same muted form, while its superseder is open: the note becomes +// "superseded · closed · hive adopted → #15123". With the copy gone from +// the list (merged, closed) the closed original goes with it. { - const closed = { number: 15029, title: 'fix: tracker pill', url: 'u29', stage: 74, state: 'closed', superseded_by: 15123, adopted_by: 15123, adopted_by_state: 'open', caption: 'closed · superseded by #15123', modifiers: [] }; + const closed = { number: 15029, title: 'fix: tracker pill', url: 'u29', stage: 74, state: 'closed', superseded_by: 15123, adopted_by: 15123, adopted_by_state: 'open', caption: 'superseded · closed · hive adopted → #15123', modifiers: [] }; const copy = { number: 15123, title: 'fix: tracker pill', url: 'u123', stage: 50, author: 'hivecommons-hive[bot]', author_kind: 'hive', modifiers: [], adopted_from: { number: 15029, url: 'u29', author: 'Karibhou', state: 'closed', text: '↳ adopted from #15029' } }; const row = stageTrackerRowHtml(issueOf([closed, copy], { stage: 50 }), stages, ctx); - assert.ok(!row.includes('ham-sub-superseded'), 'the closed original folds into the listed copy: ' + row); - assert.strictEqual(subs(row).length, 0, 'the copy rides the issue row alone'); - assert.ok(!row.includes('<span class="ham-pr-num">#15029</span>'), 'the closed original is not a PR ref of its own'); - const chipTip = (/class="ham-badge ham-adopted-from"[^>]*title="([^"]*)"/.exec(row) || [])[1] || ''; + const parts = (r) => r.split('<div class="ham-sub').slice(1); + const part = (r, n) => parts(r).find(s => s.includes('pr#' + n + '"')) || ''; + const dim = part(row, 15029); + assert.ok(dim.startsWith(' ham-sub-superseded"'), 'the closed original renders as a muted line: ' + row); + assert.strictEqual(subs(row).length, 1, 'one full sub-row: the copy'); + const note = (/<span class="ham-superseded-note"[^>]*>([^<]*)<\/span>/.exec(dim) || [])[1] || ''; + assert.strictEqual(note, 'superseded · closed · hive adopted → #15123', note); + assert.ok(text(dim).includes('#15029') && text(dim).includes('fix: tracker pill'), 'cached title, no live fetch: ' + text(dim)); + assert.ok(!dim.includes('aria-label="Pipeline progress"'), 'no hollow chevrons'); + const noteTip = (/<span class="ham-superseded-note" title="([^"]*)"/.exec(dim) || [])[1] || ''; + assert.ok(noteTip.includes('This PR is closed as superseded.'), noteTip); + const chipTip = (/class="ham-badge ham-adopted-from"[^>]*title="([^"]*)"/.exec(part(row, 15123)) || [])[1] || ''; assert.ok(chipTip.includes('#15029 is closed as superseded.'), 'the chip tooltip says closed: ' + chipTip); assert.ok(!stageTrackerLinkedPROpen(stageTrackerLinkedPRItem(issueOf([closed]), closed)), 'a closed PR is not an open linked PR'); - // Copy not listed under this issue: the closed original is still shown - // (inline when it is the only PR, a dimmed line beside other PRs). + // The issue row never shows a blank numbered sub-row. + for (const s of row.split('<div class="ham-sub').slice(1)) assert.ok(text(s).replace(/^#\d+\s*$/, '') !== '', 'never a blank numbered row: ' + text(s)); + // Copy not listed (merged / closed): the closed original is not drawn. + assert.ok(stageTrackerLinkedSupersededGone(closed, issueOf([closed])), 'no superseder listed: gone'); + assert.ok(stageTrackerLinkedSupersededGone(closed, issueOf([closed, Object.assign({}, copy, { state: 'closed' })])), 'closed superseder: gone'); + assert.deepStrictEqual(stageTrackerLinkedSorted(issueOf([closed, copy], { stage: 50 }), stages).map(lp => lp.number), [15029, 15123]); + assert.deepStrictEqual(stageTrackerLinkedSorted(issueOf([closed], { stage: 74 }), stages).map(lp => lp.number), []); const alone = stageTrackerRowHtml(issueOf([closed], { stage: 74 }), stages, ctx); - assert.ok(alone.includes('<span class="ham-pr-num">#15029</span>'), 'the orphaned closed original stays visible: ' + text(alone)); - const other = { number: 15200, title: 'docs: note', url: 'u200', stage: 70, author: 'pat', author_kind: 'human', modifiers: [] }; - const beside = stageTrackerRowHtml(issueOf([closed, other], { stage: 50 }), stages, ctx); - const dim = (/<div class="ham-sub ham-sub-superseded"[\s\S]*?<\/div>\s*<\/div>/.exec(beside) || [''])[0]; - assert.ok(dim, 'the closed original renders as a line, not a bare number: ' + beside); - assert.ok(text(dim).includes('#15029') && text(dim).includes('fix: tracker pill'), 'cached title, no live fetch: ' + text(dim)); - assert.ok(text(dim).includes('closed · superseded by #15123'), text(dim)); - assert.ok(!dim.includes('aria-label="Pipeline progress"'), 'no hollow chevrons'); - for (const s of beside.split('<div class="ham-sub').slice(1)) assert.ok(text(s).replace(/^#\d+\s*$/, '') !== '', 'never a blank numbered row: ' + text(s)); + assert.ok(!alone.includes('<span class="ham-pr-num">#15029</span>'), 'the orphaned closed original is not drawn: ' + text(alone)); } // ── 5. superseded text is pure and conservative ───────────────────────── -assert.strictEqual(stageTrackerLinkedSupersededText({ state: 'closed', superseded_by: 9 }, null), 'closed · superseded by #9'); -assert.strictEqual(stageTrackerLinkedSupersededText({ adopted_by: 9, adopted_by_state: 'open' }, { linked_prs: [{ number: 9 }] }), '', 'an open superseded original never dims as its own row — it folds'); +assert.strictEqual(stageTrackerLinkedSupersededText({ state: 'closed', superseded_by: 9 }, { linked_prs: [{ number: 9 }] }), 'superseded · closed · hive adopted → #9'); +assert.strictEqual(stageTrackerLinkedSupersededText({ state: 'closed', superseded_by: 9 }, null), '', 'a closed original without its copy listed says nothing'); +assert.strictEqual(stageTrackerLinkedSupersededText({ adopted_by: 9, adopted_by_state: 'open' }, { linked_prs: [{ number: 9 }] }), 'superseded · hive adopted → #9'); +assert.strictEqual(stageTrackerLinkedSupersededText({ superseded_by: 9 }, { linked_prs: [{ number: 9 }] }), 'superseded · hive adopted → #9'); assert.strictEqual(stageTrackerLinkedSupersededText({ adopted_by: 9, adopted_by_state: 'open' }, { linked_prs: [{ number: 8 }] }), ''); assert.strictEqual(stageTrackerLinkedSupersededText({ adopted_by: 9, adopted_by_state: 'closed' }, { linked_prs: [{ number: 9 }] }), '', 'a closed copy keeps the original live (recovering)'); +assert.strictEqual(stageTrackerLinkedSupersededText({ adopted_by: 9, adopted_by_state: 'open' }, { linked_prs: [{ number: 9, state: 'closed' }] }), '', 'a copy listed closed does not supersede'); assert.strictEqual(stageTrackerLinkedSupersededText({}, null), ''); +assert.strictEqual(stageTrackerLinkedSupersededTip({ superseded_by: 9 }), 'Hive re-authored this PR as #9 with the same commits and sign-off. This PR closes as superseded when #9 merges.'); +assert.strictEqual(stageTrackerLinkedSupersededTip({ adopted_by: 9, state: 'closed' }), 'Hive re-authored this PR as #9 with the same commits and sign-off. This PR is closed as superseded.'); assert.strictEqual(stageTrackerSupersededOriginalClause(9, 'open'), ' #9 is superseded and still open; it closes when this merges.'); assert.strictEqual(stageTrackerSupersededOriginalClause(9, 'closed'), ' #9 is closed as superseded.'); assert.strictEqual(stageTrackerSupersededOriginalClause(9, ''), ''); diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index 22a7e1b6dc..de848662f0 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -271,7 +271,9 @@ func TestStageTrackerMotionDetector(t *testing.T) { jsFunc(t, html, "stageTrackerItemKey"), jsFunc(t, html, "stageTrackerPRKey"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), jsConstLine(t, html, "STAGE_TRACKER_ATTENTION_STAGES"), jsConstLine(t, html, "STAGE_TRACKER_HUMAN_MODS"), @@ -457,7 +459,9 @@ func TestStageTrackerMotionRowStamp(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), jsFunc(t, html, "stageTrackerNeedsAttention"), stageTrackerTierJS(t, html), @@ -584,7 +588,9 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), jsFunc(t, html, "stageTrackerNeedsAttention"), stageTrackerTierJS(t, html), diff --git a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go index a7eee19c88..9e5fe1a2be 100644 --- a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go +++ b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go @@ -169,7 +169,9 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), @@ -192,7 +194,6 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerItemKey"), jsFunc(t, html, "stageTrackerMoveAttrs"), jsFunc(t, html, "stageTrackerNeedsAttention"), - jsFunc(t, html, "stageTrackerFoldSuperseded"), jsFunc(t, html, "stageTrackerVisible"), jsFunc(t, html, "stageTrackerRepoTint"), jsFunc(t, html, "stageTrackerRepoShort"), diff --git a/src/pkg/dashboard/stage_tracker_superseded_fold_test.go b/src/pkg/dashboard/stage_tracker_superseded_fold_test.go deleted file mode 100644 index a8457e142d..0000000000 --- a/src/pkg/dashboard/stage_tracker_superseded_fold_test.go +++ /dev/null @@ -1,195 +0,0 @@ -package dashboard - -import ( - "encoding/json" - "strings" - "testing" - "time" - - "github.com/hivecommons/hive/pkg/config" - "github.com/hivecommons/hive/pkg/github" - "github.com/hivecommons/hive/pkg/stagelabels" -) - -// A PR superseded by a hive adoption is closed and not listed (owner, -// hivecommons/hive#15526 under #15511 drew beside hive's #15574 as a -// greyed "Adopted → #15574 · superseded" sub-row). The server marks the -// original with `superseded_by` so the SPA folds it into the copy's -// "adopted from" chip; the copy's lineage and adopted_from carry the -// original's state ("open" while the write-back gate kept it open, -// "closed" once close-first ran). -func supersededFoldFixture(t *testing.T, now time.Time) (*Server, *stagelabels.Store, *StatusPayload, string) { - t.Helper() - s := newTestServer() - store := stagelabels.NewStore("", func() time.Time { return now }) - s.stageStore = store - s.deps = &Dependencies{Config: &config.Config{}} - orig := stagelabels.Key("hivecommons/hive", 15526) - store.Observe(orig, stagelabels.AdoptedByHive, "contributor-lane:adopted") - store.MarkAdopted(orig, "ab12cd3", 15574, now.Add(-15*time.Minute)) - store.Observe(stagelabels.Key("hivecommons/hive", 15574), stagelabels.AwaitingMergeAdmission, "merge-lane:queued") - - status := minimalPayload() - status.HiveID = "hive" - status.Repos = []FrontendRepo{{ - Name: "hive", Full: "hivecommons/hive", - ActionableIssues: []any{github.Issue{Number: 15511, Title: "Tracker lists a superseded PR", Author: "clubanderson", Labels: []string{"stage/040-covered-by-pr"}, - LinkedPRs: []github.IssueLinkedPR{ - {Number: 15526, State: "open", URL: "https://github.com/hivecommons/hive/pull/15526", Closing: true}, - {Number: 15574, State: "open", URL: "https://github.com/hivecommons/hive/pull/15574", Closing: true}, - }}}, - OpenPrs: []any{ - FrontendPR{PullRequest: github.PullRequest{Number: 15526, Title: "fix: tracker", Author: "odttlnt", HeadSHA: "ab12cd3", Labels: []string{"author/clanker", "role/contributor", "stage/074-adopted-by-hive"}, - LinkedIssues: []github.PRLinkedIssue{{Number: 15511, State: "open"}}}}, - FrontendPR{PullRequest: github.PullRequest{Number: 15574, Title: "fix: tracker", Author: "hivecommons-hive[bot]", AppAuthored: true, HeadSHA: "ef45ab6", Labels: []string{"stage/080-merge-gate"}, - LinkedIssues: []github.PRLinkedIssue{{Number: 15511, State: "open"}}}}, - }, - }} - s.UpdateStatus(status) - return s, store, status, orig -} - -func TestStageTrackerSupersededOriginalCarriesSupersededBy(t *testing.T) { - now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) - s, store, status, _ := supersededFoldFixture(t, now) - resp := s.buildStageTracker(status, store, now) - - orig := trackerItem(t, resp, "pr", 15526) - if orig.SupersededBy != 15574 || orig.AdoptedBy != 15574 || orig.AdoptedByState != "" { - t.Fatalf("original superseded_by=%d adopted_by=%d state=%q", orig.SupersededBy, orig.AdoptedBy, orig.AdoptedByState) - } - if orig.NestedUnder != 15511 { - t.Fatalf("original nested_under=%d", orig.NestedUnder) - } - copyPR := trackerItem(t, resp, "pr", 15574) - if copyPR.SupersededBy != 0 { - t.Fatalf("copy must never carry superseded_by: %d", copyPR.SupersededBy) - } - if copyPR.AdoptedFrom == nil || copyPR.AdoptedFrom.Number != 15526 || copyPR.AdoptedFrom.State != "open" { - t.Fatalf("copy adopted_from = %+v", copyPR.AdoptedFrom) - } - if copyPR.Lineage == nil || copyPR.Lineage.FromNumber != 15526 || copyPR.Lineage.FromState != "open" { - t.Fatalf("copy lineage = %+v", copyPR.Lineage) - } - issue := trackerItem(t, resp, "issue", 15511) - var mirrored bool - for _, lp := range issue.LinkedPRs { - if lp.Number == 15526 { - mirrored = lp.SupersededBy == 15574 - } - } - if !mirrored { - t.Fatalf("issue linked_prs do not mirror superseded_by: %+v", issue.LinkedPRs) - } - raw, err := json.Marshal(orig) - if err != nil { - t.Fatal(err) - } - if !strings.Contains(string(raw), `"superseded_by":15574`) { - t.Fatalf("payload lacks superseded_by: %s", raw) - } -} - -func TestStageTrackerSupersededByClearsWhenCopyDies(t *testing.T) { - now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) - s, store, status, orig := supersededFoldFixture(t, now) - store.NoteAdoptionOrphaned(orig, 15574, now) - it := trackerItem(t, s.buildStageTracker(status, store, now), "pr", 15526) - if it.SupersededBy != 0 || it.AdoptedByState != "closed" { - t.Fatalf("orphaned original must not fold: superseded_by=%d state=%q", it.SupersededBy, it.AdoptedByState) - } -} - -func TestStageTrackerSupersededByOmittedForInPlaceAdoption(t *testing.T) { - now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) - s, store, status, key := orphanTrackerFixture(t, now, stagelabels.AdoptedByHive, "contributor-lane:adopted", []string{"stage/074-adopted-by-hive"}) - store.MarkAdoptedInPlace(key, "bc3a6ea", "contributor-lane:adopted-in-place", now) - it := trackerItem(t, s.buildStageTracker(status, store, now), "pr", 14947) - if it.SupersededBy != 0 { - t.Fatalf("in-place adoption has no superseder: %d", it.SupersededBy) - } -} - -func TestStageTrackerSupersededFromStateClosedAfterCloseFirst(t *testing.T) { - now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) - s, store, status, orig := supersededFoldFixture(t, now) - store.MarkSupersededClosedFirst(orig, 15574, false, now.Add(-10*time.Minute)) - resp := s.buildStageTracker(status, store, now) - for _, it := range resp.Items { - if it.Kind == "pr" && it.Number == 15526 { - t.Fatalf("closed original rendered as a row: %+v", it) - } - } - copyPR := trackerItem(t, resp, "pr", 15574) - if copyPR.Lineage == nil || copyPR.Lineage.FromNumber != 15526 || copyPR.Lineage.FromState != "closed" { - t.Fatalf("copy lineage = %+v", copyPR.Lineage) - } - if copyPR.AdoptedFrom != nil && copyPR.AdoptedFrom.State != "closed" { - t.Fatalf("copy adopted_from = %+v", copyPR.AdoptedFrom) - } - if copyPR.Supersedes == nil || copyPR.Supersedes.Number != 15526 || copyPR.Supersedes.Open { - t.Fatalf("copy supersedes = %+v", copyPR.Supersedes) - } -} - -// Ratchet (SPA): no item whose superseded_by names a rendered open PR -// appears as a row — nested under an issue or at top level. -func TestStageTrackerSupersededFoldRatchetJS(t *testing.T) { - html := indexHTML(t) - runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+"\n"+stageTrackerRowsFixtureJS+` -const since = new Date(now - 3600000).toISOString(); -const pr = (n, extra) => Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'pr', title: 'fix: tracker', url: 'https://x/' + n, stage: 74, stage_since: since, caption: 'Adopted', author: 'odttlnt', author_kind: 'clanker', modifiers: [] }, extra || {}); -const issue = (n, prs, extra) => Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'issue', title: 'Issue ' + n, url: 'https://x/i' + n, stage: 40, stage_since: since, linked_prs: prs }, extra || {}); -const copy = (n, from, extra) => pr(n, Object.assign({ author: 'hivecommons-hive[bot]', author_kind: 'hive', stage: 80, caption: 'Merge queued', adopted_from: { number: from, url: 'https://x/' + from, author: 'odttlnt', state: 'open', text: '↳ adopted from #' + from } }, extra || {})); - -// Nested: the issue lists both; only the copy is drawn. -{ - const orig = pr(15526, { adopted_by: 15574, adopted_by_state: '', superseded_by: 15574, nested_under: 15511 }); - const cp = copy(15574, 15526, { nested_under: 15511 }); - const items = [issue(15511, [orig, cp]), orig, cp]; - const rows = stageTrackerVisible(items, { kind: 'all', repo: '' }); - assert.deepStrictEqual(rows.map(r => r.kind + '#' + r.number), ['issue#15511'], 'the nested pair draws under the issue only'); - const subs = stageTrackerLinkedSorted(rows[0]).map(lp => lp.number); - assert.deepStrictEqual(subs, [15574], 'the superseded original is not a sub-row'); - const prs = stageTrackerVisible(items, { kind: 'pr', repo: '' }).map(r => r.number); - assert.deepStrictEqual(prs, [15574], 'the Pull requests filter never lists the superseded original'); -} -// Top level: the pair without an issue; the original folds. -{ - const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574 }); - const cp = copy(15574, 15526); - assert.deepStrictEqual(stageTrackerVisible([orig, cp], { kind: 'all', repo: '' }).map(r => r.number), [15574]); - assert.deepStrictEqual(stageTrackerFoldSuperseded([orig, cp]).map(r => r.number), [15574]); -} -// The superseder not drawn (closed / merged / absent): the original stays. -{ - const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574 }); - assert.deepStrictEqual(stageTrackerFoldSuperseded([orig]).map(r => r.number), [15526], 'no superseder listed: keep'); - assert.deepStrictEqual(stageTrackerFoldSuperseded([orig, copy(15574, 15526, { state: 'closed' })]).map(r => r.number), [15526, 15574], 'closed superseder: keep'); - assert.deepStrictEqual(stageTrackerFoldSuperseded([orig, copy(15574, 15526, { modifiers: ['merged'] })]).length, 1, 'a merged copy still drops the original: the fold only asks that the copy be drawn'); - const other = pr(15526, { repo: 'hivecommons/docs', adopted_by: 15574, superseded_by: 15574 }); - assert.deepStrictEqual(stageTrackerFoldSuperseded([other, copy(15574, 15526)]).map(r => r.repo + '#' + r.number), ['hivecommons/docs#15526', 'hivecommons/hive#15574'], 'repo-scoped: a same-numbered PR elsewhere is not the superseder'); -} -// Ratchet over a mixed fixture: no drawn row's superseded_by names a drawn open PR. -{ - const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574, nested_under: 15511 }); - const cp = copy(15574, 15526, { nested_under: 15511 }); - const loose = pr(15561, { adopted_by: 15567, superseded_by: 15567 }); - const looseCopy = copy(15567, 15561); - const items = [issue(15511, [orig, cp]), orig, cp, loose, looseCopy, pr(15600, { stage: 70, caption: 'Fixing' })]; - for (const f of [{ kind: 'all', repo: '' }, { kind: 'pr', repo: '' }]) { - const rows = stageTrackerVisible(items, f); - const drawn = new Set(); - for (const r of rows) { - if (r.kind === 'pr') drawn.add(r.repo + '#' + r.number); - if (r.kind === 'issue') for (const lp of stageTrackerLinkedSorted(r)) drawn.add(r.repo + '#' + lp.number); - } - for (const r of rows) { - if (r.kind === 'pr') assert.ok(!(Number(r.superseded_by) > 0 && drawn.has(r.repo + '#' + r.superseded_by)), 'ratchet: superseded row drawn beside its open superseder: ' + r.number); - if (r.kind === 'issue') for (const lp of stageTrackerLinkedSorted(r)) assert.ok(!(Number(lp.superseded_by) > 0 && drawn.has(r.repo + '#' + lp.superseded_by)), 'ratchet: superseded sub-row drawn beside its superseder: ' + lp.number); - } - assert.ok(drawn.has('hivecommons/hive#15574') && drawn.has('hivecommons/hive#15567') && drawn.has('hivecommons/hive#15600'), 'the copies and the unrelated PR draw: ' + [...drawn].join(',')); - } -} -`) -} diff --git a/src/pkg/dashboard/stage_tracker_superseded_row_test.go b/src/pkg/dashboard/stage_tracker_superseded_row_test.go new file mode 100644 index 0000000000..ea4f3e6960 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_superseded_row_test.go @@ -0,0 +1,258 @@ +package dashboard + +import ( + "encoding/json" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// A PR superseded by a hive adoption stays listed under its issue as one +// muted, chevron-less sub-row while its superseder is open (owner, +// hivecommons/hive#15511: hive's #15574 and, beneath it, the original +// #15526 greyed). The server marks the original with `superseded_by`, the +// copy's lineage / adopted_from carry the original's state ("open" while +// it waits, "closed" once close-first ran), a closed original is listed +// under the issue only while the copy is, and the note reads "superseded · +// hive adopted → #N" / "superseded · closed · hive adopted → #N". +func supersededRowFixture(t *testing.T, now time.Time) (*Server, *stagelabels.Store, *StatusPayload, string) { + t.Helper() + s := newTestServer() + store := stagelabels.NewStore("", func() time.Time { return now }) + s.stageStore = store + s.deps = &Dependencies{Config: &config.Config{}} + orig := stagelabels.Key("hivecommons/hive", 15526) + store.Observe(orig, stagelabels.AdoptedByHive, "contributor-lane:adopted") + store.MarkAdopted(orig, "ab12cd3", 15574, now.Add(-15*time.Minute)) + store.Observe(stagelabels.Key("hivecommons/hive", 15574), stagelabels.AwaitingMergeAdmission, "merge-lane:queued") + + status := minimalPayload() + status.HiveID = "hive" + status.Repos = []FrontendRepo{{ + Name: "hive", Full: "hivecommons/hive", + ActionableIssues: []any{github.Issue{Number: 15511, Title: "Tracker lists a superseded PR", Author: "clubanderson", Labels: []string{"stage/040-covered-by-pr"}, + LinkedPRs: []github.IssueLinkedPR{ + {Number: 15526, State: "open", URL: "https://github.com/hivecommons/hive/pull/15526", Closing: true}, + {Number: 15574, State: "open", URL: "https://github.com/hivecommons/hive/pull/15574", Closing: true}, + }}}, + OpenPrs: []any{ + FrontendPR{PullRequest: github.PullRequest{Number: 15526, Title: "fix: tracker", Author: "odttlnt", HeadSHA: "ab12cd3", Labels: []string{"author/clanker", "role/contributor", "stage/074-adopted-by-hive"}, + LinkedIssues: []github.PRLinkedIssue{{Number: 15511, State: "open"}}}}, + FrontendPR{PullRequest: github.PullRequest{Number: 15574, Title: "fix: tracker", Author: "hivecommons-hive[bot]", AppAuthored: true, HeadSHA: "ef45ab6", Labels: []string{"stage/080-merge-gate"}, + LinkedIssues: []github.PRLinkedIssue{{Number: 15511, State: "open"}}}}, + }, + }} + s.UpdateStatus(status) + return s, store, status, orig +} + +func TestStageTrackerSupersededOriginalCarriesSupersededBy(t *testing.T) { + now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) + s, store, status, _ := supersededRowFixture(t, now) + resp := s.buildStageTracker(status, store, now) + + orig := trackerItem(t, resp, "pr", 15526) + if orig.SupersededBy != 15574 || orig.AdoptedBy != 15574 || orig.AdoptedByState != "" { + t.Fatalf("original superseded_by=%d adopted_by=%d state=%q", orig.SupersededBy, orig.AdoptedBy, orig.AdoptedByState) + } + if orig.NestedUnder != 15511 { + t.Fatalf("original nested_under=%d", orig.NestedUnder) + } + copyPR := trackerItem(t, resp, "pr", 15574) + if copyPR.SupersededBy != 0 { + t.Fatalf("copy must never carry superseded_by: %d", copyPR.SupersededBy) + } + if copyPR.AdoptedFrom == nil || copyPR.AdoptedFrom.Number != 15526 || copyPR.AdoptedFrom.State != "open" { + t.Fatalf("copy adopted_from = %+v", copyPR.AdoptedFrom) + } + if copyPR.Lineage == nil || copyPR.Lineage.FromNumber != 15526 || copyPR.Lineage.FromState != "open" { + t.Fatalf("copy lineage = %+v", copyPR.Lineage) + } + issue := trackerItem(t, resp, "issue", 15511) + var mirrored bool + for _, lp := range issue.LinkedPRs { + if lp.Number == 15526 { + mirrored = lp.SupersededBy == 15574 + } + } + if !mirrored { + t.Fatalf("issue linked_prs do not mirror superseded_by: %+v", issue.LinkedPRs) + } + raw, err := json.Marshal(orig) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(raw), `"superseded_by":15574`) { + t.Fatalf("payload lacks superseded_by: %s", raw) + } +} + +func TestStageTrackerSupersededByClearsWhenCopyDies(t *testing.T) { + now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) + s, store, status, orig := supersededRowFixture(t, now) + store.NoteAdoptionOrphaned(orig, 15574, now) + it := trackerItem(t, s.buildStageTracker(status, store, now), "pr", 15526) + if it.SupersededBy != 0 || it.AdoptedByState != "closed" { + t.Fatalf("orphaned original must not fold: superseded_by=%d state=%q", it.SupersededBy, it.AdoptedByState) + } +} + +func TestStageTrackerSupersededByOmittedForInPlaceAdoption(t *testing.T) { + now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) + s, store, status, key := orphanTrackerFixture(t, now, stagelabels.AdoptedByHive, "contributor-lane:adopted", []string{"stage/074-adopted-by-hive"}) + store.MarkAdoptedInPlace(key, "bc3a6ea", "contributor-lane:adopted-in-place", now) + it := trackerItem(t, s.buildStageTracker(status, store, now), "pr", 14947) + if it.SupersededBy != 0 { + t.Fatalf("in-place adoption has no superseder: %d", it.SupersededBy) + } +} + +func TestStageTrackerSupersededClosedOriginalListedWhileCopyOpen(t *testing.T) { + now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) + s, store, status, orig := supersededRowFixture(t, now) + store.MarkSupersededClosedFirst(orig, 15574, false, now.Add(-10*time.Minute)) + // The close landed: GitHub's open-PR list no longer carries #15526. + status.Repos[0].OpenPrs = status.Repos[0].OpenPrs[1:] + s.UpdateStatus(status) + resp := s.buildStageTracker(status, store, now) + for _, it := range resp.Items { + if it.Kind == "pr" && it.Number == 15526 { + t.Fatalf("closed original rendered as a row of its own: %+v", it) + } + } + copyPR := trackerItem(t, resp, "pr", 15574) + if copyPR.Lineage == nil || copyPR.Lineage.FromNumber != 15526 || copyPR.Lineage.FromState != "closed" { + t.Fatalf("copy lineage = %+v", copyPR.Lineage) + } + if copyPR.Supersedes == nil || copyPR.Supersedes.Number != 15526 || copyPR.Supersedes.Open { + t.Fatalf("copy supersedes = %+v", copyPR.Supersedes) + } + issue := trackerItem(t, resp, "issue", 15511) + var closed *StageTrackerLinkedPR + for i := range issue.LinkedPRs { + if issue.LinkedPRs[i].Number == 15526 { + closed = &issue.LinkedPRs[i] + } + } + if closed == nil { + t.Fatalf("the closed original must stay listed under the issue while #15574 is open: %+v", issue.LinkedPRs) + } + if closed.State != "closed" || closed.SupersededBy != 15574 || closed.Caption != "superseded · closed · hive adopted → #15574" || closed.Title != "fix: tracker" || closed.AuthorKind != "clanker" { + t.Fatalf("closed original = %+v", *closed) + } +} + +func TestStageTrackerSupersededClosedOriginalLeavesWithCopy(t *testing.T) { + now := time.Date(2026, 10, 29, 23, 49, 0, 0, time.UTC) + s, store, status, orig := supersededRowFixture(t, now) + store.MarkSupersededClosedFirst(orig, 15574, false, now.Add(-10*time.Minute)) + // Both gone from GitHub's open list: the copy merged. + status.Repos[0].OpenPrs = nil + s.UpdateStatus(status) + resp := s.buildStageTracker(status, store, now) + for _, it := range resp.Items { + if it.Kind == "pr" && (it.Number == 15526 || it.Number == 15574) { + t.Fatalf("closed pair rendered: %+v", it) + } + if it.Kind == "issue" && it.Number == 15511 { + for _, lp := range it.LinkedPRs { + if lp.Number == 15526 { + t.Fatalf("closed original listed without its open superseder: %+v", it.LinkedPRs) + } + } + } + } +} + +func TestStageTrackerSupersededNoteCSSNeverWraps(t *testing.T) { + html := indexHTML(t) + rule := ".ham-superseded-note {" + i := strings.Index(html, rule) + if i < 0 { + t.Fatal("index.html lacks the .ham-superseded-note rule") + } + body := html[i : i+strings.Index(html[i:], "}")] + for _, want := range []string{"white-space: nowrap", "flex: 0 0 auto"} { + if !strings.Contains(body, want) { + t.Errorf("the superseded note must not wrap nor shrink (the title ellipsizes first): %q lacks %q", body, want) + } + } +} + +// Ratchet (SPA): a superseded original whose superseder is listed open is +// exactly one muted, chevron-less sub-row with the short note, never a +// full row of its own; a closed original leaves with its superseder. +func TestStageTrackerSupersededRowRatchetJS(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+"\n"+jsFunc(t, html, "stageTrackerLinkedSupersededText")+"\n"+jsFunc(t, html, "stageTrackerLinkedSupersededTip")+"\n"+stageTrackerRowsFixtureJS+` +const since = new Date(now - 3600000).toISOString(); +const pr = (n, extra) => Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'pr', title: 'dashboard: split stage_tracker.go into 4 files, a very long title that must ellipsize before the note does', url: 'https://x/' + n, stage: 74, stage_since: since, caption: 'Adopted', author: 'odttlnt', author_kind: 'clanker', modifiers: [] }, extra || {}); +const issue = (n, prs, extra) => Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'issue', title: 'Issue ' + n, url: 'https://x/i' + n, stage: 40, stage_since: since, linked_prs: prs }, extra || {}); +const copy = (n, from, extra) => pr(n, Object.assign({ author: 'hivecommons-hive[bot]', author_kind: 'hive', stage: 80, caption: 'Merge queued', adopted_from: { number: from, url: 'https://x/' + from, author: 'odttlnt', state: 'open', text: '↳ adopted from #' + from } }, extra || {})); +const noteOf = (sub) => (/<span class="ham-superseded-note"[^>]*>([^<]*)<\/span>/.exec(sub) || [])[1] || ''; +const subsOf = (row) => row.split('<div class="ham-sub').slice(1); + +// Nested: the issue lists both; the original is the muted line. +{ + const orig = pr(15526, { adopted_by: 15574, adopted_by_state: '', superseded_by: 15574, nested_under: 15511 }); + const cp = copy(15574, 15526, { nested_under: 15511 }); + const items = [issue(15511, [orig, cp]), orig, cp]; + const rows = stageTrackerVisible(items, { kind: 'all', repo: '' }); + assert.deepStrictEqual(rows.map(r => r.kind + '#' + r.number), ['issue#15511'], 'the nested pair draws under the issue only'); + assert.deepStrictEqual(stageTrackerLinkedSorted(rows[0]).map(lp => lp.number), [15574, 15526], 'the copy first, the muted original after it'); + const row = stageTrackerRowHtml(rows[0], stages, ctx); + const subs = subsOf(row); + assert.strictEqual(subs.length, 2, 'two sub-rows: ' + row); + const dim = subs.find(s => s.includes('ham-sub-superseded')) || ''; + assert.ok(dim && dim.includes('pr#15526"'), 'the original is the muted sub-row: ' + row); + assert.strictEqual(noteOf(dim), 'superseded · hive adopted → #15574'); + assert.ok(!dim.includes('aria-label="Pipeline progress"'), 'no chevron track'); + assert.ok(dim.includes('ham-pr-title'), 'the title is in its own ellipsizing span, the note is a non-shrinking sibling'); + assert.ok(/<span class="ham-superseded-note" title="Hive re-authored this PR as #15574 with the same commits and sign-off\. This PR closes as superseded when #15574 merges\."/.test(dim), 'hover carries the long form: ' + dim); + assert.strictEqual((row.match(/aria-label="Pipeline progress"/g) || []).length, 2, 'the issue strip and the copy strip only'); +} +// Closed original, copy open: the same muted line with "closed" in the note. +{ + const closed = pr(15526, { state: 'closed', superseded_by: 15574, caption: 'superseded · closed · hive adopted → #15574' }); + const cp = copy(15574, 15526, { adopted_from: { number: 15526, url: 'https://x/15526', author: 'odttlnt', state: 'closed', text: '↳ adopted from #15526' } }); + const row = stageTrackerRowHtml(issue(15511, [closed, cp]), stages, ctx); + const dim = subsOf(row).find(s => s.includes('ham-sub-superseded')) || ''; + assert.strictEqual(noteOf(dim), 'superseded · closed · hive adopted → #15574', row); + assert.ok(dim.includes('This PR is closed as superseded.')); + // Copy gone (merged / closed): the closed original is not drawn. + assert.deepStrictEqual(stageTrackerLinkedSorted(issue(15511, [closed])).map(lp => lp.number), []); + assert.deepStrictEqual(stageTrackerLinkedSorted(issue(15511, [closed, copy(15574, 15526, { state: 'closed' })])).map(lp => lp.number), []); +} +// Ratchet over a mixed fixture: every drawn PR whose superseded_by names a +// drawn open PR under the same issue is the muted line, never a full row. +{ + const orig = pr(15526, { adopted_by: 15574, superseded_by: 15574, nested_under: 15511 }); + const cp = copy(15574, 15526, { nested_under: 15511 }); + const loose = pr(15561, { adopted_by: 15567, superseded_by: 15567, nested_under: 15560 }); + const looseCopy = copy(15567, 15561, { nested_under: 15560 }); + const items = [issue(15511, [orig, cp]), issue(15560, [loose, looseCopy]), orig, cp, loose, looseCopy, pr(15600, { stage: 70, caption: 'Fixing' })]; + for (const f of [{ kind: 'all', repo: '' }, { kind: 'pr', repo: '' }]) { + const rows = stageTrackerVisible(items, f); + for (const r of rows) { + if (r.kind !== 'issue') continue; + const html = stageTrackerRowHtml(r, stages, ctx); + const listed = new Set(stageTrackerLinkedSorted(r).filter(lp => String(lp.state || '') !== 'closed').map(lp => lp.number)); + for (const sub of subsOf(html)) { + const n = Number((/pr#(\d+)"/.exec(sub) || [])[1]); + const lp = r.linked_prs.find(x => x.number === n); + if (lp && Number(lp.superseded_by) > 0 && listed.has(Number(lp.superseded_by))) { + assert.ok(sub.includes('ham-sub-superseded') && !sub.includes('aria-label="Pipeline progress"'), 'ratchet: superseded #' + n + ' must be the muted line, not a full row: ' + sub); + assert.ok(/^superseded · (closed · )?hive adopted → #\d+$/.test(noteOf(sub)), 'ratchet: note shape: ' + noteOf(sub)); + } + } + } + const top = rows.filter(r => r.kind === 'pr').map(r => r.number); + if (f.kind === 'all') assert.ok(!top.includes(15526) && !top.includes(15561), 'nested superseded originals never float to the top level: ' + top.join(',')); + } +} +`) +} diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 8e058ad890..5088befc1c 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -192,7 +192,9 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerLinkedTip"), jsConstLine(t, html, "STAGE_TRACKER_LINKED_GLYPH"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), @@ -219,7 +221,6 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerItemKey"), jsFunc(t, html, "stageTrackerMoveAttrs"), jsFunc(t, html, "stageTrackerNeedsAttention"), - jsFunc(t, html, "stageTrackerFoldSuperseded"), jsFunc(t, html, "stageTrackerVisible"), stageTrackerCuesJS(t, html), }, "\n") @@ -943,7 +944,9 @@ func TestStageTrackerFilterSortPage(t *testing.T) { "var _stageTrackerFilter = stageTrackerDefaultFilter();", jsFunc(t, html, "stageTrackerAnchor"), jsFunc(t, html, "stageTrackerLinkedDrawnHere"), - jsFunc(t, html, "stageTrackerLinkedFoldedInto"), + jsFunc(t, html, "stageTrackerLinkedSuperseder"), + jsFunc(t, html, "stageTrackerLinkedSupersededGone"), + jsFunc(t, html, "stageTrackerLinkedSupersededTip"), jsFunc(t, html, "stageTrackerLinkedSorted"), stageTrackerTierJS(t, html), jsFunc(t, html, "stageTrackerSortKey"), @@ -966,7 +969,6 @@ func TestStageTrackerFilterSortPage(t *testing.T) { jsFunc(t, html, "stageTrackerNormalizeFilter"), jsFunc(t, html, "stageTrackerFilterActive"), jsFunc(t, html, "stageTrackerMatches"), - jsFunc(t, html, "stageTrackerFoldSuperseded"), jsFunc(t, html, "stageTrackerVisible"), jsFunc(t, html, "stageTrackerRowCount"), jsFunc(t, html, "stageTrackerSort"), diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 446eab8ac6..c30ac4e5c1 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -376,7 +376,7 @@ .cue-acting > .ham-strip-row .ham-seg.active { background-image: repeating-linear-gradient(-45deg, transparent 0 6px, color-mix(in srgb, var(--surface-0) 28%, transparent) 6px 12px); background-size: 34px 100%; animation: cue-acting-stripes 1.1s linear infinite; } .ham-sub-superseded { opacity: .55; } .ham-sub-superseded .ham-row-head { min-height: 0; } - .ham-superseded-note { color: var(--muted); font-size: var(--fs-xs); } + .ham-superseded-note { color: var(--muted); font-size: var(--fs-xs); flex: 0 0 auto; white-space: nowrap; } .ham-adopted-from { color: var(--muted); text-decoration: none; } /* The Let hive decide preview. One decision, readable in three seconds (operator feedback on the dialog, issue 15397): subject line, diff --git a/src/pkg/dashboard/static-src/js/tracker-filter.js b/src/pkg/dashboard/static-src/js/tracker-filter.js index 14f82b1ee5..740cf4fc0a 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter.js @@ -206,26 +206,11 @@ // is nested under a listed issue is drawn as that issue's sub-row only. function stageTrackerVisible(items, filter, ctx) { const f = stageTrackerNormalizeFilter(filter || _stageTrackerFilter); - const rows = stageTrackerFoldSuperseded((items || []).filter(it => stageTrackerMatches(it, f, ctx))); + const rows = (items || []).filter(it => stageTrackerMatches(it, f, ctx)); if (f.kind === 'pr') return rows; const issues = new Set(rows.filter(it => it.kind === 'issue').map(it => it.repo + '#' + it.number)); return rows.filter(it => !(it.kind === 'pr' && it.nested_under && issues.has(it.repo + '#' + it.nested_under))); } - // Pure: drop every PR row whose `superseded_by` names a PR that is - // itself drawn open on this page — as a row or as a listed issue's - // open sub-row. A superseded PR is closed and not listed (owner, - // hivecommons/hive#15526); the copy's "adopted from" chip is its one - // trace. A superseder that is not drawn (filtered out, another page, - // closed) leaves the original a row of its own. - function stageTrackerFoldSuperseded(rows) { - const drawn = new Set(); - for (const it of rows) { - if (!it) continue; - if (it.kind === 'pr' && String(it.state || '') !== 'closed') drawn.add(it.repo + '#' + it.number); - if (it.kind === 'issue' && Array.isArray(it.linked_prs)) for (const lp of it.linked_prs) if (lp && String(lp.state || '') !== 'closed' && (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') < 0) drawn.add(it.repo + '#' + lp.number); - } - return rows.filter(it => !(it && it.kind === 'pr' && Number(it.superseded_by) > 0 && Number(it.superseded_by) !== Number(it.number) && drawn.has(it.repo + '#' + Number(it.superseded_by)))); - } // The canonical tracker count (owner): rows of the default view — every // item on its own row except a PR drawn on a listed issue's row. diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index fa0f4f8ca2..602b901f39 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -943,22 +943,6 @@ } return true; } - // Pure: the listed, open PR a nested original is folded into — its - // superseder (`superseded_by` from the server; `adopted_by` while the - // copy is live, for a payload without it) when that copy is itself - // listed under the issue and not closed — else 0. A superseded PR is - // closed and not listed (owner, hivecommons/hive#15526 under #15511 - // drew the original as a dimmed second row beside hive's #15574): it - // lives only in the copy's "adopted from" chip. A closed original - // whose copy is not in the list still draws as one dimmed line. - function stageTrackerLinkedFoldedInto(lp, issue) { - if (!lp) return 0; - const live = lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed'; - const by = Number(lp.superseded_by) || (live ? Number(lp.adopted_by) || 0 : 0); - if (!(by > 0) || by === Number(lp.number)) return 0; - const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; - return linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed' && (Array.isArray(x.modifiers) ? x.modifiers : []).indexOf('merged') < 0) ? by : 0; - } // Pure: an issue's open nested PRs as row items. function stageTrackerNestedOpenPRs(issue) { if (!issue || issue.kind === 'pr') return []; @@ -1061,7 +1045,7 @@ function stageTrackerSubRowHtml(lp, issue, stages, nowMs, ctx) { const pr = stageTrackerLinkedPRItem(issue, lp); const superseded = typeof stageTrackerLinkedSupersededText === 'function' ? stageTrackerLinkedSupersededText(lp, issue) : ''; - let ref = stageTrackerPRRef(pr.number, pr.url, pr.author_kind, pr.author, pr.title, (pr.title ? pr.title + ' · ' : '') + (superseded || stageTrackerTooltip(pr, nowMs)) + ' · ' + stageTrackerLinkedTip(issue, pr.number, ctx)); + let ref = stageTrackerPRRef(pr.number, pr.url, pr.author_kind, pr.author, pr.title, (pr.title ? pr.title + ' · ' : '') + (superseded ? superseded + ' · ' + stageTrackerLinkedSupersededTip(lp) : stageTrackerTooltip(pr, nowMs)) + ' · ' + stageTrackerLinkedTip(issue, pr.number, ctx)); // One line (hivecommons/hive: "consolidate from 3 lines of text to // 1"): connector, repo chip, author icon + #N + title, the lineage / // adopted-from chip, then the base pill — all siblings of the flex-row @@ -1072,11 +1056,13 @@ ref = stageTrackerPRPillsHtml(ref, lineage || null, lp.base_ref); ref = STAGE_TRACKER_LINKED_GLYPH + ref; if (superseded) { - // The adopted original: one dimmed line, no chevron track, no row - // tools, no needs-human styling — the copy carries the chevron. + // The adopted original: one muted line, no chevron track, no row + // tools, no needs-human styling — the copy carries the chevron. The + // trailing note never wraps; the title ellipsizes first (owner, + // hivecommons/hive#15511: "superseded · hive adopted → #15574"). return `<div class="ham-sub ham-sub-superseded" data-ham-kind="pr" data-ham-stage="${pr.stage}" data-ham-sub-key="${esc(stageTrackerItemKey(pr))}" data-ham-superseded-by="${Number(lp.superseded_by || lp.adopted_by) || 0}"> <div class="ham-row-head"> - ${stageTrackerHeadColsHtml([ref + ` <span class="ham-superseded-note">· ${esc(superseded)}</span>`], '', stageTrackerActedBadgeHtml(pr, nowMs))} + ${stageTrackerHeadColsHtml([ref + ` <span class="ham-superseded-note" title="${esc(stageTrackerLinkedSupersededTip(lp))}">${esc(superseded)}</span>`], '', stageTrackerActedBadgeHtml(pr, nowMs))} </div> </div>`; } @@ -1111,7 +1097,7 @@ return stageTrackerLinkedElsewhere(item).map(lp => `<a class="ham-badge ham-linked-elsewhere" href="${esc(lp.url || '#')}" target="_blank" rel="noopener" title="${esc('PR #' + (Number(lp.number) || 0) + ' covers this issue too; its row is drawn under #' + Number(lp.drawn_under))}">↳ #${Number(lp.number) || 0} · under #${Number(lp.drawn_under)}</a>`).join(' '); } function stageTrackerLinkedSorted(item, stages) { - const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item) && !stageTrackerLinkedFoldedInto(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); + const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item) && !stageTrackerLinkedSupersededGone(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); const sinceOf = lp => Date.parse(lp.stage_since || '') || Infinity; return linked.sort((x, y) => (stageTrackerAnchor(y.stage, stages, 'pr', y) - stageTrackerAnchor(x.stage, stages, 'pr', x)) || (stageTrackerAttentionTier(x) - stageTrackerAttentionTier(y)) || (sinceOf(x) - sinceOf(y)) || ((x.number || 0) - (y.number || 0))); } diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index f7197b9abe..f2b9462a18 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -736,16 +736,39 @@ const lead = who + ' · ' + chose + ', ' + agentNowClockTime(atMs, nowMs); return lead + (d.title ? '\n' + d.title : ''); } - // Pure: a closed adopted original listed under its issue draws as one - // dimmed line without a chevron track (hivecommons/hive#15126) — only - // when its copy is not in the list; with the copy listed the original - // is folded into the copy's chip and not drawn at all - // (stageTrackerLinkedFoldedInto, hivecommons/hive#15526). + // Pure: the PR a nested original was superseded by — `superseded_by` + // from the server, or `adopted_by` while the copy is live — when that + // copy is itself listed under the issue; else 0. + function stageTrackerLinkedSuperseder(lp, issue) { + if (!lp) return 0; + const live = lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed'; + const by = Number(lp.superseded_by) || (live ? Number(lp.adopted_by) || 0 : 0); + if (!(by > 0) || by === Number(lp.number)) return 0; + const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; + return linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed') ? by : 0; + } + // Pure: an adopted original listed under its issue — closed, or still + // open — with the hive's copy in the list draws as one muted line + // without a chevron track (hivecommons/hive#15126, #15511): the note + // reads "superseded · hive adopted → #N", "superseded · closed · hive + // adopted → #N" once the close landed. '' when the copy is not listed. function stageTrackerLinkedSupersededText(lp, issue) { - if (!lp) return ''; - const by = Number(lp.superseded_by || lp.adopted_by) || 0; - if (String(lp.state || '') === 'closed') return 'closed · superseded by #' + by; - return ''; + const by = stageTrackerLinkedSuperseder(lp, issue); + if (!by) return ''; + return 'superseded · ' + (String(lp.state || '') === 'closed' ? 'closed · ' : '') + 'hive adopted → #' + by; + } + // Pure: the hover behind that note — what hive did and what becomes of + // this PR. + function stageTrackerLinkedSupersededTip(lp) { + const by = Number(lp && (lp.superseded_by || lp.adopted_by)) || 0; + if (!by) return ''; + return 'Hive re-authored this PR as #' + by + ' with the same commits and sign-off. ' + (String(lp.state || '') === 'closed' ? 'This PR is closed as superseded.' : 'This PR closes as superseded when #' + by + ' merges.'); + } + // Pure: a closed original whose superseder is no longer listed open + // under the issue (merged, closed, filtered) has nothing left to say + // and is not drawn. + function stageTrackerLinkedSupersededGone(lp, issue) { + return !!lp && String(lp.state || '') === 'closed' && !stageTrackerLinkedSuperseder(lp, issue); } function stageTrackerCoveringPR(item) { if (!item || item.kind === 'pr') return null; diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index fc7ad0a4e3..4b5e2878fc 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1701,7 +1701,7 @@ .cue-acting > .ham-strip-row .ham-seg.active { background-image: repeating-linear-gradient(-45deg, transparent 0 6px, color-mix(in srgb, var(--surface-0) 28%, transparent) 6px 12px); background-size: 34px 100%; animation: cue-acting-stripes 1.1s linear infinite; } .ham-sub-superseded { opacity: .55; } .ham-sub-superseded .ham-row-head { min-height: 0; } - .ham-superseded-note { color: var(--muted); font-size: var(--fs-xs); } + .ham-superseded-note { color: var(--muted); font-size: var(--fs-xs); flex: 0 0 auto; white-space: nowrap; } .ham-adopted-from { color: var(--muted); text-decoration: none; } /* The Let hive decide preview. One decision, readable in three seconds (operator feedback on the dialog, issue 15397): subject line, @@ -14986,16 +14986,39 @@ <h3 class="faq-group-title">Where to get help</h3> const lead = who + ' · ' + chose + ', ' + agentNowClockTime(atMs, nowMs); return lead + (d.title ? '\n' + d.title : ''); } - // Pure: a closed adopted original listed under its issue draws as one - // dimmed line without a chevron track (hivecommons/hive#15126) — only - // when its copy is not in the list; with the copy listed the original - // is folded into the copy's chip and not drawn at all - // (stageTrackerLinkedFoldedInto, hivecommons/hive#15526). + // Pure: the PR a nested original was superseded by — `superseded_by` + // from the server, or `adopted_by` while the copy is live — when that + // copy is itself listed under the issue; else 0. + function stageTrackerLinkedSuperseder(lp, issue) { + if (!lp) return 0; + const live = lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed'; + const by = Number(lp.superseded_by) || (live ? Number(lp.adopted_by) || 0 : 0); + if (!(by > 0) || by === Number(lp.number)) return 0; + const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; + return linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed') ? by : 0; + } + // Pure: an adopted original listed under its issue — closed, or still + // open — with the hive's copy in the list draws as one muted line + // without a chevron track (hivecommons/hive#15126, #15511): the note + // reads "superseded · hive adopted → #N", "superseded · closed · hive + // adopted → #N" once the close landed. '' when the copy is not listed. function stageTrackerLinkedSupersededText(lp, issue) { - if (!lp) return ''; - const by = Number(lp.superseded_by || lp.adopted_by) || 0; - if (String(lp.state || '') === 'closed') return 'closed · superseded by #' + by; - return ''; + const by = stageTrackerLinkedSuperseder(lp, issue); + if (!by) return ''; + return 'superseded · ' + (String(lp.state || '') === 'closed' ? 'closed · ' : '') + 'hive adopted → #' + by; + } + // Pure: the hover behind that note — what hive did and what becomes of + // this PR. + function stageTrackerLinkedSupersededTip(lp) { + const by = Number(lp && (lp.superseded_by || lp.adopted_by)) || 0; + if (!by) return ''; + return 'Hive re-authored this PR as #' + by + ' with the same commits and sign-off. ' + (String(lp.state || '') === 'closed' ? 'This PR is closed as superseded.' : 'This PR closes as superseded when #' + by + ' merges.'); + } + // Pure: a closed original whose superseder is no longer listed open + // under the issue (merged, closed, filtered) has nothing left to say + // and is not drawn. + function stageTrackerLinkedSupersededGone(lp, issue) { + return !!lp && String(lp.state || '') === 'closed' && !stageTrackerLinkedSuperseder(lp, issue); } function stageTrackerCoveringPR(item) { if (!item || item.kind === 'pr') return null; @@ -16618,22 +16641,6 @@ <h3 class="faq-group-title">Where to get help</h3> } return true; } - // Pure: the listed, open PR a nested original is folded into — its - // superseder (`superseded_by` from the server; `adopted_by` while the - // copy is live, for a payload without it) when that copy is itself - // listed under the issue and not closed — else 0. A superseded PR is - // closed and not listed (owner, hivecommons/hive#15526 under #15511 - // drew the original as a dimmed second row beside hive's #15574): it - // lives only in the copy's "adopted from" chip. A closed original - // whose copy is not in the list still draws as one dimmed line. - function stageTrackerLinkedFoldedInto(lp, issue) { - if (!lp) return 0; - const live = lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed'; - const by = Number(lp.superseded_by) || (live ? Number(lp.adopted_by) || 0 : 0); - if (!(by > 0) || by === Number(lp.number)) return 0; - const linked = Array.isArray(issue && issue.linked_prs) ? issue.linked_prs : []; - return linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed' && (Array.isArray(x.modifiers) ? x.modifiers : []).indexOf('merged') < 0) ? by : 0; - } // Pure: an issue's open nested PRs as row items. function stageTrackerNestedOpenPRs(issue) { if (!issue || issue.kind === 'pr') return []; @@ -16736,7 +16743,7 @@ <h3 class="faq-group-title">Where to get help</h3> function stageTrackerSubRowHtml(lp, issue, stages, nowMs, ctx) { const pr = stageTrackerLinkedPRItem(issue, lp); const superseded = typeof stageTrackerLinkedSupersededText === 'function' ? stageTrackerLinkedSupersededText(lp, issue) : ''; - let ref = stageTrackerPRRef(pr.number, pr.url, pr.author_kind, pr.author, pr.title, (pr.title ? pr.title + ' · ' : '') + (superseded || stageTrackerTooltip(pr, nowMs)) + ' · ' + stageTrackerLinkedTip(issue, pr.number, ctx)); + let ref = stageTrackerPRRef(pr.number, pr.url, pr.author_kind, pr.author, pr.title, (pr.title ? pr.title + ' · ' : '') + (superseded ? superseded + ' · ' + stageTrackerLinkedSupersededTip(lp) : stageTrackerTooltip(pr, nowMs)) + ' · ' + stageTrackerLinkedTip(issue, pr.number, ctx)); // One line (hivecommons/hive: "consolidate from 3 lines of text to // 1"): connector, repo chip, author icon + #N + title, the lineage / // adopted-from chip, then the base pill — all siblings of the flex-row @@ -16747,11 +16754,13 @@ <h3 class="faq-group-title">Where to get help</h3> ref = stageTrackerPRPillsHtml(ref, lineage || null, lp.base_ref); ref = STAGE_TRACKER_LINKED_GLYPH + ref; if (superseded) { - // The adopted original: one dimmed line, no chevron track, no row - // tools, no needs-human styling — the copy carries the chevron. + // The adopted original: one muted line, no chevron track, no row + // tools, no needs-human styling — the copy carries the chevron. The + // trailing note never wraps; the title ellipsizes first (owner, + // hivecommons/hive#15511: "superseded · hive adopted → #15574"). return `<div class="ham-sub ham-sub-superseded" data-ham-kind="pr" data-ham-stage="${pr.stage}" data-ham-sub-key="${esc(stageTrackerItemKey(pr))}" data-ham-superseded-by="${Number(lp.superseded_by || lp.adopted_by) || 0}"> <div class="ham-row-head"> - ${stageTrackerHeadColsHtml([ref + ` <span class="ham-superseded-note">· ${esc(superseded)}</span>`], '', stageTrackerActedBadgeHtml(pr, nowMs))} + ${stageTrackerHeadColsHtml([ref + ` <span class="ham-superseded-note" title="${esc(stageTrackerLinkedSupersededTip(lp))}">${esc(superseded)}</span>`], '', stageTrackerActedBadgeHtml(pr, nowMs))} </div> </div>`; } @@ -16786,7 +16795,7 @@ <h3 class="faq-group-title">Where to get help</h3> return stageTrackerLinkedElsewhere(item).map(lp => `<a class="ham-badge ham-linked-elsewhere" href="${esc(lp.url || '#')}" target="_blank" rel="noopener" title="${esc('PR #' + (Number(lp.number) || 0) + ' covers this issue too; its row is drawn under #' + Number(lp.drawn_under))}">↳ #${Number(lp.number) || 0} · under #${Number(lp.drawn_under)}</a>`).join(' '); } function stageTrackerLinkedSorted(item, stages) { - const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item) && !stageTrackerLinkedFoldedInto(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); + const linked = Array.isArray(item.linked_prs) ? item.linked_prs.filter(lp => stageTrackerLinkedDrawnHere(lp, item) && !stageTrackerLinkedSupersededGone(lp, item)) : (item.linked_pr ? [{ number: item.linked_pr }] : []); const sinceOf = lp => Date.parse(lp.stage_since || '') || Infinity; return linked.sort((x, y) => (stageTrackerAnchor(y.stage, stages, 'pr', y) - stageTrackerAnchor(x.stage, stages, 'pr', x)) || (stageTrackerAttentionTier(x) - stageTrackerAttentionTier(y)) || (sinceOf(x) - sinceOf(y)) || ((x.number || 0) - (y.number || 0))); } @@ -17818,26 +17827,11 @@ <h3 class="faq-group-title">Where to get help</h3> // is nested under a listed issue is drawn as that issue's sub-row only. function stageTrackerVisible(items, filter, ctx) { const f = stageTrackerNormalizeFilter(filter || _stageTrackerFilter); - const rows = stageTrackerFoldSuperseded((items || []).filter(it => stageTrackerMatches(it, f, ctx))); + const rows = (items || []).filter(it => stageTrackerMatches(it, f, ctx)); if (f.kind === 'pr') return rows; const issues = new Set(rows.filter(it => it.kind === 'issue').map(it => it.repo + '#' + it.number)); return rows.filter(it => !(it.kind === 'pr' && it.nested_under && issues.has(it.repo + '#' + it.nested_under))); } - // Pure: drop every PR row whose `superseded_by` names a PR that is - // itself drawn open on this page — as a row or as a listed issue's - // open sub-row. A superseded PR is closed and not listed (owner, - // hivecommons/hive#15526); the copy's "adopted from" chip is its one - // trace. A superseder that is not drawn (filtered out, another page, - // closed) leaves the original a row of its own. - function stageTrackerFoldSuperseded(rows) { - const drawn = new Set(); - for (const it of rows) { - if (!it) continue; - if (it.kind === 'pr' && String(it.state || '') !== 'closed') drawn.add(it.repo + '#' + it.number); - if (it.kind === 'issue' && Array.isArray(it.linked_prs)) for (const lp of it.linked_prs) if (lp && String(lp.state || '') !== 'closed' && (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') < 0) drawn.add(it.repo + '#' + lp.number); - } - return rows.filter(it => !(it && it.kind === 'pr' && Number(it.superseded_by) > 0 && Number(it.superseded_by) !== Number(it.number) && drawn.has(it.repo + '#' + Number(it.superseded_by)))); - } // The canonical tracker count (owner): rows of the default view — every // item on its own row except a PR drawn on a listed issue's row. From b988eea87d94768b8e347d2ad2ee8334c93e3fc4 Mon Sep 17 00:00:00 2001 From: Andrew Anderson <andy@clubanderson.com> Date: Thu, 29 Oct 2026 20:59:24 -0400 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=90=9B=20adoption:=20surface=20close?= =?UTF-8?q?=5Fsuperseded=20in=20Settings=20help;=20refresh=20config=20gold?= =?UTF-8?q?en?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson <andy@clubanderson.com> --- src/pkg/config/testdata/agent_runtime_golden.json | 1 + src/pkg/dashboard/static-src/js/config-governor.js | 2 +- src/pkg/dashboard/static-src/js/config-state.js | 2 +- src/pkg/dashboard/static/index.html | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pkg/config/testdata/agent_runtime_golden.json b/src/pkg/config/testdata/agent_runtime_golden.json index 1dfc005a14..b464060d78 100644 --- a/src/pkg/config/testdata/agent_runtime_golden.json +++ b/src/pkg/config/testdata/agent_runtime_golden.json @@ -207,6 +207,7 @@ "StrictAttribution": null, "AutoMerge": null, "MaintainerPolicy": "", + "CloseSuperseded": "", "Supersede": { "CloseFirst": null } diff --git a/src/pkg/dashboard/static-src/js/config-governor.js b/src/pkg/dashboard/static-src/js/config-governor.js index 649cf750bb..1d469f99d6 100644 --- a/src/pkg/dashboard/static-src/js/config-governor.js +++ b/src/pkg/dashboard/static-src/js/config-governor.js @@ -799,7 +799,7 @@ <div class="config-field"> <label for="cfg-stage-grace-offline">Offline contributor grace ${yamlHint('governor.labels.stage.contributor_grace_offline')}</label> <input type="text" id="cfg-stage-grace-offline" value="${esc(stageGraceOffline)}" placeholder="1h" data-change-action="markDirty" data-arg0="labels" data-arg1="stage_grace_offline" data-arg-types="s,s,w"> - <div class="config-help">Go duration after the comment-only nudge before an offline or external author's red PR is adopted. With live hub presence the hive instead waits ${yamlHint('governor.labels.stage.adoption.after_offline')} (default 30m) after a registered relay's last heartbeat, or ${yamlHint('governor.labels.stage.adoption.after_unregistered')} (default 2h) for an author with no profile here, and adopts in place on the PR's own branch when GitHub permits ${yamlHint('governor.labels.stage.adoption.in_place')} (default on) rather than opening a superseding PR. An in-place adoption keeps a changed head only when GitHub links the commit to the App bot ${yamlHint('governor.labels.stage.adoption.strict_attribution')} (default on); otherwise the hive hands the PR back to the contributor. Once the hive owns the head, the contributor lane merges it under the hive's own authority when the hive-authored gates pass (CI green on the adopted head, reviewer verdict, DCO, diff fences, soak), without requiring the original author's trust tier ${yamlHint('governor.labels.stage.adoption.auto_merge')} (default on). When the hive supersedes instead, it closes the original in the same pass that opens its copy — one note naming the copy, <code>hive/superseded</code> — and reopens it if the copy is closed unmerged or red at two heads ${yamlHint('governor.labels.stage.adoption.supersede.close_first')} (default on; off keeps the original open at stage 074 until the copy merges). A copy that conflicts with the base is handed to the fixer's rebase-resolve episode (two attempts, then stage 085 <code>rebase-failed-twice</code>); an adoption attempt that opened nothing is retried once the author's clanker has stayed offline for ${yamlHint('governor.labels.stage.adoption.offline_grace')} (default 30m).</div> + <div class="config-help">Go duration after the comment-only nudge before an offline or external author's red PR is adopted. With live hub presence the hive instead waits ${yamlHint('governor.labels.stage.adoption.after_offline')} (default 30m) after a registered relay's last heartbeat, or ${yamlHint('governor.labels.stage.adoption.after_unregistered')} (default 2h) for an author with no profile here, and adopts in place on the PR's own branch when GitHub permits ${yamlHint('governor.labels.stage.adoption.in_place')} (default on) rather than opening a superseding PR. An in-place adoption keeps a changed head only when GitHub links the commit to the App bot ${yamlHint('governor.labels.stage.adoption.strict_attribution')} (default on); otherwise the hive hands the PR back to the contributor. Once the hive owns the head, the contributor lane merges it under the hive's own authority when the hive-authored gates pass (CI green on the adopted head, reviewer verdict, DCO, diff fences, soak), without requiring the original author's trust tier ${yamlHint('governor.labels.stage.adoption.auto_merge')} (default on). When the hive supersedes instead, it closes the original in the same pass that opens its copy — one note naming the copy, <code>hive/superseded</code> — and reopens it if the copy is closed unmerged or red at two heads ${yamlHint('governor.labels.stage.adoption.supersede.close_first')} (default on; off keeps the original open at stage 074 until the copy merges). A clanker- or hive-authored original closes in that pass by policy even without the repo's write-back opt-in label, since the copy carries its commits and sign-off ${yamlHint('governor.labels.stage.adoption.close_superseded')} (default <code>on_adopt</code>; <code>on_merge</code> waits for the copy to merge; a person's PR always waits unless the label is present). A copy that conflicts with the base is handed to the fixer's rebase-resolve episode (two attempts, then stage 085 <code>rebase-failed-twice</code>); an adoption attempt that opened nothing is retried once the author's clanker has stayed offline for ${yamlHint('governor.labels.stage.adoption.offline_grace')} (default 30m).</div> </div> ${renderReporterTrustBlock()} <h4>Writing guide</h4> diff --git a/src/pkg/dashboard/static-src/js/config-state.js b/src/pkg/dashboard/static-src/js/config-state.js index c431add812..67a9688a85 100644 --- a/src/pkg/dashboard/static-src/js/config-state.js +++ b/src/pkg/dashboard/static-src/js/config-state.js @@ -81,7 +81,7 @@ { tab: 'Labels', section: 'Labels', label: 'Stage dwell overrides', key: 'governor.labels.stage.dwell', text: 'stage dwell stalled threshold governor.labels.stage.dwell' }, { tab: 'Labels', section: 'Labels', label: 'Adoption of a maintainer\'s PR', key: 'governor.labels.stage.adoption.maintainer_policy', text: 'adoption maintainer policy adopt ask never maintainer own pr clanker disconnected offline adopt action governor.labels.stage.adoption.maintainer_policy' }, { tab: 'Labels', section: 'Labels', label: 'Contributor nudge', key: 'governor.labels.stage.contributor_nudge.enabled', text: 'contributor nudge returned-to-contributor red ci fix-pr relay interrupt renudge presence window governor.labels.stage.contributor_nudge.enabled governor.labels.stage.contributor_nudge.renudge_interval governor.labels.stage.presence_window' }, - { tab: 'Labels', section: 'Labels', label: 'Adopt red contributor PRs', key: 'governor.labels.stage.adoption.enabled', text: 'adoption adopted-by-hive stage 074 red contributor pr grace online offline supersede takeover in place after offline unregistered heartbeat governor.labels.stage.adoption.enabled governor.labels.stage.contributor_grace_online governor.labels.stage.contributor_grace_offline governor.labels.stage.adoption.after_offline governor.labels.stage.adoption.after_unregistered governor.labels.stage.adoption.in_place governor.labels.stage.adoption.strict_attribution strict attribution governor.labels.stage.adoption.auto_merge auto merge adopted head hive authority governor.labels.stage.adoption.supersede.close_first close first superseded reopen copy failed governor.labels.stage.adoption.offline_grace offline grace rebase failed twice fixer resolving conflicts' }, + { tab: 'Labels', section: 'Labels', label: 'Adopt red contributor PRs', key: 'governor.labels.stage.adoption.enabled', text: 'adoption adopted-by-hive stage 074 red contributor pr grace online offline supersede takeover in place after offline unregistered heartbeat governor.labels.stage.adoption.enabled governor.labels.stage.contributor_grace_online governor.labels.stage.contributor_grace_offline governor.labels.stage.adoption.after_offline governor.labels.stage.adoption.after_unregistered governor.labels.stage.adoption.in_place governor.labels.stage.adoption.strict_attribution strict attribution governor.labels.stage.adoption.auto_merge auto merge adopted head hive authority governor.labels.stage.adoption.supersede.close_first close first superseded reopen copy failed governor.labels.stage.adoption.close_superseded close superseded on adopt on merge clanker authored opt-in label governor.labels.stage.adoption.offline_grace offline grace rebase failed twice fixer resolving conflicts' }, { tab: 'Hub', section: 'Contributor Relay', label: 'Fix budget', key: 'contribute.max_parallel_fixes', text: 'fix budget parallel fixes focus window red pr fix-pr preempt spawn contribute.max_parallel_fixes contribute.min_focus_window' }, { tab: 'Logging', section: 'Logging', label: 'Governor logging', key: 'governor.logging.max_size_mb', text: 'governor logging directory level compression max size age backups governor.logging.compress governor.logging.dir governor.logging.level governor.logging.max_age_days governor.logging.max_backups governor.logging.max_size_mb' }, { tab: 'Advisory', section: 'Advisory', label: 'Advisory digest', key: 'governor.advisory.max_findings', text: 'advisory digest max findings show all staleness pr autoclose target linear issue retry backoff' }, diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 4b5e2878fc..08634ce100 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -46199,7 +46199,7 @@ <h3 style="color:var(--amber);text-align:center">Configure LiteLLM</h3> { tab: 'Labels', section: 'Labels', label: 'Stage dwell overrides', key: 'governor.labels.stage.dwell', text: 'stage dwell stalled threshold governor.labels.stage.dwell' }, { tab: 'Labels', section: 'Labels', label: 'Adoption of a maintainer\'s PR', key: 'governor.labels.stage.adoption.maintainer_policy', text: 'adoption maintainer policy adopt ask never maintainer own pr clanker disconnected offline adopt action governor.labels.stage.adoption.maintainer_policy' }, { tab: 'Labels', section: 'Labels', label: 'Contributor nudge', key: 'governor.labels.stage.contributor_nudge.enabled', text: 'contributor nudge returned-to-contributor red ci fix-pr relay interrupt renudge presence window governor.labels.stage.contributor_nudge.enabled governor.labels.stage.contributor_nudge.renudge_interval governor.labels.stage.presence_window' }, - { tab: 'Labels', section: 'Labels', label: 'Adopt red contributor PRs', key: 'governor.labels.stage.adoption.enabled', text: 'adoption adopted-by-hive stage 074 red contributor pr grace online offline supersede takeover in place after offline unregistered heartbeat governor.labels.stage.adoption.enabled governor.labels.stage.contributor_grace_online governor.labels.stage.contributor_grace_offline governor.labels.stage.adoption.after_offline governor.labels.stage.adoption.after_unregistered governor.labels.stage.adoption.in_place governor.labels.stage.adoption.strict_attribution strict attribution governor.labels.stage.adoption.auto_merge auto merge adopted head hive authority governor.labels.stage.adoption.supersede.close_first close first superseded reopen copy failed governor.labels.stage.adoption.offline_grace offline grace rebase failed twice fixer resolving conflicts' }, + { tab: 'Labels', section: 'Labels', label: 'Adopt red contributor PRs', key: 'governor.labels.stage.adoption.enabled', text: 'adoption adopted-by-hive stage 074 red contributor pr grace online offline supersede takeover in place after offline unregistered heartbeat governor.labels.stage.adoption.enabled governor.labels.stage.contributor_grace_online governor.labels.stage.contributor_grace_offline governor.labels.stage.adoption.after_offline governor.labels.stage.adoption.after_unregistered governor.labels.stage.adoption.in_place governor.labels.stage.adoption.strict_attribution strict attribution governor.labels.stage.adoption.auto_merge auto merge adopted head hive authority governor.labels.stage.adoption.supersede.close_first close first superseded reopen copy failed governor.labels.stage.adoption.close_superseded close superseded on adopt on merge clanker authored opt-in label governor.labels.stage.adoption.offline_grace offline grace rebase failed twice fixer resolving conflicts' }, { tab: 'Hub', section: 'Contributor Relay', label: 'Fix budget', key: 'contribute.max_parallel_fixes', text: 'fix budget parallel fixes focus window red pr fix-pr preempt spawn contribute.max_parallel_fixes contribute.min_focus_window' }, { tab: 'Logging', section: 'Logging', label: 'Governor logging', key: 'governor.logging.max_size_mb', text: 'governor logging directory level compression max size age backups governor.logging.compress governor.logging.dir governor.logging.level governor.logging.max_age_days governor.logging.max_backups governor.logging.max_size_mb' }, { tab: 'Advisory', section: 'Advisory', label: 'Advisory digest', key: 'governor.advisory.max_findings', text: 'advisory digest max findings show all staleness pr autoclose target linear issue retry backoff' }, @@ -53077,7 +53077,7 @@ <h4 class="mt-6 mb-3">Stage labels</h4> <div class="config-field"> <label for="cfg-stage-grace-offline">Offline contributor grace ${yamlHint('governor.labels.stage.contributor_grace_offline')}</label> <input type="text" id="cfg-stage-grace-offline" value="${esc(stageGraceOffline)}" placeholder="1h" data-change-action="markDirty" data-arg0="labels" data-arg1="stage_grace_offline" data-arg-types="s,s,w"> - <div class="config-help">Go duration after the comment-only nudge before an offline or external author's red PR is adopted. With live hub presence the hive instead waits ${yamlHint('governor.labels.stage.adoption.after_offline')} (default 30m) after a registered relay's last heartbeat, or ${yamlHint('governor.labels.stage.adoption.after_unregistered')} (default 2h) for an author with no profile here, and adopts in place on the PR's own branch when GitHub permits ${yamlHint('governor.labels.stage.adoption.in_place')} (default on) rather than opening a superseding PR. An in-place adoption keeps a changed head only when GitHub links the commit to the App bot ${yamlHint('governor.labels.stage.adoption.strict_attribution')} (default on); otherwise the hive hands the PR back to the contributor. Once the hive owns the head, the contributor lane merges it under the hive's own authority when the hive-authored gates pass (CI green on the adopted head, reviewer verdict, DCO, diff fences, soak), without requiring the original author's trust tier ${yamlHint('governor.labels.stage.adoption.auto_merge')} (default on). When the hive supersedes instead, it closes the original in the same pass that opens its copy — one note naming the copy, <code>hive/superseded</code> — and reopens it if the copy is closed unmerged or red at two heads ${yamlHint('governor.labels.stage.adoption.supersede.close_first')} (default on; off keeps the original open at stage 074 until the copy merges). A copy that conflicts with the base is handed to the fixer's rebase-resolve episode (two attempts, then stage 085 <code>rebase-failed-twice</code>); an adoption attempt that opened nothing is retried once the author's clanker has stayed offline for ${yamlHint('governor.labels.stage.adoption.offline_grace')} (default 30m).</div> + <div class="config-help">Go duration after the comment-only nudge before an offline or external author's red PR is adopted. With live hub presence the hive instead waits ${yamlHint('governor.labels.stage.adoption.after_offline')} (default 30m) after a registered relay's last heartbeat, or ${yamlHint('governor.labels.stage.adoption.after_unregistered')} (default 2h) for an author with no profile here, and adopts in place on the PR's own branch when GitHub permits ${yamlHint('governor.labels.stage.adoption.in_place')} (default on) rather than opening a superseding PR. An in-place adoption keeps a changed head only when GitHub links the commit to the App bot ${yamlHint('governor.labels.stage.adoption.strict_attribution')} (default on); otherwise the hive hands the PR back to the contributor. Once the hive owns the head, the contributor lane merges it under the hive's own authority when the hive-authored gates pass (CI green on the adopted head, reviewer verdict, DCO, diff fences, soak), without requiring the original author's trust tier ${yamlHint('governor.labels.stage.adoption.auto_merge')} (default on). When the hive supersedes instead, it closes the original in the same pass that opens its copy — one note naming the copy, <code>hive/superseded</code> — and reopens it if the copy is closed unmerged or red at two heads ${yamlHint('governor.labels.stage.adoption.supersede.close_first')} (default on; off keeps the original open at stage 074 until the copy merges). A clanker- or hive-authored original closes in that pass by policy even without the repo's write-back opt-in label, since the copy carries its commits and sign-off ${yamlHint('governor.labels.stage.adoption.close_superseded')} (default <code>on_adopt</code>; <code>on_merge</code> waits for the copy to merge; a person's PR always waits unless the label is present). A copy that conflicts with the base is handed to the fixer's rebase-resolve episode (two attempts, then stage 085 <code>rebase-failed-twice</code>); an adoption attempt that opened nothing is retried once the author's clanker has stayed offline for ${yamlHint('governor.labels.stage.adoption.offline_grace')} (default 30m).</div> </div> ${renderReporterTrustBlock()} <h4>Writing guide</h4> From 0eef4b1423e5fe0cc0c41ba0a376e1057557fa1f Mon Sep 17 00:00:00 2001 From: Andrew Anderson <andy@clubanderson.com> Date: Thu, 29 Oct 2026 21:14:18 -0400 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=90=9B=20adoption:=20cover=20Effectiv?= =?UTF-8?q?eCloseSuperseded=20in=20config=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson <andy@clubanderson.com> --- src/pkg/config/adoption_close_first_test.go | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pkg/config/adoption_close_first_test.go b/src/pkg/config/adoption_close_first_test.go index 89fb4802dc..9db2245bb2 100644 --- a/src/pkg/config/adoption_close_first_test.go +++ b/src/pkg/config/adoption_close_first_test.go @@ -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) + } + } +}