diff --git a/changelog.d/fixed-remediating-chevron-evidence.md b/changelog.d/fixed-remediating-chevron-evidence.md new file mode 100644 index 0000000000..bd767effb6 --- /dev/null +++ b/changelog.d/fixed-remediating-chevron-evidence.md @@ -0,0 +1 @@ +- Activity Monitor: the PR in progress chevron on a red PR now reads the evidence-based remediation state — `Changes requested · unassigned · next: scanner` while nobody has picked it up, `Remediating · · 4m` only on a running fix kick, a clanker claim or a working agent on the PR, and a done-style `Fix pushed abc1234 · re-review pending` once a head lands after the red signal; a push that predates the changes-requested review no longer reads as a fix. The item carries `remediation: {actor, kind, since, source}` and the tooltip names the evidence (hivecommons/hive#16525). diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 3bac8363f4..bad434321b 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -279,6 +279,9 @@ type StageTrackerItem struct { CIActivity *StageTrackerActivity `json:"ci_activity,omitempty"` ReviewActivity *StageTrackerActivity `json:"review_activity,omitempty"` CodeActivity *StageTrackerActivity `json:"code_activity,omitempty"` + // Remediation is the pickup evidence behind a red PR's code activity + // (stage_tracker_remediation.go); absent while nobody has picked it up. + Remediation *StageTrackerRemediation `json:"remediation,omitempty"` // DisplayColumn is presentation only; native stages, filters and merge gates remain unchanged. DisplayColumn int `json:"display_column,omitempty"` Preparation *StageTrackerPreparation `json:"preparation,omitempty"` diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index 9b9ce770bc..20f560ae33 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -545,8 +545,10 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto it.ReviewActivity = stageTrackerReviewActivity(currentPR, bundle, currentAggregate, dispatchState, status, now) stageTrackerCountPerspectives(it.ReviewActivity, currentPR, bundle, currentAggregate, dispatchState, stageTrackerRepoQualifier(status), expectedPerspectives) } + activityItem.CIActivity, activityItem.ReviewActivity = it.CIActivity, it.ReviewActivity stageTrackerApplyCodeActivity(&activityItem, dispatchState, status, now) - it.CodeActivity, it.DisplayColumn, it.Caption = activityItem.CodeActivity, activityItem.DisplayColumn, activityItem.Caption + stageTrackerApplyRemediation(&activityItem, dispatchState, status, stageTrackerFixerAgent(cfg), now) + it.CodeActivity, it.Remediation, it.DisplayColumn, it.Caption = activityItem.CodeActivity, activityItem.Remediation, activityItem.DisplayColumn, activityItem.Caption } resp.NeedsHuman, resp.OnHold = stageTrackerHumanCounts(resp.Items) resp.WaitingOnHuman = stageTrackerWaitingOnHuman(resp.Items) diff --git a/src/pkg/dashboard/stage_tracker_remediation.go b/src/pkg/dashboard/stage_tracker_remediation.go new file mode 100644 index 0000000000..2bcbd3fcb3 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_remediation.go @@ -0,0 +1,345 @@ +package dashboard + +import ( + "fmt" + "strings" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/review" +) + +// Remediation evidence kinds on the wire. A red review or CI result is a +// request for remediation, never proof that anybody is remediating; the +// PR in progress chevron reads "Remediating" only on one of these. +const ( + // remediationKindKick: a hive agent holds a fix kick for this head (fix + // dispatch record, or the agent's current action is on the PR since the + // red signal), or the claim ledger names a hive agent since then. + remediationKindKick = "kick" + // remediationKindClaim: a contributor's clanker took the fix task + // (relay claim) or a clanker claim landed on the PR since the signal. + remediationKindClaim = "claim" + // remediationKindPush: a new head landed after the red signal. + remediationKindPush = "push" + // remediationKindComment is reserved for an author's acknowledging + // comment; the tracker has no per-comment attribution yet, so no + // derivation emits it (a bare updated_at bump is not evidence). + remediationKindComment = "comment" +) + +// Code activity states the remediation derivation adds. +const ( + // codeStateUnassigned: red review / CI on the current head and no + // pickup evidence — the truthful waiting word. + codeStateUnassigned = "unassigned" + // codeStateRemediating: pickup evidence exists (kick / claim). + codeStateRemediating = "remediating" + // codeStateFixPushed: a head landed after the red signal; CI and the + // re-review for it are the open work. + codeStateFixPushed = "fix_pushed" +) + +// StageTrackerRemediation is the evidence that somebody picked a red PR up: +// who, what kind of evidence, when it started and which record it rests on. +type StageTrackerRemediation struct { + Actor string `json:"actor"` + Kind string `json:"kind"` + Since *time.Time `json:"since,omitempty"` + Source string `json:"source"` + // Head is the pushed head on push evidence. + Head string `json:"head,omitempty"` +} + +// stageTrackerRedSince reports when the current head's latest red signal +// (review changes requested, CI failing) began. A 07x row with no red +// activity recorded on its head is red since it entered the stage. +func stageTrackerRedSince(it *StageTrackerItem) (time.Time, string, bool) { + var since time.Time + word := "" + if a := it.CIActivity; a != nil && strings.EqualFold(a.Head, it.Head) && a.State == "failing" { + word = "CI failing" + if a.Since != nil { + since = *a.Since + } + } + if a := it.ReviewActivity; a != nil && strings.EqualFold(a.Head, it.Head) && a.State == "changes_requested" { + word = "Changes requested" + if a.Since != nil && a.Since.After(since) { + since = *a.Since + } + } + if word != "" { + return since, word, true + } + if it.Stage == trackerNumberFixing || it.Stage == trackerNumberNeedsAuthor || it.Stage == trackerNumberReturned { + if it.StageSince != nil { + since = *it.StageSince + } + return since, stageTrackerFixRequestedWord, true + } + return time.Time{}, "", false +} + +// stageTrackerFixRequestedWord is the red word for a 07x row whose current +// head has no review / CI verdict recorded yet. +const stageTrackerFixRequestedWord = "Fix requested" + +// stageTrackerRemediationEvidence is the one place pickup evidence is read. +// Each source is independent; the most recent evidence wins so a kick that +// follows a push (the agent iterating) reads as remediating again. +func stageTrackerRemediationEvidence(it *StageTrackerItem, dispatch review.DispatchState, status *StatusPayload, redSince, now time.Time) *StageTrackerRemediation { + var best *StageTrackerRemediation + consider := func(c *StageTrackerRemediation) { + if c == nil || c.Actor == "" { + return + } + if c.Since != nil && c.Since.After(now) { + t := now + c.Since = &t + } + if best == nil || (c.Since != nil && (best.Since == nil || c.Since.After(*best.Since))) { + best = c + } + } + consider(remediationFromFixDispatch(it, dispatch, status, now)) + consider(remediationFromAgentNow(it, status, redSince, now)) + consider(remediationFromClaimant(it, redSince)) + consider(remediationFromRework(it)) + consider(remediationFromPush(it, redSince)) + return best +} + +func remediationFromFixDispatch(it *StageTrackerItem, dispatch review.DispatchState, status *StatusPayload, now time.Time) *StageTrackerRemediation { + qualify := stageTrackerRepoQualifier(status) + for _, fix := range dispatch.Fixes { + if fix.Agent == "" || !trackerHeadMatches(it.Repo, it.Number, it.Head, qualify(fix.Repo), fix.Number, fix.HeadSHA) || + fix.Dispatched.IsZero() || fix.Dispatched.After(now) || now.Sub(fix.Dispatched) > review.DefaultPendingFixTTL { + continue + } + return &StageTrackerRemediation{Actor: fix.Agent, Kind: remediationKindKick, Since: timePtr(fix.Dispatched), Source: "fix-dispatch"} + } + return nil +} + +// remediationFromAgentNow: a working hive agent whose current action is on +// this PR and landed after the red signal. Review actions are the review +// swarm's, not a fix. +func remediationFromAgentNow(it *StageTrackerItem, status *StatusPayload, redSince, now time.Time) *StageTrackerRemediation { + if status == nil { + return nil + } + qualify := stageTrackerRepoQualifier(status) + for _, worker := range status.Agents { + action := worker.LastAction + if worker.Busy != "working" || worker.Paused || action == nil || !action.Current || !agentCausedAuditActions[action.Action] || + action.Action == github.AuditActionPRReviewed || action.Action == github.AuditActionAgentReviewRequested || + action.Number != it.Number || !strings.EqualFold(qualify(action.Repo), it.Repo) { + continue + } + at, err := time.Parse(time.RFC3339Nano, action.At) + if err != nil || at.After(now) || at.Before(redSince) { + continue + } + return &StageTrackerRemediation{Actor: worker.Name, Kind: remediationKindKick, Since: &at, Source: "agent-now"} + } + return nil +} + +// remediationFromClaimant: a claim-ledger / claim-comment claim that landed +// after the red signal. Authorship (source author) is not pickup. +func remediationFromClaimant(it *StageTrackerItem, redSince time.Time) *StageTrackerRemediation { + c := it.Claimant + if c == nil || c.Since == nil || c.Since.Before(redSince) { + return nil + } + switch { + case c.Kind == claimantKindHiveAgent && (c.Source == claimantSourceClaimLedger || c.Source == claimantSourceKickHistory) && c.Agent != "": + return &StageTrackerRemediation{Actor: c.Agent, Kind: remediationKindKick, Since: c.Since, Source: c.Source} + case c.Kind == claimantKindClanker && (c.Source == claimantSourceClaimLedger || c.Source == claimantSourceClaimComment) && c.Login != "": + return &StageTrackerRemediation{Actor: "@" + c.Login + "'s clanker", Kind: remediationKindClaim, Since: c.Since, Source: c.Source} + } + return nil +} + +// remediationFromRework: the contributor relay holds the fix task +// (in_progress) or the author's head landed (pushed). +func remediationFromRework(it *StageTrackerItem) *StageTrackerRemediation { + r := it.Rework + if r == nil || r.Actor == "" { + return nil + } + switch r.State { + case reworkStateInProgress: + return &StageTrackerRemediation{Actor: "@" + r.Actor + "'s clanker", Kind: remediationKindClaim, Since: r.Since, Source: "contributor-fix-relay"} + case reworkStatePushed: + return &StageTrackerRemediation{Actor: "@" + r.Actor, Kind: remediationKindPush, Since: r.Since, Source: "rework-commit", Head: r.Head} + } + return nil +} + +// remediationFromPush: the recorded push is newer than the red signal. A +// push the red review was given on is the reviewed head, not a fix. +func remediationFromPush(it *StageTrackerItem, redSince time.Time) *StageTrackerRemediation { + p := it.Push + if p == nil || p.State != pushStatePushed || p.Since == nil || !p.Since.After(redSince) { + return nil + } + actor := p.Login + if actor == "" { + actor = it.Author + } + if actor == "" { + actor = "author" + } + head := p.Sha + if head == "" { + head = it.Head + } + return &StageTrackerRemediation{Actor: "@" + actor, Kind: remediationKindPush, Since: p.Since, Source: "recorded-push", Head: head} +} + +// stageTrackerNextRemediator names who is expected to pick a red PR up when +// nobody has: the configured fixer for hive-owned PRs, the author otherwise. +func stageTrackerNextRemediator(it *StageTrackerItem, fixer string) string { + hiveOwned := it.AuthorKind == authorKindHive || (it.Claimant != nil && it.Claimant.Kind == claimantKindHiveAgent) + if it.Stage == trackerNumberNeedsAuthor || it.Stage == trackerNumberReturned { + hiveOwned = false + } + if hiveOwned { + if fixer == "" { + fixer = review.DefaultFixerAgent + } + return fixer + } + if it.Author != "" { + return "@" + it.Author + } + return "author" +} + +// stageTrackerFixerAgent is the configured fix agent (review.fixer_agent), +// falling back to the dispatcher's default. +func stageTrackerFixerAgent(cfg *config.Config) string { + if cfg != nil && strings.TrimSpace(cfg.Review.FixerAgent) != "" { + return strings.TrimSpace(cfg.Review.FixerAgent) + } + return review.DefaultFixerAgent +} + +func stageTrackerShortSHA(sha string) string { + if len(sha) > 7 { + return sha[:7] + } + return sha +} + +func stageTrackerShortAge(since *time.Time, now time.Time) string { + if since == nil || since.After(now) { + return "" + } + d := now.Sub(*since).Round(time.Minute) + switch { + case d < time.Minute: + return "just now" + case d < time.Hour: + return fmt.Sprintf("%dm", int(d.Minutes())) + case d < 48*time.Hour: + return fmt.Sprintf("%dh", int(d.Hours())) + } + return fmt.Sprintf("%dd", int(d.Hours()/24)) +} + +// stageTrackerApplyRemediation runs after stageTrackerApplyCodeActivity: on +// a PR whose current head is red (or that sits in a 07x fix stage) it +// replaces the code activity with the evidence-based remediation word and +// records the evidence on the item. Observed code work (fixing) and a +// same-head CI retry keep their own, more specific words. +func stageTrackerApplyRemediation(it *StageTrackerItem, dispatch review.DispatchState, status *StatusPayload, fixer string, now time.Time) { + it.Remediation = nil + if it.Kind != "pr" || it.Head == "" || it.Superseded != nil || it.Stage == trackerNumberNeedsDecision || it.Stage >= trackerNumberAwaitingMerge { + return + } + redSince, redWord, red := stageTrackerRedSince(it) + if !red { + return + } + out := it.CodeActivity + if out == nil { + out = trackerUnknownActivity(it.Head, "Code activity unknown") + } + // A 07x row whose head carries no red verdict yet and a push marker: the + // push IS the new head (stageTrackerPushFor binds it to the current + // head). Its native word stands; the push is the evidence. + if redWord == stageTrackerFixRequestedWord && out.State == "pushed" && it.Push != nil { + it.Remediation = remediationFromPush(it, time.Time{}) + return + } + ev := stageTrackerRemediationEvidence(it, dispatch, status, redSince, now) + it.Remediation = ev + if out.State == "fixing" && out.Active { + return + } + if out.State == "waiting_ci" && out.Source == "recorded-ci-retry" { + return + } + redAt := "" + if !redSince.IsZero() { + redAt = " at " + redSince.UTC().Format(time.RFC3339) + } + switch { + case ev != nil && ev.Kind == remediationKindPush: + out = &StageTrackerActivity{Head: it.Head, State: codeStateFixPushed, Actor: ev.Actor, Source: ev.Source, Since: ev.Since} + out.Caption = "Fix pushed " + stageTrackerShortSHA(ev.Head) + " · re-review pending" + if a := it.CIActivity; a != nil && strings.EqualFold(a.Head, it.Head) && (a.State == "queued" || a.State == "running" || a.State == "unknown") { + out.Caption = "Fix pushed " + stageTrackerShortSHA(ev.Head) + " · CI pending" + } + out.Detail = ev.Actor + " pushed " + stageTrackerShortSHA(ev.Head) + " after the " + strings.ToLower(redWord) + " signal" + redAt + + "; CI and the re-review on the new head decide whether it stands (evidence: push, " + ev.Source + ")." + it.DisplayColumn = trackerNumberReviewPending + case ev != nil: + out = &StageTrackerActivity{Head: it.Head, State: codeStateRemediating, Actor: ev.Actor, Source: ev.Source, Since: ev.Since, ObservedAt: timePtr(now), Active: true} + out.Caption = "Remediating · " + ev.Actor + if age := stageTrackerShortAge(ev.Since, now); age != "" { + out.Caption += " · " + age + } + if it.CodeActivity != nil && it.CodeActivity.State == "waiting_ci" { + out.Caption += " · waiting for CI" + } + what := map[string]string{remediationKindKick: "a hive fix kick is running", remediationKindClaim: "a contributor clanker claimed the fix", remediationKindComment: "the author acknowledged"}[ev.Kind] + out.Detail = redWord + redAt + "; " + what + " (evidence: " + ev.Kind + ", " + ev.Source + if ev.Since != nil { + out.Detail += ", since " + ev.Since.UTC().Format(time.RFC3339) + } + out.Detail += ")." + it.DisplayColumn = trackerNumberPRInProgress + case out.State == "waiting_owner": + out.Caption = strings.Replace(out.Caption, " · not observed coding", " · "+strings.ToLower(redWord), 1) + out.Detail = redWord + redAt + "; no push, claim or fix kick seen since. A new head from @" + it.Author + ", a clanker claim or a hive adoption would move it." + it.DisplayColumn = trackerNumberPRInProgress + default: + next := stageTrackerNextRemediator(it, fixer) + out = &StageTrackerActivity{Head: it.Head, State: codeStateUnassigned, Source: "no-pickup-evidence", Since: timePtr(redSince)} + if redSince.IsZero() { + out.Since = nil + } + out.Caption = redWord + " · unassigned" + if r := it.Rework; r != nil && r.Evidence == reworkEvidenceQueued && r.Actor != "" { + out.Caption += fmt.Sprintf(" · fixer queued, %d ahead", r.Ahead) + next = "@" + r.Actor + "'s clanker" + } + out.Caption += " · next: " + next + out.Detail = redWord + redAt + "; no fix kick, claim or new head seen since. It switches to Remediating when a hive fix kick for this head runs, a clanker claims it or " + next + " pushes." + if it.CodeActivity != nil && it.CodeActivity.Blocker != "" { + out.Blocker = it.CodeActivity.Blocker + } + it.DisplayColumn = trackerNumberPRInProgress + } + it.CodeActivity = out + if it.Stage == trackerNumberFixing && it.Superseded == nil && + (it.Caption == "" || strings.HasPrefix(it.Caption, "Waiting for fixer") || strings.HasPrefix(it.Caption, "New head pushed") || + strings.HasPrefix(it.Caption, "Remediating") || strings.HasPrefix(it.Caption, "Fixing")) { + it.Caption = out.Caption + } +} diff --git a/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js b/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js new file mode 100644 index 0000000000..ca3ddcb8a7 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js @@ -0,0 +1,102 @@ +// The PR in progress chevron on a red PR (hivecommons/hive stage +// stage_tracker_remediation.go): "Changes requested · unassigned" bright +// and still, "Remediating · " pulsing on pickup evidence, and a +// done-style "Fix pushed · re-review pending" once a head lands after +// the red signal. Functions are lifted from static-src as the activity +// test does. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); + +const root = path.join(__dirname, 'static-src', 'js'); +const strip = fs.readFileSync(path.join(root, 'tracker-row-strip.js'), 'utf8'); +const anchor = fs.readFileSync(path.join(root, 'tracker-row-anchor.js'), 'utf8'); +const rowSource = fs.readFileSync(path.join(root, 'tracker-row.js'), 'utf8'); +function fn(source, name) { + const match = source.match(new RegExp('function ' + name + '\\([^]*?\\n \\}')); + assert.ok(match, name); + return match[0]; +} +const esc = text => String(text).replaceAll('&', '&').replaceAll('<', '<').replaceAll('"', '"'); +const globals = ` +const STAGE_TRACKER_PATH = [0, 10, 20, 30, 50, 80]; +const STAGE_TRACKER_TERMINAL = 110; +const STAGE_TRACKER_PR_COLUMN = 30, STAGE_TRACKER_MERGE_COLUMN = 80; +const STAGE_TRACKER_NEEDS_DECISION = 85, STAGE_TRACKER_ISSUE_NEEDS_DECISION = 45; +const STAGE_TRACKER_ISSUE_DECISION_COLUMN = 10, STAGE_TRACKER_TRIAGE_NEEDED = 15, STAGE_TRACKER_POSSIBLY_EXISTS = 17; +const STAGE_TRACKER_PRE_MERGE_SOAK = 95; +`; +const track = new Function('esc', 'stageTrackerIcon', fn(strip, 'stageTrackerTrackLead') + fn(strip, 'stageTrackerTrackWord') + fn(strip, 'stageTrackerActivityTrackHtml') + ';return stageTrackerActivityTrackHtml;')(esc, (n, cls) => ``); +const getAnchor = new Function(globals + anchor + ';return stageTrackerAnchor;')(); +const segments = new Function('stageTrackerAnchor', globals + ` +const STAGE_TRACKER_ACTIVE_WORD = {70: 'Fixing'}; +const STAGE_TRACKER_HUMAN_GATED = 85, STAGE_TRACKER_READY_FOR_HUMAN_MERGE = 90, STAGE_TRACKER_ADOPTED_BY_HIVE = 74; +function stageTrackerSentinelInLane() { return false; } +function stageTrackerUnauthorizedWord() { return ''; } +function stageTrackerManualMergeWord() { return 'Ready for human merge'; } +` + fn(rowSource, 'stageTrackerSegments') + ';return stageTrackerSegments;')(getAnchor); +const renderStrip = new Function('esc', 'stageTrackerSegments', 'stageTrackerActivityTrackHtml', globals + ` +const STAGE_TRACKER_MOTION_STATIC = 'static', STAGE_TRACKER_MOTION_ACTIVE = 'active'; +const STAGE_TRACKER_READY_FOR_HUMAN_MERGE = 90; +function stageTrackerActorKind() { return ''; } +function stageTrackerActorTip() { return ''; } +function stageTrackerMotion() { return STAGE_TRACKER_MOTION_STATIC; } +function stageTrackerIcon(n) { return ''; } +` + fn(strip, 'stageTrackerStripItems') + ';return stageTrackerStripItems;')(esc, segments, track); + +const stages = [{ number: 70, branch_from: 50 }, { number: 71, branch_from: 50 }, { number: 72, branch_from: 50 }]; +const now = Date.parse('2026-11-04T02:45:00Z'); +const red = '2026-11-04T02:05:00Z'; +const cells = item => [...renderStrip(item, stages, null, now, {}).matchAll(//g)].map(m => m[0]); +const redPR = extra => ({ + kind: 'pr', repo: 'org/repo', number: 7, head: 'abc1234def', stage: 70, modifiers: [], + ci_activity: { head: 'abc1234def', state: 'passing', caption: 'CI 11/11 passed', source: 'checks', observed_at: '2026-11-04T02:44:00Z' }, + review_activity: { head: 'abc1234def', state: 'changes_requested', caption: 'Review 5/5 · changes requested', source: 'verified-review-bundle', observed_at: '2026-11-04T02:44:00Z', since: red }, + ...extra, +}); + +test('unassigned: PR in progress is lit, bright and still, with the pickup rule in its tooltip', () => { + const item = redPR({ display_column: 30, code_activity: { head: 'abc1234def', state: 'unassigned', caption: 'Changes requested · unassigned · next: scanner', source: 'no-pickup-evidence', since: red, detail: 'Changes requested at ' + red + '; no fix kick, claim or new head seen since. It switches to Remediating when a hive fix kick for this head runs, a clanker claims it or scanner pushes.' } }); + const c = cells(item); + const pr = c[3]; + assert.match(pr, /class="ham-seg active[^"]*ham-remediation-unassigned/); + assert.match(pr, /data-remediation="unassigned"/); + assert.match(pr, /Changes requested · unassigned · next: scanner/); + assert.doesNotMatch(pr, /data-motion="active"/, 'nobody is on it: no pulse'); + assert.match(pr, /switches to Remediating when a hive fix kick/); + assert.match(c[5], /data-activity-state="changes_requested"/, 'the Review track keeps its own red state'); +}); + +test('remediating: the chevron pulses, names the actor and shows the evidence kind and time', () => { + const item = redPR({ display_column: 30, + remediation: { actor: 'scanner', kind: 'kick', since: '2026-11-04T02:41:00Z', source: 'fix-dispatch' }, + code_activity: { head: 'abc1234def', state: 'remediating', caption: 'Remediating · scanner · 4m', actor: 'scanner', active: true, source: 'fix-dispatch', since: '2026-11-04T02:41:00Z', observed_at: '2026-11-04T02:45:00Z', detail: 'Changes requested at ' + red + '; a hive fix kick is running (evidence: kick, fix-dispatch, since 2026-11-04T02:41:00Z).' } }); + const pr = cells(item)[3]; + assert.match(pr, /class="ham-seg active[^"]*ham-remediation-remediating/); + assert.match(pr, /data-motion="active"/); + assert.match(pr, /Remediating · scanner · 4m/); + assert.match(pr, /evidence: kick by scanner since 2026-11-04T02:41:00Z \(fix-dispatch\)/); +}); + +test('fix pushed: PR in progress is done-style with its word while CI / Review is the current column', () => { + const item = redPR({ display_column: 50, head: 'f269349abcdef', + ci_activity: { head: 'f269349abcdef', state: 'running', caption: 'CI running', source: 'checks', observed_at: '2026-11-04T02:44:00Z' }, + review_activity: { head: 'f269349abcdef', state: 'unknown', caption: 'Review unknown', source: 'unavailable' }, + remediation: { actor: '@hive[bot]', kind: 'push', since: '2026-11-04T02:43:00Z', source: 'recorded-push', head: 'f269349abcdef' }, + code_activity: { head: 'f269349abcdef', state: 'fix_pushed', caption: 'Fix pushed f269349 · CI pending', source: 'recorded-push', since: '2026-11-04T02:43:00Z' } }); + const c = cells(item); + const pr = c[3]; + assert.match(pr, /class="ham-seg done ham-fix-pushed/); + assert.match(pr, /data-remediation="fix_pushed"/); + assert.match(pr, /Fix pushed f269349 · CI pending/); + assert.doesNotMatch(pr, /aria-current/, 'the pushed fix is history: CI / Review is the current column'); + assert.match(pr, /evidence: push by @hive\[bot\]/); + assert.match(c[4], /ham-current/, 'CI track is current'); +}); + +test('a red PR with a stale code head renders no remediation attributes', () => { + const item = redPR({ display_column: 30, code_activity: { head: 'older', state: 'unassigned', caption: 'Changes requested · unassigned · next: scanner' } }); + const html = renderStrip(item, stages, null, now, {}); + assert.doesNotMatch(html, /data-remediation=/); +}); diff --git a/src/pkg/dashboard/stage_tracker_remediation_test.go b/src/pkg/dashboard/stage_tracker_remediation_test.go new file mode 100644 index 0000000000..9ec7e20424 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_remediation_test.go @@ -0,0 +1,225 @@ +package dashboard + +import ( + "os/exec" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/review" +) + +// A hive-authored 070 PR whose head was pushed BEFORE the review asked for +// changes: the recorded push is the reviewed head, not a fix. +func remediationRedPR(now time.Time) *StageTrackerItem { + pushed := now.Add(-3 * time.Hour) + red := now.Add(-40 * time.Minute) + stageSince := now.Add(-39 * time.Minute) + it := &StageTrackerItem{Repo: "org/repo", Kind: "pr", Number: 7, Head: "abc1234def", Author: "hive[bot]", AuthorKind: authorKindHive, + Stage: trackerNumberFixing, StageSince: &stageSince, Caption: "New head pushed · CI and re-review", + CIActivity: &StageTrackerActivity{Head: "abc1234def", State: "passing"}, + ReviewActivity: &StageTrackerActivity{Head: "abc1234def", State: "changes_requested", Since: &red}, + Push: &StageTrackerPush{State: pushStatePushed, Login: "hive[bot]", Since: &pushed, Sha: "abc1234def"}, + Claimant: &StageTrackerClaimant{Kind: claimantKindHiveAgent, Login: "hive[bot]", Source: claimantSourceAuthor, Since: &stageSince}} + stageTrackerApplyCodeActivity(it, review.DispatchState{}, nil, now) + return it +} + +func TestStageTrackerRemediationUnassignedWithoutEvidence(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + it := remediationRedPR(now) + if it.CodeActivity.State != "pushed" || it.DisplayColumn != trackerNumberReviewPending { + t.Fatalf("precondition: stale push marker expected, got %s col %d", it.CodeActivity.State, it.DisplayColumn) + } + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if it.Remediation != nil { + t.Fatalf("no evidence must yield no remediation record: %+v", it.Remediation) + } + ca := it.CodeActivity + if ca.State != codeStateUnassigned || ca.Caption != "Changes requested · unassigned · next: scanner" || it.DisplayColumn != trackerNumberPRInProgress { + t.Fatalf("unassigned word: state=%s caption=%q col=%d", ca.State, ca.Caption, it.DisplayColumn) + } + if !strings.Contains(ca.Detail, "switches to Remediating when") || ca.Since == nil || !ca.Since.Equal(now.Add(-40*time.Minute)) { + t.Fatalf("detail should explain pickup triggers and date the red signal: %q since=%v", ca.Detail, ca.Since) + } + if it.Caption != ca.Caption { + t.Fatalf("070 caption follows the code word: %q", it.Caption) + } +} + +func TestStageTrackerRemediationCIFailingWordAndPersonNext(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + it := remediationRedPR(now) + it.ReviewActivity = &StageTrackerActivity{Head: it.Head, State: "unknown"} + red := now.Add(-10 * time.Minute) + it.CIActivity = &StageTrackerActivity{Head: it.Head, State: "failing", Since: &red} + it.AuthorKind, it.Author, it.Claimant = authorKindHuman, "alice", nil + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if got := it.CodeActivity.Caption; got != "CI failing · unassigned · next: @alice" { + t.Fatalf("CI-only red names CI and the author: %q", got) + } +} + +func TestStageTrackerRemediationEvidenceKickFromFixDispatch(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + it := remediationRedPR(now) + dispatched := now.Add(-4 * time.Minute) + dispatch := review.DispatchState{Fixes: []review.PendingFix{{Repo: it.Repo, Number: it.Number, HeadSHA: it.Head, Agent: "scanner", Dispatched: dispatched}}} + stageTrackerApplyRemediation(it, dispatch, nil, "scanner", now) + ev := it.Remediation + if ev == nil || ev.Kind != remediationKindKick || ev.Actor != "scanner" || ev.Source != "fix-dispatch" || !ev.Since.Equal(dispatched) { + t.Fatalf("fix dispatch is kick evidence: %+v", ev) + } + ca := it.CodeActivity + if ca.State != codeStateRemediating || ca.Caption != "Remediating · scanner · 4m" || !ca.Active || it.DisplayColumn != trackerNumberPRInProgress { + t.Fatalf("remediating word: state=%s caption=%q active=%v col=%d", ca.State, ca.Caption, ca.Active, it.DisplayColumn) + } + if !strings.Contains(ca.Detail, "evidence: kick, fix-dispatch, since "+dispatched.Format(time.RFC3339)) { + t.Fatalf("tooltip carries evidence kind and time: %q", ca.Detail) + } + // An expired dispatch is no evidence. + dispatch.Fixes[0].Dispatched = now.Add(-review.DefaultPendingFixTTL - time.Minute) + it = remediationRedPR(now) + stageTrackerApplyRemediation(it, dispatch, nil, "scanner", now) + if it.Remediation != nil || it.CodeActivity.State != codeStateUnassigned { + t.Fatalf("expired dispatch must not read as pickup: %+v %s", it.Remediation, it.CodeActivity.State) + } +} + +func TestStageTrackerRemediationEvidenceKickFromAgentNow(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + it := remediationRedPR(now) + at := now.Add(-2 * time.Minute) + status := &StatusPayload{Agents: []FrontendAgent{ + {Name: "reviewer", Busy: "working", LastAction: &FrontendAgentLastAction{Repo: it.Repo, Number: it.Number, Action: github.AuditActionPRReviewed, Current: true, At: at.Format(time.RFC3339Nano)}}, + {Name: "scanner", Busy: "working", LastAction: &FrontendAgentLastAction{Repo: it.Repo, Number: it.Number, Action: github.AuditActionAgentCommentCreated, Current: true, At: at.Format(time.RFC3339Nano)}}, + }} + stageTrackerApplyRemediation(it, review.DispatchState{}, status, "scanner", now) + if ev := it.Remediation; ev == nil || ev.Kind != remediationKindKick || ev.Actor != "scanner" || ev.Source != "agent-now" { + t.Fatalf("working agent on the PR after the red signal is kick evidence: %+v", ev) + } + // The reviewer alone is the review swarm, not a fix; an action older + // than the red signal is the earlier turn. + status.Agents = status.Agents[:1] + it = remediationRedPR(now) + stageTrackerApplyRemediation(it, review.DispatchState{}, status, "scanner", now) + if it.Remediation != nil { + t.Fatalf("review action is not pickup: %+v", it.Remediation) + } + status.Agents = []FrontendAgent{{Name: "scanner", Busy: "working", LastAction: &FrontendAgentLastAction{Repo: it.Repo, Number: it.Number, Action: github.AuditActionAgentPRCreated, Current: true, At: now.Add(-2 * time.Hour).Format(time.RFC3339Nano)}}} + it = remediationRedPR(now) + stageTrackerApplyRemediation(it, review.DispatchState{}, status, "scanner", now) + if it.Remediation != nil { + t.Fatalf("pre-signal action is not pickup: %+v", it.Remediation) + } +} + +func TestStageTrackerRemediationEvidenceClaim(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + since := now.Add(-9 * time.Minute) + it := remediationRedPR(now) + it.Rework = &StageTrackerRework{State: reworkStateInProgress, Actor: "bob", Evidence: reworkEvidenceClaim, Since: &since} + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if ev := it.Remediation; ev == nil || ev.Kind != remediationKindClaim || ev.Actor != "@bob's clanker" || ev.Source != "contributor-fix-relay" { + t.Fatalf("relay claim is claim evidence: %+v", ev) + } + if got := it.CodeActivity.Caption; got != "Remediating · @bob's clanker · 9m" { + t.Fatalf("claim word: %q", got) + } + // A clanker claim on the PR after the signal counts; the authorship + // claimant never does. + it = remediationRedPR(now) + it.Claimant = &StageTrackerClaimant{Kind: claimantKindClanker, Login: "carol", Source: claimantSourceClaimComment, Since: &since} + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if ev := it.Remediation; ev == nil || ev.Kind != remediationKindClaim || ev.Actor != "@carol's clanker" { + t.Fatalf("claim comment is claim evidence: %+v", ev) + } + before := now.Add(-2 * time.Hour) + it = remediationRedPR(now) + it.Claimant = &StageTrackerClaimant{Kind: claimantKindClanker, Login: "carol", Source: claimantSourceClaimLedger, Since: &before} + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if it.Remediation != nil { + t.Fatalf("claim older than the red signal is not pickup: %+v", it.Remediation) + } + // A queued relay fix is a waiting word with its queue position. + it = remediationRedPR(now) + it.Rework = &StageTrackerRework{State: reworkStateRequested, Actor: "bob", Evidence: reworkEvidenceQueued, Ahead: 3} + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if it.Remediation != nil || it.CodeActivity.Caption != "Changes requested · unassigned · fixer queued, 3 ahead · next: @bob's clanker" { + t.Fatalf("queued fix is waiting, not remediating: %+v %q", it.Remediation, it.CodeActivity.Caption) + } +} + +func TestStageTrackerRemediationEvidencePush(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + it := remediationRedPR(now) + pushed := now.Add(-2 * time.Minute) + it.Push = &StageTrackerPush{State: pushStatePushed, Login: "hive[bot]", Since: &pushed, Sha: "f269349abcdef"} + it.Head = "f269349abcdef" + it.CIActivity = &StageTrackerActivity{Head: it.Head, State: "running"} + it.ReviewActivity = &StageTrackerActivity{Head: it.Head, State: "changes_requested", Since: it.ReviewActivity.Since} + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if ev := it.Remediation; ev == nil || ev.Kind != remediationKindPush || ev.Actor != "@hive[bot]" || ev.Head != "f269349abcdef" || ev.Source != "recorded-push" { + t.Fatalf("push after the signal is push evidence: %+v", ev) + } + ca := it.CodeActivity + if ca.State != codeStateFixPushed || ca.Caption != "Fix pushed f269349 · CI pending" || ca.Active || it.DisplayColumn != trackerNumberReviewPending { + t.Fatalf("fix pushed word: state=%s caption=%q active=%v col=%d", ca.State, ca.Caption, ca.Active, it.DisplayColumn) + } + it.CIActivity.State = "passing" + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if got := it.CodeActivity.Caption; got != "Fix pushed f269349 · re-review pending" { + t.Fatalf("green CI leaves the re-review: %q", got) + } + // 072: the author's head after the ask (rework pushed) is push evidence. + it = remediationRedPR(now) + it.Stage, it.Author, it.AuthorKind = trackerNumberReturned, "dave", authorKindClanker + it.Push = nil + it.Rework = &StageTrackerRework{State: reworkStatePushed, Actor: "dave", Evidence: reworkEvidenceCommit, Head: "0123456789", Since: &pushed} + stageTrackerApplyCodeActivity(it, review.DispatchState{}, nil, now) + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if ev := it.Remediation; ev == nil || ev.Kind != remediationKindPush || ev.Actor != "@dave" || it.CodeActivity.Caption != "Fix pushed 0123456 · re-review pending" { + t.Fatalf("rework push: %+v %q", ev, it.CodeActivity.Caption) + } +} + +func TestStageTrackerRemediationKeepsOwnerWaitAndObservedWork(t *testing.T) { + now := time.Date(2026, 11, 4, 2, 45, 0, 0, time.UTC) + it := remediationRedPR(now) + it.Stage, it.Author, it.AuthorKind, it.Push = trackerNumberReturned, "erin", authorKindClanker, nil + stageTrackerApplyCodeActivity(it, review.DispatchState{}, nil, now) + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + ca := it.CodeActivity + if ca.State != "waiting_owner" || ca.Caption != "Waiting for @erin · changes requested" || it.DisplayColumn != trackerNumberPRInProgress || it.Remediation != nil { + t.Fatalf("person-owned wait keeps its word with the red reason: state=%s caption=%q col=%d ev=%+v", ca.State, ca.Caption, it.DisplayColumn, it.Remediation) + } + // Observed code work already reads Remediating · agent; untouched. + it = remediationRedPR(now) + it.CodeActivity = &StageTrackerActivity{Head: it.Head, State: "fixing", Caption: "Remediating · scanner", Active: true, Source: "fix-dispatch+successful-edit+verified-git-worktree"} + it.DisplayColumn = trackerNumberPRInProgress + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if it.CodeActivity.State != "fixing" || it.CodeActivity.Caption != "Remediating · scanner" { + t.Fatalf("observed work keeps its word: %+v", it.CodeActivity) + } + // Not red, not in a fix stage: nothing changes. + it = remediationRedPR(now) + it.Stage = trackerNumberReviewPending + it.ReviewActivity = &StageTrackerActivity{Head: it.Head, State: "reviewing"} + stageTrackerApplyCodeActivity(it, review.DispatchState{}, nil, now) + before := it.CodeActivity + stageTrackerApplyRemediation(it, review.DispatchState{}, nil, "scanner", now) + if it.Remediation != nil || it.CodeActivity != before { + t.Fatalf("green PR untouched: %+v", it.CodeActivity) + } +} + +func TestStageTrackerRemediationJavaScript(t *testing.T) { + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node unavailable") + } + if output, err := exec.Command(node, "--test", "stage_tracker_remediation_chevron.test.js").CombinedOutput(); err != nil { + t.Fatalf("remediation chevron JavaScript: %v\n%s", err, output) + } +} diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 82b4e8f92c..b352c33a67 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -350,6 +350,12 @@ .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); } + /* Evidence-based remediation on the PR in progress chevron: a red PR + nobody has picked up is bright and still; a pushed fix head is a + done-style step that keeps its word (stage_tracker_remediation.go). */ + .ham-seg.active.ham-remediation-unassigned { background: color-mix(in srgb, var(--amber) 70%, var(--red)); } + .ham-seg.done.ham-fix-pushed { color: var(--green); } + .ham-seg.done.ham-fix-pushed .ham-seg-t::before { content: '✓'; margin-right: var(--sp-1); } .ham-seg.todo { background: transparent; color: var(--text-faint); box-shadow: inset 0 0 0 var(--line-width) var(--line-subtle); opacity: 0.5; } .ham-seg.blank { visibility: hidden; } .ham-sub { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: var(--sp-2); margin-top: var(--sp-3); position: relative; } diff --git a/src/pkg/dashboard/static-src/js/tracker-row-strip.js b/src/pkg/dashboard/static-src/js/tracker-row-strip.js index 2724213df8..c19c1ba60a 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -195,13 +195,22 @@ if (code && !codeWorking && Number(item.display_column) === 30) motion = STAGE_TRACKER_MOTION_STATIC; if (motion === STAGE_TRACKER_MOTION_ACTIVE && !worker) motion = STAGE_TRACKER_MOTION_STATIC; if (codeWorking && Number(item.display_column) === 30) motion = STAGE_TRACKER_MOTION_ACTIVE; + // Evidence-based remediation (stage_tracker_remediation.go): the PR in + // progress chevron pulses only while somebody is KNOWN to be on a red + // PR (kick / claim); "unassigned" is bright but still; a fix head + // pushed after the red signal is done-style with its word. + const codeOnHead = code && String(code.head || '') === String(item.head || ''); + const remediation = codeOnHead && ['unassigned', 'remediating', 'fix_pushed'].includes(code.state) ? code.state : ''; + if (remediation === 'remediating' && Number(item.display_column) === 30) motion = STAGE_TRACKER_MOTION_ACTIVE; + const evidence = item.remediation && item.remediation.kind ? 'evidence: ' + item.remediation.kind + (item.remediation.actor ? ' by ' + item.remediation.actor : '') + (item.remediation.since ? ' since ' + item.remediation.since : '') + (item.remediation.source ? ' (' + item.remediation.source + ')' : '') : ''; const motionAttr = motion === STAGE_TRACKER_MOTION_STATIC ? '' : ` data-motion="${motion}"`; return segs.map(sg => { if (sg.number === 50) return ['ci', 'review'].map(kind => stageTrackerActivityTrackHtml(item, kind, sg, sg.number < from || sg.number > to, nowMs)).join(''); if (sg.number < from || sg.number > to) return ``; const sentinel = !!(sg.detour && sg.detour.sentinel); const sentinelSuffix = !!(sg.detour && sg.detour.sentinelSuffix); - const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); + const fixPushed = sg.number === 30 && sg.state === 'done' && remediation === 'fix_pushed'; + const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', fixPushed ? 'ham-fix-pushed' : '', sg.state === 'active' && sg.number === 30 && remediation ? 'ham-remediation-' + remediation : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); const active = sg.state === 'active'; let tip = ''; let gateCaption = ''; @@ -241,6 +250,8 @@ if (!sg.cap && typeof stageTrackerCueLead === 'function') tip = stageTrackerCueLead(item, worker, nowMs) + tip; if (sg.number === 30 && item.code_activity && Number(item.display_column) === 30) { tip = (codeWorking ? code.caption : sg.detour ? sg.detour.text : 'Code activity unknown') + ' · head ' + (item.head || 'unknown') + ' · ' + (code.source || 'unavailable') + ' · observed ' + (code.observed_at || 'unknown') + ' · since ' + (code.since || 'unknown'); + if (code.detail) tip += ' · ' + code.detail; + if (evidence) tip += ' · ' + evidence; if (code.blocker) tip += ' · ' + code.blocker; if (claimant) tip += ' · ' + stageTrackerClaimantLine(claimant, nowMs); } @@ -280,8 +291,12 @@ const content = `${gateCue}${workIco}${text}${actorIco || holderIco}`; // A decision's dialog is its sole hover/focus detail surface. inner = decision ? `${content}` : `${content}${esc(fullTip)}`; + } else if (fixPushed) { + const pushedTip = [code.caption, code.detail, evidence, item.head ? 'head ' + item.head : '', code.since ? 'since ' + code.since : ''].filter(Boolean).join(' · '); + const tipID = 'ham-chevron-tip-' + [item.repo || '', item.kind || '', item.number || 0, sg.number].map(x => encodeURIComponent(String(x))).join('-'); + inner = `${stageTrackerIcon(sg.number, 'ham-ico')}${esc(code.caption)}${esc(pushedTip)}`; } else inner = stageTrackerIcon(sg.number, 'ham-ico'); - return `
  • ${inner}
  • `; + return `
  • ${inner}
  • `; }).join(''); } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index eb212665ca..8742902402 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1687,6 +1687,12 @@ .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); } + /* Evidence-based remediation on the PR in progress chevron: a red PR + nobody has picked up is bright and still; a pushed fix head is a + done-style step that keeps its word (stage_tracker_remediation.go). */ + .ham-seg.active.ham-remediation-unassigned { background: color-mix(in srgb, var(--amber) 70%, var(--red)); } + .ham-seg.done.ham-fix-pushed { color: var(--green); } + .ham-seg.done.ham-fix-pushed .ham-seg-t::before { content: '✓'; margin-right: var(--sp-1); } .ham-seg.todo { background: transparent; color: var(--text-faint); box-shadow: inset 0 0 0 var(--line-width) var(--line-subtle); opacity: 0.5; } .ham-seg.blank { visibility: hidden; } .ham-sub { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: var(--sp-2); margin-top: var(--sp-3); position: relative; } @@ -17978,13 +17984,22 @@

    Where to get help

    if (code && !codeWorking && Number(item.display_column) === 30) motion = STAGE_TRACKER_MOTION_STATIC; if (motion === STAGE_TRACKER_MOTION_ACTIVE && !worker) motion = STAGE_TRACKER_MOTION_STATIC; if (codeWorking && Number(item.display_column) === 30) motion = STAGE_TRACKER_MOTION_ACTIVE; + // Evidence-based remediation (stage_tracker_remediation.go): the PR in + // progress chevron pulses only while somebody is KNOWN to be on a red + // PR (kick / claim); "unassigned" is bright but still; a fix head + // pushed after the red signal is done-style with its word. + const codeOnHead = code && String(code.head || '') === String(item.head || ''); + const remediation = codeOnHead && ['unassigned', 'remediating', 'fix_pushed'].includes(code.state) ? code.state : ''; + if (remediation === 'remediating' && Number(item.display_column) === 30) motion = STAGE_TRACKER_MOTION_ACTIVE; + const evidence = item.remediation && item.remediation.kind ? 'evidence: ' + item.remediation.kind + (item.remediation.actor ? ' by ' + item.remediation.actor : '') + (item.remediation.since ? ' since ' + item.remediation.since : '') + (item.remediation.source ? ' (' + item.remediation.source + ')' : '') : ''; const motionAttr = motion === STAGE_TRACKER_MOTION_STATIC ? '' : ` data-motion="${motion}"`; return segs.map(sg => { if (sg.number === 50) return ['ci', 'review'].map(kind => stageTrackerActivityTrackHtml(item, kind, sg, sg.number < from || sg.number > to, nowMs)).join(''); if (sg.number < from || sg.number > to) return ``; const sentinel = !!(sg.detour && sg.detour.sentinel); const sentinelSuffix = !!(sg.detour && sg.detour.sentinelSuffix); - const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); + const fixPushed = sg.number === 30 && sg.state === 'done' && remediation === 'fix_pushed'; + const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', fixPushed ? 'ham-fix-pushed' : '', sg.state === 'active' && sg.number === 30 && remediation ? 'ham-remediation-' + remediation : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.isNew ? 'ham-open-new' : '', sg.advisory ? 'ham-open-advisory' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel || sentinelSuffix ? 'ham-sentinel' : ''].filter(Boolean).join(' '); const active = sg.state === 'active'; let tip = ''; let gateCaption = ''; @@ -18024,6 +18039,8 @@

    Where to get help

    if (!sg.cap && typeof stageTrackerCueLead === 'function') tip = stageTrackerCueLead(item, worker, nowMs) + tip; if (sg.number === 30 && item.code_activity && Number(item.display_column) === 30) { tip = (codeWorking ? code.caption : sg.detour ? sg.detour.text : 'Code activity unknown') + ' · head ' + (item.head || 'unknown') + ' · ' + (code.source || 'unavailable') + ' · observed ' + (code.observed_at || 'unknown') + ' · since ' + (code.since || 'unknown'); + if (code.detail) tip += ' · ' + code.detail; + if (evidence) tip += ' · ' + evidence; if (code.blocker) tip += ' · ' + code.blocker; if (claimant) tip += ' · ' + stageTrackerClaimantLine(claimant, nowMs); } @@ -18063,8 +18080,12 @@

    Where to get help

    const content = `${gateCue}${workIco}${text}${actorIco || holderIco}`; // A decision's dialog is its sole hover/focus detail surface. inner = decision ? `${content}` : `${content}${esc(fullTip)}`; + } else if (fixPushed) { + const pushedTip = [code.caption, code.detail, evidence, item.head ? 'head ' + item.head : '', code.since ? 'since ' + code.since : ''].filter(Boolean).join(' · '); + const tipID = 'ham-chevron-tip-' + [item.repo || '', item.kind || '', item.number || 0, sg.number].map(x => encodeURIComponent(String(x))).join('-'); + inner = `${stageTrackerIcon(sg.number, 'ham-ico')}${esc(code.caption)}${esc(pushedTip)}`; } else inner = stageTrackerIcon(sg.number, 'ham-ico'); - return `
  • ${inner}
  • `; + return `
  • ${inner}
  • `; }).join(''); }