From e988e73b9e82f85e2c3e272d430f8127f00db5a1 Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:47:02 +0000 Subject: [PATCH 1/2] fix(backup): the age-key proof has no deadline and no alert (ADR-0120) SecretsKeyBackupUnproven and SecretsKeyRecipientsUnrecorded are removed with their tests, verify-key-backup and verify-key-backup-sensitive leave install-timers.sh, and Glance stops listing the proof. The stale-job rules and ScheduledJobNeverRan skip both names so an older homelab-jobs.prom stays quiet. make secrets-verify-backup stays as an optional check. Closes #671. Co-Authored-By: Claude Opus 5.5 --- Makefile | 20 +- README.md | 16 +- ...recipient-and-prove-each-one-separately.md | 5 + .../0120-drop-the-age-key-proof-deadline.md | 57 ++++ docs/changelog.md | 23 ++ docs/observability.md | 40 +-- docs/roadmap.md | 21 +- docs/runbooks/back-up-the-age-key.md | 86 ++---- docs/runbooks/copy-the-backups-offsite.md | 12 +- docs/runbooks/deploy-stack.md | 2 +- docs/runbooks/schedule-maintenance.md | 36 +-- docs/runbooks/successor-handover.md | 2 +- docs/security.md | 11 +- scripts/add-recipient.sh | 16 +- scripts/check_sops_rules.py | 4 +- scripts/install-timers.sh | 73 ++--- scripts/key-recipients.sh | 8 +- scripts/verify-key-backup.sh | 13 +- stacks/observability/README.md | 2 +- .../prometheus/rules/backup.rules.yaml | 184 +++---------- .../prometheus/tests/backup.test.yaml | 251 +----------------- stacks/sensitive/glance/pages/maintenance.yml | 34 +-- systemd/homelab-recipient-state.service | 14 +- 23 files changed, 258 insertions(+), 672 deletions(-) create mode 100644 docs/adr/0120-drop-the-age-key-proof-deadline.md diff --git a/Makefile b/Makefile index 618a640a..87302018 100644 --- a/Makefile +++ b/Makefile @@ -503,9 +503,9 @@ recipient-state: ## Record which age recipients can open the secrets, and when e @# Reads the recipient list out of the encrypted file's own metadata and @# writes one series per recipient into the textfile dir, carrying every @# existing proof timestamp forward and setting none. Needs no key: the - @# `sops:` block is plaintext. This is what SecretsKeyBackupUnproven reads; - @# without it a host that proved its key before ADR-0024 has no series and - @# the ninety-day nag is silent. secrets-verify-backup is what sets a proof. + @# `sops:` block is plaintext. No alert reads it since ADR-0120; it is the + @# recipient list remove-recipient.sh checks against. secrets-verify-backup + @# is what sets a proof. ./scripts/key-recipients.sh --record --stack $(STACK) .PHONY: ca-key-state @@ -741,15 +741,11 @@ secrets-verify-backup: ## Check a backup age key decrypts the secrets (KEY=/path printf 'See docs/runbooks/back-up-the-age-key.md\n' >&2; \ exit 2; \ } - @# Wrapped, even though a human runs it, and that is the whole point of #77. - @# This is the one job that cannot be put on a timer — verify-key-backup.sh - @# refuses the live key by device:inode precisely so that what gets tested is - @# a copy on removable media, and no timer can mount that. So the schedule is - @# enforced from the other end: a successful run records its timestamp, and - @# SecretsKeyBackupUnproven fires when that proof passes ninety days old. - @# Nagging is not as good as running it, but it beats remembering. - @# STACK=sensitive records verify-key-backup-sensitive, trinity's row in - @# install-timers.sh: a job name may be declared on one host only. + @# Optional since ADR-0120: run it when you want to know a copy of the key + @# still opens the secrets. Nothing waits for it and no alert fires if it + @# is never run. verify-key-backup.sh refuses the live key by device:inode, + @# so what gets tested is a copy. Wrapped so the run is still recorded; + @# STACK=sensitive records it as verify-key-backup-sensitive. ./scripts/run-scheduled.sh --job verify-key-backup$(if $(filter sensitive,$(STACK)),-sensitive) --lock keys \ -- ./scripts/verify-key-backup.sh "$(KEY)" $(STACK) diff --git a/README.md b/README.md index b3ed4120..26501b0a 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ documents for different readers. can't run an agent (firewall, switch, UPS, iLO). One agent config, deployed identically everywhere. [How](docs/architecture.md#observability-data-flow) - **Dashboards and alerting as code.** 8 provisioned dashboards, 156 panels, and - 185 alert rules — 164 metric-based in Prometheus, 21 log-based in Loki — sharing + 183 alert rules — 162 metric-based in Prometheus, 21 log-based in Loki — sharing one Alertmanager routing tree. No dashboard exists only in a database. - **Secrets encrypted in-repo with SOPS + age.** Per-device credentials, decrypted at deploy time into gitignored paths, with `git log` showing which @@ -136,7 +136,7 @@ documents for different readers. at all. Every pinned digest is also scanned weekly for fixable HIGH and CRITICAL CVEs, and each image with findings has an open issue until a scan finds it clean. -- **Documented decisions and runbooks.** 119 ADRs covering what was chosen +- **Documented decisions and runbooks.** 120 ADRs covering what was chosen and what was rejected — including the costs accepted knowingly; 55 runbooks for the operations that are easy to get wrong at 1am, one of which is the handover page a successor reads first. Every critical alert links to @@ -207,7 +207,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology . ├── stacks/ │ ├── observability/ # the estate's stack on prometheus — ten services -│ │ ├── prometheus/ # config, file_sd targets, 164 alert rules +│ │ ├── prometheus/ # config, file_sd targets, 162 alert rules │ │ ├── alertmanager/ # routing and inhibition │ │ ├── loki/ # single-binary config + 21 LogQL rules │ │ ├── alloy/ # the agent config directory, shipped to every host @@ -236,7 +236,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology │ ├── architecture.md network.md hardware.md │ ├── observability.md security.md roadmap.md changelog.md │ ├── diagrams/ # the network diagram (SVG) and its predecessors -│ ├── adr/ # 119 ADRs — architecture decision records +│ ├── adr/ # 120 ADRs — architecture decision records │ ├── exercises/ # purple-team exercise records — see its README │ └── runbooks/ # 55 runbooks; successor-handover.md is the front door └── Makefile # make help @@ -320,9 +320,11 @@ $ make help The timers are what stop `backup`, `backup-firewall`, `snmp-verify` and now deployment itself being things someone has to remember, and the alert rules that come with them fire on a job having *stopped being run* rather than only on one that failed -([#77](https://github.com/Gerrrt/HomeLab/issues/77)). One job deliberately has no -timer: `secrets-verify-backup` needs a human to mount removable media, so it gets -a ninety-day deadline and an alert instead. See +([#77](https://github.com/Gerrrt/HomeLab/issues/77)). The human proofs that need +removable media, such as `certs-verify-backup`, have no timer and get a +ninety-day deadline and an alert instead. `secrets-verify-backup` is optional +and has no deadline +([ADR-0120](docs/adr/0120-drop-the-age-key-proof-deadline.md)). See [`docs/runbooks/schedule-maintenance.md`](docs/runbooks/schedule-maintenance.md). ## Dashboards diff --git a/docs/adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md b/docs/adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md index 7778dc59..609e1b1c 100644 --- a/docs/adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md +++ b/docs/adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md @@ -3,6 +3,11 @@ **Status:** Accepted · 2026-09 > [!NOTE] +> **No proof deadline, 2026-11-20.** +> [ADR-0120](0120-drop-the-age-key-proof-deadline.md) removes part 3's +> ninety-day deadline and `SecretsKeyBackupUnproven`. Proving a copy is +> optional and still recorded per recipient. Parts 1 and 2 are unchanged. +> > **The second recipient also opens the household's copy, 2026-10-01.** > [ADR-0073](0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md) > adds it to `stacks/sensitive/household.recipients` as the fallback behind diff --git a/docs/adr/0120-drop-the-age-key-proof-deadline.md b/docs/adr/0120-drop-the-age-key-proof-deadline.md new file mode 100644 index 00000000..95535128 --- /dev/null +++ b/docs/adr/0120-drop-the-age-key-proof-deadline.md @@ -0,0 +1,57 @@ +# ADR-0120: Drop the age-key proof deadline + +**Status:** Accepted · 2026-11 · amends [ADR-0024](0024-hold-a-second-age-recipient-and-prove-each-one-separately.md) + +## Context + +[ADR-0024](0024-hold-a-second-age-recipient-and-prove-each-one-separately.md) +part 3 gave every age recipient its own ninety-day proof. A human mounts an +offline copy of the key, runs `make secrets-verify-backup`, and +`SecretsKeyBackupUnproven` fires for any recipient whose last proof is older +than that. `SecretsKeyRecipientsUnrecorded` was added later (#400) for a host +that declared the deadline and had no per-recipient series. #1501 extended the +deadline to `trinity` as `verify-key-backup-sensitive`. + +Neither key has ever been proved on `trinity`, and the operator does not +intend to start. A trinity audit on 2026-11-20 raised the proofs again. The +operator's position is that recurring offline and off-site key drills are too +much for a home lab. They also rule out bringing in anyone outside the family +as a technical second to hold or check a copy. An alert that is never acted on is noise, and it trains +the operator to ignore the channel the real alerts arrive on. + +## Decision + +**The age-key proof has no deadline and no alert.** + +- `verify-key-backup` leaves `JOBS` and `verify-key-backup-sensitive` leaves + `SENSITIVE_JOBS` in `scripts/install-timers.sh`. +- `SecretsKeyBackupUnproven` and `SecretsKeyRecipientsUnrecorded` are removed + from `backup.rules.yaml`, with their tests. +- The Glance maintenance page stops listing the age-key proof. +- `ScheduledJobStale`, `ScheduledJobStaleCritical` and `ScheduledJobNeverRan` + skip both names. A host whose `homelab-jobs.prom` predates this change then + stays quiet until `make install-timers` rewrites it. + +**`make secrets-verify-backup` stays, as an optional check.** It still proves +that a copy opens the secrets, and it still records which recipient was +checked. Nothing waits for it. + +**`recipient-state` stays.** It still writes `key-recipients.prom` daily. +`remove-recipient.sh` reads the recipient list from that file, and keeping it +current costs nothing. + +**Unchanged:** ADR-0024 parts 1 and 2 (the second recipient, and how one is +added) and `check_sops_rules.py`'s rule that a stack guarding data has two +recipients. The CA key's proof (`CaKeyBackupUnproven`, ADR-0043), the off-site +copy (`OffsiteCopyStale`, ADR-0048) and the household copy +(`HouseholdCopyStale`, ADR-0073) are also unchanged. Each has its own deadline +and is a separate decision. + +## Consequences + +- A lost or corrupted offline key copy is found only when someone goes to use + it. The operator accepts that. +- One reason for `recipient-state` is gone. The timer stays for the file it + writes. +- Proving a copy is still possible and is still recorded, so a later decision + to bring the deadline back is a timer row and a rule, not new tooling. diff --git a/docs/changelog.md b/docs/changelog.md index 7e655d73..e91cca09 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,6 +17,29 @@ roadmap as it read that day, and the *Done* entries keep the shape they had there. `check_docs.py` does not check this file, for the reason its module docstring gives: it is a record, not a claim about now. +## 2026-11-20 + +- **The age-key proof has no deadline and no alert.** + [ADR-0120](adr/0120-drop-the-age-key-proof-deadline.md) amends ADR-0024 part + 3. `SecretsKeyBackupUnproven` and `SecretsKeyRecipientsUnrecorded` are + removed with their tests, which takes the Prometheus rules from 164 to 162. + `verify-key-backup` and `verify-key-backup-sensitive` leave `install-timers.sh`'s + tables, and the Glance maintenance page stops listing them. + - **Optional.** `make secrets-verify-backup` still checks a copy and records + which recipient it checked. + - **Kept.** `recipient-state` still writes `key-recipients.prom` daily, for + `remove-recipient.sh`. + - **Old declarations stay quiet.** The stale-job rules and + `ScheduledJobNeverRan` skip both names. A host whose `homelab-jobs.prom` + predates this change is therefore quiet until `make install-timers` + rewrites the file. + - **Unchanged.** The CA key, off-site and household deadlines. + - **#671 closes.** Its remaining step was proving the lab key's second + recipient. Its section, *Saruman: the domain, then the SOC*, leaves the + roadmap empty. + - **This reverses part of the 2026-11-14 entry.** That entry added + `verify-key-backup-sensitive` (#1501). The row is gone again. + ## 2026-11-19 - **`phoenix`'s own way in is closed: `sshd` takes keys only, and `ufw` is diff --git a/docs/observability.md b/docs/observability.md index ed836857..1290600b 100644 --- a/docs/observability.md +++ b/docs/observability.md @@ -352,7 +352,7 @@ separates a quiet stream from a stopped one. ## Alerting -185 rules in total: 164 metric-based in `prometheus/rules/`, and 21 log-based in +183 rules in total: 162 metric-based in `prometheus/rules/`, and 21 log-based in `loki/rules/`. ### Log-based (Loki ruler) @@ -513,7 +513,7 @@ argument and for what to do when it exits 1. ### Metric-based (Prometheus) -164 rules across twelve files in `prometheus/rules/`: +162 rules across twelve files in `prometheus/rules/`: | File | Covers | | --- | --- | @@ -525,7 +525,7 @@ argument and for what to do when it exits 1. | `watchdog.rules.yaml` | One rule that always fires, so that its absence is detectable | | `blackbox.rules.yaml` | Whether an endpoint can actually be reached, from outside the service, and how many days its certificate has left — the sensitive tier's seven-day ACME leaves excepted, which an hours pair watches for a stalled renewal instead — `TlsAcmeRenewalLate` at 48h, `TlsAcmeRenewalStalled` at 36h ([#426](https://github.com/Gerrrt/HomeLab/issues/426)) — Grafana and the wiki verified against the lab CA ([#847](https://github.com/Gerrrt/HomeLab/issues/847)), the APC card's self-signed one read but not trusted, Prometheus, Loki and Alertmanager over plain http (the switch UI's probes were removed on 2026-09-06, `targets/blackbox.yaml`), each of the household sites behind `trinity`'s Caddy, verified against the tier's root, paging as `SiteDown` after ten minutes so a `make up` restart does not ([#855](https://github.com/Gerrrt/HomeLab/issues/855)), and — the other way round — that the ingest proxy on `10.0.99.20:9090` and `:3100` still refuses a request with no token (`IngestAuthNotEnforced`, [#182](https://github.com/Gerrrt/HomeLab/issues/182)). `EeroUnreachable` is a warning for an eero unit that has not answered ping for five minutes, from the `blackbox-eero` job, through one Winterfell pass in force since 2026-11-11 ([#1228](https://github.com/Gerrrt/HomeLab/issues/1228), [ADR-0112](adr/0112-probe-the-eeros-by-icmp-from-prometheus.md)). The iLO and pfSense UIs are written into `targets/blackbox.yaml` and left disabled: each needs a firewall pass from `10.0.99.20` that is a segmentation decision, not a monitoring one ([#91](https://github.com/Gerrrt/HomeLab/issues/91)). Their certificates' expiry is watched without that pass, from `host.rules.yaml` ([#857](https://github.com/Gerrrt/HomeLab/issues/857)) | | `dns.rules.yaml` | Whether the house is still filtering DNS, asked directly at AdGuard Home on port 53 rather than through pfSense. Since [ADR-0055](adr/0055-forward-to-adguard-alone.md) AdGuard is the only forwarder, so `AdGuardNotAnswering` is **critical** at five minutes: the house cannot resolve outside names. `AdGuardNotFiltering` stays a warning, because a filter that fails open is a convenience lost, not an outage. The targets in `targets/blackbox-dns.yaml` are live since 2026-09-28, against AdGuard on `trinity` ([#126](https://github.com/Gerrrt/HomeLab/issues/126), [#404](https://github.com/Gerrrt/HomeLab/issues/404)) | -| `backup.rules.yaml` | Whether the scheduled maintenance jobs are still being run at all — staleness, failure, never-ran, and the page: `ScheduledJobStaleCritical` at three of a job's own periods and never under a day, because the warning reaches only the in-house channel and a backup that stopped in week one was otherwise a notification repeating on the same network for as long as nobody acted (2026-10-14) — whether the age-key proof record exists to be held to its deadline, whether the CA key's offline copy has been proved lately ([#496](https://github.com/Gerrrt/HomeLab/issues/496)), whether the newest backup sets have been carried onto the second recipient's medium within ninety days ([ADR-0048](adr/0048-carry-the-estates-backup-sets-with-the-second-recipient.md)), and whether the household's copy has been carried to the holder's drive within ninety days and proved by the holder within a year ([ADR-0073](adr/0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md)) | +| `backup.rules.yaml` | Whether the scheduled maintenance jobs are still being run at all — staleness, failure, never-ran, and the page: `ScheduledJobStaleCritical` at three of a job's own periods and never under a day, because the warning reaches only the in-house channel and a backup that stopped in week one was otherwise a notification repeating on the same network for as long as nobody acted (2026-10-14) — whether the CA key's offline copy has been proved lately ([#496](https://github.com/Gerrrt/HomeLab/issues/496)), whether the newest backup sets have been carried onto the second recipient's medium within ninety days ([ADR-0048](adr/0048-carry-the-estates-backup-sets-with-the-second-recipient.md)), and whether the household's copy has been carried to the holder's drive within ninety days and proved by the holder within a year ([ADR-0073](adr/0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md)) | | `deploy.rules.yaml` | Whether each host that pulls — `prometheus` and `trinity` ([#533](https://github.com/Gerrrt/HomeLab/issues/533)) — is running what the repository says: an uncommitted edit made on the host, a revision that did not verify, and how far behind `main` it is, and a host whose record stopped arriving. Reads the record `scripts/converge.sh` writes hourly ([#99](https://github.com/Gerrrt/HomeLab/issues/99), [ADR-0021](adr/0021-converge-on-a-timer-instead-of-deploying-over-ssh.md)). Also whether convergence had to start a stack service that something stopped — `DeployServiceRevived` — and whether one has been left stopped for two hours, held or under a backup — `DeployServicesStopped` ([ADR-0087](adr/0087-start-a-stopped-stack-service-from-the-converge-timer.md)) | | `internet.rules.yaml` | Why the internet is slow ([#914](https://github.com/Gerrrt/HomeLab/issues/914)): three scheduled speed tests in a row under 400 Mbit/s down or 100 up, the WAN held above 85% of what it can carry, frames arriving corrupted on the WAN port — `WanReceiveErrors`, the fault found the day these were written, when a cable between the XB7 and `morpheus` cut downloads to ~2 Mbit/s — and `speedtest-tracker` itself going quiet or unreachable. Also records `homelab_wan_bits_per_second` from pf's own em0 counters. Download thresholds are against the ~940 Mbit/s the 1000baseT WAN port can carry, not the plan's 2000. `speedtest-tracker` is left out of `InstanceDown`, so its outage is a warning and not a page | | `ids.rules.yaml` | Whether Suricata is running on each interface it is declared for, read from the firewall's process table over SNMP — the fast, per-interface half; `SuricataLogsStopped` in `loki/rules/security.rules.yaml` is the slow, aggregate half ([#90](https://github.com/Gerrrt/HomeLab/issues/90), [#441](https://github.com/Gerrrt/HomeLab/issues/441)) | @@ -549,7 +549,7 @@ as loaded and healthy and could not fire for any input ([#63](https://github.com `prometheus/tests/*.test.yaml` holds `promtool test rules` unit tests, which feed a rule synthetic series and assert it fires — paired with a case asserting it stays quiet, because a test that only ever expects silence would have passed -against the broken rule too. Coverage is 164 rules of 164 so far ([#843](https://github.com/Gerrrt/HomeLab/issues/843)) — all twelve +against the broken rule too. Coverage is 162 rules of 162 so far ([#843](https://github.com/Gerrrt/HomeLab/issues/843)) — all twelve in `blackbox.rules.yaml`, all three in `dns.rules.yaml`, `GatewayFilesystemCritical`, `ContainerHighMemory`, `ContainerNearMemoryLimit`, `ContainerRestartLoop`, `ContainerCpuThrottled`, the three container-state rules from @@ -962,8 +962,8 @@ The threshold each job is held to is a *fifth* series, `homelab_job_max_age_seconds`, written by `scripts/install-timers.sh` from the same table that decides the cadence. That is what lets the rules in `prometheus/rules/backup.rules.yaml` cover every job without naming any of them -— the three that do name one concern the two human proofs, `verify-key-backup` -and `verify-ca-key-backup`, below — and what makes `make check-timers` able to assert that a threshold is +— the ones that do name one concern the human proofs, such as +`verify-ca-key-backup`, below — and what makes `make check-timers` able to assert that a threshold is at least twice its timer's real period. Two things are deliberate and easy to undo by accident: @@ -983,22 +983,15 @@ checking, with the key that is on that machine, against the disk that is in it. `verify-backups` proves an archive still decrypts; it says nothing about a dead disk or a fire. The jobs that prove anything beyond this shelf are the ones that cannot be automated, because each needs a human to mount removable media: -`secrets-verify-backup` for the key, and since +`secrets-verify-backup` for the key, optional and with no deadline since +[ADR-0120](adr/0120-drop-the-age-key-proof-deadline.md), and since [ADR-0048](adr/0048-carry-the-estates-backup-sets-with-the-second-recipient.md) `backup-offsite` for the sets themselves, which carries the newest of each kind onto the -second recipient's medium and hashes it there. `SecretsKeyBackupUnproven` and -`OffsiteCopyStale` nag at ninety days instead. On `trinity`, `household-copy` +second recipient's medium and hashes it there. `OffsiteCopyStale` nags at +ninety days instead. On `trinity`, `household-copy` and `household-proof` are the household's equivalents ([ADR-0073](adr/0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md)), -and `HouseholdCopyStale` nags at ninety days and at a year. `SecretsKeyBackupUnproven` is the one rule in `backup.rules.yaml` not keyed -on `homelab_job`: -[ADR-0024](adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md) -allows the secrets to be encrypted to more than one age recipient, so it fires -per recipient off `homelab_key_recipient_last_proof_timestamp_seconds` rather -than off the job. One timestamp for every copy would mean proving either one -vouched for the other, which is backwards when the whole point of the second -copy is that it fails independently. With a single recipient it behaves exactly -as it always has. Three outputs leave: `backup-firewall` copies each export +and `HouseholdCopyStale` nags at ninety days and at a year. Three outputs leave: `backup-firewall` copies each export to `oracle` and fails if it cannot, so its failure alert doubles as "the config has stopped leaving this host"; since [#535](https://github.com/Gerrrt/HomeLab/issues/535) `backup-volumes` does the @@ -1009,17 +1002,6 @@ copies its set the same way. `verify-backups` hashes the far side of both set directories every morning. No rule names any of the three; the generic pair carries them all. -That series has to exist for the nag to mean anything, and for four days it did -not ([#400](https://github.com/Gerrrt/HomeLab/issues/400)): it was written only -by a proof run or by adding a recipient, and this host had proved its key before -the series was invented, so the rule went quiet the day it was deployed while -the fallback it named — `ScheduledJobNeverRan` — was satisfied by the old proof. -The `recipient-state` timer now writes the recipient list daily, carrying proofs -forward and setting none, and `SecretsKeyRecipientsUnrecorded` fires when the -deadline row exists and the recipient series does not — an `unless` against the -declaration row, not an `absent()`, so it carries labels like every other rule -in the file. - Installing, tuning and troubleshooting all of it: [`runbooks/schedule-maintenance.md`](runbooks/schedule-maintenance.md). diff --git a/docs/roadmap.md b/docs/roadmap.md index 4ca848ef..0f98ed81 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -9,7 +9,7 @@ how a checkbox stops being true, and for a month this file was the second place — [#577](https://github.com/Gerrrt/HomeLab/issues/577) moved the history out. -The order is the five open +The order is the four open [milestones](https://github.com/Gerrrt/HomeLab/milestones), each of which states what closes it. This file adds what a milestone cannot say: the order between them, and inside each the order and the gate where an issue cannot @@ -33,11 +33,9 @@ What an entry here may contain: — first because nothing gates them; most wait on an upstream release. 2. [**trinity**](https://github.com/Gerrrt/HomeLab/milestone/2) — the host is built and serving; what is left is its gates, and the off-estate copy. -3. [**Saruman: the domain, then the SOC**](https://github.com/Gerrrt/HomeLab/milestone/3) - — one proof left, the lab's second key. -4. [**exercises**](https://github.com/Gerrrt/HomeLab/milestone/5) — the +3. [**exercises**](https://github.com/Gerrrt/HomeLab/milestone/5) — the pipeline is built; what is left is using it, one exercise per weakness. -5. [**last**](https://github.com/Gerrrt/HomeLab/milestone/6) — gated on the +4. [**last**](https://github.com/Gerrrt/HomeLab/milestone/6) — gated on the domain, on a household observation, or on something to publish. ## Nothing blocks these @@ -149,19 +147,6 @@ Closes when #404 and #132 close, and #455 has its holder. has only the nightly volume set on `oracle`. Adding it to the copy is part of this, and Memos' *Durable* row is not met before it is. -## Saruman: the domain, then the SOC - -Closes when it is empty. Both things its name names are done. The domain was -built by hand on 2026-09-24 and 25, and -[#414](https://github.com/Gerrrt/HomeLab/issues/414) closed on 2026-10-02 with -its authentication generator running and §10 read from Hicks. The SOC followed: -Wazuh and Velociraptor reported the six agents in on 2026-09-27. - -- **[#671](https://github.com/Gerrrt/HomeLab/issues/671) Prove the lab's - second key.** `secrets/lab.sops.yaml` is encrypted to the offline technical - second as well as `alexander`'s key since 2026-10-07. What remains is - `make secrets-verify-backup STACK=lab KEY=…` with the offline copy. - ## exercises Closes when #449 does. The pipeline it names is built: Packer, OpenTofu, diff --git a/docs/runbooks/back-up-the-age-key.md b/docs/runbooks/back-up-the-age-key.md index d36b4da5..382566a8 100644 --- a/docs/runbooks/back-up-the-age-key.md +++ b/docs/runbooks/back-up-the-age-key.md @@ -61,7 +61,8 @@ would provide. ## 2. Verify it actually decrypts -Not optional, and not the same as looking at it. From a checkout of this repo: +Worth doing once, when you make the copy; looking at it is not the same. From +a checkout of this repo: ```bash make secrets-verify-backup KEY=/path/to/the/copy @@ -75,9 +76,7 @@ Expect: -- decrypting observability.sops.yaml with the backup key only ok — keys.txt decrypts secrets/observability.sops.yaml (9/9 keys) Proven: this key, on its own, recovers every secret in the repo. - Not proven: the other 1 recipient(s) of this file. Each needs its own - run against its own copy — SecretsKeyBackupUnproven names any that go - ninety days without one. + Not checked by this run: the other 1 recipient(s) of this file. Not proven: that where you keep it will still exist after a fire, a theft, or a forgotten password. That part is your judgement. ``` @@ -205,66 +204,27 @@ the damage is recoverable — but the error it produces afterwards (`sops metadata not found`, or a failed decrypt) sends you looking in the wrong place. Restore is a file copy, nothing more. -## The ninety-day deadline - -Verifying the backup is the only thing in this repository that proves the secrets -are recoverable from anywhere but the monitoring host — every other scheduled -job runs on that machine, with the key that is on it, against its disk. It is -also the only one that cannot be put on a timer, because the check above refuses -the live key by device and inode on purpose: what gets tested has to be a copy on -removable media, and no timer can mount that. - -So it is enforced from the other end. `make secrets-verify-backup` records the -timestamp of a successful run **against the recipient it just proved**, and -`SecretsKeyBackupUnproven` fires when any recipient's proof passes ninety days -old — routed to the normal alert channel like any other warning. A recipient -that has never been proved is recorded as `0`, so it fires with an absurd age -rather than being invisible, which is the honest reading of a key backup nobody -has ever tested. - -That record has to exist for any of it to work, and until -[#400](https://github.com/Gerrrt/HomeLab/issues/400) nothing guaranteed it did: -the per-recipient series was written only by a proof run or by adding a -recipient, so a host that had proved its key *before* the series was invented -never wrote it, and the nag was silent from the day it was deployed. The -`recipient-state` timer now writes the recipient list every day — carrying every -existing proof forward and setting none, since it never touches a key — and -`SecretsKeyRecipientsUnrecorded` fires if the deadline is declared and the file -is missing anyway. On a host with exactly one recipient, the first write -inherits the pre-ADR-0024 proof from the old `verify-key-backup` series rather -than starting from never; with more than one, the old series cannot say which -key it was, and every recipient starts at `0`. - -The per-recipient part is [ADR-0024](../adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md) -and it only starts to matter once there is more than one. With one recipient -this is the same alert it always was. With two, one timestamp for both would -mean that proving either copy vouched for the other — which is exactly backwards, -because the point of the second copy is that it fails independently. +## No deadline + +There is no schedule for re-checking a copy and no alert if it is never +checked ([ADR-0120](../adr/0120-drop-the-age-key-proof-deadline.md)). Run +`make secrets-verify-backup` whenever you want to know a copy still opens the +secrets. Each successful run is recorded against the recipient it checked, in +`key-recipients.prom`, which the `recipient-state` timer keeps current. ### On trinity `trinity` holds its own key, which opens only -[`secrets/sensitive.sops.yaml`](../../secrets/sensitive.sops.yaml), and the -same deadline applies to every recipient of that file. Its row is -`verify-key-backup-sensitive` in `SENSITIVE_JOBS`, not `verify-key-backup`, -because the alert rules join on the job name alone and a name declared on two -hosts breaks them. Prove each copy from the checkout on `trinity`, so the proof -lands in `trinity`'s own `key-recipients.prom`: +[`secrets/sensitive.sops.yaml`](../../secrets/sensitive.sops.yaml). To check a +copy of it, run this from the checkout on `trinity`: ```bash make secrets-verify-backup KEY=/path/to/copy/keys.txt STACK=sensitive ``` -`STACK=sensitive` is what records the run under `trinity`'s job name; without -it the make target checks the estate's file instead. `trinity` has no -`recipient-state` timer, so `make recipient-state STACK=sensitive` is what -rewrites its recipient list after a change that did not go through -`add-recipient.sh`. - -Nagging is not as good as running it. It is a great deal better than remembering. -The threshold lives in the `JOBS` table in -[`install-timers.sh`](../../scripts/install-timers.sh); the mechanism is in -[`schedule-maintenance.md`](schedule-maintenance.md). +Without `STACK=sensitive` the make target checks the estate's file instead. +`make recipient-state STACK=sensitive` rewrites `trinity`'s recipient list +after a change that did not go through `add-recipient.sh`. ## Adding a second recipient @@ -306,12 +266,9 @@ disagree. Both files change and belong in one commit: git add .sops.yaml secrets/observability.sops.yaml ``` -The new recipient starts unproven, and says so: `SecretsKeyBackupUnproven` fires -against it immediately and names it. Clear it the same way as the first — -`make secrets-verify-backup KEY=/path/to/the/new/copy` — and note that this is -the point of the whole exercise. **Proving one recipient does not clear another.** -Each copy has to be mounted and tested on its own, which is four trips a year -rather than two. +The new recipient is recorded as never checked. To check it, run +`make secrets-verify-backup KEY=/path/to/the/new/copy`. A run checks only the +recipient whose copy you mounted. The table in [Copy the key](#1-copy-the-key) and the disqualifiers in [Confirm the copy is not republishing itself](#3-confirm-the-copy-is-not-republishing-itself) @@ -336,11 +293,8 @@ move. The location stays out of this repository, as the first key's does. Whether their key can open the secrets yet is read from the ciphertext (`./scripts/key-recipients.sh --list`), not from this paragraph. Adding it is the procedure above — `make secrets-add-recipient` with their public half — and -then `make secrets-verify-backup` with *each* key, because a re-key that drops -a recipient is the failure mode here. What this still does not solve: their -copy cannot be proved from here on their behalf. `SecretsKeyBackupUnproven` -names the recipient that is overdue, and clearing it for theirs is a visit with -the removable medium, not a timer. +then, if you want to check, `make secrets-verify-backup` with each key, because +a re-key that drops a recipient is the failure mode here. **Replacing a recipient is add, then remove, then prove.** A key that was never kept, or a holder who changes, is handled in that order so the secrets diff --git a/docs/runbooks/copy-the-backups-offsite.md b/docs/runbooks/copy-the-backups-offsite.md index fd4c4430..089efcb5 100644 --- a/docs/runbooks/copy-the-backups-offsite.md +++ b/docs/runbooks/copy-the-backups-offsite.md @@ -107,25 +107,23 @@ start of the *next* visit is for; and that anyone but the holder knows where it is. Those parts are judgement, not a check, and the medium's location is not written down in this repository, for the same reason the key's is not. -Then, while the medium is mounted, do the other thing it is here for: +While the medium is mounted you can also check the key copy on it. This is +optional and has no deadline +([ADR-0120](../adr/0120-drop-the-age-key-proof-deadline.md)): ```bash make secrets-verify-backup KEY=/path/to/the/medium/keys.txt ``` -That clears `SecretsKeyBackupUnproven` for the second recipient; this runbook -clears `OffsiteCopyStale`. Neither clears the other. - ## 3. The ninety-day deadline -Like the two key proofs, this cannot be put on a timer — it needs a human to +Like the CA key proof, this cannot be put on a timer — it needs a human to mount a medium — so it is enforced from the other end. A successful run of the copy records `offsite-copy` through `run-scheduled.sh`, and `OffsiteCopyStale` fires when that success passes ninety days old, routed to the normal alert channel like any other warning. The threshold is the `offsite-copy` row in the `JOBS` table in [`install-timers.sh`](../../scripts/install-timers.sh), -beside `verify-key-backup` and `verify-ca-key-backup`, so one number governs -the whole visit. +beside `verify-ca-key-backup`, so one number governs the whole visit. `ARGS=--list`, `ARGS=--verify-only` and `ARGS=--prune` run outside the wrapper on purpose: looking at the medium, or tidying it, is not refreshing it and diff --git a/docs/runbooks/deploy-stack.md b/docs/runbooks/deploy-stack.md index adc8343e..618d90d4 100644 --- a/docs/runbooks/deploy-stack.md +++ b/docs/runbooks/deploy-stack.md @@ -151,7 +151,7 @@ Then in the UI: 1. **Prometheus → Status → Targets.** Every job `UP`. The four `snmp` targets take up to 45 seconds on their first scrape. 2. **Prometheus → Status → Rules.** Every rule loaded, none in error. The - page lists 170: the 164 alert rules this repository counts everywhere + page lists 168: the 162 alert rules this repository counts everywhere else, plus the six recording rules: `homelab_suricata_expected_interface`, `homelab_battery_runtime_seconds`, and the two directions each of diff --git a/docs/runbooks/schedule-maintenance.md b/docs/runbooks/schedule-maintenance.md index 54d35872..a1f07de1 100644 --- a/docs/runbooks/schedule-maintenance.md +++ b/docs/runbooks/schedule-maintenance.md @@ -19,21 +19,14 @@ that is on that machine, against the disk that is in it. spin up next month, and it cannot prove anything at all about a fire or a theft. A green dashboard here is a narrower claim than it looks. -The one job that genuinely proves off-host recoverability is -`make secrets-verify-backup`, and it is exactly the job that **cannot** be put on -a timer: [`verify-key-backup.sh`](../../scripts/verify-key-backup.sh) refuses the -live key by device and inode, precisely so that what gets tested is a copy on -removable media. No timer can mount that. So it is enforced from the other end — -a successful run records its timestamp against the recipient it proved, and -`SecretsKeyBackupUnproven` fires when that proof passes ninety days old. The -`recipient-state` timer is what makes that series exist at all: it writes one -row per recipient every day, carrying proofs forward and setting none, because -a host that had proved its key before the per-recipient series existed had -nothing else that would ever write it, and the nag was silent for as long as -that lasted ([#400](https://github.com/Gerrrt/HomeLab/issues/400)). -`SecretsKeyRecipientsUnrecorded` fires if the file is missing anyway. - -The estate CA's private key has the same arrangement since +`make secrets-verify-backup` checks that an offline copy of an age key still +opens the secrets. It is optional and has no deadline +([ADR-0120](../adr/0120-drop-the-age-key-proof-deadline.md)): run it when you +want to know, and nothing alerts if you never do. A run records its timestamp +against the recipient it checked, and the `recipient-state` timer keeps that +per-recipient list (`key-recipients.prom`) current every day. + +The estate CA's private key does have a deadline, since [#496](https://github.com/Gerrrt/HomeLab/issues/496): `make certs-verify-backup` is the human proof — a comparison of public keys against a copy on the same offline medium, no timer, ninety days — `CaKeyBackupUnproven` is the nag, and @@ -123,7 +116,6 @@ the host. | `gateway-state` | `make gateway-state` | every 15 minutes | 90 minutes | | `silence-state` | `make silence-state` | every 15 minutes | 90 minutes | | `prune-images` | `make prune-images` | Mondays 04:00 | 14 days | -| `verify-key-backup` | **you**, `make secrets-verify-backup KEY=…` | no timer | 90 days | | `verify-ca-key-backup` | **you**, `make certs-verify-backup KEY=…` | no timer | 90 days | | `offsite-copy` | **you**, `make backup-offsite DEST=…` | no timer | 90 days | | `neo`'s HTTPS leaf | **you**, `make certs ARGS="--host neo.matrix.elysium --ip 10.7.7.2 --force"`, then import it on the switch | no timer; once, before **2029-01-06** | **nothing alerts** | @@ -752,7 +744,6 @@ checkout ([#404](https://github.com/Gerrrt/HomeLab/issues/404) step 9): | `verify-backups-sensitive` | `make verify-backups` with `STACK=sensitive` | daily 06:30 | 2 days | | `household-copy` | **you**, `make household-copy DEST=…` | no timer | 90 days | | `household-proof` | **you** and the holder, `make household-proof CODE=…` | no timer | 1 year | -| `verify-key-backup-sensitive` | **you**, `make secrets-verify-backup KEY=… STACK=sensitive` | no timer | 90 days | It runs daily, not weekly like the estate's backup, because it holds the password vault. Each run also copies the set to `oracle`, the same way the @@ -789,14 +780,10 @@ make install-timers PROFILE=sensitive ``` That writes a `homelab-jobs.prom` on `trinity` that declares only these -seven. `household-copy` and `household-proof` are the household's copy +six. `household-copy` and `household-proof` are the household's copy ([ADR-0073](../adr/0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md), [`carry-the-household-copy.md`](carry-the-household-copy.md)). They have no -timer, and `HouseholdCopyStale` reads them. `verify-key-backup-sensitive` is -the estate's `verify-key-backup` for the tier's own age recipients: no timer, -the same ninety days, and `SecretsKeyBackupUnproven` holds every recipient in -`trinity`'s `key-recipients.prom` to it -([`back-up-the-age-key.md`](back-up-the-age-key.md#on-trinity)). The alert rules join on the job name alone, so a name may appear in only +timer, and `HouseholdCopyStale` reads them. The alert rules join on the job name alone, so a name may appear in only one table, and `--check` enforces that. The installer primes `backup-library`, `converge-sensitive` and `verify-backups-sensitive`, which stop nothing, and not `backup-sensitive`, which stops the tier. `make check-timers` checks both profiles, and `make validate` on `trinity` fails until the backup and converge timers are @@ -922,11 +909,10 @@ expected rather than a second fault. | Symptom | Cause | Fix | | --- | --- | --- | -| `ScheduledJobNeverRan` right after install | The job has a threshold declared and has never reported a result | Expected for `verify-key-backup` and `verify-ca-key-backup` until you first verify each key (on `trinity`, `verify-key-backup-sensitive`), for `offsite-copy` until the first visit makes the copy, and on `trinity` for `household-copy` and `household-proof` until there is a household holder and the holder has opened it. For anything else, `systemctl start homelab-.service` and read the journal | +| `ScheduledJobNeverRan` right after install | The job has a threshold declared and has never reported a result | Expected for `verify-ca-key-backup` until you first verify the CA key, for `offsite-copy` until the first visit makes the copy, and on `trinity` for `household-copy` and `household-proof` until there is a household holder and the holder has opened it. For anything else, `systemctl start homelab-.service` and read the journal | | `ScheduledJobStaleCritical` | A job has gone three of its own periods without a success — one and a half of the allowance in the `JOBS` table, which is twice the period; a weekly backup three weeks stale, a nightly one three nights, and never under a day for the hourly collectors — and the `ScheduledJobStale` warning for it has been repeating on the in-house channel unanswered | The same first look as the warning: `systemctl list-timers 'homelab-*'`, then `journalctl -u homelab-.service`. The rows below name the usual cause per job. The page holds the warning back while it is up, so a job that recovers clears both at once | | `OffsiteCopyStale` | Ninety days since the newest sets were last copied to the second recipient's medium and proved there | Mount it and run `make backup-offsite DEST=…` — [`copy-the-backups-offsite.md`](copy-the-backups-offsite.md). `--list`, `--verify-only` and `--prune` do not clear it, on purpose | | `CaKeyBackupUnproven` | No offline copy of `certificates/ca-key.pem` has been proved in ninety days — or ever, or not since the CA was re-minted, which the fingerprint label tells apart | Mount the medium and `make certs-verify-backup KEY=…` ([`back-up-the-ca-key.md`](back-up-the-ca-key.md)). After a re-mint, copy the new key there first; the old copy is refused | -| `SecretsKeyRecipientsUnrecorded` | The ninety-day deadline is declared and no recipient has a proof series, so `SecretsKeyBackupUnproven` cannot fire however stale the proof is | `systemctl start homelab-recipient-state.service`. If that unit does not exist the timers predate [#400](https://github.com/Gerrrt/HomeLab/issues/400): `make install-timers` adds it and primes it. On a host with one recipient the first write inherits the old `verify-key-backup` proof rather than starting from never | | `ScheduledJobMetricsAbsent` | Nothing from the textfile directory has reached Prometheus in six hours | This is the whole directory, not one file — check Alloy is up and the directory still exists. A single malformed file shows as `node_textfile_scrape_error 1` and costs only that file | | One job's series missing, `node_textfile_scrape_error` is 1 | That job's `.prom` failed to parse — a truncated write, or something wrote it without the temp-then-rename | The other files are unaffected. Re-run the job; if it recurs, something is writing the file directly instead of through `run-scheduled.sh` | | Every `homelab_job_*` series missing, no scrape error | The `textfile` block in `config.alloy` is not reading the right path | It must carry the `ALLOY_ROOTFS` prefix (`/rootfs` in the container). `rootfs_path` does **not** apply to that argument, and a wrong path reports an empty directory rather than an error | diff --git a/docs/runbooks/successor-handover.md b/docs/runbooks/successor-handover.md index 97ba2c3f..4732e111 100644 --- a/docs/runbooks/successor-handover.md +++ b/docs/runbooks/successor-handover.md @@ -198,7 +198,7 @@ inherits without knowing. | --- | --- | --- | | **Alert delivery to a destination you do not own** | Immediately, and silently | You do not. This is step 2 above, and it is the reason it is step 2 | | **The external heartbeat watcher** — a free-tier cron-monitor on somebody else's account | Whenever that account lapses | Nothing here can tell you. A watcher on this host would fail with the thing it watches, which is why it is off-host and therefore outside anything this repository can check | -| **The age key backup goes unproven** | 90 days after the last verification, *per recipient* | `SecretsKeyBackupUnproven`, routed to the normal alert channel, naming the recipient — proving one copy does not clear another ([ADR-0024](../adr/0024-hold-a-second-age-recipient-and-prove-each-one-separately.md)). A recipient never proved is recorded as never, and fires; `SecretsKeyRecipientsUnrecorded` fires instead if the record itself is missing ([#400](https://github.com/Gerrrt/HomeLab/issues/400)) | +| **An offline copy of the age key stops working** | Whenever it happens | Nothing alerts. Checking a copy is optional and has no deadline ([ADR-0120](../adr/0120-drop-the-age-key-proof-deadline.md)); `make secrets-verify-backup KEY=…` checks one when you want to know ([`back-up-the-age-key.md`](back-up-the-age-key.md)) | | **The offsite copy of the backup sets goes stale** | 90 days after the last visit that carried them | `OffsiteCopyStale`, routed to the normal alert channel. Before the first visit it is `ScheduledJobNeverRan` naming `offsite-copy` instead, which is the honest state of a copy nobody has made ([`copy-the-backups-offsite.md`](copy-the-backups-offsite.md)) | | **The household's copy goes stale, or its holder's proof does** | 90 days after the last visit to the household drive; a year after the holder last opened it | `HouseholdCopyStale`, naming `household-copy` or `household-proof`. Until a household holder is named in `stacks/sensitive/household.recipients` it is `ScheduledJobNeverRan` for both. The drive is the household's, at their address, and their key opens it without you ([ADR-0073](../adr/0073-carry-the-household-copy-on-a-drive-the-holder-keeps.md), [`carry-the-household-copy.md`](carry-the-household-copy.md)) | | **The CA key backup goes unproven** | 90 days after the last proof, and immediately after a re-mint | `CaKeyBackupUnproven`, routed to the normal alert channel. The proof is a comparison of public keys against a copy on the offline medium, keyed on the key's fingerprint so a re-minted root starts at never ([`back-up-the-ca-key.md`](back-up-the-ca-key.md)) | diff --git a/docs/security.md b/docs/security.md index b9302aec..159eee52 100644 --- a/docs/security.md +++ b/docs/security.md @@ -31,7 +31,7 @@ What this network is actually built to survive: | Someone on the lab segment reaching the lab's Grafana or BloodHound, or a detonation reaching `diabolos`'s UIs | **Scoped by address, as the SOC's are.** `alexander`'s Grafana (`3000`) is published by the lab stack's `caddy`, and `eden`'s BloodHound (`8443`) by the bloodhound stack's own `caddy`; each answers Hicks's `10.0.50.0/24` and refuses the rest of VLAN 30, the six domain guests included. `diabolos`, not yet built, has soc's fence for its dashboard and GUI. Until then Grafana and BloodHound answered all of VLAN 30, where BloodHound's graph is the domain's attack-path map ([#1428](https://github.com/Gerrrt/HomeLab/issues/1428)). The residuals are the SOC row's: Hicks is a whole /24, and an address on VLAN 30 can be spoofed for a one-way packet but not for the TLS session the UIs need | | A range target with a path out | It has none — `gandalf`'s targets sit on a bridge with no physical port, on `172.30.30.0/24`, which the firewall does not route and on which nothing has a default route at all ([ADR-0014](adr/0014-put-ifrit-on-imaginationlan-and-give-the-targets-no-route.md), [ADR-0017](adr/0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md)) | | Someone with the trusted Wi-Fi key quietly joining | Kea's lease log reaches Loki; `UnknownDeviceOnTrustedSegment` fires the first time a MAC appears on VLAN 50 in seven days ([ADR-0019](adr/0019-read-device-joins-from-the-dhcp-server.md)) | -| Losing visibility of a failure | 185 alert rules, 30 days of metrics and logs | +| Losing visibility of a failure | 183 alert rules, 30 days of metrics and logs | | Someone on a reachable VLAN silencing an alert to hide a failure | Alertmanager binds to `127.0.0.1`; silences go through authenticated Grafana | | Mains power loss | **The rack, yes; the monitoring path, yes — on two laptop cells that were measured for the first time on 2026-09-12.** A pack fitted to `mjolnir` on 2026-08-28 passed its self-test; the TP-Link carrying `prometheus` and `oracle` has been on UPS power since 2026-09-08 ([#110](https://github.com/Gerrrt/HomeLab/issues/110)); the laptops ride a cut out on their own batteries, which `HostBatteryHealthLow` in `host.rules.yaml` now reads — `prometheus`'s cell was replaced on 2026-09-18 and reads 101 % of design, `oracle`'s was replaced on 2026-09-29 and reads 100 %, its design figure rather than a learned one ([#531](https://github.com/Gerrrt/HomeLab/issues/531)) — and **each runtime was measured once: `prometheus`'s on 2026-09-19, about 2.5 hours from full at the stack's load, and `oracle`'s on 2026-09-29, about 5.2 hours**; since the same day the projection is recorded on every cut and pages under thirty minutes (`HostBatteryRuntimeLow`, [#532](https://github.com/Gerrrt/HomeLab/issues/532)), but neither pack reports a moving cell temperature, so this row is answered for both hosts' runtime and for neither's cell temperature — see below. **What happens when the cut outlasts the pack is armed and not proved.** Since 2026-09-23 the firewall's NUT server reads `mjolnir`, and `Saruman` and `smaug` subscribe to it on their own gateway addresses, so a real cut would now try to run the sequence [ADR-0049](adr/0049-shut-down-on-the-ups-from-a-nut-server-on-the-firewall.md) decides: `Saruman` and `smaug` halt first and `morpheus` last. Nobody has watched it run. Since the move into the 32U rack on 2026-11-06 the PDU also carries `trinity`, `gandalf` (off until its build) and the console, with `smaug` racked and on the PDU directly rather than by its old long cord to the media room. [ADR-0107](adr/0107-subscribe-trinity-to-the-ups-and-bound-saruman-s-guest-stop.md) makes `trinity` a third subscriber and bounds `Saruman`'s guest stop. `Saruman`'s half was applied on 2026-11-13 (`down=90` on the four ordered guests, and its monitor stays logged in until they are down); `trinity`'s subscription, `HOSTSYNC 600` on `morpheus` and the card's 16-minute threshold are not, so `trinity` still stops uncleanly when the pack empties and the card still holds 8 minutes; `gandalf`, the console and `neo` are left to the pack by decision. The pack itself is unmeasured: about 47 minutes at 21 % load is the card's own estimate. [`shut-down-on-the-ups.md`](runbooks/shut-down-on-the-ups.md) §5 to §7 are what is left — the forced-shutdown proof and the one mains pull that measures the pack ([#574](https://github.com/Gerrrt/HomeLab/issues/574)) | | The estate being down while the person who runs it is unavailable | **Documentation, yes; data, not yet off the estate.** ADR-0011 puts the emergency tier on paper; [ADR-0023](adr/0023-keep-the-household-recovery-path-outside-the-estate.md) extends the same reasoning to the sensitive tier's data. That tier has held real photographs since 2026-09-28, and their off-estate copy is built but has no holder yet ([#455](https://github.com/Gerrrt/HomeLab/issues/455)) — see below | @@ -669,10 +669,11 @@ assumption consistent with what they are. age key, and is covered below.) That host's disk is not encrypted — see [below](#everything-above-sits-on-an-unencrypted-disk). - That key is the single point of failure for every encrypted secret here, so it - is copied off the host and the copy is proven to decrypt with - `make secrets-verify-backup KEY=` — which refuses to run against the live - key and blanks the environment first, because the obvious hand-typed - equivalent passes even for an unrelated keypair. See + is copied off the host. `make secrets-verify-backup KEY=` can check a + copy decrypts — it refuses to run against the live key and blanks the + environment first, because the obvious hand-typed equivalent passes even for + an unrelated keypair. The check is optional and nothing alerts on it + ([ADR-0120](adr/0120-drop-the-age-key-proof-deadline.md)). See [`runbooks/back-up-the-age-key.md`](runbooks/back-up-the-age-key.md). - `scripts/render-config.sh` decrypts at deploy time into gitignored files. Nothing writes a plaintext secret into a tracked path. diff --git a/scripts/add-recipient.sh b/scripts/add-recipient.sh index cbf57f97..3749fe59 100755 --- a/scripts/add-recipient.sh +++ b/scripts/add-recipient.sh @@ -240,27 +240,23 @@ fi trap - EXIT INT TERM rm -f "${BACKUP}" -# The new recipient starts life unproven, and says so out loud rather than -# waiting for the next verification of some OTHER key to notice it exists. -# key-recipients.sh writes 0 for it, SecretsKeyBackupUnproven reads that as -# "never", and the nagging starts now instead of in ninety days. +# Record the new recipient now, as never proved (0). No alert reads that since +# ADR-0120; it keeps key-recipients.prom's list current for remove-recipient.sh. "${REPO_ROOT}/scripts/key-recipients.sh" --record --stack "${STACK}" || true cat <&2; exit 1; } @@ -483,8 +464,8 @@ if [[ "${MODE}" == check ]]; then stale=() for row in "${JOBS[@]}"; do unit="$(job_unit "${row}")" - # verify-key-backup has no unit: it is a deadline declared for a human, - # and the table says so with a "-". Nothing to install, nothing to check. + # A "-" unit is a deadline declared for a human (verify-ca-key-backup, + # offsite-copy). Nothing to install, nothing to check. [[ "${unit}" == "-" ]] && continue state="$(systemctl is-enabled "${unit}.timer" 2>/dev/null || true)" case "${state}" in @@ -531,9 +512,8 @@ if [[ "${MODE}" == check ]]; then run_home="$(getent passwd "${run_user}" | cut -d: -f6)" for row in "${SENSITIVE_JOBS[@]}"; do unit="$(job_unit "${row}")" - # household-copy, household-proof and verify-key-backup-sensitive are - # human jobs, "-" as on the estate's side: no timer to be enabled - # (ADR-0073, ADR-0024). + # household-copy and household-proof are human jobs, "-" as on the + # estate's side: no timer to be enabled (ADR-0073). [[ "${unit}" == "-" ]] && continue state="$(systemctl is-enabled "${unit}.timer" 2>/dev/null || true)" case "${state}" in @@ -720,8 +700,7 @@ if [[ "${PROFILE}" == sensitive ]]; then fi info "backup-volumes was NOT primed: it stops the stack. Run it when you can watch:" info " sudo systemctl start homelab-backup-volumes.service" -info "verify-key-backup has no timer and never will — docs/runbooks/back-up-the-age-key.md" -info "recipient-state was primed, so SecretsKeyBackupUnproven has a series per recipient to read (#400)" -info "verify-ca-key-backup has no timer either — docs/runbooks/back-up-the-ca-key.md" +info "recipient-state was primed: key-recipients.prom lists who can open the secrets (#400)" +info "verify-ca-key-backup has no timer — docs/runbooks/back-up-the-ca-key.md" info "offsite-copy has no timer either — docs/runbooks/copy-the-backups-offsite.md" info "ca-key-state was primed, so CaKeyBackupUnproven has the CA key's fingerprint to read (#496)" diff --git a/scripts/key-recipients.sh b/scripts/key-recipients.sh index a365d924..1f8d14bc 100755 --- a/scripts/key-recipients.sh +++ b/scripts/key-recipients.sh @@ -27,15 +27,15 @@ # # A recipient that has never been verified is recorded as 0 rather than omitted. # time() - 0 is about 1.8 billion seconds, which exceeds every threshold, so -# "never proved" and "not proved lately" are one alert — the same choice -# run-scheduled.sh makes and for the same reason. +# "never proved" and "not proved lately" read the same — the same choice +# run-scheduled.sh makes and for the same reason. (No alert reads this file +# since ADR-0120; the record stays.) # # WHO RUNS --record. verify-key-backup.sh after a proof (with --proved), # add-recipient.sh after a re-key, and — since #400 — the recipient-state timer # every day with neither. That last caller is what guarantees the file exists: # the first two only run when a human does something, and a host that proved -# its key before this script existed had nothing that would ever write it, so -# the alert that reads it was silent from the day it was deployed. +# its key before this script existed had nothing that would ever write it. # # THE FIRST WRITE CARRIES THE OLD PROOF OVER. Before ADR-0024 the only record of # a proof was homelab_job_last_success_timestamp_seconds{homelab_job= diff --git a/scripts/verify-key-backup.sh b/scripts/verify-key-backup.sh index 49269440..a166626c 100755 --- a/scripts/verify-key-backup.sh +++ b/scripts/verify-key-backup.sh @@ -310,8 +310,8 @@ fi # homelab_job="verify-key-backup" whichever key was mounted, so with more than # one recipient it answers "a key was proved" to the question "was THIS key # proved" — and proving one silences the ninety-day deadline for all of them. -# key-recipients.sh keeps a series per recipient, which is what -# SecretsKeyBackupUnproven actually reads. +# key-recipients.sh keeps a series per recipient. No alert reads it since +# ADR-0120; it is the record of which copy was checked and when. # # Before the ok line and allowed to be fatal, deliberately. An unrecorded proof # is the failure #77 is about: the job ran, nothing can see that it ran, and the @@ -322,15 +322,10 @@ printf '\033[0;32mok\033[0m — %s decrypts secrets/%s.sops.yaml (%d/%d keys)\n' "$(basename "${BACKUP}")" "${STACK}" "${found}" "${#REQUIRED[@]}" printf ' Proven: this key, on its own, recovers every secret in the repo.\n' -# The line the single-series metric could never say. Proving one recipient used -# to read as proving the backup; with more than one it proves exactly one of -# them, and the other copies are still only as good as the last time somebody -# went and got them out. +# With more than one recipient, a run proves exactly one of them. if ((${#RECIPIENTS[@]} > 1)); then - printf ' Not proven: the other %d recipient(s) of this file. Each needs its own\n' \ + printf ' Not checked by this run: the other %d recipient(s) of this file.\n' \ "$((${#RECIPIENTS[@]} - 1))" - printf ' run against its own copy — SecretsKeyBackupUnproven names any that go\n' - printf ' ninety days without one.\n' fi printf ' Not proven: that where you keep it will still exist after a fire,\n' diff --git a/stacks/observability/README.md b/stacks/observability/README.md index e2ab0ba2..ebd8d959 100644 --- a/stacks/observability/README.md +++ b/stacks/observability/README.md @@ -53,7 +53,7 @@ prometheus/ targets/snmp.yaml SNMP targets — hot-reloaded, no restart needed targets/node.yaml node_exporter scrapes, for the host that runs no Alloy (smaug) targets/blackbox*.yaml probe targets, http, dns and latency — hot-reloaded, no restart - rules/*.rules.yaml 164 alert rules: host, network, ups, containers, blackbox, + rules/*.rules.yaml 162 alert rules: host, network, ups, containers, blackbox, dns, backup, ids, deploy, stack, internet and watchdog tests/*.test.yaml promtool unit tests — assert the rules can fire blackbox/blackbox.yaml probe modules — reachability, and what a resolver said diff --git a/stacks/observability/prometheus/rules/backup.rules.yaml b/stacks/observability/prometheus/rules/backup.rules.yaml index 2c098961..33fa1cc9 100644 --- a/stacks/observability/prometheus/rules/backup.rules.yaml +++ b/stacks/observability/prometheus/rules/backup.rules.yaml @@ -22,12 +22,19 @@ # JOBS table that also decides the cadence, so a threshold and a schedule cannot # drift apart. It also means NO RULE HERE NAMES A JOB: adding a timer is a row in # that table, not an edit to this file. That is deliberate — a rule file listing -# job names is a list that silently stops growing. The four rules at the bottom -# are the one exception, and they name the three jobs that are not timers: the -# human proofs — verify-key-backup, whose deadline is applied per age -# recipient, verify-ca-key-backup, whose deadline is applied to the CA key's -# current fingerprint (#496), and offsite-copy, the newest set of each kind -# carried onto the second recipient's medium on the same visit (ADR-0048). +# job names is a list that silently stops growing. The rules at the bottom are +# the one exception, and they name the jobs that are not timers: the human +# proofs — verify-ca-key-backup, whose deadline is applied to the CA key's +# current fingerprint (#496), offsite-copy, the newest set of each kind carried +# onto the second recipient's medium (ADR-0048), and the household's pair +# (ADR-0073). +# +# The age-key proof is no longer one of them. ADR-0120 dropped its deadline: +# verify-key-backup and verify-key-backup-sensitive are not declared any more, +# and SecretsKeyBackupUnproven and SecretsKeyRecipientsUnrecorded are gone. +# Both names stay in the exclusions below, and ScheduledJobNeverRan skips them +# too, so a host whose homelab-jobs.prom was written before that change stays +# quiet until `make install-timers` rewrites it. # # That claim has since been tested rather than merely asserted. #99 added # `converge`, an hourly job on a different cadence to everything above, and @@ -43,9 +50,7 @@ # exactly the list this file is avoiding — and it reacts to a single missed # scrape. `unless on(homelab_job)` against the declaration series says the same # thing generically. absent_over_time appears once, in ScheduledJobMetricsAbsent, -# for the one question that genuinely has no series to join against. Even the -# per-recipient file being missing (#400) is asked as an `unless` against the -# verify-key-backup declaration row rather than as an absent(). +# for the one question that genuinely has no series to join against. groups: - name: backup interval: 60s @@ -73,13 +78,14 @@ groups: # A second monitored host would then be indistinguishable from the # first, and the two would collide into one alert. # - # verify-key-backup is excluded because SecretsKeyBackupUnproven says - # something different about it and earns its own description, - # verify-ca-key-backup for the same reason — CaKeyBackupUnproven — - # and offsite-copy for OffsiteCopyStale. All three are human runs - # against a mounted medium: "check the journal" would be wrong advice - # for any of them. household-copy and household-proof are the same - # shape, and HouseholdCopyStale reads them (ADR-0073). + # verify-ca-key-backup is excluded because CaKeyBackupUnproven says + # something different about it and earns its own description, and + # offsite-copy for OffsiteCopyStale. Both are human runs against a + # mounted medium: "check the journal" would be wrong advice for + # either. household-copy and household-proof are the same shape, and + # HouseholdCopyStale reads them (ADR-0073). verify-key-backup and + # verify-key-backup-sensitive have no deadline since ADR-0120 and are + # excluded only for a host whose declarations predate it (header). expr: | (time() - homelab_job_last_success_timestamp_seconds{ homelab_job!~"verify-key-backup|verify-key-backup-sensitive|verify-ca-key-backup|offsite-copy|household-copy|household-proof"}) @@ -170,12 +176,11 @@ groups: # Declared in the JOBS table, with no success series to go with it: the # job has never run, or its .prom file was deleted. # - # This is also the state verify-key-backup starts in and stays in until - # someone actually verifies the key backup for the first time, which is - # the honest reading — before that first run, nothing has proven the - # secrets are recoverable from anywhere but this host. + # The age-key proof jobs are skipped: ADR-0120 removed their deadline, + # and a row left in a homelab-jobs.prom written before that is not a + # job anyone is expected to run (header). expr: | - homelab_job_max_age_seconds + homelab_job_max_age_seconds{homelab_job!~"verify-key-backup|verify-key-backup-sensitive"} unless on(homelab_job) homelab_job_last_success_timestamp_seconds for: 1h labels: @@ -228,135 +233,9 @@ groups: to parse; this alert means the whole directory stopped arriving. docs/runbooks/schedule-maintenance.md. - - alert: SecretsKeyBackupUnproven - # The one job with no timer, and the sharpest edge in #77. - # - # verify-key-backup.sh refuses the live key by device:inode and refuses - # a copy sitting inside a git tree, precisely so that what gets tested is - # a real off-host copy. That means a human has to mount removable media, - # and no timer can do it. What a timer CAN do is notice that nobody has. - # - # ONE SERIES PER RECIPIENT, and this is the only rule in the file that - # is not keyed on homelab_job. ADR-0024 added a second age recipient, and - # the moment there were two, homelab_job_last_success_timestamp_seconds - # {homelab_job="verify-key-backup"} became a wrong answer: it is a single - # series that run-scheduled.sh writes whichever key was mounted, so - # proving one copy reset the ninety-day deadline for every copy and the - # other could rot behind a green alert. scripts/key-recipients.sh emits - # homelab_key_recipient_last_proof_timestamp_seconds per recipient, read - # out of the encrypted file's own metadata, and this fires per recipient. - # - # The threshold still comes from the same declaration series as - # everything else, so the ninety days lives in scripts/install-timers.sh - # and nowhere else. It is joined on(instance) rather than on(homelab_job) - # because the left side has no homelab_job label to join on — both series - # are written into the same textfile directory on the same host. - # group_left() for the reason ScheduledJobStale gives above: without it - # the result carries only the labels named in on(), and `recipient` — the - # entire point of this rule — would be silently dropped. - # - # A recipient that has never been verified is recorded as 0, not omitted, - # so it fires here with an absurd duration rather than being invisible. - # - # That only holds once key-recipients.sh has written its file. This rule - # used to claim ScheduledJobNeverRan covered the time before that, and it - # does not: NeverRan looks for the JOB series, and a host that proved its - # key before ADR-0024 has one — so the fallback was satisfied, this rule - # had no left side, and the deadline went unwatched from the day it was - # deployed (#400). SecretsKeyRecipientsUnrecorded, below, is the rule - # for that state, and the recipient-state timer is what ends it. - # - # Two declaration names, one per host. trinity proves the sensitive - # tier's recipients and declares the same ninety days as - # verify-key-backup-sensitive, because a name may be in only one of - # install-timers.sh's tables: ScheduledJobStale and the rules beside it - # join on(homelab_job) alone, and one name declared on two instances - # makes those joins many-to-many, so they error rather than fire. Here - # the join is on(instance), and each host declares exactly one of the - # two, so the regex still finds one row per host. - # - # The second branch is for a host that records proofs but declares - # neither name, as trinity did before its timers were reinstalled with - # that row: the on(instance) join has no right side there, and its - # recipients would sit at 0 — never proven — with nothing firing. Such - # a host is held to the estate's declared deadline instead, taken with - # max() so the ninety days is still written in one place only. - expr: | - ( - (time() - homelab_key_recipient_last_proof_timestamp_seconds) - > on(instance) group_left() - homelab_job_max_age_seconds{homelab_job=~"verify-key-backup|verify-key-backup-sensitive"} - ) - or - ( - ( - (time() - homelab_key_recipient_last_proof_timestamp_seconds) - unless on(instance) - homelab_job_max_age_seconds{homelab_job=~"verify-key-backup|verify-key-backup-sensitive"} - ) - > on() group_left() max(homelab_job_max_age_seconds{homelab_job="verify-key-backup"}) - ) - for: 1h - labels: - component: backup - severity: warning - category: correctness - annotations: - summary: "No proven backup of age recipient {{ $labels.recipient }} in {{ $value | humanizeDuration }}" - description: >- - Nothing else here proves the {{ $labels.stack }} secrets are - recoverable from anywhere but this host — every other job runs on the - same machine, with the same key, against the same disk. Proving a - DIFFERENT recipient does not clear this one. Get that copy out and - run `make secrets-verify-backup KEY= STACK={{ $labels.stack }}`: - docs/runbooks/back-up-the-age-key.md. - - - alert: SecretsKeyRecipientsUnrecorded - # The deadline is declared and nothing can be held to it. install-timers - # writes the verify-key-backup threshold row; key-recipients.sh writes - # the per-recipient series SecretsKeyBackupUnproven compares against it. - # If the first exists and the second does not, the ninety-day nag has - # no left side and is silent — which is exactly what #400 found: the - # host had proved its key under the old single series, ADR-0024 moved - # the rule onto a file nothing had yet written, and the fallback that - # rule named was satisfied by the old proof. - # - # An `unless` against the declaration row and not absent(), for the - # reason the header gives: absent() would have to invent the labels, - # and this way the alert carries homelab_job and instance like every - # other rule here. It is keyed on one job by name, which the header - # also explains — verify-key-backup is the one job that is not a timer. - # - # Since #400 the recipient-state timer writes the file daily and the - # installer primes it, so in steady state this cannot fire. It fires - # for a host installed before that timer existed, for a file removed - # from the textfile directory, and for a recipient-state job that has - # never run — the last of which ScheduledJobNeverRan also names. - expr: | - homelab_job_max_age_seconds{homelab_job=~"verify-key-backup|verify-key-backup-sensitive"} - unless on(instance) homelab_key_recipient_last_proof_timestamp_seconds - for: 1h - labels: - component: backup - severity: warning - category: correctness - annotations: - summary: "The age-key deadline is declared but no recipient has a proof series to hold to it" - description: >- - scripts/install-timers.sh declared the ninety-day deadline for - {{ $labels.homelab_job }} on {{ $labels.instance }} and nothing has - written homelab_key_recipient_last_proof_timestamp_seconds there, so - SecretsKeyBackupUnproven has nothing to read and cannot fire however - stale the proof is. On the monitoring host - `systemctl start homelab-recipient-state.service` writes it; if that - unit does not exist, the timers predate #400 and - `make install-timers` adds it. On trinity, which has no such timer, - `make recipient-state STACK=sensitive` writes it. - docs/runbooks/back-up-the-age-key.md. - - alert: CaKeyBackupUnproven - # The estate CA's private key, held to the same ninety days as the age - # key (#496, ADR-0043 decision 4). verify-ca-key-backup.sh refuses the + # The estate CA's private key, held to ninety days (#496, ADR-0043 + # decision 4; the age key's own deadline went with ADR-0120). verify-ca-key-backup.sh refuses the # live key by device:inode and a copy inside a git tree, so what gets # proved is a real offline copy, a human has to mount it, and no timer # can. What a timer CAN do is notice that nobody has. @@ -370,12 +249,11 @@ groups: # a re-minted CA fires here the next morning with an absurd duration # rather than inheriting ninety days of green. # - # Same join as SecretsKeyBackupUnproven, and for the same reasons: - # on(instance) because the left side has no homelab_job label, and - # group_left() so that `ca` and `spki_sha256` survive the join. The + # Joined on(instance) because the left side has no homelab_job label, + # with group_left() so that `ca` and `spki_sha256` survive the join. The # threshold is the verify-ca-key-backup row in install-timers.sh. # - # No `…Unrecorded` sibling. The age key needed one because its series + # No `…Unrecorded` sibling. The age key had one because its series # was invented after its proof (#400); the ca-key-state timer is born # with this series, gen-certs.sh writes it at the mint, and a host where # it has never been written is ScheduledJobNeverRan{homelab_job= diff --git a/stacks/observability/prometheus/tests/backup.test.yaml b/stacks/observability/prometheus/tests/backup.test.yaml index 7cfe7730..90faeae9 100644 --- a/stacks/observability/prometheus/tests/backup.test.yaml +++ b/stacks/observability/prometheus/tests/backup.test.yaml @@ -80,8 +80,8 @@ tests: # `for`: quiet at 2h (which is what asserts the floor is there), pending at # 24h20m, firing at 25h. job-fresh's allowance is 100000s, so its line is # 150000s, about 41h40m, and it is quiet throughout. The second case feeds - # a human-only job far past both lines, which is SecretsKeyBackupUnproven's - # business and not a page to read an empty journal. + # a leftover verify-key-backup row far past both lines: it has had no + # deadline since ADR-0120, and is not a page to read an empty journal. - interval: 1m input_series: - series: 'homelab_job_last_success_timestamp_seconds{homelab_job="job-stale", instance="prometheus"}' @@ -172,261 +172,26 @@ tests: `journalctl -u homelab-backup-sensitive.service` on trinity — docs/runbooks/schedule-maintenance.md. - # --- ScheduledJobStale: verify-key-backup is not its business ------------ + # --- ScheduledJobStale: a leftover verify-key-backup row is not its business # - # The human-only job is excluded from ScheduledJobStale and handled by - # SecretsKeyBackupUnproven instead, so the operator is told to fetch the - # offline copy rather than to go and read a journal that has nothing in it. + # ADR-0120 removed the age-key deadline, but a host whose homelab-jobs.prom + # predates that still carries the row until install-timers rewrites it. The + # stale-job rules and ScheduledJobNeverRan stay quiet about it. - interval: 1m input_series: - series: 'homelab_job_last_success_timestamp_seconds{homelab_job="verify-key-backup", instance="prometheus"}' values: "0+0x180" - series: 'homelab_job_max_age_seconds{homelab_job="verify-key-backup", instance="prometheus"}' values: "3600+0x180" - alert_rule_test: - - eval_time: 2h30m - alertname: ScheduledJobStale - exp_alerts: [] - - # And SecretsKeyBackupUnproven does not fire off the JOB series either. - # It reads the per-recipient series and nothing else, so a host where - # verify-key-backup has run but key-recipients.sh has not written its file - # gets nothing from it. This case used to say ScheduledJobNeverRan covered - # that state; it cannot, because the job series exists — that is #400, and - # the next two assertions are the rule that does cover it. - - eval_time: 2h30m - alertname: SecretsKeyBackupUnproven - exp_alerts: [] - - # --- SecretsKeyRecipientsUnrecorded: silent inside its `for` ------------ - - eval_time: 30m - alertname: SecretsKeyRecipientsUnrecorded - exp_alerts: [] - - # --- SecretsKeyRecipientsUnrecorded: the #400 state ------------------- - # - # The deadline row is declared, the job series says a proof happened, and - # no per-recipient series exists. Before this rule, nothing fired here. - - eval_time: 2h30m - alertname: SecretsKeyRecipientsUnrecorded - exp_alerts: - - exp_labels: - alertname: SecretsKeyRecipientsUnrecorded - homelab_job: verify-key-backup - instance: prometheus - component: backup - severity: warning - category: correctness - exp_annotations: - summary: "The age-key deadline is declared but no recipient has a proof series to hold to it" - description: >- - scripts/install-timers.sh declared the ninety-day deadline for - verify-key-backup on prometheus and nothing has written - homelab_key_recipient_last_proof_timestamp_seconds there, so - SecretsKeyBackupUnproven has nothing to read and cannot fire - however stale the proof is. On the monitoring host `systemctl - start homelab-recipient-state.service` writes it; if that unit - does not exist, the timers predate #400 and `make - install-timers` adds it. On trinity, which has no such timer, - `make recipient-state STACK=sensitive` writes it. - docs/runbooks/back-up-the-age-key.md. - - # --- SecretsKeyBackupUnproven: one alert per recipient -------------------- - # - # The assertion ADR-0024 turns on. Two recipients, one of them verified - # 30 minutes ago and one never — the shape the estate is in the moment a - # second key is added. Exactly one alert, naming the unproven key. - # - # Under the single-series rule this replaced, the fresh proof of `age1aaa` - # was the only series there was, so this state was silent. That is the whole - # defect: proving one copy vouched for every copy. - - interval: 1m - input_series: - - series: 'homelab_key_recipient_last_proof_timestamp_seconds{stack="observability", - recipient="age1aaa", instance="prometheus"}' - values: "9000+0x180" - - series: 'homelab_key_recipient_last_proof_timestamp_seconds{stack="observability", - recipient="age1bbb", instance="prometheus"}' - values: "0+0x180" - - series: 'homelab_job_max_age_seconds{homelab_job="verify-key-backup", instance="prometheus"}' - values: "3600+0x180" - alert_rule_test: - - eval_time: 2h30m - alertname: SecretsKeyBackupUnproven - exp_alerts: - - exp_labels: - alertname: SecretsKeyBackupUnproven - stack: observability - recipient: age1bbb - instance: prometheus - component: backup - severity: warning - category: correctness - exp_annotations: - summary: "No proven backup of age recipient age1bbb in 2h 30m 0s" - description: >- - Nothing else here proves the observability secrets are - recoverable from anywhere but this host — every other job runs - on the same machine, with the same key, against the same disk. - Proving a DIFFERENT recipient does not clear this one. Get that - copy out and run `make secrets-verify-backup KEY= - STACK=observability`: docs/runbooks/back-up-the-age-key.md. - - # --- SecretsKeyRecipientsUnrecorded: silent once the file exists -------- - # - # The paired case for the #400 assertion above: the same declaration row, - # and this time the per-recipient series is present, so the "no series" - # rule has nothing to say even though one recipient is unproved. - - eval_time: 2h30m - alertname: SecretsKeyRecipientsUnrecorded - exp_alerts: [] - - # --- SecretsKeyBackupUnproven: trinity's recipients, trinity's row -------- - # - # trinity declares the age-key deadline as verify-key-backup-sensitive, not - # verify-key-backup, because one name on two instances makes every - # on(homelab_job) join many-to-many (install-timers.sh check 8). This pins - # the three things that name has to do: the stale-job rules still evaluate - # with both declarations present (a stale ordinary job still fires), the - # per-recipient rule holds trinity's never-proved recipient to trinity's - # row, and neither the job series nor the monitoring host's fresh proof - # leaks into the other host's answer. - - interval: 1m - input_series: - - series: 'homelab_job_max_age_seconds{homelab_job="verify-key-backup", instance="prometheus"}' - values: "3600+0x180" - series: 'homelab_job_max_age_seconds{homelab_job="verify-key-backup-sensitive", instance="trinity"}' values: "3600+0x180" - - series: 'homelab_key_recipient_last_proof_timestamp_seconds{stack="observability", - recipient="age1aaa", instance="prometheus"}' - values: "9000+0x180" - - series: 'homelab_key_recipient_last_proof_timestamp_seconds{stack="sensitive", - recipient="age1ccc", instance="trinity"}' - values: "0+0x180" - - series: 'homelab_job_last_success_timestamp_seconds{homelab_job="verify-key-backup-sensitive", - instance="trinity"}' - values: "0+0x180" - - series: 'homelab_job_last_success_timestamp_seconds{homelab_job="backup-volumes", instance="prometheus"}' - values: "0+0x180" - - series: 'homelab_job_max_age_seconds{homelab_job="backup-volumes", instance="prometheus"}' - values: "3600+0x180" alert_rule_test: - - eval_time: 2h30m - alertname: SecretsKeyBackupUnproven - exp_alerts: - - exp_labels: - alertname: SecretsKeyBackupUnproven - stack: sensitive - recipient: age1ccc - instance: trinity - component: backup - severity: warning - category: correctness - exp_annotations: - summary: "No proven backup of age recipient age1ccc in 2h 30m 0s" - description: >- - Nothing else here proves the sensitive secrets are recoverable - from anywhere but this host — every other job runs on the same - machine, with the same key, against the same disk. Proving a - DIFFERENT recipient does not clear this one. Get that copy out - and run `make secrets-verify-backup KEY= - STACK=sensitive`: docs/runbooks/back-up-the-age-key.md. - - # The stale-job rule still evaluates with both declarations present, and - # the human proof's own job series is not its business on trinity either. - eval_time: 2h30m alertname: ScheduledJobStale - exp_alerts: - - exp_labels: - alertname: ScheduledJobStale - homelab_job: backup-volumes - instance: prometheus - component: backup - severity: warning - category: correctness - exp_annotations: - summary: "backup-volumes has not succeeded in 2h 30m 0s" - description: >- - The timer has stopped running this, or every run since has - failed. Check `systemctl list-timers 'homelab-*'` and - `journalctl -u homelab-backup-volumes.service` on prometheus — - docs/runbooks/schedule-maintenance.md. - - - eval_time: 2h30m - alertname: SecretsKeyRecipientsUnrecorded exp_alerts: [] - - # --- SecretsKeyRecipientsUnrecorded: trinity's row with no file ---------- - - interval: 1m - input_series: - - series: 'homelab_job_max_age_seconds{homelab_job="verify-key-backup-sensitive", instance="trinity"}' - values: "3600+0x180" - alert_rule_test: - - eval_time: 2h - alertname: SecretsKeyRecipientsUnrecorded - exp_alerts: - - exp_labels: - alertname: SecretsKeyRecipientsUnrecorded - homelab_job: verify-key-backup-sensitive - instance: trinity - component: backup - severity: warning - category: correctness - exp_annotations: - summary: "The age-key deadline is declared but no recipient has a proof series to hold to it" - description: >- - scripts/install-timers.sh declared the ninety-day deadline for - verify-key-backup-sensitive on trinity and nothing has written - homelab_key_recipient_last_proof_timestamp_seconds there, so - SecretsKeyBackupUnproven has nothing to read and cannot fire - however stale the proof is. On the monitoring host `systemctl - start homelab-recipient-state.service` writes it; if that unit - does not exist, the timers predate #400 and `make - install-timers` adds it. On trinity, which has no such timer, - `make recipient-state STACK=sensitive` writes it. - docs/runbooks/back-up-the-age-key.md. - - # --- SecretsKeyBackupUnproven: a host with no deadline row of its own ----- - # - # (trinity before its timers carry verify-key-backup-sensitive.) - # - # trinity records its recipients but cannot declare verify-key-backup (check - # 8 in install-timers.sh), so the per-instance join used to find nothing and - # its never-proven keys were silent. It is held to the estate's deadline. The - # monitoring host's own fresh proof stays quiet, so the fallback branch adds - # trinity's alert without duplicating anyone's. - - interval: 1m - input_series: - - series: 'homelab_key_recipient_last_proof_timestamp_seconds{stack="observability", - recipient="age1aaa", instance="prometheus"}' - values: "9000+0x180" - - series: 'homelab_key_recipient_last_proof_timestamp_seconds{stack="sensitive", - recipient="age1ccc", instance="trinity"}' - values: "0+0x180" - - series: 'homelab_job_max_age_seconds{homelab_job="verify-key-backup", instance="prometheus"}' - values: "3600+0x180" - alert_rule_test: - eval_time: 2h30m - alertname: SecretsKeyBackupUnproven - exp_alerts: - - exp_labels: - alertname: SecretsKeyBackupUnproven - stack: sensitive - recipient: age1ccc - instance: trinity - component: backup - severity: warning - category: correctness - exp_annotations: - summary: "No proven backup of age recipient age1ccc in 2h 30m 0s" - description: >- - Nothing else here proves the sensitive secrets are - recoverable from anywhere but this host — every other job runs - on the same machine, with the same key, against the same disk. - Proving a DIFFERENT recipient does not clear this one. Get that - copy out and run `make secrets-verify-backup KEY= - STACK=sensitive`: - docs/runbooks/back-up-the-age-key.md. + alertname: ScheduledJobNeverRan + exp_alerts: [] # --- CaKeyBackupUnproven: keyed on the key's fingerprint (#496) ------------ # diff --git a/stacks/sensitive/glance/pages/maintenance.yml b/stacks/sensitive/glance/pages/maintenance.yml index 956dec20..c4841246 100644 --- a/stacks/sensitive/glance/pages/maintenance.yml +++ b/stacks/sensitive/glance/pages/maintenance.yml @@ -20,16 +20,15 @@ # that reads "never succeeded", not an age of decades. # - A job is overdue when its last success is older than its declared limit # (ScheduledJobStale), and flagged when its last run failed. - # - verify-key-backup (verify-key-backup-sensitive on trinity) and - # verify-ca-key-backup are not read from the generic success time. One - # proof refreshes that for every key, so it can be green while one key - # rots. They are judged per age recipient - # (homelab_key_recipient_last_proof_timestamp_seconds) and per current CA - # key (homelab_ca_key_backup_last_proof_timestamp_seconds) against the same - # limit, as SecretsKeyBackupUnproven and CaKeyBackupUnproven do. A proof - # recorded as 0 reads "never proved", and a declaration with no proof - # series at all on its host reads "no proofs recorded" and counts as - # needing attention, as SecretsKeyRecipientsUnrecorded does. + # - verify-ca-key-backup is not read from the generic success time. One + # proof refreshes that for every key, so it can be green while the + # current key rots. It is judged per current CA key + # (homelab_ca_key_backup_last_proof_timestamp_seconds) against the same + # limit, as CaKeyBackupUnproven does. A proof recorded as 0 reads "never + # proved", and a declaration with no proof series at all on its host + # reads "no proofs recorded" and counts as needing attention. + # - The age-key proof has no deadline since ADR-0120. A verify-key-backup + # row left in a host's declarations from before then is not listed. # # Everything is joined on `instance`, the machine label the rules join on. # Needing attention comes first; the rest follow. @@ -38,7 +37,7 @@ cache: 5m <<: *prometheus parameters: - query: homelab_job_max_age_seconds + query: homelab_job_max_age_seconds{homelab_job!~"verify-key-backup|verify-key-backup-sensitive"} subrequests: success: <<: *prometheus @@ -48,10 +47,6 @@ <<: *prometheus parameters: query: homelab_job_last_exit_code != 0 - keys: - <<: *prometheus - parameters: - query: time() - homelab_key_recipient_last_proof_timestamp_seconds ca: <<: *prometheus parameters: @@ -60,7 +55,6 @@ {{ $decl := sortByString "metric.homelab_job" "asc" (.JSON.Array "data.result") }} {{ $success := (.Subrequest "success").JSON.Array "data.result" }} {{ $failed := (.Subrequest "failed").JSON.Array "data.result" }} - {{ $keys := (.Subrequest "keys").JSON.Array "data.result" }} {{ $ca := (.Subrequest "ca").JSON.Array "data.result" }} {{ if or (ne .Response.StatusCode 200) (eq (len $decl) 0) }}

