From 4255147cbd0b71d685ddc20d1525eb356f176884 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 04:42:34 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20feat(notifications):=20fold=20r?= =?UTF-8?q?elay=20state,=20blocker=20re-target=20and=20decision-downgrade?= =?UTF-8?q?=20notes=20into=20the=20issue=20status=20card=20under=20the=20a?= =?UTF-8?q?ttention=20pilot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/changed-16270-issue-notes.md | 1 + src/pkg/github/issue_blocked.go | 5 + .../issue_notes_attention_pilot_test.go | 102 ++++++++++++++++++ src/pkg/github/issue_request_watcher.go | 16 ++- src/pkg/prstatus/issue.go | 3 + 5 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 changelog.d/changed-16270-issue-notes.md create mode 100644 src/pkg/github/issue_notes_attention_pilot_test.go diff --git a/changelog.d/changed-16270-issue-notes.md b/changelog.d/changed-16270-issue-notes.md new file mode 100644 index 0000000000..a44eb837fb --- /dev/null +++ b/changelog.d/changed-16270-issue-notes.md @@ -0,0 +1 @@ +With the attention pilot on, issue relay state notes and decision-downgrade notes now fold into the issue's single status comment instead of posting new comments. diff --git a/src/pkg/github/issue_blocked.go b/src/pkg/github/issue_blocked.go index 4a43559e47..d286621e41 100644 --- a/src/pkg/github/issue_blocked.go +++ b/src/pkg/github/issue_blocked.go @@ -492,6 +492,11 @@ func (c *Client) reconcileBlockedTargets(ctx context.Context, targets []blockedI continue } } + // Stays a standalone comment even under the attention pilot: + // blockedSweepComments finds the current blocker from the + // newest comment carrying the marker, and a status-card + // section keeps the card's original position and would + // hide this marker from that ordering. note := fmt.Sprintf("%s\nRe-targeted: blocker #%d was superseded by #%d.", BlockedOnMarker(prRepo, supersededBy), prNumber, supersededBy) if err := c.CreateIssueCommentBudgeted(ctx, t.repo, t.number, note); err != nil { logger.Warn("blocked sweep: re-target note not posted", "repo", t.repo, "issue", t.number, "error", err) diff --git a/src/pkg/github/issue_notes_attention_pilot_test.go b/src/pkg/github/issue_notes_attention_pilot_test.go new file mode 100644 index 0000000000..a0c877f1fc --- /dev/null +++ b/src/pkg/github/issue_notes_attention_pilot_test.go @@ -0,0 +1,102 @@ +package github + +import ( + "context" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/hivecommons/hive/pkg/prstatus" +) + +// relayServer serves the status-comment fake and answers label calls itself. +func relayServer(t *testing.T, s *statusCommentServer) *httptest.Server { + t.Helper() + inner := s.start(t).Config.Handler + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if strings.Contains(r.URL.Path, "/labels") { + w.Header().Set("Content-Type", "application/json") + if r.Method == http.MethodGet { + _, _ = w.Write([]byte(`{"name":"x"}`)) + return + } + _, _ = w.Write([]byte(`[]`)) + return + } + inner.ServeHTTP(w, r) + })) + t.Cleanup(srv.Close) + return srv +} + +func TestRelayCommentStateNoteFoldsUnderAttentionPilot(t *testing.T) { + for _, tc := range []struct { + name string + pilot bool + wantCreates, wantEdits int + }{ + {"pilot on", true, 1, 1}, + {"pilot off", false, 2, 0}, + } { + t.Run(tc.name, func(t *testing.T) { + s := &statusCommentServer{} + c := issueTestClient(t, relayServer(t, s).URL) + c.SetAppBotLogin("hive-app[bot]") + c.SetAttentionPilot(func() bool { return tc.pilot }) + dir := withIssueDir(t) + for _, body := range []string{"hive/awaiting-ci: CI pending", "already fixed in #9"} { + if _, err := WriteIssueRequest(dir, IssueRequest{Kind: "comment", Repo: "o/r", Number: 41, Body: body, Agent: "quality"}); err != nil { + t.Fatal(err) + } + } + c.ProcessIssueRequestsOnce(context.Background()) + if s.creates != tc.wantCreates || s.edits != tc.wantEdits { + t.Fatalf("creates=%d edits=%d, want %d/%d", s.creates, s.edits, tc.wantCreates, tc.wantEdits) + } + cards := 0 + for _, cm := range s.comments { + if b, _ := cm["body"].(string); prstatus.IsStatusComment(b) { + cards++ + } + } + if (cards == 1) != tc.pilot { + t.Fatalf("status cards=%d with pilot=%v", cards, tc.pilot) + } + }) + } +} + +func TestLabelDecisionDowngradeNoteFoldsUnderAttentionPilot(t *testing.T) { + for _, tc := range []struct { + name string + pilot bool + }{{"pilot on", true}, {"pilot off", false}} { + t.Run(tc.name, func(t *testing.T) { + s := &statusCommentServer{} + c := issueTestClient(t, relayServer(t, s).URL) + c.SetAppBotLogin("hive-app[bot]") + c.SetAttentionPilot(func() bool { return tc.pilot }) + dir := withIssueDir(t) + if _, err := WriteIssueRequest(dir, IssueRequest{ + Kind: "label", Repo: "o/r", Number: 41, Agent: "quality", + Labels: []string{c.needsDecisionLabel()}, + Body: "Choose approach A vs B for config shape and scope", + }); err != nil { + t.Fatal(err) + } + c.ProcessIssueRequestsOnce(context.Background()) + if len(s.comments) != 1 { + t.Fatalf("comments=%d, want exactly one", len(s.comments)) + } + body, _ := s.comments[0]["body"].(string) + _, folded := prstatus.Get(body, prstatus.KeyIssueDecisionDowngrade) + if folded != tc.pilot || prstatus.IsStatusComment(body) != tc.pilot { + t.Fatalf("folded=%v pilot=%v body=%q", folded, tc.pilot, body) + } + if !tc.pilot && !strings.Contains(body, "Hive did not park this") { + t.Fatalf("raw note missing: %q", body) + } + }) + } +} diff --git a/src/pkg/github/issue_request_watcher.go b/src/pkg/github/issue_request_watcher.go index 22891c6277..bcb7076697 100644 --- a/src/pkg/github/issue_request_watcher.go +++ b/src/pkg/github/issue_request_watcher.go @@ -21,6 +21,7 @@ import ( "github.com/hivecommons/hive/pkg/decisionpolicy" "github.com/hivecommons/hive/pkg/effects" "github.com/hivecommons/hive/pkg/issueshape" + "github.com/hivecommons/hive/pkg/prstatus" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -669,9 +670,10 @@ func (c *Client) handleOneIssueRequest(ctx context.Context, path string, nowFn f parkBlocked = true } } - if key := relayStatusNoteKey(body); key != "" && c.notificationsQuiet() { + if key := relayStatusNoteKey(body); key != "" && (c.notificationsQuiet() || c.attentionPilot()) { // A one-line state note (awaiting-ci, parking, already fixed) - // is a section of the item's status comment in quiet mode. + // is a section of the item's status comment in quiet mode or + // under the attention pilot. var created bool created, err = c.UpsertPRStatusSection(ctx, req.Repo, req.Number, key, body) if err == nil && !created { @@ -739,7 +741,15 @@ func (c *Client) handleOneIssueRequest(ctx context.Context, path string, nowFn f } } if err == nil && issueDecisionDowngrade.Active { - err = c.CreateIssueCommentBudgeted(ctx, req.Repo, req.Number, issueDecisionDowngrade.Note) + if c.notificationsQuiet() || c.attentionPilot() { + var created bool + created, err = c.UpsertPRStatusSection(ctx, req.Repo, req.Number, prstatus.KeyIssueDecisionDowngrade, issueDecisionDowngrade.Note) + if err == nil && !created { + c.noteCommentSuppressed() + } + } else { + err = c.CreateIssueCommentBudgeted(ctx, req.Repo, req.Number, issueDecisionDowngrade.Note) + } } if err == nil { resp.OK = true diff --git a/src/pkg/prstatus/issue.go b/src/pkg/prstatus/issue.go index 3a49e5d048..0b5a069faf 100644 --- a/src/pkg/prstatus/issue.go +++ b/src/pkg/prstatus/issue.go @@ -21,6 +21,9 @@ const ( // KeyIssuePartialPrefix + PR number is the partial-work/remainder note // a non-closing merged PR leaves on the issue. KeyIssuePartialPrefix = "issue-partial:" + // KeyIssueDecisionDowngrade is the note that a label change walked + // back an earlier maintainer decision on the issue. + KeyIssueDecisionDowngrade = "issue-decision-downgrade" // KeyIssuePRLink is the stage note naming the PR that covers the issue. KeyIssuePRLink = "issue-pr-link" // KeyIssueAttentionPrefix + cause is a newly required action recorded From 000662976780d891436bb59bd3e94445547ecc91 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 09:43:03 +0000 Subject: [PATCH 2/3] changelog: fragment for #16409 Generated by changelog-fragment-guard from the PR title (#5675). Edit the wording freely, or replace this file with the no-changelog label if the change is not user-visible. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/added-16409.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/added-16409.md diff --git a/changelog.d/added-16409.md b/changelog.d/added-16409.md new file mode 100644 index 0000000000..013e706463 --- /dev/null +++ b/changelog.d/added-16409.md @@ -0,0 +1 @@ +- feat(notifications): fold remaining routine issue notes into the hive:status card under the attention pilot (#16409) From 9156c119a3b046afe26d2081fd4bd622458021b8 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 04:55:52 -0500 Subject: [PATCH 3/3] fix(notifications): address review on issue-note folds - decision-downgrade note folds under the attention pilot only; quiet mode keeps the standalone comment as docs/notifications.md states - prstatus.Upsert neutralises the card's own section/status markers in section text so quoted issue-authored prose cannot close or open sections - notifications.md lists the relay state notes and the decision-downgrade note among the folded sections - one changelog fragment (changed-16409-issue-notes.md) with the required leading bullet and #16270 link replaces the two prior fragments Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/added-16409.md | 1 - changelog.d/changed-16270-issue-notes.md | 1 - changelog.d/changed-16409-issue-notes.md | 1 + src/docs/notifications.md | 18 +++++++++++----- src/pkg/github/issue_request_watcher.go | 4 +++- src/pkg/prstatus/prstatus.go | 20 ++++++++++++++++-- src/pkg/prstatus/prstatus_test.go | 26 ++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 10 deletions(-) delete mode 100644 changelog.d/added-16409.md delete mode 100644 changelog.d/changed-16270-issue-notes.md create mode 100644 changelog.d/changed-16409-issue-notes.md diff --git a/changelog.d/added-16409.md b/changelog.d/added-16409.md deleted file mode 100644 index 013e706463..0000000000 --- a/changelog.d/added-16409.md +++ /dev/null @@ -1 +0,0 @@ -- feat(notifications): fold remaining routine issue notes into the hive:status card under the attention pilot (#16409) diff --git a/changelog.d/changed-16270-issue-notes.md b/changelog.d/changed-16270-issue-notes.md deleted file mode 100644 index a44eb837fb..0000000000 --- a/changelog.d/changed-16270-issue-notes.md +++ /dev/null @@ -1 +0,0 @@ -With the attention pilot on, issue relay state notes and decision-downgrade notes now fold into the issue's single status comment instead of posting new comments. diff --git a/changelog.d/changed-16409-issue-notes.md b/changelog.d/changed-16409-issue-notes.md new file mode 100644 index 0000000000..5f6990f6a0 --- /dev/null +++ b/changelog.d/changed-16409-issue-notes.md @@ -0,0 +1 @@ +- Attention pilot (`github.notifications.attention_pilot: true`): the last two routine issue notes that still posted standalone comments now fold into the issue's single `hive:status` card — the relay's one-line state notes (awaiting CI, parking, already fixed) and the decision-downgrade note left when a label change walks back an earlier maintainer decision (section `issue-decision-downgrade`). Quiet mode without the pilot is unchanged. Section text is also neutralised so quoted issue-authored text can no longer open or close status-card sections ([#16270](https://github.com/hivecommons/hive/issues/16270)). diff --git a/src/docs/notifications.md b/src/docs/notifications.md index 35989f6d17..a1589410cc 100644 --- a/src/docs/notifications.md +++ b/src/docs/notifications.md @@ -569,11 +569,19 @@ issue gets the same card, written through the same single status writer "Fixed by #N … Reply /reopen if the problem persists" and the decomposed parent's all-children-delivered close — (`issue-close`), reopened-after-merge (`issue-reopened`), a lapsed claim's stage regression - (`stage-regressed`), the covering-PR stage note (`issue-pr-link`) and the - blocker-settled note (`unblocked`, whatever `mode` says). Claim notes - already fold under `claim` in quiet mode. The legacy markers stay inside - each section, so every reader that greps for them still finds them, and - the reopen/release guidance stays visible on the card. + (`stage-regressed`), the covering-PR stage note (`issue-pr-link`), the + relay's one-line state notes — awaiting CI, parking, already fixed — + (`agent-note:`), the decision-downgrade note left when a label + change walks back an earlier maintainer decision + (`issue-decision-downgrade`) and the blocker-settled note (`unblocked`, + whatever `mode` says). Claim notes and the relay state notes already fold + under `claim` and `agent-note:` in quiet mode; the + decision-downgrade note folds under the pilot only. The legacy markers + stay inside each section, so every reader that greps for them still finds + them, and the reopen/release guidance stays visible on the card. Section + text that quotes issue-authored prose has the card's own + `` markers neutralised, so it cannot close its + section or open another. - **Native events notify instead.** The issue is still closed (with its state reason) by the API call, which is GitHub's own notification; the hive no longer adds a "for visibility" comment beside it. diff --git a/src/pkg/github/issue_request_watcher.go b/src/pkg/github/issue_request_watcher.go index bcb7076697..363f80cf9f 100644 --- a/src/pkg/github/issue_request_watcher.go +++ b/src/pkg/github/issue_request_watcher.go @@ -741,7 +741,9 @@ func (c *Client) handleOneIssueRequest(ctx context.Context, path string, nowFn f } } if err == nil && issueDecisionDowngrade.Active { - if c.notificationsQuiet() || c.attentionPilot() { + // Pilot only: quiet mode leaves issue notes as standalone + // comments (docs/notifications.md), so it keeps the raw note. + if c.attentionPilot() { var created bool created, err = c.UpsertPRStatusSection(ctx, req.Repo, req.Number, prstatus.KeyIssueDecisionDowngrade, issueDecisionDowngrade.Note) if err == nil && !created { diff --git a/src/pkg/prstatus/prstatus.go b/src/pkg/prstatus/prstatus.go index 4053f7426a..f2e35cf5e3 100644 --- a/src/pkg/prstatus/prstatus.go +++ b/src/pkg/prstatus/prstatus.go @@ -85,10 +85,12 @@ func Render(sections []Section) string { // Upsert returns existing with the section key set to text: replaced in // place when present, appended otherwise. An empty text removes the -// section. existing may be "" (no status comment yet). +// section. existing may be "" (no status comment yet). Section text that +// carries the card's own markers (some notes quote issue-authored text) +// is neutralised so it cannot close its section or open another. func Upsert(existing, key, text string) string { sections := Parse(existing) - text = strings.TrimSpace(text) + text = neutraliseMarkers(strings.TrimSpace(text)) out := make([]Section, 0, len(sections)+1) replaced := false for _, s := range sections { @@ -108,6 +110,20 @@ func Upsert(existing, key, text string) string { return Render(out) } +// markerNeutraliser defangs the card's own structural markers inside +// section text by escaping the comment opener, so Parse never sees them +// as section boundaries. Legacy `` markers that readers +// grep for are left alone. +var markerNeutraliser = strings.NewReplacer( + sectionOpenPrefix, "<!--"+strings.TrimPrefix(sectionOpenPrefix, "") { + t.Fatalf("neutralised text lost:\n%s", body) + } + // A legacy marker readers grep for is left intact. + body = Upsert("", KeyStageStalled, "\nstage 080") + if !strings.Contains(body, "") { + t.Fatalf("legacy marker altered:\n%s", body) + } + // Re-upserting the same text is still stable. + if again := Upsert(body, KeyIssueDecisionDowngrade, hostile); Upsert(again, KeyIssueDecisionDowngrade, hostile) != again { + t.Fatalf("not idempotent after neutralising") + } +} + func TestUpsertEmptyRemovesSection(t *testing.T) { body := Upsert("", KeyDuplicateGuard, "redirect") body = Upsert(body, KeyHuman071Note, "note")