diff --git a/changelog.d/added-16237-sentinel-paths-in-decision.md b/changelog.d/added-16237-sentinel-paths-in-decision.md new file mode 100644 index 0000000000..dbe7918947 --- /dev/null +++ b/changelog.d/added-16237-sentinel-paths-in-decision.md @@ -0,0 +1 @@ +- The *Let hive decide* dialog, the tracker payload (`sentinel_details`), `/api/sentinel` (`findings`) and the hive's "reviewed, intended" decision comment now name the files and the sentinel rule that fired — bounded to 10 paths per finding with a "+N more" count — instead of only "changes N sensitive path(s)" ([#16237](https://github.com/hivecommons/hive/issues/16237)). diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index 2e54eb5489..ed0faa99a2 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -233,6 +233,8 @@ A pull request the suspicious-activity sentinel flagged — it wears the `sentin The tooltip reads "Sentinel flagged security-relevant changes at ``: ``" (a generic description stands in when the bundle has no reason). An issue carried by one flagged PR shows the lane text too, and a nested PR sub-row shows its own. The *Decide…* dialogs for a flagged PR open with a ⚠ line per flagged PR naming the sentinel reason, and *Approve* is styled as a dangerous action. +The payload also carries `sentinel_details`: one entry per finding with its `rule` (`sensitive_path`, `permission_escalation`, `ci_gate_weakening`, …), `summary`, the flagged `paths` (sorted, at most 10 per finding) and `more_paths` for any cut. The *Let hive decide* dialog's ▼ Details and the ⚠ chip tooltip list them under the sentinel line — `· sensitive_path: .github/workflows/release.yml (+N more)` — so the person can see *which* files tripped the sentinel, not just how many; `/api/sentinel` serves the same `findings` per row, and the hive's "reviewed, intended" decision comment on a trusted author's flagged PR names the same files after the reason. The findings come from the head's review evidence bundle or the sweep's own record; nothing is re-fetched from GitHub. + A person's *Approve* through that dialog **is** the human review the alert asked for: it removes the `sentinel-alert` label when present and records a `sentinel_acknowledged` human action keyed to the head in the review evidence bundle, so a bundle-only alert (findings but no label — hivecommons/crux#30) clears too; the payload then reads `sentinel_alert: false` with `sentinel_reason` suffixed `— acknowledged by @login`, the findings stay on record, and a new head starts over. The delegated *Let hive decide* path never clears it. Hovering the lit chevron of a parked row names the parking stage itself (`Needs human decision`), not the 080 column it rides on; `Next move` follows the real stage (human at 085, hive at 080). Lane text and chip update in place on refresh (keyed reconcile, no flash). diff --git a/src/pkg/dashboard/api_repo_item_decide_delegated.go b/src/pkg/dashboard/api_repo_item_decide_delegated.go index 228cdc1648..6bbbb62e8a 100644 --- a/src/pkg/dashboard/api_repo_item_decide_delegated.go +++ b/src/pkg/dashboard/api_repo_item_decide_delegated.go @@ -661,6 +661,7 @@ func (s *Server) gatherDelegatedInput(ctx context.Context, repoFull string, numb } in.CIGreen, in.CIPending = ci.green, ci.pending s.gatherDelegatedRecordedPark(repoFull, number, pr.GetHead().GetSHA(), &in) + in.SentinelReason = s.delegatedSentinelReason(repoFull, number, pr.GetHead().GetSHA(), req.SentinelReason) if files, _, err := api.PullRequests.ListFiles(ctx, owner, repoName, number, &gh.ListOptions{PerPage: delegatedDecisionGatherLimit}); err == nil && len(files) > 0 { in.LowRiskPaths = true for _, f := range files { @@ -687,7 +688,9 @@ func (s *Server) gatherDelegatedInput(ctx context.Context, repoFull string, numb in.SentinelAlert = true } } - in.SentinelReason = strings.TrimSpace(req.SentinelReason) + if in.SentinelReason == "" { + in.SentinelReason = strings.TrimSpace(req.SentinelReason) + } lowerReason := strings.ToLower(reason) if in.Kind == delegatedecision.KindPR && in.HiveAuthored && s.hiveSupersedingAutoMerge() { in.HiveSuperseding = ghpkg.HiveSupersedingPR(true, in.Body) @@ -730,6 +733,24 @@ func (s *Server) delegatedAdoptionGraceElapsed(repoFull string, number int) bool return rec.AdoptionBlocked(rec.NudgeHead) != "" } +// delegatedSentinelReason is the sentinel reason the decider and its comment +// carry: the tracker row's own words ("changes 1 sensitive path(s)") followed +// by the paths the hive recorded for head, so the "reviewed, intended" +// rationale names the files, as the operator asked. The row's words stand +// alone when the hive holds no findings for that head. +func (s *Server) delegatedSentinelReason(repoFull string, number int, head, rowReason string) string { + reason := strings.TrimSpace(rowReason) + text := sentinelDetailsText(s.sentinelDetailsForHead(repoFull, number, head)) + switch { + case text == "": + return reason + case reason == "": + return text + default: + return reason + " — " + text + } +} + // delegatedHeadCIState is what the head's checks say: green (every // gating check passed), pending (some still running, none failed), or // neither (a check failed, or none ever reported). diff --git a/src/pkg/dashboard/api_writeback.go b/src/pkg/dashboard/api_writeback.go index 2936588d0e..8c04b77b56 100644 --- a/src/pkg/dashboard/api_writeback.go +++ b/src/pkg/dashboard/api_writeback.go @@ -88,17 +88,20 @@ func (s *Server) handleWritebackSuppressed(w http.ResponseWriter, r *http.Reques // SentinelFinding is one sentinel evaluation the dashboard keeps for the // Security tab and /api/sentinel, whether or not it reached GitHub. type SentinelFinding struct { - At time.Time `json:"at"` - Repo string `json:"repo"` - Number int `json:"number"` - Author string `json:"author"` - Title string `json:"title,omitempty"` - HeadSHA string `json:"head_sha,omitempty"` - Rules []string `json:"rules"` - Blocked bool `json:"blocked"` - TrustedReason string `json:"trusted_reason,omitempty"` - Suppressed bool `json:"suppressed"` - SuppressedReason string `json:"suppressed_reason,omitempty"` + At time.Time `json:"at"` + Repo string `json:"repo"` + Number int `json:"number"` + Author string `json:"author"` + Title string `json:"title,omitempty"` + HeadSHA string `json:"head_sha,omitempty"` + Rules []string `json:"rules"` + // Findings names each rule's flagged paths (bounded per finding), so + // the Security tab and the decision dialog can say which files. + Findings []SentinelDetail `json:"findings,omitempty"` + Blocked bool `json:"blocked"` + TrustedReason string `json:"trusted_reason,omitempty"` + Suppressed bool `json:"suppressed"` + SuppressedReason string `json:"suppressed_reason,omitempty"` } const maxSentinelFindings = 1000 @@ -113,7 +116,7 @@ func (f *sentinelFindings) record(ev github.SentinelSweepEvent, now time.Time) { f.mu.Lock() defer f.mu.Unlock() item := SentinelFinding{At: now.UTC(), Repo: ev.Repo, Number: ev.Number, Author: ev.Author, Title: ev.Title, HeadSHA: ev.HeadSHA, - Rules: ev.Rules(), Blocked: ev.Blocked, TrustedReason: ev.TrustedReason, Suppressed: ev.Suppressed, SuppressedReason: ev.SuppressedReason} + Rules: ev.Rules(), Findings: sentinelDetailsFromSweep(ev), Blocked: ev.Blocked, TrustedReason: ev.TrustedReason, Suppressed: ev.Suppressed, SuppressedReason: ev.SuppressedReason} // One row per repo#number@head: a re-evaluation of the same head // replaces the earlier row rather than stacking. for i := range f.items { @@ -137,6 +140,19 @@ func (f *sentinelFindings) list() []SentinelFinding { return out } +// detailsFor returns the findings recorded for repo#number at head, or nil. +func (f *sentinelFindings) detailsFor(repo string, number int, head string) []SentinelDetail { + f.mu.Lock() + defer f.mu.Unlock() + for i := range f.items { + it := &f.items[i] + if it.Number == number && strings.EqualFold(it.Repo, repo) && strings.EqualFold(it.HeadSHA, head) { + return append([]SentinelDetail(nil), it.Findings...) + } + } + return nil +} + // RecordSentinelFinding is the sentinel sweep's Audit hook target: every // finding, written or suppressed, lands here for the Security tab. func (s *Server) RecordSentinelFinding(ev github.SentinelSweepEvent) { diff --git a/src/pkg/dashboard/sentinel_details.go b/src/pkg/dashboard/sentinel_details.go new file mode 100644 index 0000000000..8541d833dc --- /dev/null +++ b/src/pkg/dashboard/sentinel_details.go @@ -0,0 +1,141 @@ +package dashboard + +import ( + "fmt" + "sort" + "strings" + + "github.com/hivecommons/hive/pkg/evidence" + "github.com/hivecommons/hive/pkg/github" +) + +// SentinelDetail is one sentinel finding as the decision dialog and the +// hive's comment name it: the rule that fired, its one-line summary and the +// files it fired on. "Changes 1 sensitive path(s)" alone left the operator +// unable to decide ("knowing what the sensitive path(s) (and files) are in +// this alert dialog would really help me make a decision"), so the rows +// carry the paths themselves, bounded to SentinelDetailMaxPaths per finding +// with MorePaths counting the rest. +type SentinelDetail struct { + Rule string `json:"rule"` + Summary string `json:"summary,omitempty"` + Paths []string `json:"paths,omitempty"` + // MorePaths is how many flagged paths were cut after the first + // SentinelDetailMaxPaths; 0 when every path is listed. + MorePaths int `json:"more_paths,omitempty"` +} + +// SentinelDetailMaxPaths bounds the paths one finding lists in a tracker +// row, the dialog and the hive's comment. +const SentinelDetailMaxPaths = 10 + +// sentinelDetailOf builds the bounded detail for one finding; paths are +// sorted so the list is stable across snapshots. +func sentinelDetailOf(rule, summary string, paths []string) SentinelDetail { + d := SentinelDetail{Rule: strings.TrimSpace(rule), Summary: strings.TrimSpace(summary)} + sorted := make([]string, 0, len(paths)) + for _, p := range paths { + if p = strings.TrimSpace(p); p != "" { + sorted = append(sorted, p) + } + } + sort.Strings(sorted) + if len(sorted) > SentinelDetailMaxPaths { + d.MorePaths = len(sorted) - SentinelDetailMaxPaths + sorted = sorted[:SentinelDetailMaxPaths] + } + if len(sorted) > 0 { + d.Paths = sorted + } + return d +} + +// sentinelDetailsFromEvidence converts a review evidence bundle's sentinel +// findings for the tracker payload. +func sentinelDetailsFromEvidence(findings []evidence.SentinelFinding) []SentinelDetail { + if len(findings) == 0 { + return nil + } + out := make([]SentinelDetail, 0, len(findings)) + for _, f := range findings { + out = append(out, sentinelDetailOf(f.Rule, f.Summary, f.Paths)) + } + return out +} + +// sentinelDetailsFromSweep converts the sweep event's own findings for the +// /api/sentinel ring (field access only: the dashboard does not import the +// sentinel package — see TestDashboardInternalImportCountRatchet). +func sentinelDetailsFromSweep(ev github.SentinelSweepEvent) []SentinelDetail { + if len(ev.Findings) == 0 { + return nil + } + out := make([]SentinelDetail, 0, len(ev.Findings)) + for _, f := range ev.Findings { + out = append(out, sentinelDetailOf(f.Rule, f.Summary, f.Paths)) + } + return out +} + +// sentinelDetailsText renders the details on one line for a comment or a +// tooltip: "sensitive_path: .github/workflows/ci.yml, OWNERS (+3 more); +// ci_gate_weakening: .github/workflows/ci.yml". Findings without paths name +// the rule and its summary. Empty when there is nothing to say. +func sentinelDetailsText(details []SentinelDetail) string { + parts := make([]string, 0, len(details)) + for _, d := range details { + label := d.Rule + if label == "" { + label = d.Summary + } + if label == "" { + continue + } + if len(d.Paths) == 0 { + if d.Rule != "" && d.Summary != "" { + label += " (" + d.Summary + ")" + } + parts = append(parts, label) + continue + } + line := label + ": " + strings.Join(d.Paths, ", ") + if d.MorePaths > 0 { + line += fmt.Sprintf(" (+%d more)", d.MorePaths) + } + parts = append(parts, line) + } + return strings.Join(parts, "; ") +} + +// sentinelDetailsFor returns the sentinel findings the hive holds for +// repo#number at head without touching GitHub: the /api/sentinel ring the +// sweep's audit hook fills. Nil when the sweep never saw that head. +func (s *Server) sentinelDetailsFor(repo string, number int, head string) []SentinelDetail { + if s == nil || number <= 0 || strings.TrimSpace(head) == "" { + return nil + } + return s.sentinelFindings.detailsFor(repo, number, head) +} + +// sentinelDetailsForHead is sentinelDetailsFor with the on-disk review +// evidence bundle as the second source, for a request path that has not +// loaded the bundle itself (the delegated decision). The ring is in-memory +// and empties on restart; the bundle survives it. +func (s *Server) sentinelDetailsForHead(repo string, number int, head string) []SentinelDetail { + head = strings.TrimSpace(head) + if details := s.sentinelDetailsFor(repo, number, head); len(details) > 0 { + return details + } + if s == nil || number <= 0 || head == "" { + return nil + } + verifier, err := s.reviewEvidenceVerifier() + if err != nil { + return nil + } + b, err := github.LoadVerifiedReviewEvidence(github.ReviewEvidencePath("", repo, number, head), verifier) + if err != nil || b == nil { + return nil + } + return sentinelDetailsFromEvidence(b.Sentinel) +} diff --git a/src/pkg/dashboard/sentinel_details_test.go b/src/pkg/dashboard/sentinel_details_test.go new file mode 100644 index 0000000000..7877bcbc92 --- /dev/null +++ b/src/pkg/dashboard/sentinel_details_test.go @@ -0,0 +1,129 @@ +package dashboard + +import ( + "encoding/json" + "fmt" + "path/filepath" + "reflect" + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/evidence" + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/sentinel" +) + +// TestSentinelDetailBoundsAndText: a finding's paths are sorted, bounded +// to SentinelDetailMaxPaths with the rest counted, and rendered on one line +// per rule for the hive's comment. +func TestSentinelDetailBoundsAndText(t *testing.T) { + var many []string + for i := 0; i < SentinelDetailMaxPaths+3; i++ { + many = append(many, fmt.Sprintf("p/%02d.yml", SentinelDetailMaxPaths+3-i)) + } + d := sentinelDetailOf(sentinel.RuleSensitivePath, fmt.Sprintf("changes %d sensitive path(s)", len(many)), many) + if len(d.Paths) != SentinelDetailMaxPaths || d.MorePaths != 3 { + t.Fatalf("bound: %d paths, %d more", len(d.Paths), d.MorePaths) + } + if d.Paths[0] != "p/01.yml" || d.Paths[SentinelDetailMaxPaths-1] != fmt.Sprintf("p/%02d.yml", SentinelDetailMaxPaths) { + t.Fatalf("paths not sorted/bounded: %v", d.Paths) + } + if got := sentinelDetailsText([]SentinelDetail{d}); !strings.HasPrefix(got, "sensitive_path: p/01.yml, p/02.yml") || !strings.HasSuffix(got, " (+3 more)") { + t.Fatalf("text = %q", got) + } + + two := sentinelDetailsFromSweep(github.SentinelSweepEvent{Findings: []sentinel.Finding{ + {Rule: sentinel.RuleSensitivePath, Summary: "changes 2 sensitive path(s)", Paths: []string{"OWNERS", ".github/workflows/ci.yml"}}, + {Rule: sentinel.RulePermissionEscalation, Summary: "widens workflow permissions"}, + }}) + want := "sensitive_path: .github/workflows/ci.yml, OWNERS; permission_escalation (widens workflow permissions)" + if got := sentinelDetailsText(two); got != want { + t.Fatalf("text = %q, want %q", got, want) + } + if sentinelDetailsText(nil) != "" || sentinelDetailsFromSweep(github.SentinelSweepEvent{}) != nil || sentinelDetailsFromEvidence(nil) != nil { + t.Fatal("empty input must render nothing") + } +} + +// TestSentinelRingCarriesPathsForDecision: the sweep's audit hook stores +// each finding's paths; /api/sentinel serves them and the decision path +// reads them back by repo#number@head without touching GitHub. +func TestSentinelRingCarriesPathsForDecision(t *testing.T) { + s := covApiServer(t) + ev := github.SentinelSweepEvent{Repo: "acme/console", Number: 16230, Author: "m", HeadSHA: "4396f46abc", Blocked: true, Findings: []sentinel.Finding{ + {Rule: sentinel.RuleSensitivePath, Summary: "changes 1 sensitive path(s)", Paths: []string{".github/workflows/release.yml"}}, + }} + s.RecordSentinelFinding(ev) + + rec := doGet(s, "/api/sentinel?repo=acme/console") + var payload struct { + Findings []SentinelFinding `json:"findings"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil || len(payload.Findings) != 1 { + t.Fatalf("sentinel = %d %s (%v)", rec.Code, rec.Body.String(), err) + } + if got := payload.Findings[0].Findings; len(got) != 1 || got[0].Rule != sentinel.RuleSensitivePath || !reflect.DeepEqual(got[0].Paths, []string{".github/workflows/release.yml"}) { + t.Fatalf("api findings = %+v", got) + } + + if got := s.sentinelDetailsFor("ACME/console", 16230, "4396F46ABC"); len(got) != 1 || got[0].Paths[0] != ".github/workflows/release.yml" { + t.Fatalf("detailsFor = %+v", got) + } + if got := s.sentinelDetailsFor("acme/console", 16230, "other"); got != nil { + t.Fatalf("other head = %+v", got) + } + // The delegated decision's comment names the files after the row's words. + want := "changes 1 sensitive path(s) — sensitive_path: .github/workflows/release.yml" + if got := s.delegatedSentinelReason("acme/console", 16230, "4396f46abc", "changes 1 sensitive path(s)"); got != want { + t.Fatalf("reason = %q, want %q", got, want) + } + if got := s.delegatedSentinelReason("acme/console", 16230, "4396f46abc", ""); got != "sensitive_path: .github/workflows/release.yml" { + t.Fatalf("reason without row words = %q", got) + } + if got := s.delegatedSentinelReason("acme/console", 1, "nohead", "changes 1 sensitive path(s)"); got != "changes 1 sensitive path(s)" { + t.Fatalf("unknown head keeps the row's words: %q", got) + } +} + +// TestStageTrackerSentinelDetailsFromBundleOrRing: the tracker row's +// sentinel_details come from the verified evidence bundle for the head, +// or from the sweep's ring when no bundle was written, so the decision +// dialog can name the files either way. +func TestStageTrackerSentinelDetailsFromBundleOrRing(t *testing.T) { + prev := github.ReviewEvidenceRoot + root := filepath.Join(t.TempDir(), "evidence") + github.ReviewEvidenceRoot = root + t.Cleanup(func() { github.ReviewEvidenceRoot = prev }) + s := newTestServer() + verifier := &github.ReviewEvidenceVerifier{} + const head = "4396f46aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + writeSentinelBundle(t, root, "acme/console", 501, head, []evidence.SentinelFinding{ + {Rule: "sensitive_path", Summary: "changes 2 sensitive path(s)", Paths: []string{"OWNERS", ".github/workflows/ci.yml"}}, + }) + _, _, _, details := s.stageTrackerSentinel(verifier, "acme/console", 501, head, []string{config.DefaultSentinelLabel}) + if len(details) != 1 || !reflect.DeepEqual(details[0].Paths, []string{".github/workflows/ci.yml", "OWNERS"}) || details[0].Rule != "sensitive_path" { + t.Fatalf("bundle details = %+v", details) + } + if got := s.sentinelDetailsForHead("acme/console", 501, head); !reflect.DeepEqual(got, details) { + t.Fatalf("detailsForHead via bundle = %+v, want %+v", got, details) + } + + s.RecordSentinelFinding(github.SentinelSweepEvent{Repo: "acme/console", Number: 502, HeadSHA: head, Blocked: true, Findings: []sentinel.Finding{ + {Rule: sentinel.RuleCIGateWeakening, Summary: "softens CI gates", Paths: []string{".github/workflows/ci.yml"}}, + }}) + _, n, reason, details := s.stageTrackerSentinel(verifier, "acme/console", 502, head, []string{config.DefaultSentinelLabel}) + if n != 0 || reason != "" || len(details) != 1 || details[0].Rule != sentinel.RuleCIGateWeakening { + t.Fatalf("ring fallback = %d %q %+v", n, reason, details) + } + if _, _, _, details := s.stageTrackerSentinel(verifier, "acme/console", 503, head, nil); details != nil { + t.Fatalf("unknown PR = %+v", details) + } + + var it StageTrackerItem + it.SentinelDetails = details + raw, _ := json.Marshal(it) + if !strings.Contains(string(raw), `"sentinel_details":[{"rule":"ci_gate_weakening","summary":"softens CI gates","paths":[".github/workflows/ci.yml"]}]`) { + t.Fatalf("payload = %s", raw) + } +} diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index e46dbc5e92..29dae0631d 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -431,6 +431,10 @@ type StageTrackerItem struct { SentinelAlert bool `json:"sentinel_alert,omitempty"` SentinelFindings int `json:"sentinel_findings,omitempty"` SentinelReason string `json:"sentinel_reason,omitempty"` + // SentinelDetails names each finding's rule and flagged paths (bounded + // per finding) so the decision dialog can say which files, not just how + // many. + SentinelDetails []SentinelDetail `json:"sentinel_details,omitempty"` // SentinelNotice marks verified informational findings without the live // blocking label. The notice remains visible but is not a decision gate. SentinelNotice bool `json:"sentinel_notice,omitempty"` @@ -696,9 +700,10 @@ type StageTrackerLinkedPR struct { DeferredModifiers []string `json:"deferred_modifiers,omitempty"` // SentinelAlert / SentinelReason mirror the nested PR's own row fields // so a sub-row under an issue names the alert too. - SentinelAlert bool `json:"sentinel_alert,omitempty"` - SentinelReason string `json:"sentinel_reason,omitempty"` - SentinelNotice bool `json:"sentinel_notice,omitempty"` + SentinelAlert bool `json:"sentinel_alert,omitempty"` + SentinelReason string `json:"sentinel_reason,omitempty"` + SentinelDetails []SentinelDetail `json:"sentinel_details,omitempty"` + SentinelNotice bool `json:"sentinel_notice,omitempty"` // HumanApprover / ManualMerge / HumanMergeReason(Text) mirror the // nested PR's 090 fields so a sub-row's gate cell says why a person // merges it, as the top-level row would (hivecommons/hive#14658). @@ -1106,7 +1111,7 @@ const stageTrackerSentinelMoreFormat = " (+%d more)" // notice-only alert asked for, so it clears the bundle-promoted alert (the // label, while still on, still stands); the reason then names who // acknowledged it. -func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, repo string, number int, head string, labels []string) (alert bool, findings int, reason string) { +func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, repo string, number int, head string, labels []string) (alert bool, findings int, reason string, details []SentinelDetail) { label := s.sentinelLabel() for _, l := range labels { if strings.EqualFold(strings.TrimSpace(l), label) { @@ -1115,12 +1120,14 @@ func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, r } } if head == "" || verifier == nil { - return alert, 0, "" + return alert, 0, "", s.sentinelDetailsFor(repo, number, head) } b, err := github.LoadVerifiedReviewEvidence(github.ReviewEvidencePath("", repo, number, head), *verifier) if err != nil || b == nil || len(b.Sentinel) == 0 { - return alert, 0, "" + // No bundle: the sweep's own ring still knows the paths. + return alert, 0, "", s.sentinelDetailsFor(repo, number, head) } + details = sentinelDetailsFromEvidence(b.Sentinel) findings = len(b.Sentinel) reason = strings.TrimSpace(b.Sentinel[0].Summary) if reason == "" { @@ -1132,7 +1139,7 @@ func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, r if by := b.SentinelAcknowledgedBy(); by != "" { // The label, while still on, is the sweep's live block; only the // bundle-promoted alert is answered by the acknowledgment. - return alert, findings, reason + stageTrackerSentinelAckSuffix + by + return alert, findings, reason + stageTrackerSentinelAckSuffix + by, details } for _, f := range b.Sentinel { if f.Notice { @@ -1140,7 +1147,7 @@ func (s *Server) stageTrackerSentinel(verifier *github.ReviewEvidenceVerifier, r break } } - return alert, findings, reason + return alert, findings, reason, details } // stageTrackerSentinelAckSuffix precedes the login of the person whose diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index 7a5ec54109..c4d4bb98ef 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -402,7 +402,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto // After the New caption: an unclassified clanker PR whose clanker // is offline says what that means for it. it.Caption = stageTrackerOfflineAuthorCaption(it.Caption, it.Presence, it.Stage, adoptionClock, now) - it.SentinelAlert, it.SentinelFindings, it.SentinelReason = s.stageTrackerSentinel(evidenceVerifier, repoName, pr.Number, pr.HeadSHA, pr.Labels) + it.SentinelAlert, it.SentinelFindings, it.SentinelReason, it.SentinelDetails = s.stageTrackerSentinel(evidenceVerifier, repoName, pr.Number, pr.HeadSHA, pr.Labels) it.SentinelNotice = it.SentinelAlert && !slices.ContainsFunc(pr.Labels, func(label string) bool { return strings.EqualFold(strings.TrimSpace(label), sentinelLabel) }) diff --git a/src/pkg/dashboard/stage_tracker_links.go b/src/pkg/dashboard/stage_tracker_links.go index 33f92c10fb..5b66a5b902 100644 --- a/src/pkg/dashboard/stage_tracker_links.go +++ b/src/pkg/dashboard/stage_tracker_links.go @@ -322,7 +322,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.SentinelNotice = pr.SentinelNotice + lp.SentinelNotice, lp.SentinelDetails = pr.SentinelNotice, pr.SentinelDetails lp.Claimant = pr.Claimant lp.Adoption = pr.Adoption lp.Presence = pr.Presence diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 40e0d66b7d..6c8c70cb69 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -848,6 +848,8 @@ func stageTrackerConfirmOptOutJS(t *testing.T, html string) string { jsConstLine(t, html, "STAGE_TRACKER_SENTINEL_TIP"), jsConstLine(t, html, "STAGE_TRACKER_SENTINEL_TIP_FALLBACK"), jsFunc(t, html, "stageTrackerSentinelTip"), + jsFunc(t, html, "stageTrackerSentinelPathLines"), + jsFunc(t, html, "stageTrackerSentinelTipWithPaths"), jsFunc(t, html, "stageTrackerSentinelPreface"), jsFunc(t, html, "stageTrackerConfirmSkipped"), jsFunc(t, html, "stageTrackerSetConfirmSkip"), @@ -1735,6 +1737,24 @@ assert.deepStrictEqual(buttons(html), ['Cancel', 'Let hive do that'], 'exactly t assert.ok(html.includes('btn-danger hive-dialog-btn primary" data-initial-focus'), 'the sentinel case keeps the danger primary'); assert.ok(html.indexOf('hive-dialog-btn cancel') < html.indexOf('hive-dialog-btn primary'), 'Cancel first, primary last'); +// 1b. The sentinel line names the files and the rule that fired, from the +// row's sentinel_details, bounded by the server (hivecommons/hive: "knowing +// what the sensitive path(s) (and files) are in this alert dialog would +// really help me make a decision"); the Details paragraph keeps the +// line breaks (white-space: pre-line) and the chip's tooltip carries it. +const flagged = { repo: 'hivecommons/hive', number: 16230, kind: 'pr', head: '4396f46abcdef', sentinel_alert: true, sentinel_reason: 'changes 1 sensitive path(s)', + sentinel_details: [{ rule: 'sensitive_path', summary: 'changes 1 sensitive path(s)', paths: ['.github/workflows/release.yml'] }, { rule: 'permission_escalation', summary: 'widens workflow permissions' }] }; +assert.deepStrictEqual(stageTrackerSentinelPathLines(flagged), ['sensitive_path: .github/workflows/release.yml', 'permission_escalation (widens workflow permissions)']); +assert.deepStrictEqual(stageTrackerSentinelPathLines(Object.assign({}, flagged, { sentinel_details: [{ rule: 'sensitive_path', paths: ['a', 'b'], more_paths: 4 }] })), ['sensitive_path: a, b (+4 more)']); +assert.deepStrictEqual(stageTrackerSentinelPathLines({ sentinel_alert: true }), []); +let preface = stageTrackerSentinelPreface([flagged]); +assert.strictEqual(preface, '⚠ hivecommons/hive#16230 — Sentinel flagged security-relevant changes at 4396f46: changes 1 sensitive path(s)\n · sensitive_path: .github/workflows/release.yml\n · permission_escalation (widens workflow permissions)', preface); +assert.strictEqual(stageTrackerSentinelPreface([Object.assign({}, flagged, { sentinel_details: [] })]), '⚠ hivecommons/hive#16230 — Sentinel flagged security-relevant changes at 4396f46: changes 1 sensitive path(s)', 'no details: the line is unchanged'); +html = stageTrackerDelegatePlanHtml(stageTrackerDelegatePlanView([Object.assign({}, pr15332, { ref: 'hivecommons/hive#16230', number: 16230 })], preface)); +assert.ok(detailsOf(html).includes('

