carlos / platform Public

console: fleet alerts routes in the registries; NewServer record-write census re-pinned

Every new route is in claim-routes.txt with a claim fixture and a probe:
reads for the history and the doors' GETs, nonApp probes with effect
witnesses for the operator writes, the doors' POSTs, and the two GETs
that make the alert signing key on first use. perf-budgets.txt skips the
POST-only doors, the token pages and the plain-text key; the rail test
counts the Alerts item; the screenshot list gains both pages.

fleetAlertsWriteCensusInventory re-pins NewServer over
fleetPublicRoutesWriteCensusInventory: route registrations and a comment
only, the same "instances" literal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 297e535956baa3503778475d4ee3ab99f1e04f33 parent 2572113
9 files changed, +275 −3
  • internal/console/claim_invariant_fixtures_test.go +19 −0
  • internal/console/claim_invariant_probes_nonapp_test.go +149 −0
  • internal/console/claim_invariant_probes_read_test.go +47 −0
  • internal/console/opshell_test.go +2 −2
  • internal/console/opshots_test.go +2 −0
  • internal/console/testdata/claim-routes.txt +13 −0
  • internal/console/testdata/perf-budgets.txt +8 −0
  • internal/provision/fleet_alerts_census_test.go +34 −0
  • internal/provision/plan9_b8_census_test.go +1 −1

CI failed — run details

Intent

