Fleet alerts Plan 1: build rulings R-1..R-45 open
On branch design-fleet-alerts
Controller rulings made while building fleet alerts Plan 1 (subagent-driven). Each says what was decided and what it costs if wrong. Ledger order.
- Ruling R-1: engine_silent is evaluated in metrics.Evaluate like every box rule: host computes
Observation.EngineSilent *bool(nil = unarmed) from beatState + grace, and alertTick gains abeat *engineBeatWatchparameter in T3 — keeps rule state, hysteresis and the alerts/boxes file uniform — cost if wrong: one extra parameter refactor. - Ruling R-2: T8 stores an alertNote (without URLs) as body_json; T6 mints the snooze (bound to the incident key, 30 d) and unsubscribe (bound to the connector) tokens at render time per delivery and fills the URLs — tokens exist only for messages actually sent — cost if wrong: token rows grow per sent message (alerts are rare).
- Ruling R-3: per-task reviewers: Sonnet for T1, T2, T4, T7, T9, T11; Opus for T3 (root-adjacent), T5, T6, T8, T10 (security gates); whole-branch review by Astra — AGENTS.md stopping rule 3 — cost if wrong: a security issue found later at the whole-branch review.
- Ruling R-4: DiskTrend uses the Theil–Sen estimator (median of pairwise slopes over the window's points; at most 360 points, ~64k pairs/minute) and projects from the latest observed used bytes. A single step makes at most half the pairs positive, so the median slope stays ≤ 0, while steady growth gives the true slope — robust where OLS is not — cost if wrong: slower reaction to growth that only began in the last third of the window (it fires once over half the pairs see it).
- Ruling R-5: commit trailers name the model that actually wrote the commit (Sonnet 5.5 for Sonnet implementers) — honest attribution — cost if wrong: none.
- Ruling R-6: Theil–Sen's exact-centre step (50.14% positive pairs) forecasts for ~20 min as the step crosses the centre; accepted because the 2 h hold can't be met by it — cost if wrong: one false forecast only if a box makes repeated steps exactly every ~3 h for 2 h straight.
- Ruling R-7: the heartbeat recomputes verdict(time.Now()) rather than reading a cached last ETA — it gains the 5-minute stale guard for one 64k-pair fit per 5 minutes — cost if wrong: negligible CPU.
- Ruling R-8: engineBeatLstat is accepted as a new root-read census unit with a claim (runtime-refused for euid 0); the census is source-only and the reviewer decides its class at Task 11 — cost if wrong: the census reviewer asks for a different disposition at merge.
- Ruling R-9: Minors 1 (PostJSON *url.Error puts the Slack URL path, i.e. the secret, into the journal) and 3 (a firing engine_silent never clears once unarmed) enter fix round 1, because they break the Global Constraint "errors reduced to URL-free categories before anything stores or logs them" and the anti-goal of a permanent open incident; Minor 4 (ignored Symlink error) is cheap and rides along — cost if wrong: one extra fix round.
- Ruling R-10: outbox rows for fire/clear/update/reminder are only ever built for incidents already persisted (Task 7 emits a fire only at notify_at, after the opening pass committed) — Task 8 must assert IncidentID != 0 for those kinds before CommitAlertStep — cost if wrong: an emit for an unsaved incident would be dropped by the assertion rather than mis-linked.
- Ruling R-11: a successful test send on a suspended connector lifts the suspension (Task 6 sendTestAlert, via a new store accessor) — gives operators a way back without delete/re-add — cost if wrong: one accessor.
- Ruling R-12: refusedAddr also refuses NAT64 64:ff9b::/96 and 64:ff9b:1::/48 (they can translate to private IPv4 on a NAT64 host); joins the fix round — cost if wrong: a webhook on a NAT64-only network can't use the translated path.
- Ruling R-13: the plan-mandated duplication is fixed by extracting shared ed25519Key/signLabelled/labelledBytes (mail outputs unchanged byte for byte); the address/host/header hardening minors (IPv4-compatible, 6to4, Teredo, 240/4, 198.18/15, fec0::/10, numeric hosts, ASCII Slack host, checked URL object, 16 KiB headers) ride in the same fix round because they sit on the same security boundary — cost if wrong: one larger fix diff.
- Ruling R-14: held rows (unconfirmed, suspended, needs re-entry, no seal) are not failed attempts — re-check them every 5 minutes with attempts unchanged, and the connector's health untouched — so confirming or resuming a connector delivers within 5 minutes, not up to 12 h — joins the fix round — cost if wrong: a held row is rescanned 288 times a day (cheap SQLite).
- Ruling R-15: alertNote.ConfirmURL accepted; confirm links are <origin>/alerts/confirm/<token> (Task 10 must match); verify emails end with the confirm link instead of unsubscribe and the owner suspension email has none (nothing to unsubscribe from) — cost if wrong: copy tweak.
- Ruling R-16: Minors 1 (completed send recorded even if ctx ends after), 2 (ErrNoRows drops the row), 4 (note scope must equal connector scope), 5 (scope check before operator delete), 6 (no health for unconfirmed), 8 (log a lost suspension notice) ride in fix round 1 — they are correctness or tenancy checks on the same drain — cost if wrong: a larger fix diff.
- Ruling R-17: accepted the implementer's Task 7 design — LastSeenAt doubles as the flapping "quiet since" (zero while firing; no new column, idle steps stay empty); Members = firing now; emits exclude snoozed subjects (Task 8 takes message members from the emit); a snoozed fire is released when the snooze ends if still firing; Gone stores "box gone", shown as "no further reports"; flapping final clear emitted if notified — cost if wrong: a later reader misreads LastSeenAt; the reviewer is asked to judge it.
- Ruling R-18: fix round 1 adds a seeded randomized invariant simulation (500 seeds × 3 days) over the noise rules, alongside the specific fixes — per memory invariant-simulations-over-example-fixes, so later rounds don't find interleavings one by one — cost if wrong: ~10 s of test time.
- Ruling R-19: update gate = now ≥ LastReminderAt+30m (fire and reminder set LastReminderAt) and now ≥ LastUpdateAt+1h — keeps spec §6.2's "after 30 minutes" while stopping an update right after a late fire — cost if wrong: one gate expression.
- Ruling R-20: operator email seeding runs every pass (idempotent), not only the first pass after start — an operator granted later is covered within a minute — cost if wrong: one cheap SQL per pass.
- Ruling R-21: an unusable seal key is not a job failure; the pass completes with a job-status note and the seal_key incident carries the alert — a per-minute Failed job would add noise to the dashboard's failed-jobs list — cost if wrong: one status path.
- Ruling R-22: accepted regressions — a geoip reason change while firing no longer re-mails (the engine sends one message per fire); a box whose alert file can't be read on the cutover pass may re-fire to operators already told — cost if wrong: one extra message in rare cases.
- Ruling R-23: fix round 1 also takes Minors 1 (HostClaim recorded as off, not Failed), 2 (boxsilent membership not dropped by the 24 h ListMod horizon; alertClockNow), 5 (one box name: the object key), 7 (delete dead alertMessage), 8 (marshal errors), 9 (no jobFailed on cancelled ctx), 11 (move the engine to alertenginepass.go) — correctness, noise or reviewability on the same code — cost if wrong: a larger fix diff.
- Ruling R-24: each operator address is seeded once ever (durable alert_meta marker written with the connector) — so deleting a seeded connector sticks, while later-granted operators are still seeded within a minute — cost if wrong: an operator who deleted theirs by mistake re-adds it by hand.
- Ruling R-25: reverses R-23 Minor 2 — keep the 24 h ListMod horizon (matching LoadBoxes); a box silent past it closes as "no further reports" — status/boxes objects are never deleted, so keeping all keys made every replaced box a permanent member and broke the 200-key cap — cost if wrong: a box dead for over a day stops alerting after its incident and reminders.
- Ruling R-26: an operator with no usable connector is a job note, not a failure (as R-21); revoking deletes the seeded marker with the connector so re-granting re-seeds — cost if wrong: the dashboard's failed-jobs list no longer flags an unreachable operator.
- Ruling R-27: keep the approved job label "Alert checks" (OPS-84) instead of "Alert engine" — no reason to churn approved copy — cost if wrong: one label.
- Ruling R-28: message snooze links carry no duration; the snooze door's GET shows a page with three buttons (1 hour, 1 day, 1 week) that POST with for=1h|1d|1w — Task 10 builds it — cost if wrong: one extra click.
- Ruling R-29: threshold bounds — boxsilent 5..1440 minutes, certexpiring 1..60 days — cost if wrong: an operator can't set an extreme value.
- Ruling R-30: the signing-key route serves the bare base64 key as text/plain, no prose — receivers fetch it programmatically — cost if wrong: none.
- Ruling R-31: on Luna's flags — (1) subjectless fire/update/clear variants are derived from the Luna-approved strings by dropping the subject clause, marked "derived" in the deck; (2) job notes carry no %v diagnostics (the seal read/size fragments stay in logs only); (3) box disketa and enginesilent strings are separate, derived from the approved group 3 fire/clear text; (4) box alerts reuse the approved group 3 "how long" and "what to do" lines for the same rule; (5) the box formatter passes the group 2 display name, not the rule ID — copy approved by delegation (memory large-copy-decks-delegated) — cost if wrong: copy edits after Paul reads a live alert.
- Ruling R-32: display names take a lower-case first letter mid-sentence; Luna's capital "Location" in box.geoip.2 is a slip, lower-cased; the email send category gets "Email delivery failed." (derived) — cost if wrong: copy edits.
- Ruling R-33: a reason composed after a colon starts lower-case ("The test did not get through: the address did not respond in time.") — applied in Task 10 to alertTestFailed and conn.added.webhook.failed — cost if wrong: copy edit.
- Ruling R-34: GET /fleet/alerts and /alerts/signing-key are classed nonApp writes because the signing key is created on first use — accurate to what the code does — cost if wrong: a census reviewer asks for the key to be created at startup instead.
- Ruling R-35: fix round 1 takes minors 1 (4 KiB body cap + ParseForm on public door POSTs), 2 (show an unsubscribed connector distinctly; test lift clears the marker), 3 (confirm on a suspended connector says paused), 4 (absent threshold keeps the stored value), 10 (201-row fetch for the "older not shown" note) — public-door hardening and truthful status — cost if wrong: a small fix diff.
- Ruling R-36: fix round 1 takes the Important plus the doc minors (em dash, beat wording, double delivery note, wraps, safe host.env appends, witness no-clear instruction and worst case, per-step account lines, other consoles out of scope, cli.md engine-beat suffix) — docs only, cheap — cost if wrong: none.
- Ruling R-37: unsubscribe clears confirmed_at; only the recipient's fresh confirm lifts it; a test never does (failure suspensions still lift on a test) — recipient consent outranks operator convenience — cost if wrong: an operator needs the recipient to click a new link.
- Ruling R-38: every process's first pass reconciles decryptability of every sealed target and persists needs_reentry; the drain's seal hold persists it too — cost if wrong: one Open per sealed connector per start.
- Ruling R-39: a flapping incident enters its quiet hold whenever firingMembers empties (clear or Gone), replacing the fire-timestamp reconstruction — cost if wrong: a fully retired flapping group holds 1 h before closing.
- Ruling R-40: cert_expiring counts as covered only when no listed box was excluded as stale — missing evidence never clears — cost if wrong: a cert alert stays open while a box is stale.
- Ruling R-41: no unconditional fallbacks after GetIfChanged/ListMod errors (capability absence still uses the plain call) — cost if wrong: one source reads as unread during an outage.
- Ruling R-42: setting a rule Off deletes its unsent incident rows in the same transaction; the drain rechecks enablement — cost if wrong: an alert queued just before Off is lost (intended).
- Ruling R-43: README and roll notes get a Luna docs pass, applied verbatim — cost if wrong: docs edits.
- Ruling R-44: Luna docs flags — witness History check says 'one incident created by the witness'; host-claim statement stands (claims shelved); roll notes open with a reconfirm-inventory line — cost if wrong: none.
- Ruling R-40b: replaces R-40's implementation — cert_expiring is judged from fresh boxes; an open member missing from fresh readings is kept (no Gone) while any listed box is stale; Gone only with no stale box — R-40 as built silenced every cert alert for up to 24 h after a box replacement — cost if wrong: a retired host's cert incident stays open until the stale box ages out.
- Ruling R-45: the fixer's three corrected README lines stand over Luna's wording (Luna's versions reversed facts) — facts outrank wording — cost if wrong: copy edits.