No data: Prometheus returned no job declarations.

@@ -80,10 +74,8 @@ {{ range $decl }} {{ $j := .String "metric.homelab_job" }}{{ $i := .String "metric.instance" }} {{ $limit := .Float "value.1" }} - {{ if or (eq $j "verify-key-backup") (eq $j "verify-key-backup-sensitive") - (eq $j "verify-ca-key-backup") }} - {{ $proofs := $keys }}{{ $label := "recipient" }} - {{ if eq $j "verify-ca-key-backup" }}{{ $proofs = $ca }}{{ $label = "ca" }}{{ end }} + {{ if eq $j "verify-ca-key-backup" }} + {{ $proofs := $ca }}{{ $label := "ca" }} {{ $n := 0 }} {{ range $proofs }} {{ if eq (.String "metric.instance") $i }} @@ -111,7 +103,7 @@ {{ end }} {{ end }} {{/* Declared and nothing recorded for this host: the rule that - would nag has no left side (SecretsKeyRecipientsUnrecorded). */}} + would nag has no left side. */}} {{ if eq $n 0 }} {{ if eq $pass 0 }}{{ $all = add $all 1 }}{{ $bad = add $bad 1 }} {{ else if eq $pass 1 }} diff --git a/systemd/homelab-recipient-state.service b/systemd/homelab-recipient-state.service index a80ff482..7eec044a 100644 --- a/systemd/homelab-recipient-state.service +++ b/systemd/homelab-recipient-state.service @@ -1,17 +1,9 @@ # Daily record of which age recipients can open the secrets, and when each was # last proved to (#400). # -# WHY A TIMER WRITES A FILE THAT A HUMAN RUN ALREADY WRITES. ADR-0024 moved -# SecretsKeyBackupUnproven from the verify-key-backup job series onto one series -# per recipient, and scripts/key-recipients.sh writes those — but only when -# called, and until this unit existed it was called by exactly two things: a -# human proving a key from removable media, and add-recipient.sh. On a host that -# had proved its key BEFORE the per-recipient series existed, neither ran again, -# the file was never written, and the ninety-day alert had nothing to read while -# the fallback it named (ScheduledJobNeverRan) was satisfied by the old proof. -# Silent, and wrong in the direction that looks clean. This unit is the -# unconditional statement: the recipient list exists on disk every day, whether -# or not anyone has mounted a key lately. +# It was added so the per-recipient proof alert always had a series to read. +# That alert went with ADR-0120; the file stays because remove-recipient.sh +# reads the recipient list from it, and it costs nothing to keep current. # # Needs no root, no network and no private key. key-recipients.sh reads the # recipient list out of the plaintext `sops:` metadata of the encrypted file and From f8d3de407c1fd128c7ff4f51d2ece4cbbe1594cf Mon Sep 17 00:00:00 2001 From: Garrett Allen <98648590+Gerrrt@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:56:15 +0000 Subject: [PATCH 2/2] fix(backup): a failed optional age-key check does not fire ScheduledJobFailed Copilot on #1592: make secrets-verify-backup still records its exit code, and ScheduledJobFailed read it without consulting declarations. Co-Authored-By: Claude Opus 5.5 --- docs/adr/0120-drop-the-age-key-proof-deadline.md | 3 ++- docs/changelog.md | 4 ++-- .../prometheus/rules/backup.rules.yaml | 10 +++++++--- .../prometheus/tests/backup.test.yaml | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/docs/adr/0120-drop-the-age-key-proof-deadline.md b/docs/adr/0120-drop-the-age-key-proof-deadline.md index 95535128..c954ff07 100644 --- a/docs/adr/0120-drop-the-age-key-proof-deadline.md +++ b/docs/adr/0120-drop-the-age-key-proof-deadline.md @@ -30,7 +30,8 @@ the operator to ignore the channel the real alerts arrive on. - The Glance maintenance page stops listing the age-key proof. - `ScheduledJobStale`, `ScheduledJobStaleCritical` and `ScheduledJobNeverRan` skip both names. A host whose `homelab-jobs.prom` predates this change then - stays quiet until `make install-timers` rewrites it. + stays quiet until `make install-timers` rewrites it. `ScheduledJobFailed` + skips them too: a failed optional check is on the screen of whoever ran it. **`make secrets-verify-backup` stays, as an optional check.** It still proves that a copy opens the secrets, and it still records which recipient was diff --git a/docs/changelog.md b/docs/changelog.md index e91cca09..b7fb454a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -29,8 +29,8 @@ docstring gives: it is a record, not a claim about now. which recipient it checked. - **Kept.** `recipient-state` still writes `key-recipients.prom` daily, for `remove-recipient.sh`. - - **Old declarations stay quiet.** The stale-job rules and - `ScheduledJobNeverRan` skip both names. A host whose `homelab-jobs.prom` + - **Old declarations stay quiet.** The stale-job rules, + `ScheduledJobNeverRan` and `ScheduledJobFailed` skip both names. A host whose `homelab-jobs.prom` predates this change is therefore quiet until `make install-timers` rewrites the file. - **Unchanged.** The CA key, off-site and household deadlines. diff --git a/stacks/observability/prometheus/rules/backup.rules.yaml b/stacks/observability/prometheus/rules/backup.rules.yaml index 33fa1cc9..fafe8427 100644 --- a/stacks/observability/prometheus/rules/backup.rules.yaml +++ b/stacks/observability/prometheus/rules/backup.rules.yaml @@ -32,8 +32,8 @@ # The age-key proof is no longer one of them. ADR-0120 dropped its deadline: # verify-key-backup and verify-key-backup-sensitive are not declared any more, # and SecretsKeyBackupUnproven and SecretsKeyRecipientsUnrecorded are gone. -# Both names stay in the exclusions below, and ScheduledJobNeverRan skips them -# too, so a host whose homelab-jobs.prom was written before that change stays +# Both names stay in the exclusions below, and ScheduledJobNeverRan and +# ScheduledJobFailed skip them too, so a host whose homelab-jobs.prom was written before that change stays # quiet until `make install-timers` rewrites it. # # That claim has since been tested rather than merely asserted. #99 added @@ -159,7 +159,11 @@ groups: # # 75 is EX_TEMPFAIL, which run-scheduled.sh uses for "could not acquire # the lock in time" — the job never started rather than ran and failed. - expr: homelab_job_last_exit_code != 0 + # + # The age-key check is skipped. Since ADR-0120 it is optional and run + # by hand, so a failure is already on the screen of the person who ran + # it, and an alert that waits for a re-run would nag about it. + expr: homelab_job_last_exit_code{homelab_job!~"verify-key-backup|verify-key-backup-sensitive"} != 0 for: 10m labels: component: backup diff --git a/stacks/observability/prometheus/tests/backup.test.yaml b/stacks/observability/prometheus/tests/backup.test.yaml index 90faeae9..0948dfde 100644 --- a/stacks/observability/prometheus/tests/backup.test.yaml +++ b/stacks/observability/prometheus/tests/backup.test.yaml @@ -193,6 +193,22 @@ tests: alertname: ScheduledJobNeverRan exp_alerts: [] + # --- ScheduledJobFailed: a failed optional age-key check is not paged --- + # + # make secrets-verify-backup still records its exit code. A failed run, or + # a failure left over from before ADR-0120, does not alert; the person who + # ran it saw the failure. + - interval: 1m + input_series: + - series: 'homelab_job_last_exit_code{homelab_job="verify-key-backup", instance="prometheus"}' + values: "1+0x60" + - series: 'homelab_job_last_exit_code{homelab_job="verify-key-backup-sensitive", instance="trinity"}' + values: "2+0x60" + alert_rule_test: + - eval_time: 30m + alertname: ScheduledJobFailed + exp_alerts: [] + # --- CaKeyBackupUnproven: keyed on the key's fingerprint (#496) ------------ # # The re-mint shape: the old key's copy was proved 30 minutes ago and the