Attributed to this commit: 20.6 g CO₂e (2,595,654 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-fleet-alerts, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index 3a6cf01e6..ebb0360d2 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -738,6 +738,12 @@ var claimFixtures = map[string]claimFixture{
"route /fleet/economics/bill": claimNonApp("operator bill form, stored under economics/"),
"route /fleet/economics/scenarios": claimNonApp("operator pricing scenarios, stored under economics/"),
"route /fleet/economics/tier": claimNonApp("an account's economics tier: an account record, not an app"),
+ "route /fleet/alerts/connectors": claimNonApp("operator adds a fleet alert connector: its alert_connectors row, " +
+ "and a confirmation outbox row or a signed test; names no app"),
+ "route /fleet/alerts/connectors/{id}/delete": claimNonApp("operator deletes a fleet alert connector with its queued rows and links"),
+ "route /fleet/alerts/connectors/{id}/test": claimNonApp("operator sends a fleet alert connector a test; one that gets through " +
+ "confirms a webhook and lifts a suspension (alert_connectors)"),
+ "route /fleet/alerts/rules/{rule}": claimNonApp("operator sets a fleet alert rule: alert_rules and alert_subscriptions rows"),
// ---- DELETE ----
// Alias-only detach is intentionally unsupported (claimUnsupported); the
@@ -898,6 +904,10 @@ var claimFixtures = map[string]claimFixture{
"route GET /fleet/boxes": claimRead("operator boxes view: fleet.json, box snapshots, the storage queue"),
"route GET /fleet/economics": claimRead("operator economics view"),
"route GET /fleet/activity": claimRead("operator activity feed; SQLite only"),
+ "route GET /fleet/alerts/history": claimRead("operator alert incidents; SQLite only, writes nothing"),
+ "route GET /alerts/confirm/{token}": claimRead("an alert confirm link's page: reads the token and its connector; confirming is the POST"),
+ "route GET /alerts/unsubscribe/{token}": claimRead("an alert unsubscribe link's page: reads the token and its connector; turning off is the POST"),
+ "route GET /alerts/snooze/{token}": claimRead("an alert snooze link's page: reads the token; snoozing is the POST"),
"route GET /fleet/economics/accounts": claimRead("operator per-account economics table"),
"route GET /fleet/index": claimRead("operator section index; reads nothing remote"),
"route GET /fleet/metrics": claimRead("operator box metrics"),
@@ -911,6 +921,12 @@ var claimFixtures = map[string]claimFixture{
"route GET /upgrade": claimRead("the pricing page's upgrade entry (plans 6b): redirects to the billing page of the account the caller owns, or the front door; writes nothing"),
"route GET /{$}": claimRead("the front door: redirects or renders sign-in"),
+ // The page and the plain-text key both make the webhook signing key on
+ // first use (a keys row, as the first webhook send would): deployment
+ // state, no app's.
+ "route GET /fleet/alerts": claimNonApp("operator alerts page: SQLite reads, and the alert signing key made on first use"),
+ "route GET /alerts/signing-key": claimNonApp("the alert signing key's public half, the key made on first use"),
+
// GET that writes: a replica file download streams versioned objects (reads
// only) but audits every successful GET as an activity row of the app
// (apidb.go: auditActivity), an app-scoped SQL write that needs admission.
@@ -1434,6 +1450,9 @@ var claimFixtures = map[string]claimFixture{
"route POST /auth/signout": claimNonApp("ends the session"),
"route POST /fleet/store/{account}/{decision}": claimNonApp("operator entitlement decision for an account"),
"route POST /invite/{token}": claimNonApp("accepts an invitation: membership"),
+ "route POST /alerts/confirm/{token}": claimNonApp("redeems an alert confirm link: the token spent and its fleet connector confirmed"),
+ "route POST /alerts/unsubscribe/{token}": claimNonApp("redeems an alert unsubscribe link: its fleet connector turned off"),
+ "route POST /alerts/snooze/{token}": claimNonApp("redeems an alert snooze link: an alert_snoozes row for its rule and subject"),
"route POST /api/cli/apps/{account}/{app}/regions/guess": claimRead("answers a region guess from the caller's hints; writes nothing"),
// Re-issues every relay-enabled app's key: app config and relay records.
diff --git a/internal/console/claim_invariant_probes_nonapp_test.go b/internal/console/claim_invariant_probes_nonapp_test.go
index f4d6b207f..b88216132 100644
--- a/internal/console/claim_invariant_probes_nonapp_test.go
+++ b/internal/console/claim_invariant_probes_nonapp_test.go
@@ -7,12 +7,14 @@ package console
import (
"context"
+ "database/sql"
"encoding/json"
"errors"
"fmt"
"github.com/carlosframework/platform/internal/hostactors"
"net/http"
"net/url"
+ "strconv"
"strings"
"testing"
"time"
@@ -264,7 +266,154 @@ func claimAcceptInviteProbe() claimProbe {
}
}
+// claimAlertDoorPost is a POST to an alert link's door from a browser with
+// no session, as a person pressing the page's button sends it.
+func claimAlertDoorPost(path string, kv ...string) func(*testing.T, *claimCase) claimReply {
+ return func(t *testing.T, cx *claimCase) claimReply {
+ t.Helper()
+ c := newBrowser(t)
+ v := url.Values{}
+ for i := 0; i+1 < len(kv); i += 2 {
+ v.Add(kv[i], kv[i+1])
+ }
+ status, loc, body := postForm(t, c, cx.ts.URL+cx.expand(path), v)
+ return cx.browserReply(c, status, loc, body)
+ }
+}
+
+// claimAlertConnector reads fleet alert connector <alertconn>.
+func (cx *claimCase) claimAlertConnector(t *testing.T) (alertConnector, error) {
+ t.Helper()
+ id, err := strconv.ParseInt(cx.vars["alertconn"], 10, 64)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return cx.st.AlertConnector(id)
+}
+
+// claimAlertSigningKeyMade is the signing key's effect witness: its keys row.
+func claimAlertSigningKeyMade(t *testing.T, cx *claimCase, _ claimReply) string {
+ if cx.sqlCount(t, `SELECT COUNT(*) FROM keys WHERE name = 'alert-sign'`) != 1 {
+ return "no alert signing key in keys"
+ }
+ return ""
+}
+
var claimNonAppProbes = map[string]claimProbe{
+ // ---- fleet alerts (alertpages.go) ----
+ "route GET /fleet/alerts": {do: claimPageReply("/fleet/alerts"), body: []string{"<h1>Alerts</h1>", "Public key (Ed25519, base64)"},
+ effect: claimAlertSigningKeyMade},
+ "route GET /alerts/signing-key": {
+ do: func(t *testing.T, cx *claimCase) claimReply {
+ return cx.pageReplyAs(t, newBrowser(t), "/alerts/signing-key")
+ },
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if msg := claimAlertSigningKeyMade(t, cx, r); msg != "" {
+ return msg
+ }
+ key, err := cx.st.AlertSigningKey()
+ if err != nil || r.Body != alertPublicKey(key)+"\n" {
+ return fmt.Sprintf("served %q, not the signing key's public half (%v)", r.Body, err)
+ }
+ return ""
+ },
+ },
+ "route /fleet/alerts/connectors": {
+ do: claimFormReply("/fleet/alerts/connectors", "kind", "email", "name", "census", "target", "census@example.com"),
+ status: http.StatusSeeOther, loc: "/fleet/alerts",
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if cx.sqlCount(t, `SELECT COUNT(*) FROM alert_connectors WHERE scope = 'fleet' AND kind = 'email' AND target_plain = 'census@example.com' AND confirmed_at = 0`) != 1 {
+ return "no unconfirmed census@example.com connector"
+ }
+ if cx.sqlCount(t, `SELECT COUNT(*) FROM alert_outbox WHERE kind = 'verify' AND sent_at IS NULL`) != 1 {
+ return "no confirmation queued"
+ }
+ return ""
+ },
+ },
+ "route /fleet/alerts/connectors/{id}/test": {
+ // A confirmed email connector, suspended: a test that gets through
+ // (to a mailer standing in for Keymail) turns it back on.
+ setup: func(t *testing.T, cx *claimCase) {
+ claimWorldAlertLinks(t, cx)
+ cx.srv.consoleMail, cx.srv.sendFederated = &fakeConsoleMail{ready: true}, nil
+ if _, err := cx.st.db.Exec(`UPDATE alert_connectors SET confirmed_at = 1, suspended_at = 1 WHERE id = ?`, cx.vars["alertconn"]); err != nil {
+ t.Fatal(err)
+ }
+ },
+ do: claimFormReply("/fleet/alerts/connectors/<alertconn>/test"),
+ status: http.StatusSeeOther, loc: "/fleet/alerts",
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if c, err := cx.claimAlertConnector(t); err != nil || c.Suspended {
+ return fmt.Sprintf("the connector is still suspended (%v)", err)
+ }
+ if n := len(cx.srv.consoleMail.(*fakeConsoleMail).sentCopy()); n != 1 {
+ return fmt.Sprintf("%d test emails sent, want 1", n)
+ }
+ return ""
+ },
+ },
+ "route /fleet/alerts/connectors/{id}/delete": {
+ setup: claimWorldAlertLinks,
+ do: claimFormReply("/fleet/alerts/connectors/<alertconn>/delete"),
+ status: http.StatusSeeOther, loc: "/fleet/alerts",
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if _, err := cx.claimAlertConnector(t); !errors.Is(err, sql.ErrNoRows) {
+ return fmt.Sprintf("the connector is still there (%v)", err)
+ }
+ if cx.sqlCount(t, `SELECT COUNT(*) FROM alert_tokens WHERE connector_id = ?`, cx.vars["alertconn"]) != 0 {
+ return "its links outlived it"
+ }
+ return ""
+ },
+ },
+ "route /fleet/alerts/rules/{rule}": {
+ do: claimFormReply("/fleet/alerts/rules/box_silent", "enabled", "on", "threshold", "30"),
+ status: http.StatusSeeOther, loc: "/fleet/alerts",
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if cx.sqlCount(t, `SELECT COUNT(*) FROM alert_rules WHERE scope = 'fleet' AND rule = 'box_silent' AND enabled = 1 AND threshold = 30`) != 1 {
+ return "box_silent is not on at 30 minutes"
+ }
+ return ""
+ },
+ },
+ "route POST /alerts/confirm/{token}": {
+ setup: claimWorldAlertLinks,
+ do: claimAlertDoorPost("/alerts/confirm/<alertconfirm>"),
+ body: []string{"Confirmed. Alerts now go to census."},
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if c, err := cx.claimAlertConnector(t); err != nil || !c.Confirmed {
+ return fmt.Sprintf("the connector is not confirmed (%v)", err)
+ }
+ if cx.sqlCount(t, `SELECT COUNT(*) FROM alert_tokens WHERE action = 'confirm' AND used_at IS NOT NULL`) != 1 {
+ return "the confirm link was not spent"
+ }
+ return ""
+ },
+ },
+ "route POST /alerts/unsubscribe/{token}": {
+ setup: claimWorldAlertLinks,
+ do: claimAlertDoorPost("/alerts/unsubscribe/<alertunsub>"),
+ body: []string{"Stopped. Nothing more will be sent to census."},
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if c, err := cx.claimAlertConnector(t); err != nil || !c.Suspended {
+ return fmt.Sprintf("the connector is not turned off (%v)", err)
+ }
+ return ""
+ },
+ },
+ "route POST /alerts/snooze/{token}": {
+ setup: claimWorldAlertLinks,
+ do: claimAlertDoorPost("/alerts/snooze/<alertsnooze>", "for", "1h"),
+ body: []string{"Snoozed until "},
+ effect: func(t *testing.T, cx *claimCase, r claimReply) string {
+ if on, err := cx.st.Snoozed(alertScopeFleet, "disk", "box-1", time.Now()); err != nil || !on {
+ return fmt.Sprintf("disk on box-1 is not snoozed (%v)", err)
+ }
+ return ""
+ },
+ },
+
// ---- operator economics ----
"route /api/economics/bill": {
do: claimAPIReply(http.MethodPost, "/api/economics/bill", `{"month":"`+claimBillMonth+`","total_usd":123.45,"services":{"AmazonEC2":55}}`),
diff --git a/internal/console/claim_invariant_probes_read_test.go b/internal/console/claim_invariant_probes_read_test.go
index b1ec3ca4a..97a224860 100644
--- a/internal/console/claim_invariant_probes_read_test.go
+++ b/internal/console/claim_invariant_probes_read_test.go
@@ -118,6 +118,47 @@ func claimWorldGeoip(t *testing.T, cx *claimCase) {
}
}
+// claimWorldAlertLinks is an unconfirmed fleet email connector, census, and
+// one alert link of each kind for it (the snooze for disk on box-1), their
+// tokens and its id in vars.
+func claimWorldAlertLinks(t *testing.T, cx *claimCase) {
+ t.Helper()
+ id, err := cx.st.AddAlertConnector(alertConnector{Scope: alertScopeFleet, Kind: alertConnectorEmail, Name: "census",
+ TargetHint: "census@example.com"}, nil, "census@example.com")
+ if err != nil {
+ t.Fatal(err)
+ }
+ cx.vars["alertconn"] = itoa(id)
+ for v, tok := range map[string]alertToken{
+ "alertconfirm": {Action: alertTokenConfirm, Scope: alertScopeFleet, ConnectorID: id, ExpiresAt: time.Now().Add(alertConfirmLinkTTL)},
+ "alertunsub": {Action: alertTokenUnsubscribe, Scope: alertScopeFleet, ConnectorID: id},
+ "alertsnooze": {Action: alertTokenSnooze, Scope: alertScopeFleet, Rule: "disk", Subject: "box-1", ExpiresAt: time.Now().Add(alertSnoozeLinkTTL)},
+ } {
+ raw, err := cx.st.NewAlertToken(tok)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cx.vars[v] = raw
+ }
+}
+
+// claimAlertDoorRead is an alert link's page, opened by a browser with no
+// session: the token in the path is the only credential.
+func claimAlertDoorRead(path string, want ...string) claimProbe {
+ return claimProbe{setup: claimWorldAlertLinks, body: want,
+ do: func(t *testing.T, cx *claimCase) claimReply { return cx.pageReplyAs(t, newBrowser(t), path) }}
+}
+
+// claimWorldAlertIncident is one closed fleet incident, disk on box-1.
+func claimWorldAlertIncident(t *testing.T, cx *claimCase) {
+ t.Helper()
+ now := time.Now()
+ if err := cx.st.CommitAlertStep([]alertIncident{{Scope: alertScopeFleet, Rule: "disk", Level: "incident",
+ OpenedAt: now.Add(-time.Hour), NotifyAt: now, ClosedAt: now, CloseReason: alertCloseCleared, Members: []string{"box-1"}}}, nil, nil); err != nil {
+ t.Fatal(err)
+ }
+}
+
func claimInvitePageProbe() claimProbe {
return claimProbe{
setup: claimInviteWorld,
@@ -172,6 +213,7 @@ var claimReadProbes = map[string]claimProbe{
"route GET /invite/{token}": claimInvitePageProbe(),
"route GET /fleet": claimPageRead(nil, "/fleet", "<h1>Dashboard</h1>"),
"route GET /fleet/activity": claimPageRead(nil, "/fleet/activity", "<h1>Activity</h1>"),
+ "route GET /fleet/alerts/history": claimPageRead(claimWorldAlertIncident, "/fleet/alerts/history", "<h1>History</h1>", `id="incident-1"`, "box-1"),
"route GET /fleet/boxes": claimPageRead(nil, "/fleet/boxes", "<h1>Boxes</h1>"),
"route GET /fleet/economics": claimPageRead(nil, "/fleet/economics", "<h1>Economics</h1>"),
"route GET /fleet/economics/accounts": claimPageRead(nil, "/fleet/economics/accounts", "<h1>Economics</h1>"),
@@ -183,6 +225,11 @@ var claimReadProbes = map[string]claimProbe{
"route GET /healthz": claimPageRead(nil, "/healthz", "ok"),
"route GET /static/{hash}/{file...}": claimPageRead(nil, assetURL("rastrillo/tokens.css"), "--rst-"),
+ // ---- alert links: each GET is a page with a button ----
+ "route GET /alerts/confirm/{token}": claimAlertDoorRead("/alerts/confirm/<alertconfirm>", "Confirm alerts to census"),
+ "route GET /alerts/unsubscribe/{token}": claimAlertDoorRead("/alerts/unsubscribe/<alertunsub>", "Stop alerts to census"),
+ "route GET /alerts/snooze/{token}": claimAlertDoorRead("/alerts/snooze/<alertsnooze>", "Snooze disk nearly full on box-1"),
+
// ---- redirects ----
"route GET /apps": claimRedirectRead("/apps", http.StatusFound, "/a/"),
"route GET /apps/{app}": claimRedirectRead("/apps/kass", http.StatusFound, "/a/"),
diff --git a/internal/console/opshell_test.go b/internal/console/opshell_test.go
index 5388e4007..b79fb9e65 100644
--- a/internal/console/opshell_test.go
+++ b/internal/console/opshell_test.go
@@ -201,8 +201,8 @@ func TestRailHidesStorageFromOtherOperators(t *testing.T) {
t.Fatalf("/fleet/index = %d", status)
}
links := opNavLinks(t, body)
- if len(links) != 7 {
- t.Fatalf("the rail has %d links, want 7: %+v", len(links), links)
+ if len(links) != 8 {
+ t.Fatalf("the rail has %d links, want 8: %+v", len(links), links)
}
if strings.Contains(body, `href="/fleet/store"`) {
t.Fatal("an operator not on StoreOperators is shown /fleet/store")
diff --git a/internal/console/opshots_test.go b/internal/console/opshots_test.go
index d414a296e..b376fad3c 100644
--- a/internal/console/opshots_test.go
+++ b/internal/console/opshots_test.go
@@ -32,6 +32,8 @@ var opShotPages = []struct{ name, path string }{
{"accounts", "/fleet/people?show=accounts"},
{"activity", "/fleet/activity"},
{"metrics", "/fleet/metrics"},
+ {"alerts", "/fleet/alerts"},
+ {"alerts-history", "/fleet/alerts/history"},
{"economics", "/fleet/economics"},
{"economics-accounts", "/fleet/economics/accounts"},
{"architecture", "/fleet/architecture"},
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt
index ab88f917e..70c810158 100644
--- a/internal/console/testdata/claim-routes.txt
+++ b/internal/console/testdata/claim-routes.txt
@@ -1,5 +1,9 @@
route /api/economics/backhaul
route /api/economics/bill
+route /fleet/alerts/connectors
+route /fleet/alerts/connectors/{id}/delete
+route /fleet/alerts/connectors/{id}/test
+route /fleet/alerts/rules/{rule}
route /fleet/architecture
route /fleet/architecture/refresh
route /fleet/economics/bill
@@ -42,6 +46,10 @@ route GET /a/{sqid}/team
route GET /a/{sqid}/trash
route GET /a/{sqid}/{$}
route GET /accounts/new
+route GET /alerts/confirm/{token}
+route GET /alerts/signing-key
+route GET /alerts/snooze/{token}
+route GET /alerts/unsubscribe/{token}
route GET /api/cli/accounts/{account}/plan
route GET /api/cli/apps
route GET /api/cli/apps/{account}/list
@@ -118,6 +126,8 @@ route GET /auth/signin
route GET /auth/stepup/callback
route GET /fleet
route GET /fleet/activity
+route GET /fleet/alerts
+route GET /fleet/alerts/history
route GET /fleet/boxes
route GET /fleet/economics
route GET /fleet/economics/accounts
@@ -190,6 +200,9 @@ route POST /a/{sqid}/store/apply
route POST /a/{sqid}/trash/delete
route POST /a/{sqid}/trash/restore
route POST /accounts/new
+route POST /alerts/confirm/{token}
+route POST /alerts/snooze/{token}
+route POST /alerts/unsubscribe/{token}
route POST /api/cli/accounts/{account}/plan
route POST /api/cli/accounts/{account}/store/apply
route POST /api/cli/accounts/{account}/store/approve
diff --git a/internal/console/testdata/perf-budgets.txt b/internal/console/testdata/perf-budgets.txt
index a2b47649e..6ef1b2585 100644
--- a/internal/console/testdata/perf-budgets.txt
+++ b/internal/console/testdata/perf-budgets.txt
@@ -40,6 +40,14 @@ GET /static/{hash}/{file...} skip: static asset, not a screen; consolePerfSkip l
/fleet/economics/bill skip: POST-only door; a GET answers 404 on its first line by design (economicspass.go)
/fleet/economics/scenarios skip: POST-only door; a GET answers 404 on its first line by design (economicspass.go)
/fleet/economics/tier skip: POST-only door; a GET answers 404 on its first line by design (economicspass.go)
+/fleet/alerts/connectors skip: POST-only door; a GET answers 404 on its first line by design (alertpages.go)
+/fleet/alerts/connectors/{id}/delete skip: POST-only door; a GET answers 404 on its first line by design (alertpages.go)
+/fleet/alerts/connectors/{id}/test skip: POST-only door; a GET answers 404 on its first line by design (alertpages.go)
+/fleet/alerts/rules/{rule} skip: POST-only door; a GET answers 404 on its first line by design (alertpages.go)
+GET /alerts/confirm/{token} skip: an alert link's page, opened from a message by whoever holds the link; the walk mints no alert token, and it reads one SQLite row
+GET /alerts/unsubscribe/{token} skip: an alert link's page, opened from a message by whoever holds the link; the walk mints no alert token, and it reads one SQLite row
+GET /alerts/snooze/{token} skip: an alert link's page, opened from a message by whoever holds the link; the walk mints no alert token, and it reads one SQLite row
+GET /alerts/signing-key skip: the webhook public key as plain text for receivers to fetch, not a screen
# Deferred parts: timed and printed, held to the 500 ms worst only.
GET /a/{sqid}/apps/new calls 1: the account telemetry settings, which set the analytics checkbox the form starts from (1 S3 call warm, 10 ms or less)
diff --git a/internal/provision/fleet_alerts_census_test.go b/internal/provision/fleet_alerts_census_test.go
new file mode 100644
index 000000000..de743423c
--- /dev/null
+++ b/internal/provision/fleet_alerts_census_test.go
@@ -0,0 +1,34 @@
+package provision
+
+// Record-write census entry for fleet alerts plan 1 (the alert engine and
+// connectors), layered on fleetPublicRoutesWriteCensusInventory. Reviewed by
+// the branch author. No record write is added, moved or reclassified:
+// - NewServer: Task 8 renames StartAlertWatcher to StartAlertEngine in
+// the comment saying no goroutine starts there; Task 10 registers the
+// Alerts pages (GET /fleet/alerts, GET /fleet/alerts/history and four
+// methodless operator POST doors) and the public alert links (confirm,
+// unsubscribe and snooze, GET and POST each, and GET
+// /alerts/signing-key), all in alertpages.go, which writes console.db
+// alert tables and nothing in the bucket. Same "instances" literal:
+// still key-site.
+func fleetAlertsWriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), fleetPublicRoutesWriteCensusInventory()...)
+ repins := []censusEntry{
+ {"internal/console/server.go", "NewServer", "key-site", "lit:instances", "09ac87c287d0eb18bf3276beb8c90e64b4e9f1c69f107720e56401fc7f8df599"},
+ }
+ for _, r := range repins {
+ found := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ if e.Class != r.Class || e.Kinds != r.Kinds {
+ panic("fleet-alerts re-pin changes the class or kinds of " + r.File + ":" + r.Unit)
+ }
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ panic("fleet-alerts re-pin of an unlisted unit " + r.File + ":" + r.Unit)
+ }
+ }
+ return entries
+}
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 893794f4d..02e032572 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := fleetPublicRoutesWriteCensusInventory()
+ inventory := fleetAlertsWriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))