diff --git a/changelog.d/added-tracker-claimant-identity.md b/changelog.d/added-tracker-claimant-identity.md new file mode 100644 index 0000000000..9b02818f44 --- /dev/null +++ b/changelog.d/added-tracker-claimant-identity.md @@ -0,0 +1 @@ +- The activity monitor says who holds a claimed item, not just what kind of actor. `GET /api/stage-tracker` rows (and nested `linked_prs[]`) carry `claimant: {kind: hive-agent|clanker|person, login, agent, hive, since, source}` on claimed / in-progress issues and PRs under review or rework, derived from the worker-claim ledger, the `hive:claim` marker (with its hive fingerprint), an assignee or the agent the status payload says is on it. The lit chevron appends one token after its word — **Claimed · quality**, **Claimed · quality@alchemy** (another hive), **Claimed · @bob's clanker**, **Claimed · @alice** — and the chevron hover adds *Held by: since ()*. Nothing is added when nobody is named. diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index de90bd05ce..ae05a924a3 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -38,7 +38,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/budget-ignore` | Dashboard auth/session | Budget Ignore Get | `pkg/dashboard/api.go:172` | | `POST` | `/api/budget-ignore` | Owner only | Budget Ignore Set | `pkg/dashboard/api.go:173` | | `GET` | `/api/summaries` | Dashboard auth/session | Summaries | `pkg/dashboard/api.go:185` | -| `GET` | `/api/stage-tracker` | Dashboard auth/session | Stage Tracker: every open issue and pull request of the watched repos for the Hive activity monitor — actionable, held, claimed, in-progress, covered-by-PR, filtered (`needs-*`), draft and exempt-labelled items alike, each with `stage`, `stage_since`, `labels`, `created_at`, `author_kind`, `modifiers`, (PRs) `sentinel_alert` / `sentinel_findings` / `sentinel_reason` when the sentinel flagged the PR, `decision_needed` on a row parked on a person (085 / 045 / 015, the needs-human pill; mirrored onto the issue's `linked_prs[]` entry): `{question, asked_by, since, blocker, blocker_reason, options: [{action, label, enabled, reason_if_disabled}]}` — the reviewer's own decision question when the verdict record has one, the blocker in plain words, and the applicable actions under the row context menu's action ids (`decide:delegate` first), (PRs) `lineage` on the hive's copy of an adopted PR — `{kind: adopted|superseded|rebased-by-hive, from_number, from_url, from_author, from_author_kind, to_number, to_url, at, reason}`, derived from the stage store's adoption record or the `hive/adopt-` head branch, mirrored onto the issue's `linked_prs[]` entry; absent on every other row — and (issues) `linked_prs`; items with no stage yet report stage `0` "Open"; `needs_human_labels` is the "a person must act" label set behind the monitor's Needs human facet (the same list as `/api/status.labelPresets[needs-human]`); `recently_merged` lists the PRs (`repo`, `number`, `merged_at`) whose `pr_merged` audit entry is under 30 minutes old, so a client diffing two payloads can tell a merge from a close. Served from a server-side cache rebuilt at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from the spoke's existing snapshot — a request never calls GitHub. Carries `generated_at`, `source` (`cache` or `fresh`), `cache_ttl_s`, an `ETag` and `Cache-Control: private, max-age=`; `If-None-Match` yields 304. Each hit is recorded under REST caller `dashboard:stage-tracker` so `/api/gh-rate-limits` shows it charged nothing. | `pkg/dashboard/api.go:186` | +| `GET` | `/api/stage-tracker` | Dashboard auth/session | Stage Tracker: every open issue and pull request of the watched repos for the Hive activity monitor — actionable, held, claimed, in-progress, covered-by-PR, filtered (`needs-*`), draft and exempt-labelled items alike, each with `stage`, `stage_since`, `labels`, `created_at`, `author_kind`, `modifiers`, `claimant: {kind: hive-agent|clanker|person, login, agent, hive, since, source: claim-comment|assignee|kick-history|author}` naming who holds a claimed / in-progress issue or a PR under review or rework (absent when nobody is named; mirrored onto `linked_prs[]`), (PRs) `sentinel_alert` / `sentinel_findings` / `sentinel_reason` when the sentinel flagged the PR, `decision_needed` on a row parked on a person (085 / 045 / 015, the needs-human pill; mirrored onto the issue's `linked_prs[]` entry): `{question, asked_by, since, blocker, blocker_reason, options: [{action, label, enabled, reason_if_disabled}]}` — the reviewer's own decision question when the verdict record has one, the blocker in plain words, and the applicable actions under the row context menu's action ids (`decide:delegate` first), (PRs) `lineage` on the hive's copy of an adopted PR — `{kind: adopted|superseded|rebased-by-hive, from_number, from_url, from_author, from_author_kind, to_number, to_url, at, reason}`, derived from the stage store's adoption record or the `hive/adopt-` head branch, mirrored onto the issue's `linked_prs[]` entry; absent on every other row — and (issues) `linked_prs`; items with no stage yet report stage `0` "Open"; `needs_human_labels` is the "a person must act" label set behind the monitor's Needs human facet (the same list as `/api/status.labelPresets[needs-human]`); `recently_merged` lists the PRs (`repo`, `number`, `merged_at`) whose `pr_merged` audit entry is under 30 minutes old, so a client diffing two payloads can tell a merge from a close. Served from a server-side cache rebuilt at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from the spoke's existing snapshot — a request never calls GitHub. Carries `generated_at`, `source` (`cache` or `fresh`), `cache_ttl_s`, an `ETag` and `Cache-Control: private, max-age=`; `If-None-Match` yields 304. Each hit is recorded under REST caller `dashboard:stage-tracker` so `/api/gh-rate-limits` shows it charged nothing. | `pkg/dashboard/api.go:186` | | `POST` | `/api/prs/{owner}/{repo}/{number}/queue-automerge` | Merger/owner role | Queue PRAuto Merge | `pkg/dashboard/api.go:187` | | `GET` | `/api/inference/models/{backend}` | Dashboard auth/session | Inference Models | `pkg/dashboard/api.go:363` | | `GET` | `/api/hive-id` | Dashboard auth/session | Hive IDGet | `pkg/dashboard/api.go:425` | diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 5fe05229c8..83392b9582 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -1109,6 +1109,10 @@ The small icon after the lit pill's words names whose move the row is, and it co Issues riding one covering PR take that PR's actor; nested PR sub-rows carry their own. +#### Who holds it (claimant) + +The icon says what kind of actor holds the row; the `claimant` says *who*. On a claimed or in-progress issue and on a PR from review through its author's rework and adoption (050–074), the payload carries `claimant: {kind, login, agent, hive, since, source}` and the lit chevron appends one short token after its word: a hive lane name (**Claimed · quality**), the lane and a short hive name when the claim came from another hive (**Claimed · quality@alchemy**, the `hosted-ibm-` prefix dropped), a contributor's connected hive (**Claimed · @bob's clanker**) or a person (**Claimed · @alice**). `kind` is `hive-agent` (`agent` is the lane; `hive` is set only when it is not this hive), `clanker` (`login` is the contributor the hive acts for — a registered contributor with a connected hive) or `person`; `source` says where the identity was read: `claim-comment` (the worker-claim ledger or the `hive:claim` marker, which carries the hive fingerprint), `assignee`, `kick-history` (the agent the status payload says is on it) or `author` (a PR's author or adopting agent). The chevron hover adds one line — *Held by: hive agent quality@hosted-ibm-alchemy since 3h ago (claim comment)*. When nothing names a holder the field is absent and nothing is added. Nested covering-PR sub-rows carry their PR's `claimant`. + #### One row per PR A pull request that closes several open issues (`Closes #A` and `Closes #B`) is drawn once, under the issue the server names in each linked entry's `drawn_under` (its `nested_under`, the lowest-numbered open issue it closes). The other issues keep their own strip and show a compact **↳ #N · under #M** chip beside the title (tooltip: *PR #N covers this issue too; its row is drawn under #M*) instead of a second identical sub-row, so hivecommons/hive#14921 appears once under #14910 and #14911 points at it. diff --git a/src/docs/scale-envelope.md b/src/docs/scale-envelope.md index b1bfe44a51..d4bb7653ed 100644 --- a/src/docs/scale-envelope.md +++ b/src/docs/scale-envelope.md @@ -34,7 +34,7 @@ ones to: 2. **Truncation must preserve the prioritization signal, not cut an arbitrary slice.** This holds today and is easy to assume backwards: - Issues are sorted by actionable rank tier, then **oldest first** within each tier before any cap is applied - (`RankActionableIssues`, `src/pkg/github/client.go:4804-4814`, descending `AgeMinutes` within each tier). + (`RankActionableIssues`, `src/pkg/github/client.go:4809-4819`, descending `AgeMinutes` within each tier). - PRs are sorted by **review class then oldest-first within class** (`SortPullRequestsForReview`, `src/pkg/github/review_priority.go:334`; fixes → refactors/docs → tests). diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index d92e2a25dc..1fda30cc06 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -492,6 +492,10 @@ type StageTrackerItem struct { // ClaimantKind is the author kind of whoever holds the live claim on a // claimed issue (human / clanker / hive), from the worker-claim ledger. ClaimantKind string `json:"claimant_kind,omitempty"` + // Claimant names who holds the row — the agent, clanker owner or person + // — for the chevron suffix and the "Held by:" hover line + // (stage_tracker_claimant.go). + Claimant *StageTrackerClaimant `json:"claimant,omitempty"` // StageActor is who holds the next move on this row — hive, clanker, // human, a foreign bot, or nobody — with the plain-words why. The SPA // draws the stage pill's actor icon from StageActor.Kind only @@ -608,6 +612,9 @@ type StageTrackerLinkedPR struct { DCOUnsigned int `json:"dco_unsigned,omitempty"` DCOTotal int `json:"dco_total,omitempty"` Head string `json:"head,omitempty"` + // Claimant mirrors the nested PR's holder so the sub-row's chevron + // names them too. + Claimant *StageTrackerClaimant `json:"claimant,omitempty"` // DecisionNeeded mirrors the nested PR's own row field so the issue's // sub-row can open the same "Needs human" popover. DecisionNeeded *StageTrackerDecision `json:"decision_needed,omitempty"` @@ -1982,6 +1989,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto soakWindow := s.stageTrackerSoakWindow() attempts := s.stageTrackerMergeAttempts() workers := stageTrackerWorkersFromStatus(status) + isClankerOwner := stageTrackerIsClankerOwner() adoptionClock := s.stageTrackerAdoptionClock() rerouteCandidates, adoptionEnabled, takeoverGrace := s.stageTrackerRerouteCandidates(), s.stageAdoptionEnabled(), s.takeoverGrace() finish := func(it *StageTrackerItem, labels []string, stage stagelabels.Stage, rec stagelabels.Record, hasRec bool, draft bool) { @@ -2182,6 +2190,15 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto if it.Stage == trackerNumberClaimed { it.ClaimantKind = s.stageTrackerClaimantKind(repoName, issue.Number) } + if stageTrackerClaimantStage(it.Kind, it.Stage) { + var worker *stageTrackerWorker + if w, ok := stageTrackerWorkerOn(workers, repoName, issue.Number); ok { + worker = &w + } + it.Claimant = stageTrackerIssueClaimant(stageTrackerClaimInputs{Ledger: s.stageTrackerLedgerClaim(repoName, issue.Number), + MarkerKind: issue.ClaimKind, MarkerHolder: issue.ClaimedBy, MarkerHive: issue.ClaimHive, Assignees: issue.Assignees, + Worker: worker, Since: it.StageSince, HiveID: status.HiveID, IsClankerOwner: isClankerOwner}) + } for _, lp := range issue.LinkedPRs { // The claims index may still say "open" for a PR the hive closed // since (close-first supersession, hivecommons/hive#15135); the @@ -2276,6 +2293,13 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto } it.DecisionNeeded = stageTrackerDecisionNeededWith(it, agg, sentinelLabel, now, bctx) it.StageActor = stageTrackerStageActor(it, workers, now) + if stageTrackerClaimantStage(it.Kind, it.Stage) { + var worker *stageTrackerWorker + if w, ok := stageTrackerWorkerOn(workers, repoName, pr.Number); ok { + worker = &w + } + it.Claimant = stageTrackerPRClaimant(stageTrackerClaimInputs{Worker: worker, Since: it.StageSince, Labels: pr.Labels, Author: it.Author, AuthorKind: it.AuthorKind}) + } add(it) } for _, repo := range status.Repos { @@ -2295,7 +2319,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto // bucket, the open items the first tracker never showed. w := it.WorkIssue addIssue(repoName, github.Issue{Repo: w.Repo, Number: w.Number, Title: w.Title, Author: w.Author, Labels: w.Labels, Assignees: w.Assignees, - CreatedAt: w.CreatedAt, UpdatedAt: w.UpdatedAt, URL: w.URL, ClaimKind: w.ClaimKind, ClaimedBy: w.ClaimedBy, LinkedPRs: w.LinkedPRs, ClaimContext: w.ClaimContext, IsTracker: w.IsTracker, Children: w.Children}, w.Bucket, w.Reason, w.TrackerProgress, w.Advisory) + CreatedAt: w.CreatedAt, UpdatedAt: w.UpdatedAt, URL: w.URL, ClaimKind: w.ClaimKind, ClaimedBy: w.ClaimedBy, ClaimHive: w.ClaimHive, LinkedPRs: w.LinkedPRs, ClaimContext: w.ClaimContext, IsTracker: w.IsTracker, Children: w.Children}, w.Bucket, w.Reason, w.TrackerProgress, w.Advisory) default: w := it.WorkPR addPR(repoName, github.PullRequest{Repo: w.Repo, Number: w.Number, Title: w.Title, Author: w.Author, Labels: w.Labels, Draft: w.Draft, @@ -3050,6 +3074,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin lp.Title, lp.Author, lp.AuthorKind, lp.Stage = pr.Title, pr.Author, pr.AuthorKind, pr.Stage lp.StageSince, lp.Caption = pr.StageSince, pr.Caption lp.SentinelAlert, lp.SentinelReason, lp.Head = pr.SentinelAlert, pr.SentinelReason, pr.Head + lp.Claimant = pr.Claimant lp.Adoption = pr.Adoption lp.Presence = pr.Presence lp.Rework = pr.Rework diff --git a/src/pkg/dashboard/stage_tracker_claimant.go b/src/pkg/dashboard/stage_tracker_claimant.go new file mode 100644 index 0000000000..3271a891f7 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_claimant.go @@ -0,0 +1,226 @@ +package dashboard + +import ( + "strings" + "time" + + "github.com/hivecommons/hive/pkg/claims" +) + +// StageTrackerClaimant names who holds a tracker row right now — the +// identity, not just the kind the actor icon already draws. The SPA +// appends it to the lit chevron (" · quality", " · @alice", +// " · @bob's clanker", " · quality@alchemy") and adds one "Held by:" line +// to the chevron hover (hivecommons/hive#15422). +// +// Kind is claimantKindHiveAgent (Agent is the lane name; Hive is set only +// when the claim came from another hive), claimantKindClanker (Login is +// the contributor the connected hive acts for) or claimantKindPerson +// (Login is the GitHub login). Since is when they took it when known; +// Source says where the identity was read from. +type StageTrackerClaimant struct { + Kind string `json:"kind"` + Login string `json:"login,omitempty"` + Agent string `json:"agent,omitempty"` + Hive string `json:"hive,omitempty"` + Since *time.Time `json:"since,omitempty"` + Source string `json:"source"` +} + +const ( + claimantKindHiveAgent = "hive-agent" + claimantKindClanker = "clanker" + claimantKindPerson = "person" + + claimantSourceClaimComment = "claim-comment" + claimantSourceAssignee = "assignee" + claimantSourceKickHistory = "kick-history" + claimantSourceAuthor = "author" + + agentLaneLabelPrefix = "agent/" +) + +// stageTrackerClaimInputs is everything the claimant derivation reads, +// gathered by the tracker build so the derivation itself is pure. +type stageTrackerClaimInputs struct { + // Ledger is the worker-claim ledger's live claim, when the ledger is + // on and holds one. + Ledger *claims.Claim + // MarkerKind / MarkerHolder / MarkerHive are the issue's live claim as + // read from GitHub (Issue.ClaimKind / ClaimedBy / ClaimHive): a + // `hive:claim` marker when MarkerKind is set, else an assignee or lease. + MarkerKind, MarkerHolder, MarkerHive string + Assignees []string + // Worker is the busy agent on the item from the status payload, when any. + Worker *stageTrackerWorker + Since *time.Time + HiveID string + Labels []string + Author string + AuthorKind string + // IsClankerOwner reports whether a GitHub login belongs to a registered + // contributor with a connected hive (a clanker owner). Nil means unknown. + IsClankerOwner func(login string) bool +} + +// stageTrackerIssueClaimant derives the holder of a claimed / in-progress +// issue: the worker ledger first, then the claim marker read from GitHub, +// then an assignee, then the agent the status payload says is on it. Nil +// when nothing names anyone. +func stageTrackerIssueClaimant(in stageTrackerClaimInputs) *StageTrackerClaimant { + if c := in.Ledger; c != nil && c.Holder != "" { + out := &StageTrackerClaimant{Source: claimantSourceClaimComment, Since: in.Since} + if !c.ClaimedAt.IsZero() { + out.Since = timePtr(c.ClaimedAt) + } + switch c.Kind { + case claims.KindAgent: + out.Kind, out.Agent = claimantKindHiveAgent, c.Holder + case claims.KindContributor, claims.KindExternal: + out.Kind, out.Login = claimantKindClanker, c.Holder + default: + out.Kind, out.Login = claimantKindPerson, c.Holder + } + out.Hive = stageTrackerForeignHive(c.Hive, in.HiveID) + return out + } + if in.MarkerHolder != "" { + out := &StageTrackerClaimant{Source: claimantSourceClaimComment, Since: in.Since} + switch in.MarkerKind { + case string(claims.KindAgent): + out.Kind, out.Agent = claimantKindHiveAgent, in.MarkerHolder + case string(claims.KindContributor), string(claims.KindExternal): + out.Kind, out.Login = claimantKindClanker, in.MarkerHolder + case string(claims.KindHuman): + out.Kind, out.Login = claimantKindPerson, in.MarkerHolder + default: + // No kind: the live claim is an assignee (issueclaim.SourceAssignee). + out.Source = claimantSourceAssignee + out.Kind, out.Login = stageTrackerLoginKind(in.MarkerHolder, in.IsClankerOwner), in.MarkerHolder + } + out.Hive = stageTrackerForeignHive(in.MarkerHive, in.HiveID) + return out + } + for _, a := range in.Assignees { + if a = strings.TrimSpace(a); a != "" { + return &StageTrackerClaimant{Kind: stageTrackerLoginKind(a, in.IsClankerOwner), Login: a, Since: in.Since, Source: claimantSourceAssignee} + } + } + if w := in.Worker; w != nil && w.Agent != "" { + out := &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: w.Agent, Since: in.Since, Source: claimantSourceKickHistory} + if !w.At.IsZero() { + out.Since = timePtr(w.At) + } + return out + } + return nil +} + +// stageTrackerPRClaimant derives who holds a PR row: the author, by the +// author kind the row already resolved. A hive PR names the agent on it +// (the status payload's busy agent, else the agent/ label) and the +// adopting agent counts the same way. Nil for a foreign bot or an unknown +// author kind. +func stageTrackerPRClaimant(in stageTrackerClaimInputs) *StageTrackerClaimant { + switch in.AuthorKind { + case authorKindHive: + out := &StageTrackerClaimant{Kind: claimantKindHiveAgent, Since: in.Since, Source: claimantSourceAuthor} + if w := in.Worker; w != nil && w.Agent != "" { + out.Agent, out.Source = w.Agent, claimantSourceKickHistory + if !w.At.IsZero() { + out.Since = timePtr(w.At) + } + return out + } + out.Agent = stageTrackerAgentLane(in.Labels) + if out.Agent == "" { + out.Login = in.Author + } + if out.Agent == "" && out.Login == "" { + return nil + } + return out + case authorKindClanker: + if in.Author == "" { + return nil + } + return &StageTrackerClaimant{Kind: claimantKindClanker, Login: in.Author, Since: in.Since, Source: claimantSourceAuthor} + case authorKindHuman: + if in.Author == "" { + return nil + } + return &StageTrackerClaimant{Kind: claimantKindPerson, Login: in.Author, Since: in.Since, Source: claimantSourceAuthor} + } + return nil +} + +// stageTrackerAgentLane is the lane named by an agent/ label, or "". +func stageTrackerAgentLane(labels []string) string { + for _, l := range labels { + if lane, ok := strings.CutPrefix(strings.TrimSpace(l), agentLaneLabelPrefix); ok && lane != "" { + return lane + } + } + return "" +} + +// stageTrackerLoginKind is clanker for a registered contributor's login +// (its connected hive acts for them), else person. +func stageTrackerLoginKind(login string, isClankerOwner func(string) bool) string { + if isClankerOwner != nil && isClankerOwner(login) { + return claimantKindClanker + } + return claimantKindPerson +} + +// stageTrackerForeignHive is the claim's hive when it is not this hive. +func stageTrackerForeignHive(hive, local string) string { + hive = strings.TrimSpace(hive) + if hive == "" || strings.EqualFold(hive, strings.TrimSpace(local)) { + return "" + } + return hive +} + +// stageTrackerClaimantStage says whether a row at this stage shows its +// holder: issues while claimed or with a PR under way; PRs from review +// through the author's rework and adoption, before the merge gate (where +// the gate word carries its own live detail). +func stageTrackerClaimantStage(kind string, stage int) bool { + if kind == "pr" { + return stage >= trackerNumberReviewPending && stage < trackerNumberAwaitingMerge + } + return stage == trackerNumberClaimed || stage == trackerNumberPRInProgress +} + +// stageTrackerIsClankerOwner memoises the contributor-registry lookup for +// one tracker build: a login with a profile is a clanker owner. +func stageTrackerIsClankerOwner() func(string) bool { + seen := map[string]bool{} + return func(login string) bool { + key := strings.ToLower(strings.TrimSpace(login)) + if key == "" { + return false + } + if v, ok := seen[key]; ok { + return v + } + v := findContributor(strings.TrimSpace(login)) != nil + seen[key] = v + return v + } +} + +// stageTrackerLedgerClaim reads the worker ledger's live claim for the +// issue, nil when the ledger is off or holds none. +func (s *Server) stageTrackerLedgerClaim(repo string, number int) *claims.Claim { + l := s.claimsLedger() + if l == nil { + return nil + } + c, ok := l.Lookup(repo, number) + if !ok { + return nil + } + return &c +} diff --git a/src/pkg/dashboard/stage_tracker_claimant_test.go b/src/pkg/dashboard/stage_tracker_claimant_test.go new file mode 100644 index 0000000000..b544f98221 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_claimant_test.go @@ -0,0 +1,177 @@ +package dashboard + +import ( + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/claims" +) + +// The tracker names who holds a claimed item — agent, clanker owner or +// person — from the worker ledger, the claim marker, an assignee or the +// busy agent, in that order; nothing names nobody (hivecommons/hive#15422). +func TestStageTrackerIssueClaimant(t *testing.T) { + now := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC) + since := now.Add(-3 * time.Hour) + claimedAt := now.Add(-20 * time.Minute) + kickedAt := now.Add(-5 * time.Minute) + clankerOwners := func(login string) bool { return strings.EqualFold(login, "bob") } + cases := []struct { + name string + in stageTrackerClaimInputs + want *StageTrackerClaimant + }{ + {"ledger agent from another hive", stageTrackerClaimInputs{Ledger: &claims.Claim{Holder: "quality", Kind: claims.KindAgent, Hive: "hosted-ibm-alchemy", ClaimedAt: claimedAt}, HiveID: "hosted-ibm-main", Since: &since}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "quality", Hive: "hosted-ibm-alchemy", Since: &claimedAt, Source: claimantSourceClaimComment}}, + {"ledger agent from this hive drops the hive", stageTrackerClaimInputs{Ledger: &claims.Claim{Holder: "quality", Kind: claims.KindAgent, Hive: "hosted-ibm-main", ClaimedAt: claimedAt}, HiveID: "hosted-ibm-main"}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "quality", Since: &claimedAt, Source: claimantSourceClaimComment}}, + {"ledger contributor is a clanker", stageTrackerClaimInputs{Ledger: &claims.Claim{Holder: "bob", Kind: claims.KindContributor, ClaimedAt: claimedAt}}, + &StageTrackerClaimant{Kind: claimantKindClanker, Login: "bob", Since: &claimedAt, Source: claimantSourceClaimComment}}, + {"ledger human is a person", stageTrackerClaimInputs{Ledger: &claims.Claim{Holder: "alice", Kind: claims.KindHuman, ClaimedAt: claimedAt}}, + &StageTrackerClaimant{Kind: claimantKindPerson, Login: "alice", Since: &claimedAt, Source: claimantSourceClaimComment}}, + {"marker with fleet fingerprint", stageTrackerClaimInputs{MarkerKind: "agent", MarkerHolder: "fixer", MarkerHive: "hosted-ibm-alchemy", HiveID: "local", Since: &since}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "fixer", Hive: "hosted-ibm-alchemy", Since: &since, Source: claimantSourceClaimComment}}, + {"assignee who owns a clanker", stageTrackerClaimInputs{MarkerHolder: "Bob", Since: &since, IsClankerOwner: clankerOwners}, + &StageTrackerClaimant{Kind: claimantKindClanker, Login: "Bob", Since: &since, Source: claimantSourceAssignee}}, + {"plain assignee is a person", stageTrackerClaimInputs{Assignees: []string{"alice"}, Since: &since, IsClankerOwner: clankerOwners}, + &StageTrackerClaimant{Kind: claimantKindPerson, Login: "alice", Since: &since, Source: claimantSourceAssignee}}, + {"kick history fallback", stageTrackerClaimInputs{Worker: &stageTrackerWorker{Agent: "fixer", At: kickedAt}, Since: &since}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "fixer", Since: &kickedAt, Source: claimantSourceKickHistory}}, + {"ledger beats assignee", stageTrackerClaimInputs{Ledger: &claims.Claim{Holder: "quality", Kind: claims.KindAgent, ClaimedAt: claimedAt}, Assignees: []string{"alice"}}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "quality", Since: &claimedAt, Source: claimantSourceClaimComment}}, + {"nobody", stageTrackerClaimInputs{Since: &since}, nil}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got := stageTrackerIssueClaimant(tc.in) + if !claimantEqual(got, tc.want) { + t.Fatalf("got %+v (since %v), want %+v", got, claimantSince(got), tc.want) + } + }) + } +} + +func TestStageTrackerPRClaimant(t *testing.T) { + now := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC) + since := now.Add(-time.Hour) + kickedAt := now.Add(-time.Minute) + cases := []struct { + name string + in stageTrackerClaimInputs + want *StageTrackerClaimant + }{ + {"hive PR names the agent on it", stageTrackerClaimInputs{Author: "hive-bot[bot]", AuthorKind: authorKindHive, Labels: []string{"agent/quality"}, Worker: &stageTrackerWorker{Agent: "fixer", At: kickedAt}, Since: &since}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "fixer", Since: &kickedAt, Source: claimantSourceKickHistory}}, + {"hive PR names its lane label", stageTrackerClaimInputs{Author: "hive-bot[bot]", AuthorKind: authorKindHive, Labels: []string{"stage/070-fixing", "agent/quality"}, Since: &since}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Agent: "quality", Since: &since, Source: claimantSourceAuthor}}, + {"hive PR without a lane falls back to the login", stageTrackerClaimInputs{Author: "hive-bot[bot]", AuthorKind: authorKindHive, Since: &since}, + &StageTrackerClaimant{Kind: claimantKindHiveAgent, Login: "hive-bot[bot]", Since: &since, Source: claimantSourceAuthor}}, + {"clanker PR", stageTrackerClaimInputs{Author: "bob", AuthorKind: authorKindClanker, Since: &since}, + &StageTrackerClaimant{Kind: claimantKindClanker, Login: "bob", Since: &since, Source: claimantSourceAuthor}}, + {"human PR", stageTrackerClaimInputs{Author: "alice", AuthorKind: authorKindHuman, Since: &since}, + &StageTrackerClaimant{Kind: claimantKindPerson, Login: "alice", Since: &since, Source: claimantSourceAuthor}}, + {"foreign bot", stageTrackerClaimInputs{Author: "dependabot[bot]", AuthorKind: "", Since: &since}, nil}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + if got := stageTrackerPRClaimant(tc.in); !claimantEqual(got, tc.want) { + t.Fatalf("got %+v, want %+v", got, tc.want) + } + }) + } +} + +func TestStageTrackerClaimantStage(t *testing.T) { + for _, tc := range []struct { + kind string + stage int + want bool + }{ + {"issue", trackerNumberClaimed, true}, {"issue", trackerNumberPRInProgress, true}, {"issue", trackerNumberActionable, false}, {"issue", trackerNumberCoveredByPR, false}, + {"pr", trackerNumberReviewPending, true}, {"pr", trackerNumberFixing, true}, {"pr", trackerNumberReturned, true}, {"pr", trackerNumberAdopted, true}, + {"pr", trackerNumberAwaitingMerge, false}, {"pr", trackerNumberNeedsDecision, false}, {"pr", 0, false}, + } { + if got := stageTrackerClaimantStage(tc.kind, tc.stage); got != tc.want { + t.Errorf("%s stage %d: got %v, want %v", tc.kind, tc.stage, got, tc.want) + } + } +} + +func claimantSince(c *StageTrackerClaimant) time.Time { + if c == nil || c.Since == nil { + return time.Time{} + } + return *c.Since +} + +func claimantEqual(a, b *StageTrackerClaimant) bool { + if (a == nil) != (b == nil) { + return false + } + if a == nil { + return true + } + return a.Kind == b.Kind && a.Login == b.Login && a.Agent == b.Agent && a.Hive == b.Hive && a.Source == b.Source && claimantSince(a).Equal(claimantSince(b)) +} + +// The chevron carries one short holder token after the stage word and the +// hover one "Held by:" line; an unknown holder adds nothing. +func TestStageTrackerClaimantChevronJS(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+"\n"+stageTrackerActorIconJS(t, html)+stageTrackerRowsFixtureJS+` +const litWord = (html) => text((/
  • ]*>([\s\S]*?)<\/li>/.exec(strip(html)) || ['', ''])[1]); +const litTitle = (html) => (/
  • ]*title="([^"]*)"/.exec(strip(html)) || [])[1] || ''; +const heldLine = (html) => (/Held by: .*$/.exec(litTitle(html)) || [''])[0].replace(/'/g, "'"); +const since = new Date(now - 3 * 3600000).toISOString(); +const issue = (n, extra) => Object.assign({ repo: 'hivecommons/hive', number: n, kind: 'issue', title: 'fix it', url: 'https://x/' + n, stage: 20, stage_since: since, caption: 'Claimed', author: 'alice', stage_actor: { kind: 'hive', why: 'holds the live claim' } }, extra || {}); + +// Hive agent from this hive: lane name only. +let row = stageTrackerRowHtml(issue(1, { claimant: { kind: 'hive-agent', agent: 'quality', since, source: 'claim-comment' } }), stages, ctx); +assert.strictEqual(litWord(row), 'Claimed · quality', litWord(row)); +assert.strictEqual(heldLine(row), 'Held by: hive agent quality since 3h ago (claim comment)', litTitle(row)); +assert.ok(strip(row).includes('class="ham-ico ham-actor-ico"'), 'the actor icon stays'); + +// Hive agent from another hive: lane@short-hive on the chevron, the full hive in the hover. +row = stageTrackerRowHtml(issue(2, { claimant: { kind: 'hive-agent', agent: 'quality', hive: 'hosted-ibm-alchemy', since, source: 'claim-comment' } }), stages, ctx); +assert.strictEqual(litWord(row), 'Claimed · quality@alchemy', litWord(row)); +assert.ok(heldLine(row).startsWith('Held by: hive agent quality@hosted-ibm-alchemy since 3h ago'), litTitle(row)); + +// Clanker: the owner's login plus "'s clanker". +row = stageTrackerRowHtml(issue(3, { stage_actor: { kind: 'clanker', why: 'holds the live claim' }, claimant: { kind: 'clanker', login: 'bob', since, source: 'assignee' } }), stages, ctx); +assert.strictEqual(litWord(row), "Claimed · @bob's clanker", litWord(row)); +assert.ok(heldLine(row).startsWith("Held by: @bob's clanker since 3h ago (assignee)"), litTitle(row)); + +// Person: @login. +row = stageTrackerRowHtml(issue(4, { stage_actor: { kind: 'human', why: 'holds the live claim' }, claimant: { kind: 'person', login: 'alice', since, source: 'assignee' } }), stages, ctx); +assert.strictEqual(litWord(row), 'Claimed · @alice', litWord(row)); +assert.ok(heldLine(row).startsWith('Held by: @alice since 3h ago (assignee)'), litTitle(row)); + +// Kick history on PR in progress: the agent and the source. +row = stageTrackerRowHtml(issue(5, { stage: 30, caption: 'PR in progress', claimant: { kind: 'hive-agent', agent: 'fixer', since: new Date(now - 30000).toISOString(), source: 'kick-history' } }), stages, ctx); +assert.strictEqual(litWord(row), 'PR in progress · fixer', litWord(row)); +assert.strictEqual(heldLine(row), 'Held by: hive agent fixer since just now (kick history)', litTitle(row)); + +// Unknown: nothing added, no slug or "unknown" leaks. +row = stageTrackerRowHtml(issue(6), stages, ctx); +assert.strictEqual(litWord(row), 'Claimed', litWord(row)); +assert.strictEqual(heldLine(row), '', litTitle(row)); +row = stageTrackerRowHtml(issue(7, { claimant: { kind: 'person', source: 'assignee' } }), stages, ctx); +assert.strictEqual(litWord(row), 'Claimed', 'a claimant without an identity adds nothing: ' + litWord(row)); +assert.ok(!/hive-agent|kick-history|claim-comment|unknown/i.test(text(row)), 'no slug leakage: ' + text(row)); + +// A returned-to-contributor PR names its author on the detour word. +const pr = stageTrackerRowHtml({ repo: 'hivecommons/hive', number: 8, kind: 'pr', title: 'docs', url: 'https://x/8', stage: 72, stage_since: since, caption: 'Returned', author: 'bob', author_kind: 'clanker', stage_actor: { kind: 'clanker', login: 'bob', why: '@bob must act' }, claimant: { kind: 'clanker', login: 'bob', since, source: 'author' } }, stages, ctx); +assert.ok(litWord(pr).endsWith("· @bob's clanker"), litWord(pr)); +assert.ok(heldLine(pr).startsWith("Held by: @bob's clanker since 3h ago (PR author)"), litTitle(pr)); + +// The covering-PR sub-row carries its PR's holder. +const covered = stageTrackerRowHtml(issue(9, { stage: 40, caption: 'Covered by PR', stage_actor: { kind: 'hive', why: 'its PR' }, linked_prs: [ + { number: 91, url: 'https://x/91', title: 'fix', author: 'hive-bot', author_kind: 'hive', stage: 70, stage_since: since, caption: 'Fixing', stage_actor: { kind: 'hive', login: 'fixer', why: 'fixer is on it' }, claimant: { kind: 'hive-agent', agent: 'fixer', since, source: 'kick-history' } }, + { number: 92, url: 'https://x/92', title: 'alt', author: 'alice', author_kind: 'human', stage: 50, stage_since: since, caption: 'CI', stage_actor: { kind: 'hive', why: 'review' }, claimant: { kind: 'person', login: 'alice', since, source: 'author' } }, +] }), stages, ctx); +const subWords = strips(covered).slice(1).map(s => text((/
  • ]*>([\s\S]*?)<\/li>/.exec(s) || ['', ''])[1])); +assert.deepStrictEqual(subWords, ['Fixing · fixer', 'CI / Review · @alice'], JSON.stringify(subWords)); +console.log('claimant chevron ok'); +`) +} diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index f08e6849f9..acd6699414 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -140,6 +140,12 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerStageActor"), jsFunc(t, html, "stageTrackerActorKind"), jsFunc(t, html, "stageTrackerActorTip"), + jsConstLine(t, html, "STAGE_TRACKER_HIVE_PREFIXES"), + jsConstLine(t, html, "STAGE_TRACKER_CLAIMANT_SOURCE"), + jsFunc(t, html, "stageTrackerShortHive"), + jsFunc(t, html, "stageTrackerClaimant"), + jsFunc(t, html, "stageTrackerClaimantShort"), + jsFunc(t, html, "stageTrackerClaimantLine"), jsConstLine(t, html, "STAGE_TRACKER_MOTION_STATIC"), jsConstLine(t, html, "STAGE_TRACKER_MOTION_ACTIVE"), jsConstLine(t, html, "STAGE_TRACKER_MOTION_HUMAN"), diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 705d00c2a3..3598aac83b 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -276,6 +276,7 @@ .ham-seg.active.merged { background: var(--green); color: var(--surface-0); animation: none; } .ham-seg.active.merged .ham-ico { stroke-width: 2.5; } .ham-seg-t { white-space: normal; overflow-wrap: anywhere; } + .ham-holder { font-weight: normal; } .ham-ico { width: 12px; height: 12px; flex: 0 0 auto; } .ham-actor-ico { margin-left: var(--sp-1); stroke-width: 2; } .ham-seg.done { background: var(--panel-strong); color: var(--text-faint); } diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 6c6c9a8062..4be085ba19 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -173,6 +173,39 @@ if (sa.kind === STAGE_TRACKER_ACTOR_NONE) return sa.why ? ' · ' + STAGE_TRACKER_NOBODY_LEAD + ' — ' + sa.why : ''; return ' · Next move: ' + sa.kind + (sa.login ? ' @' + sa.login : '') + (sa.why ? ' — ' + sa.why : ''); } + // Who holds the row: the payload's claimant {kind, login, agent, hive, + // since, source} (hivecommons/hive#15422). The chevron gets one short + // token after the stage word; the hover gets one "Held by:" line. + const STAGE_TRACKER_HIVE_PREFIXES = ['hosted-ibm-', 'hosted-']; + const STAGE_TRACKER_CLAIMANT_SOURCE = { 'claim-comment': 'claim comment', assignee: 'assignee', 'kick-history': 'kick history', author: 'PR author' }; + function stageTrackerShortHive(hive) { + const h = String(hive || ''); + const p = STAGE_TRACKER_HIVE_PREFIXES.find(x => h.startsWith(x)); + return p ? h.slice(p.length) : h; + } + function stageTrackerClaimant(item) { + const c = item && item.claimant; + return c && typeof c === 'object' && c.kind && (c.login || c.agent) ? c : null; + } + // "quality", "quality@alchemy", "@alice" or "@bob's clanker"; '' when unknown. + function stageTrackerClaimantShort(c) { + if (!c) return ''; + if (c.kind === 'hive-agent') return c.agent ? c.agent + (c.hive ? '@' + stageTrackerShortHive(c.hive) : '') : (c.login ? '@' + c.login : ''); + if (!c.login) return ''; + return '@' + c.login + (c.kind === 'clanker' ? "'s clanker" : ''); + } + // "Held by: hive agent quality@hosted-ibm-alchemy since 3h ago (claim comment)". + function stageTrackerClaimantLine(c, nowMs) { + if (!c) return ''; + let who; + if (c.kind === 'hive-agent') who = 'hive agent ' + (c.agent || '@' + c.login) + (c.hive ? '@' + c.hive : ''); + else who = '@' + c.login + (c.kind === 'clanker' ? "'s clanker" : ''); + const sinceMs = Date.parse(c.since || ''); + let since = ''; + if (sinceMs && nowMs) { const ago = stageTrackerShortAgo(nowMs - sinceMs); since = ago === 'now' ? ' since just now' : ' since ' + ago + ' ago'; } + const src = STAGE_TRACKER_CLAIMANT_SOURCE[c.source] || c.source || ''; + return 'Held by: ' + who + since + (src ? ' (' + src + ')' : ''); + } // The Fixing column word when nobody is fixing: a bot-authored PR the // hive does not touch, or an unowned red PR, reads as its state in // plain words instead of an active "Fixing" (hivecommons/docs#500). @@ -268,6 +301,9 @@ const actorKind = stageTrackerActorKind(item); const actorIco = actorKind ? stageTrackerIcon(actorKind, 'ham-ico ham-actor-ico', 'Next move: ' + actorKind) : ''; const actorTip = stageTrackerActorTip(item); + const claimant = typeof stageTrackerClaimant === 'function' ? stageTrackerClaimant(item) : null; + const holderShort = claimant ? stageTrackerClaimantShort(claimant) : ''; + const holderHtml = holderShort ? ` · ${esc(holderShort)}` : ''; // Static chevrons carry no data-motion: the CSS only animates the two // moving buckets. The hive-acting pulse needs an agent actually on // the item (tracker-cues: working); a hive stage with nobody on it is @@ -304,6 +340,7 @@ // The reason is the whole story; the stage description would only repeat it (hivecommons/hive#15394). else if (curStage === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.human_merge_reason_text) tip = ((sg.detour && sg.detour.text) || sg.label) + ' — ' + String(item.human_merge_reason_text).trim(); if (actorTip && !sg.cap) tip += actorTip; + if (claimant && !sg.cap) tip += ' · ' + stageTrackerClaimantLine(claimant, nowMs); // The sentinel's reason leads the lane tooltip so the security // implication is read before the stage mechanics. if (sentinel) tip = stageTrackerSentinelTip(item) + ' — ' + tip; @@ -320,7 +357,7 @@ // On the merge gate the word carries its live detail and the // leading glyph says in words what hive is doing (#15073). const gateWord = active && !sg.cap && !sg.detour && typeof stageTrackerMergeGateWordHtml === 'function' ? stageTrackerMergeGateWordHtml(item, nowMs) : ''; - const word = sg.detour ? `${esc(sg.detour.text)}` : (gateWord || `${esc(sg.short)}`); + const word = sg.detour ? `${esc(sg.detour.text)}${holderHtml}` : (gateWord || `${esc(sg.short)}${holderHtml}`); const gateCue = gateWord && typeof stageTrackerGateCueHtml === 'function' ? stageTrackerGateCueHtml(item, nowMs) : ''; // The agent-working spinner (tracker-cues) names the agent and what // it did, so a spinning glyph is never unexplained. @@ -844,7 +881,7 @@ stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.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 || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.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 || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / superseded). @@ -1157,7 +1194,7 @@ const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + 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.base_ref ? ` ${esc(lp.base_ref)}` : '') + (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? ' ' + stageTrackerLineageChipHtml(lp, nowMs) : '')]; 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, 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 }); + 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) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index b5ceefdcd8..06b986266b 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1599,6 +1599,7 @@ .ham-seg.active.merged { background: var(--green); color: var(--surface-0); animation: none; } .ham-seg.active.merged .ham-ico { stroke-width: 2.5; } .ham-seg-t { white-space: normal; overflow-wrap: anywhere; } + .ham-holder { font-weight: normal; } .ham-ico { width: 12px; height: 12px; flex: 0 0 auto; } .ham-actor-ico { margin-left: var(--sp-1); stroke-width: 2; } .ham-seg.done { background: var(--panel-strong); color: var(--text-faint); } @@ -15487,6 +15488,39 @@

    Where to get help

    if (sa.kind === STAGE_TRACKER_ACTOR_NONE) return sa.why ? ' · ' + STAGE_TRACKER_NOBODY_LEAD + ' — ' + sa.why : ''; return ' · Next move: ' + sa.kind + (sa.login ? ' @' + sa.login : '') + (sa.why ? ' — ' + sa.why : ''); } + // Who holds the row: the payload's claimant {kind, login, agent, hive, + // since, source} (hivecommons/hive#15422). The chevron gets one short + // token after the stage word; the hover gets one "Held by:" line. + const STAGE_TRACKER_HIVE_PREFIXES = ['hosted-ibm-', 'hosted-']; + const STAGE_TRACKER_CLAIMANT_SOURCE = { 'claim-comment': 'claim comment', assignee: 'assignee', 'kick-history': 'kick history', author: 'PR author' }; + function stageTrackerShortHive(hive) { + const h = String(hive || ''); + const p = STAGE_TRACKER_HIVE_PREFIXES.find(x => h.startsWith(x)); + return p ? h.slice(p.length) : h; + } + function stageTrackerClaimant(item) { + const c = item && item.claimant; + return c && typeof c === 'object' && c.kind && (c.login || c.agent) ? c : null; + } + // "quality", "quality@alchemy", "@alice" or "@bob's clanker"; '' when unknown. + function stageTrackerClaimantShort(c) { + if (!c) return ''; + if (c.kind === 'hive-agent') return c.agent ? c.agent + (c.hive ? '@' + stageTrackerShortHive(c.hive) : '') : (c.login ? '@' + c.login : ''); + if (!c.login) return ''; + return '@' + c.login + (c.kind === 'clanker' ? "'s clanker" : ''); + } + // "Held by: hive agent quality@hosted-ibm-alchemy since 3h ago (claim comment)". + function stageTrackerClaimantLine(c, nowMs) { + if (!c) return ''; + let who; + if (c.kind === 'hive-agent') who = 'hive agent ' + (c.agent || '@' + c.login) + (c.hive ? '@' + c.hive : ''); + else who = '@' + c.login + (c.kind === 'clanker' ? "'s clanker" : ''); + const sinceMs = Date.parse(c.since || ''); + let since = ''; + if (sinceMs && nowMs) { const ago = stageTrackerShortAgo(nowMs - sinceMs); since = ago === 'now' ? ' since just now' : ' since ' + ago + ' ago'; } + const src = STAGE_TRACKER_CLAIMANT_SOURCE[c.source] || c.source || ''; + return 'Held by: ' + who + since + (src ? ' (' + src + ')' : ''); + } // The Fixing column word when nobody is fixing: a bot-authored PR the // hive does not touch, or an unowned red PR, reads as its state in // plain words instead of an active "Fixing" (hivecommons/docs#500). @@ -15582,6 +15616,9 @@

    Where to get help

    const actorKind = stageTrackerActorKind(item); const actorIco = actorKind ? stageTrackerIcon(actorKind, 'ham-ico ham-actor-ico', 'Next move: ' + actorKind) : ''; const actorTip = stageTrackerActorTip(item); + const claimant = typeof stageTrackerClaimant === 'function' ? stageTrackerClaimant(item) : null; + const holderShort = claimant ? stageTrackerClaimantShort(claimant) : ''; + const holderHtml = holderShort ? ` · ${esc(holderShort)}` : ''; // Static chevrons carry no data-motion: the CSS only animates the two // moving buckets. The hive-acting pulse needs an agent actually on // the item (tracker-cues: working); a hive stage with nobody on it is @@ -15618,6 +15655,7 @@

    Where to get help

    // The reason is the whole story; the stage description would only repeat it (hivecommons/hive#15394). else if (curStage === STAGE_TRACKER_READY_FOR_HUMAN_MERGE && item.human_merge_reason_text) tip = ((sg.detour && sg.detour.text) || sg.label) + ' — ' + String(item.human_merge_reason_text).trim(); if (actorTip && !sg.cap) tip += actorTip; + if (claimant && !sg.cap) tip += ' · ' + stageTrackerClaimantLine(claimant, nowMs); // The sentinel's reason leads the lane tooltip so the security // implication is read before the stage mechanics. if (sentinel) tip = stageTrackerSentinelTip(item) + ' — ' + tip; @@ -15634,7 +15672,7 @@

    Where to get help

    // On the merge gate the word carries its live detail and the // leading glyph says in words what hive is doing (#15073). const gateWord = active && !sg.cap && !sg.detour && typeof stageTrackerMergeGateWordHtml === 'function' ? stageTrackerMergeGateWordHtml(item, nowMs) : ''; - const word = sg.detour ? `${esc(sg.detour.text)}` : (gateWord || `${esc(sg.short)}`); + const word = sg.detour ? `${esc(sg.detour.text)}${holderHtml}` : (gateWord || `${esc(sg.short)}${holderHtml}`); const gateCue = gateWord && typeof stageTrackerGateCueHtml === 'function' ? stageTrackerGateCueHtml(item, nowMs) : ''; // The agent-working spinner (tracker-cues) names the agent and what // it did, so a spinning glyph is never unexplained. @@ -16158,7 +16196,7 @@

    Where to get help

    stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.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 || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.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 || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / superseded). @@ -16471,7 +16509,7 @@

    Where to get help

    const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + 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.base_ref ? ` ${esc(lp.base_ref)}` : '') + (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? ' ' + stageTrackerLineageChipHtml(lp, nowMs) : '')]; 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, 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 }); + 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) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. diff --git a/src/pkg/github/client.go b/src/pkg/github/client.go index 9927550a53..3dc4e94bbe 100644 --- a/src/pkg/github/client.go +++ b/src/pkg/github/client.go @@ -795,6 +795,9 @@ type Issue struct { // stage/030-pr-in-progress from stage/020-claimed; the claim's kind // alone never does (hivecommons/hive#13069). ClaimPRStarted bool `json:"claim_pr_started,omitempty"` + // ClaimHive is the marker's hive= — the hive that recorded the live + // claim — when the claim came from a `hive:claim` marker; empty otherwise. + ClaimHive string `json:"claim_hive,omitempty"` // ClaimAdvisory is set when the issue carries a live contributor claim // the live-claim filter chose NOT to honour — the issue is in contributor // cool-off, or contributor claims have kept hive agents off it past the @@ -4612,6 +4615,7 @@ type RepoWorkIssue struct { ClaimKind string `json:"claim_kind,omitempty"` ClaimedBy string `json:"claimed_by,omitempty"` ClaimPRStarted bool `json:"claim_pr_started,omitempty"` + ClaimHive string `json:"claim_hive,omitempty"` // LinkedPRs and ClaimContext carry the PR-claim evidence of an issue the // duplicate-PR guard suppressed into the claimed_by_pr bucket // (hivecommons/hive#12144), so the repo card can render the same @@ -4656,6 +4660,7 @@ func repoWorkIssueFromIssue(issue Issue, bucket, reason string) RepoWorkIssue { ClaimKind: issue.ClaimKind, ClaimedBy: issue.ClaimedBy, ClaimPRStarted: issue.ClaimPRStarted, + ClaimHive: issue.ClaimHive, LinkedPRs: append([]IssueLinkedPR(nil), issue.LinkedPRs...), ClaimContext: issue.ClaimContext, Children: issue.Children, diff --git a/src/pkg/github/issue_claims.go b/src/pkg/github/issue_claims.go index 11393b13e7..e21bfde9de 100644 --- a/src/pkg/github/issue_claims.go +++ b/src/pkg/github/issue_claims.go @@ -145,6 +145,7 @@ func (c *Client) annotateIssueClaims(ctx context.Context, owner, repo string, is issue.ClaimSource = claim.Source issue.ClaimKind = claim.Kind issue.ClaimPRStarted = claim.PRStarted + issue.ClaimHive = claim.Hive } }