Feat/operator alerts (#1635)
* feat(state): durable operator alerts owned by the State Store Alerts dedup on org+kind+subject, resolve themselves when a condition clears, and are raised, resolved, dismissed and listed through the state contract. Task transitions raise needs-human and failed alerts in the same transaction; the store checks service health and prunes closed alerts. Each raise and resolve queues a webhook delivery whose attempts are kept. * feat(notify): deliver operator alerts to the webhook; raise config and release alerts notify.webhook now receives raised and resolved alerts above a severity threshold with HMAC-signed payloads, bounded retry and every attempt recorded on the alert. archied raises model alias, provider and credential-binding alerts from the effective configuration, an update alert from the release channel, and a credential-rejected alert from the egress resolver. The dashboard API lists and dismisses the caller's org's alerts. * feat(ui): alert bell in the top bar and webhook alert settings The bell lists the org's open alerts by severity with dismiss and a link per alert, and refreshes from the event stream. The task settings page gains the webhook severity threshold and signing secret. ui/dist rebuilt.
This commit is contained in:
1 parent
f34f60f9c7
commit
8a3ba32c5a
43 files changed
+4671
-465
No files matched your search
@@ -1,16 +1,13 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// notify posts a one-way notice on a forge-backed task's issue and, when
|
||||
// configured, to the notify webhook.
|
||||
// notify posts a one-way notice on a forge-backed task's issue. The operator
|
||||
// alert for the task waiting on a human is raised by the State Store when the
|
||||
// task parks.
|
||||
func notify(ctx context.Context, tc *TaskContext, kind string) {
|
||||
if tc.Task.IsForgeBacked() {
|
||||
if _, err := tc.Forge.Comment(ctx, tc.Task.Owner, tc.Task.Repo, tc.Task.IssueNumber, deliveryNotice(tc, kind)); err != nil {
|
||||
@@ -18,37 +15,6 @@ func notify(ctx context.Context, tc *TaskContext, kind string) {
|
||||
"kind", kind, "issue", tc.Task.IssueNumber, "err", err)
|
||||
}
|
||||
}
|
||||
url := tc.Cfg.Notify.Webhook
|
||||
if url == "" {
|
||||
return
|
||||
}
|
||||
fields := map[string]any{
|
||||
"type": kind, "repo": tc.Repo.FullName(), "task_id": tc.Task.ID,
|
||||
"source": tc.Task.Source, "identity": tc.Task.Identity,
|
||||
"title": tc.Task.Title, "prd": tc.Task.Plan,
|
||||
}
|
||||
if tc.Task.IsForgeBacked() {
|
||||
fields["issue"] = tc.Task.IssueNumber
|
||||
fields["issue_url"] = fmt.Sprintf("%s/%s/issues/%d",
|
||||
tc.Cfg.Forge.Host, tc.Repo.FullName(), tc.Task.IssueNumber)
|
||||
}
|
||||
payload, _ := json.Marshal(fields)
|
||||
reqCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
req, err := http.NewRequestWithContext(reqCtx, http.MethodPost, url, bytes.NewReader(payload))
|
||||
if err != nil {
|
||||
tc.Log.Warn("notify webhook request build failed", "err", err)
|
||||
return
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
tc.Log.Warn("notify webhook failed", "err", err)
|
||||
return
|
||||
}
|
||||
if err := resp.Body.Close(); err != nil {
|
||||
tc.Log.Warn("close notify webhook response", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
// deliveryNotice is the body of the one-way notice notify posts on a
|
||||
|
||||
Reference in new issue
Block a user