diff --git a/changelog.d/fixed-16344.md b/changelog.d/fixed-16344.md new file mode 100644 index 0000000000..4d8995b40a --- /dev/null +++ b/changelog.d/fixed-16344.md @@ -0,0 +1 @@ +- fix(automerge): route the engine status-comment create through the tagged notification primitive (#16344) diff --git a/src/docs/notifications.md b/src/docs/notifications.md index 483e250f39..b6a086b54a 100644 --- a/src/docs/notifications.md +++ b/src/docs/notifications.md @@ -457,6 +457,7 @@ without a class. Review submissions and review requests are always counted as | `github.(*Client).PostNoteOrFold` | `status` | passthrough wrapper; attributed to its caller | | `github.(*Client).SweepLegacyFleetReportIssues` | `status` | | | `github.(*Client).UpsertIssueMarkerComment` | `status` | passthrough wrapper; attributed to its caller | +| `automerge.(*engineStatusForge).CreateComment` | `status` | passthrough wrapper (status-comment forge under `prstatus.Write`); attributed to its caller | | `github.(*clientStatusForge).CreateComment` | `status` | passthrough wrapper (status-comment forge under `prstatus.Write`); attributed to its caller | | `github.(*Client).PostIssueNote` | `status` | passthrough wrapper (issue status card, `attention_pilot`); attributed to its caller | | `github.(*Client).closeDecomposedParent` | `status` | | diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index d9ee6f3dd2..7df7f9a741 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -1547,8 +1547,17 @@ func (f *engineStatusForge) EditComment(ctx context.Context, id int64, body stri } func (f *engineStatusForge) CreateComment(ctx context.Context, body string) error { - _, _, err := f.e.gh.Issues.CreateComment(ctx, f.owner, f.repo, f.number, &gh.IssueComment{Body: gh.Ptr(body)}) - return err + commenter, ok := f.e.transport.(issueCommenter) + if !ok { + return fmt.Errorf("creating hive status comment on %s/%s#%d: transport has no comment primitive", f.owner, f.repo, f.number) + } + return commenter.CreateIssueComment(ctx, f.owner+"/"+f.repo, f.number, body) +} + +// issueCommenter is the tagged notification-write primitive (canary gate, +// effects journal) the production transport, *hgithub.Client, provides. +type issueCommenter interface { + CreateIssueComment(ctx context.Context, repo string, number int, body string) error } func (f *engineStatusForge) DeleteComment(ctx context.Context, id int64) error { diff --git a/src/pkg/github/notification_write_sites.go b/src/pkg/github/notification_write_sites.go index 4cf02f14bf..acb3c2c3e7 100644 --- a/src/pkg/github/notification_write_sites.go +++ b/src/pkg/github/notification_write_sites.go @@ -21,14 +21,15 @@ type NotificationWriteSite struct { // same table is documented in src/docs/notifications.md. var notificationWriteSites = map[string]NotificationWriteSite{ // Passthrough wrappers. - "github.(*Client).CreateIssueCommentBudgeted": {Class: NotificationClassStatus, Passthrough: true}, - "github.(*Client).PostNoteOrFold": {Class: NotificationClassStatus, Passthrough: true}, - "github.(*Client).RequestReviewers": {Class: NotificationClassRequiredReview, Passthrough: true}, - "main.(*repoForgeRouter).CreateIssueComment": {Class: NotificationClassAttention, Passthrough: true}, - "main.liveTriageCommenter.CreateIssueComment": {Class: NotificationClassAttention, Passthrough: true}, - "github.(*Client).UpsertIssueMarkerComment": {Class: NotificationClassStatus, Passthrough: true}, - "github.(*clientStatusForge).CreateComment": {Class: NotificationClassStatus, Passthrough: true}, - "github.(*Client).PostIssueNote": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).CreateIssueCommentBudgeted": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).PostNoteOrFold": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).RequestReviewers": {Class: NotificationClassRequiredReview, Passthrough: true}, + "main.(*repoForgeRouter).CreateIssueComment": {Class: NotificationClassAttention, Passthrough: true}, + "main.liveTriageCommenter.CreateIssueComment": {Class: NotificationClassAttention, Passthrough: true}, + "github.(*Client).UpsertIssueMarkerComment": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*clientStatusForge).CreateComment": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).PostIssueNote": {Class: NotificationClassStatus, Passthrough: true}, + "automerge.(*engineStatusForge).CreateComment": {Class: NotificationClassStatus, Passthrough: true}, // status: bookkeeping readable on demand. "dashboard.(*ContributeWSHub).markAlreadyDoneIssue": {Class: NotificationClassStatus}, diff --git a/src/pkg/writeback/testdata/direct-writes-baseline.txt b/src/pkg/writeback/testdata/direct-writes-baseline.txt index fd121804ef..08557c5b10 100644 --- a/src/pkg/writeback/testdata/direct-writes-baseline.txt +++ b/src/pkg/writeback/testdata/direct-writes-baseline.txt @@ -15,7 +15,7 @@ raw pkg/github/automerge/automerge_held_runs.go 3 raw pkg/github/automerge/automerge_merge_commit.go 1 raw pkg/github/automerge/automerge_merge_forward.go 1 raw pkg/github/automerge/automerge_stage_human.go 1 -raw pkg/github/automerge/automerge_stage_labels.go 5 +raw pkg/github/automerge/automerge_stage_labels.go 4 raw pkg/github/automerge/automerge_sweep_queued.go 3 raw pkg/github/automerge/automerge_sweep_trusted.go 4 raw pkg/github/automerge/automerge_unauthorized.go 3 @@ -81,6 +81,7 @@ wrap pkg/forge/gitea_forge.go 2 wrap pkg/forge/github_forge.go 3 wrap pkg/forge/gitlab_forge.go 2 wrap pkg/gfi/gfi.go 3 +wrap pkg/github/automerge/automerge_stage_labels.go 1 wrap pkg/github/claimed_by_human_migration.go 2 wrap pkg/github/claimed_by_label.go 5 wrap pkg/github/clarity_gate_resume.go 1