Repository navigation
feat(sensor): check hourly that fenrir is still an appliance - #1580
Merged
Merged
Conversation
A collector on fenrir reads what build-the-sensor-guest.md leaves (sshd, the keys, root's keys, sudoers.d, login accounts, groups, user units and linger, snaps, apt sources, host listeners, the size of $HOME) and writes one 0-or-1 per check. ApplianceCheckFailed and ApplianceStateStopped read it in the lab. It catches drift by accident only: root on fenrir can make it read clean, and the collector's header and security.md say so. Refs #1577 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1577 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Collector validation gaps can falsely report compliance, while alert timing and missing-series handling can cause premature firing or clearing without recovery.
5 open issues
What changed in this PR
Adds hourly appliance-drift monitoring for fenrir, using the existing agent-collector and lab Prometheus infrastructure to detect departures from the sensor runbook.
Changes:
- Adds eleven pass/fail checks, a hardened systemd service and timer, and installer integration.
- Adds lab alerts and rule tests for failed checks and stopped reporting.
- Documents installation, monitoring coverage, and limitations: guest root can falsify results, and lab alerts page no one.
| File | Description |
|---|---|
| systemd/README.md | Lists the new appliance-check timer. |
| systemd/agent/homelab-appliance-state.timer | Schedules hourly and post-boot checks. |
| systemd/agent/homelab-appliance-state.service | Runs the collector with restricted write access. |
| stacks/lab/README.md | Updates the lab alert inventory. |
| stacks/lab/prometheus/tests/lab.test.yaml | Tests failed checks and missing or stale reporting. |
| stacks/lab/prometheus/rules/lab.rules.yaml | Adds appliance failure and reporting alerts. |
| scripts/README.md | Documents the new collector. |
| scripts/install-agent-collectors.sh | Registers the sensor-specific installer row. |
| scripts/collect-appliance-state.sh | Implements eleven checks and parser fixtures. |
| docs/security.md | Describes drift monitoring and its trust limitations. |
| docs/runbooks/schedule-maintenance.md | Adds appliance monitoring to the collector inventory. |
| docs/runbooks/build-the-sensor-guest.md | Adds fingerprint setup and installation instructions. |
| docs/changelog.md | Records implementation and deployment evidence. |
Review effort: Balanced
- The Lint failure: a diff3 base marker left in the changelog by the rebase. - root's keys: an indented key is a key, and a read error no longer passes. - User units: ~/.local/share/systemd/user and /etc/systemd/user count too, the second against 26.04's baseline as measured on fenrir. - apt: every URI in each .list and .sources file must be an allowed origin, not only the filenames. - ApplianceCheckFailed holds 75m, past a single run's jitter, with tests at the boundary that fail against the old 1h. - ApplianceStateStopped reads fenrir's absence directly, so it no longer clears itself a day after the collector stops. Refs #1577 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt
added a commit
that referenced
this pull request
Nov 19, 2026
…1585) * fix(alerts): stopped-collector rules hold for two weeks, not a day PatchStateStopped (estate and lab) and GuestStateStopped looked back [1d] offset 6h, so about 30 h after the last sample the "was reporting" side emptied and the alert resolved with nothing recovered. They now look back 14 days, inside both Prometheuses' retention. New promtool cases fire at 3 d and 10 d and are quiet at 16 d; with [1d] put back the 3 d and 10 d cases fail. The sensor runbook's sshd step also removes cloud-init's 50-cloud-init.conf, now removed on fenrir. The changelog records both, and that alexander's pending security updates are Ubuntu's phasing. Refs #1580 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(alerts): say what the 14-day stopped rules cannot see Review on #1585: - The estate's PatchStateStopped and GuestStateStopped see a series vanish, not a timer that stops and leaves its .prom file, which is re-served on every scrape. The rule comments and changelog now say so; the lab's copy has an mtime branch, the estate's do not yet. - The lab has no Alertmanager (ADR-0020), so its rule comment no longer says to silence a retired guest. - GuestStateStopped's long-gap test now also asserts quiet at 16 d. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changed
fenrirnow checks hourly that it is still the appliancebuild-the-sensor-guest.mdleaves.scripts/collect-appliance-state.shruns as root under a hardened unit and writes one 0-or-1 per check toappliance-state.prom, eleven in all:sshdsettings, the authorized keys, root's keys andsudoers.datreus's groups, user units and linger$HOMETwo lab rules read it, with promtool tests:
ApplianceCheckFailed, a check failed on two hourly runs (for: 75m, past a single run's jitter), andApplianceStateStopped, fenrir's series absent or the file stale for three hours, for as long as that lasts. The runbook gains the install step, andsecurity.md's row says what this does and does not catch.Why
The 2026-11-13 audit found
fenrirused as a workstation for weeks with nothing saying so, andsecurity.mdsaid "Nothing re-checks this". This was the audit's last open next step.Closes #1577.
Blast radius
fenrironly: the installer row requires/srv/sensor-data. The collector only reads; its one write is the textfile directory. If an allowlist is wrong, the cost is a falseApplianceCheckFailedin the lab, which pages no one (ADR-0020).secrets/*.sops.yamlVerification
collect-appliance-state.sh --self-test: 41 of 41 fixtures pass, run throughself-tests.shdiscovery. fenrir's livess -H -lntupasseslisteners_ok, and the same output plus a127.0.0.1:3000listener fails it.promtool test rules lab.test.yaml: SUCCESS, with a firing and a quiet case for each rule, including the stale-file branch.check_docs.pypasses, with the lab rule count going from 23 to 25. shellcheck passes.lint.shmatchesmainon this Mac: ansible-lint FAILs from the Mac runner, and markdownlint-cli2, zizmor, packer, tofu and editorconfig-checker SKIP for lack of a docker daemon. Those are left to CI.Of the other self-test suites, 15 fail on this Mac, and the same 15 fail on
main.On fenrir:
make install-agent-collectors AGENT=atreus@10.0.30.90 ARGS='--only appliance-state'passed and wrote 11 samples. The first run loggedall 11 checks pass, and the lab's Prometheus received the 11 series underjob="fenrir-metrics".A failure on purpose: a throwaway public key, with its private half deleted, was appended to
authorized_keys. The 05:01 UTC run loggedFAILED: keys, and the lab's Prometheus readkeysas 0. The key was then removed, and the 06:01 run will read 1 again.After review (cacc5e6): root's keys, user units in all three load paths, and apt origins rather than filenames. The new apt and
/etc/systemd/userparsers pass on fenrir's live files. With the oldfor: 1hput back, the new boundary tests fail at 3h10m and 3h15m.Not yet: fenrir runs the pre-review collector until
install-agent-collectors --only appliance-stateis re-run after merge, and the rules are not loaded onalexanderuntilmake up STACK=labruns there.make validatepasses (not run in full on the Mac; see above)Deployed to the lab and confirmed working
Docs updated (
docs/, service README, ordocs/roadmap.md)🤖 Generated with Claude Code