' + hiveDialogEscape(preface) + '

'), 'the Details finding names the files: ' + detailsOf(html)); +assert.ok(html.includes('⚠ Sentinel'), 'the chip tooltip names the files too'); +assert.ok(!visibleOf(html).includes('.github/workflows/release.yml'), 'the paths stay behind Details'); + // 2. A stale "Hive would:" prefix in the payload is still rendered once. view = stageTrackerDelegatePlanView([Object.assign({}, pr15332, { summary: 'Hive would: Hive would: send #15332 back' })], ''); assert.strictEqual(view.decisions[0].sentence, 'Send #15332 back.'); diff --git a/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go b/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go index 015840c26c..10bc03a06f 100644 --- a/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go +++ b/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go @@ -250,7 +250,7 @@ func TestStageTrackerSentinelLabelClearsBlockingBundle(t *testing.T) { if tt.findings != nil { writeSentinelBundle(t, root, "acme/console", tt.number, head, tt.findings, tt.actions...) } - alert, findings, reason := s.stageTrackerSentinel(verifier, "acme/console", tt.number, head, tt.labels) + alert, findings, reason, _ := s.stageTrackerSentinel(verifier, "acme/console", tt.number, head, tt.labels) if alert != tt.wantAlert || findings != tt.wantFindings || reason != tt.wantReason { t.Fatalf("stageTrackerSentinel = alert %v findings %d reason %q, want %v %d %q", alert, findings, reason, tt.wantAlert, tt.wantFindings, tt.wantReason) } @@ -263,13 +263,13 @@ func TestStageTrackerSentinelLabelClearsBlockingBundle(t *testing.T) { func TestStageTrackerSentinelConfiguredLabel(t *testing.T) { s := newTestServer() s.deps = &Dependencies{Config: &config.Config{Sentinel: config.SentinelConfig{Label: "security-hold"}}} - if alert, _, _ := s.stageTrackerSentinel(nil, "acme/console", 1, "", []string{"Security-Hold"}); !alert { + if alert, _, _, _ := s.stageTrackerSentinel(nil, "acme/console", 1, "", []string{"Security-Hold"}); !alert { t.Fatal("configured label (case-insensitive) must flag") } - if alert, _, _ := s.stageTrackerSentinel(nil, "acme/console", 1, "", []string{config.DefaultSentinelLabel}); alert { + if alert, _, _, _ := s.stageTrackerSentinel(nil, "acme/console", 1, "", []string{config.DefaultSentinelLabel}); alert { t.Fatal("the default label is not the configured one") } - if alert, n, reason := s.stageTrackerSentinel(nil, "acme/console", 1, "", nil); alert || n != 0 || reason != "" { + if alert, n, reason, _ := s.stageTrackerSentinel(nil, "acme/console", 1, "", nil); alert || n != 0 || reason != "" { t.Fatal("no label, no head → clean") } } @@ -295,7 +295,9 @@ func TestStageTrackerSentinelLaneWiring(t *testing.T) { `confirmLabel: 'Post /lgtm + /approve', danger: !!sentinel`, `label: preface + 'What should the hive change on '`, `if (item.sentinel_alert && deferred.indexOf(STAGE_TRACKER_SENTINEL_CHIP) < 0) lines.push(stageTrackerSentinelTip(item));`, - `sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', sentinel_notice: !!lp.sentinel_notice, head: lp.head || ''`, + `sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', sentinel_details: lp.sentinel_details || [], sentinel_notice: !!lp.sentinel_notice, head: lp.head || ''`, + `function stageTrackerSentinelPathLines(item)`, + `function stageTrackerSentinelTipWithPaths(item)`, } { if !strings.Contains(html, want) { t.Errorf("index.html missing sentinel lane wiring %q", want) @@ -330,6 +332,8 @@ func TestStageTrackerSentinelLaneText(t *testing.T) { } html := indexHTML(t) script := stageTrackerRepoGroupingHarness(t, html) + strings.Join([]string{ + jsFunc(t, html, "stageTrackerSentinelPathLines"), + jsFunc(t, html, "stageTrackerSentinelTipWithPaths"), jsFunc(t, html, "stageTrackerSentinelPreface"), jsConstLine(t, html, "STAGE_TRACKER_MOTION_MAX_ROWS"), jsConstLine(t, html, "STAGE_TRACKER_EXIT_MS"), diff --git a/src/pkg/dashboard/stage_tracker_sentinel_notice_test.go b/src/pkg/dashboard/stage_tracker_sentinel_notice_test.go index 91e7ee2aa7..5737795610 100644 --- a/src/pkg/dashboard/stage_tracker_sentinel_notice_test.go +++ b/src/pkg/dashboard/stage_tracker_sentinel_notice_test.go @@ -39,6 +39,8 @@ func TestStageTrackerSentinelNoticePreservesActualReviewerDecision(t *testing.T) } html := indexHTML(t) runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+stageTrackerRowsFixtureJS+ + jsFunc(t, html, "stageTrackerSentinelPathLines")+ + jsFunc(t, html, "stageTrackerSentinelTipWithPaths")+ jsFunc(t, html, "stageTrackerSentinelPreface")+ "\nconst notice = "+string(payload)+";\n"+` assert.strictEqual(stageTrackerSentinelInLane(notice), false); diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 7784736e8f..14449263ea 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -447,7 +447,7 @@ .ham-plan-details > summary:hover { color: var(--text); } .ham-plan-details > :not(summary) { margin: var(--sp-3) 0 0; } .ham-plan-details .ham-plan-label { margin-top: var(--sp-4); } - .ham-plan-finding { color: var(--status-error); } + .ham-plan-finding { color: var(--status-error); white-space: pre-line; } .ham-plan-ruled-out { padding-left: 1.4em; } .ham-plan-rails { font-size: var(--fs-xs); color: var(--text-faint); } /* The preview opens as a skeleton while the plan is gathered diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index 8bb58ca51e..31410bbf68 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -1470,7 +1470,7 @@ // flagged PR, so the operator reads the security reason before // choosing Approve; '' when nothing in items is flagged. function stageTrackerSentinelPreface(items) { - return (items || []).filter(it => it && it.sentinel_alert && !it.sentinel_notice).map(it => '⚠ ' + stageTrackerRefOf(it) + ' — ' + stageTrackerSentinelTip(it)).join('\n'); + return (items || []).filter(it => it && it.sentinel_alert && !it.sentinel_notice).map(it => '⚠ ' + stageTrackerRefOf(it) + ' — ' + stageTrackerSentinelTipWithPaths(it)).join('\n'); } // Every confirm a row action raises can be opted out of per browser, // per action id (the dialog's "Don't ask again for this action" box; diff --git a/src/pkg/dashboard/static-src/js/tracker-row-layout.js b/src/pkg/dashboard/static-src/js/tracker-row-layout.js index 9a18548399..6f44f80fcd 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-layout.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-layout.js @@ -63,7 +63,7 @@ return { repo: canonical ? canonical[1] : (lp.repo || issue.repo), number: lp.number, kind: 'pr', title: lp.title || '', url: lp.url || '', author: lp.author || '', author_kind: lp.author_kind || '', state: lp.state || '', terminal_merge: !!lp.terminal_merge, merged_by: lp.merged_by || '', 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 || '', preparation: lp.preparation || null, human_attention: lp.human_attention || 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 || '', sentinel_notice: !!lp.sentinel_notice, head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || 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 || '', sentinel_details: lp.sentinel_details || [], sentinel_notice: !!lp.sentinel_notice, 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, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || 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 }; diff --git a/src/pkg/dashboard/static-src/js/tracker-row-render.js b/src/pkg/dashboard/static-src/js/tracker-row-render.js index ee8a699d9e..8d313f34d6 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-render.js @@ -106,7 +106,7 @@ prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null), lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), 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, preparation: lp.preparation || null, terminal_merge: !!lp.terminal_merge, merged_by: lp.merged_by || '', - 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 || '', sentinel_notice: !!lp.sentinel_notice, 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, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || 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 || '', sentinel_details: lp.sentinel_details || [], sentinel_notice: !!lp.sentinel_notice, 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, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || 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-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index 6de3010af7..d94d7d5f2b 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -450,6 +450,34 @@ const fallback = item.sentinel_notice ? 'informational findings; no blocking sentinel label' : STAGE_TRACKER_SENTINEL_TIP_FALLBACK; return lead + (head ? ' at ' + head : '') + ': ' + (reason || fallback); } + // Pure: one line per sentinel finding naming its rule and the files it + // fired on — "sensitive_path: .github/workflows/ci.yml, OWNERS (+3 + // more)" — from the row's sentinel_details (hivecommons/hive: "knowing + // what the sensitive path(s) (and files) are in this alert dialog would + // really help me make a decision"). The server bounds the paths per + // finding and reports the rest as more_paths. [] without details. + function stageTrackerSentinelPathLines(item) { + const details = item && Array.isArray(item.sentinel_details) ? item.sentinel_details : []; + return details.map(d => { + const rule = String((d && d.rule) || '').trim(); + const summary = String((d && d.summary) || '').trim(); + const paths = (d && Array.isArray(d.paths) ? d.paths : []).map(p => String(p || '').trim()).filter(Boolean); + const more = Number(d && d.more_paths) || 0; + const label = rule || summary; + if (!label) return ''; + if (!paths.length) return rule && summary ? rule + ' (' + summary + ')' : label; + return label + ': ' + paths.join(', ') + (more > 0 ? ' (+' + more + ' more)' : ''); + }).filter(Boolean); + } + // Pure: the sentinel tip followed by its path lines, one per line and + // indented, for the decision dialogs and result toasts; the tip alone + // when the row carries no details. + function stageTrackerSentinelTipWithPaths(item) { + const tip = stageTrackerSentinelTip(item); + if (!tip) return ''; + const lines = stageTrackerSentinelPathLines(item); + return lines.length ? tip + lines.map(l => '\n · ' + l).join('') : tip; + } // Whether the item's lit chevron word carries the alert itself (a PR // parked at 085, or an issue riding one): the chip then adds nothing. function stageTrackerSentinelInLane(item) { diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index a5133153cc..938df796bf 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1784,7 +1784,7 @@ .ham-plan-details > summary:hover { color: var(--text); } .ham-plan-details > :not(summary) { margin: var(--sp-3) 0 0; } .ham-plan-details .ham-plan-label { margin-top: var(--sp-4); } - .ham-plan-finding { color: var(--status-error); } + .ham-plan-finding { color: var(--status-error); white-space: pre-line; } .ham-plan-ruled-out { padding-left: 1.4em; } .ham-plan-rails { font-size: var(--fs-xs); color: var(--text-faint); } /* The preview opens as a skeleton while the plan is gathered @@ -17009,6 +17009,34 @@

