Documentation
¶
Overview ¶
Package escalate routes auto-merge refusals to the operator through the shared generic notification system, so a refused PR is never held in silence.
One escalation item is published per (repo#number, head SHA, class). The episode key is the whole point: a PR that stays refused is re-polled every cycle, and without the key it would re-notify on every poll.
Index ¶
Constants ¶
const ChecksNotGreenThreshold = 2
ChecksNotGreenThreshold is the number of consecutive poll cycles a labelled PR may stay non-green before the watcher escalates it. It is pinned here, in code, and never chosen at run time.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class string
Class names the refusal class carried in the escalation item. The values are part of the operator-facing contract: the escalation message and the watcher's `escalated pr=… class=…` log line both carry them, and the task's verification probes grep for them.
const ( // ClassUntrustedAuthor is a labelled PR whose author is outside the trust // gate, so the watcher refuses to arm auto-merge. ClassUntrustedAuthor Class = "untrusted-author" // ClassTrustCheckError is a trust decision that failed to evaluate. The // refusal is not a verdict on the author, so it escalates under its own // class rather than as untrusted. ClassTrustCheckError Class = "trust-check-error" // ClassEnableAutoMergeError is a failed arm request (permissions, an // already-clean PR, a transient API error). ClassEnableAutoMergeError Class = "enable-auto-merge-error" // ClassChecksNotGreen is a labelled PR still non-green after // ChecksNotGreenThreshold consecutive poll cycles. ClassChecksNotGreen Class = "checks-not-green" // ClassReviewRequestChanges is a PR whose latest review on the current head // SHA is CHANGES_REQUESTED, so GitHub will never merge it. ClassReviewRequestChanges Class = "review-request-changes" )
type Escalation ¶
type Escalation struct {
// PRURL is the PR's HTML URL. It is what the operator clicks and what the
// verification probe filters the notification body on.
PRURL string
// Repo is the `owner/repo` pair.
Repo string
// Number is the pull-request number.
Number int
// HeadSHA is the commit the refusal applies to. A new head SHA is a new
// episode and may escalate again.
HeadSHA string
// Class is the refusal class.
Class Class
// Detail is a short human-readable reason (an error string or a status).
Detail string
}
Escalation is one refusal to publish.
type Escalator ¶
type Escalator interface {
// Escalate publishes the escalation unless this episode was already
// notified. It returns true when it published, false when it suppressed a
// duplicate. A publish failure returns an error and does NOT mark the
// episode notified, so the next poll retries.
Escalate(ctx context.Context, escalation Escalation) (bool, error)
// ObserveNotGreen records one poll-cycle observation of a non-green PR and
// escalates once ChecksNotGreenThreshold consecutive observations are
// reached. It is idempotent past the threshold because Escalate dedupes.
ObserveNotGreen(ctx context.Context, escalation Escalation) (bool, error)
// Reset drops every non-green observation counter for a PR, across all head
// SHAs. The watcher calls it once the PR's checks go green, so a PR that
// goes green and red again must accumulate the threshold afresh.
Reset(ctx context.Context, repo string, number int)
}
Escalator publishes auto-merge refusals exactly once per episode.
func NewEscalator ¶
func NewEscalator(publish PublishFunc) Escalator
NewEscalator returns an Escalator that publishes through publish.
type PublishFunc ¶
PublishFunc sends one rendered escalation message. It exists so the episode logic is testable without a Kafka broker.
func NewNotificationPublishFunc ¶
func NewNotificationPublishFunc( sender notification.NotificationPublishCommandSender, ) PublishFunc
NewNotificationPublishFunc adapts the generic notification sender to a PublishFunc, publishing every escalation as an `agent-escalation` item.