Documentation
¶
Overview ¶
Package notify POSTs short messages to Slack and Discord webhooks.
Port of orchestrator/notifications.py. Two properties are load-bearing and both come straight from that file's own reasoning:
- **Best effort, always.** A broken webhook must never surface into the dispatch loop. The goal is "the operator does not have to babysit the dashboard", not "add another way for a run to die". Every method except Test swallows its errors.
- **Disabled is the default.** An empty URL disables that channel, and a Notifier with no channels is a working no-op — safe to build and call unconditionally from the engine, which is exactly how the engine uses it.
The event log remains the source of truth for what happened; these are a side channel.
Index ¶
- Constants
- func BudgetAlertText(a budget.Alert) string
- func DigestText(summaryText string, milestones []Milestone) string
- type Milestone
- type Notifier
- func (n *Notifier) Blocked(ctx context.Context, taskID, reason string)
- func (n *Notifier) BudgetAlert(ctx context.Context, a budget.Alert)
- func (n *Notifier) CIBlocked(ctx context.Context, taskID, prURL string, attempts int)
- func (n *Notifier) Enabled() bool
- func (n *Notifier) RunSummary(ctx context.Context, text string)
- func (n *Notifier) Stalled(ctx context.Context, stalledFor time.Duration, waitingOn string)
- func (n *Notifier) Test(ctx context.Context, message string) bool
Constants ¶
const DefaultTimeout = 5 * time.Second
DefaultTimeout is Python's `notifications.timeout_s` default.
Variables ¶
This section is empty.
Functions ¶
func BudgetAlertText ¶
BudgetAlertText is the message BudgetAlert sends, exported so `orch notify test --budget` can preview it without a run.
func DigestText ¶
DigestText composes the digest body. Pure: no I/O and no clock, so it can be pinned against what Python produced for the same input.
summaryText is `executive_summary`'s own text, reused verbatim rather than rebuilt — that function is the single source of wording for the dashboard and for this, and two phrasings of the same number is worse than one.
The shape, which is what testdata/digest-*.txt pin:
<summary text> Milestones: - Billing: 3/5 — ETA 2026-09-19
with the whole thing trimmed and exactly one trailing newline — so an empty summary and no milestones produce a lone "\n", not an empty string.
Types ¶
type Milestone ¶
type Milestone struct {
Name string
ID string
Done int
Total int
// ETADate is a date string, or empty when none has been computed.
ETADate string
}
Milestone is one row of the digest's table: a name, its progress, and an ETA if one has been computed.
A struct rather than the loose dict Python passes around, so the three fallbacks it applies — name or id or "?", a missing progress counting as 0/0, a missing ETA rendering as an em dash — are visible here rather than spread across `.get()` calls.
type Notifier ¶
type Notifier struct {
SlackWebhook string
DiscordWebhook string
Timeout time.Duration
// Client is the HTTP client. Nil uses a client with Timeout.
Client *http.Client
// Log receives the best-effort failures. Nil uses slog's default.
Log *slog.Logger
}
Notifier posts to whichever channels are configured.
The zero value is a valid disabled notifier, so a caller that never configured one does not need a nil check.
func (*Notifier) Blocked ¶
Blocked announces a task the dispatch loop gave up on.
Only the reason's first line is sent, truncated — see reasonMaxChars. An empty reason becomes "unknown", because a message that just says a task is blocked tells the reader nothing they can act on.
func (*Notifier) BudgetAlert ¶
BudgetAlert announces a provider whose budget window is near its cap, or has reached it and is deferring tasks. The engine decides when; this only words it.
func (*Notifier) RunSummary ¶
RunSummary posts a finished run's summary (receipt.Summary's text), all of it: what was built, why each blocked task stopped and what to do next.
func (*Notifier) Stalled ¶
Stalled announces a run that has made no progress for stalledFor, and what it is waiting on, cut like a block reason. Go only: Python never noticed a stall (#255).