Where to get help

const fallback = item.sentinel_notice ? 'informational findings; no blocking sentinel label' : STAGE_TRACKER_SENTINEL_TIP_FALLBACK; return lead + (head ? ' at ' + head : '') + ': ' + (reason || fallback); } + // Pure: one line per sentinel finding naming its rule and the files it + // fired on — "sensitive_path: .github/workflows/ci.yml, OWNERS (+3 + // more)" — from the row's sentinel_details (hivecommons/hive: "knowing + // what the sensitive path(s) (and files) are in this alert dialog would + // really help me make a decision"). The server bounds the paths per + // finding and reports the rest as more_paths. [] without details. + function stageTrackerSentinelPathLines(item) { + const details = item && Array.isArray(item.sentinel_details) ? item.sentinel_details : []; + return details.map(d => { + const rule = String((d && d.rule) || '').trim(); + const summary = String((d && d.summary) || '').trim(); + const paths = (d && Array.isArray(d.paths) ? d.paths : []).map(p => String(p || '').trim()).filter(Boolean); + const more = Number(d && d.more_paths) || 0; + const label = rule || summary; + if (!label) return ''; + if (!paths.length) return rule && summary ? rule + ' (' + summary + ')' : label; + return label + ': ' + paths.join(', ') + (more > 0 ? ' (+' + more + ' more)' : ''); + }).filter(Boolean); + } + // Pure: the sentinel tip followed by its path lines, one per line and + // indented, for the decision dialogs and result toasts; the tip alone + // when the row carries no details. + function stageTrackerSentinelTipWithPaths(item) { + const tip = stageTrackerSentinelTip(item); + if (!tip) return ''; + const lines = stageTrackerSentinelPathLines(item); + return lines.length ? tip + lines.map(l => '\n · ' + l).join('') : tip; + } // Whether the item's lit chevron word carries the alert itself (a PR // parked at 085, or an issue riding one): the chip then adds nothing. function stageTrackerSentinelInLane(item) { @@ -18182,7 +18210,7 @@

Where to get help

return { repo: canonical ? canonical[1] : (lp.repo || issue.repo), number: lp.number, kind: 'pr', title: lp.title || '', url: lp.url || '', author: lp.author || '', author_kind: lp.author_kind || '', state: lp.state || '', terminal_merge: !!lp.terminal_merge, merged_by: lp.merged_by || '', 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 || '', preparation: lp.preparation || null, human_attention: lp.human_attention || 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 || '', sentinel_notice: !!lp.sentinel_notice, head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || 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 || '', sentinel_details: lp.sentinel_details || [], sentinel_notice: !!lp.sentinel_notice, 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, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || 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 }; @@ -18609,7 +18637,7 @@

Where to get help

prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null), lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), 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, preparation: lp.preparation || null, terminal_merge: !!lp.terminal_merge, merged_by: lp.merged_by || '', - 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 || '', sentinel_notice: !!lp.sentinel_notice, 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, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || 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 || '', sentinel_details: lp.sentinel_details || [], sentinel_notice: !!lp.sentinel_notice, 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, push: lp.push || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || 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. @@ -22472,7 +22500,7 @@

All labels

// flagged PR, so the operator reads the security reason before // choosing Approve; '' when nothing in items is flagged. function stageTrackerSentinelPreface(items) { - return (items || []).filter(it => it && it.sentinel_alert && !it.sentinel_notice).map(it => '⚠ ' + stageTrackerRefOf(it) + ' — ' + stageTrackerSentinelTip(it)).join('\n'); + return (items || []).filter(it => it && it.sentinel_alert && !it.sentinel_notice).map(it => '⚠ ' + stageTrackerRefOf(it) + ' — ' + stageTrackerSentinelTipWithPaths(it)).join('\n'); } // Every confirm a row action raises can be opted out of per browser, // per action id (the dialog's "Don't ask again for this action" box;