Repository navigation
feat(range): build gandalf's power-off timer (ADR-0124) - #1649
Merged
Gerrrt merged 6 commits intoNov 23, 2026
Merged
Conversation
scripts/range-poweroff.sh powers gandalf off six hours after boot or after the last range-extend (1 to 12 hours). It warns every shell at 30 and 5 minutes, and waits while dpkg holds its lock. systemd/range/ runs it every five minutes. build-the-playground.md section 7 installs it from Hicks (range-extend 6 first, so an install on a long-up box doesn't power it off at once), and the read-back checks the timer is enabled and active. Its 18-fixture --self-test is discovered by self-tests.sh. It passed locally and under gandalf's bash, and each of three deliberate breaks failed it. Not installed on gandalf yet. Refs #1647. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…poweroff-timer # Conflicts: # docs/runbooks/build-the-playground.md
Installed 2026-11-22 17:44 from this branch by section 7's commands. The self-test passed, the deadline was 23:44, a run by hand succeeded, and the timer is enabled and active. The one-power-off proof is not yet run. Refs #1647. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unlocked deadline operations can trigger shutdown after a successful extension or mishandle concurrent updates, while the timer cadence can skip the five-minute warning.
2 open issues
What changed in this PR
Implements ADR-0124’s automatic power-off backstop for gandalf, the range host. Deployment and the live warning, extension, and shutdown proof remain pending under #1647.
Changes:
- Adds deadline checks, shell warnings, bounded extensions, and shutdown deferral while package installation is busy.
- Adds a hardened systemd service and five-minute timer.
- Documents installation and verification, adds deadline-logic fixtures, and records implementation progress.
| File | Description |
|---|---|
systemd/README.md |
Documents the new range unit directory. |
systemd/range/homelab-range-poweroff.timer |
Schedules periodic deadline checks. |
systemd/range/homelab-range-poweroff.service |
Runs the shutdown check with sandboxing. |
scripts/self-tests.sh |
Adds a comment describing the range fixtures. |
scripts/README.md |
Documents the power-off script and its purpose. |
scripts/range-poweroff.sh |
Implements deadline management, warnings, shutdown, and fixtures. |
docs/runbooks/build-the-playground.md |
Adds installation, read-back, and live-proof steps. |
docs/roadmap.md |
Updates implementation and deployment tracking. |
docs/changelog.md |
Records the build and pending host deployment. |
Review effort: Balanced
Gerrrt
added a commit
that referenced
this pull request
Nov 23, 2026
Review on #1649: a five-minute cadence equals the five-minute warning window, so a late run could skip the last warning. And without a lock, a check could act on a deadline an extension had just replaced. The decision now says every minute and one lock, and the Consequence's lag is about a minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…minute Review on #1649 caught two problems: - Without a lock, a check that had read the old deadline could power off after range-extend reported success, and two extensions shared one temporary file. check and extend now hold one flock for the whole operation, and the temporary file is unique. - A five-minute timer equals the five-minute warning window, so a late run could skip the last warning. The timer now runs every minute with AccuracySec=5s. Two fixtures prove the lock's interleavings. They skip where there is no flock (macOS) and both fail with the lock removed. The self-test has 21 fixtures and passed under gandalf's bash. Reinstalled on gandalf. Refs #1647. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gerrrt
added a commit
that referenced
this pull request
Nov 23, 2026
* docs(range): write gandalf's 2026-11-22 audit fixes into the runbook The second read-only audit found containment holding and four gaps. build-the-playground.md gains: - section 2: ip-forward off on vmbr0, and a netdev ingress table on vmbr1 so the host takes nothing from the range, ARP included; - section 4: X11 and TCP forwarding off in the keys-only drop-in, and "Nothing else on gandalf", which removes the dotfiles install and the third-party apt repos; - section 7: a read-back for each; - section 8: check four proves the ingress table, and the stale "until 902 is rebuilt" note is updated. security.md gains the row. The changelog records the audit, including the credential cleanup nothing had recorded. None of it is applied on gandalf yet. Refs #421. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(adr): ADR-0124, power gandalf off on a timer Two audits found the range host left on for days, against the "off between sessions" that ADR-0017's "no monitoring" rests on. ADR-0124 chooses a timer on the host over a collector and an "on too long" alert. The host powers off six hours after boot or after the last range-extend (capped at twelve hours), warns 30 and 5 minutes before, and waits while dpkg holds its lock. ADR-0017 gains a note. build-the-playground.md section 7 says the timer is decided and not built. The changelog and roadmap gain entries, and README's ADR count is 124. #1647 builds it. Refs #1647. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(adr): ADR-0124's six hours is the default deadline, not the bound range-extend replaces the deadline with 1 to 12 hours from now, and the power-off can lag the deadline by a timer period and by a held dpkg lock. The decision and the first Consequence now say so, and the ADR-0017 note, the changelog entry and section 7 match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(adr): ADR-0124's check runs every minute, under one lock Review on #1649: a five-minute cadence equals the five-minute warning window, so a late run could skip the last warning. And without a lock, a check could act on a deadline an extension had just replaced. The decision now says every minute and one lock, and the Consequence's lag is about a minute. 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
Builds ADR-0124 in the repository. Nothing is installed on
gandalfyet.scripts/range-poweroff.sh(as/usr/local/sbin/homelab-range-poweroff):checkwarns or powers off;statusprints the deadline and the time left;extend Hsets the deadline H hours from now, 1 to 12. The same script linked asrange-extenddoes this too./run, so every boot starts the six hours again. It defaults to six hours after boot.wallwarns at 30 and 5 minutes. Each warning is recorded against its deadline, so an extension re-arms both.dpkgholds its lock, then runssystemctl poweroff. Proxmox's ownstopallstops the guests.systemd/range/: a oneshot service with a hardened sandbox, and a timer every 5 minutes from 5 minutes after boot.systemd/README.mdgains the directory (now five), andscripts/README.mdthe row.build-the-playground.md§7:enabledandactive.range-extend 6before enabling. Otherwise, on a box already up six hours, the first run would power it off five minutes after the install.Stacked on #1648, which is stacked on #1646. Merge those first.
Why
Two audits found
gandalfleft on for days. ADR-0124 chose a timer on the host as the backstop. This is that timer. Refs #1647.Blast radius
gandalfonly, once installed. What goes wrong if this is wrong:The
dpkgwait has no cap. A hungdpkgwould hold the box on until someone looks, and that was chosen over cutting a package install half way. A session driven only from the8006web UI sees nowallwarning, and §7 says so.secrets/*.sops.yamlVerification
./scripts/range-poweroff.sh --self-test: 18/18 PASS (bash 5.3, macOS). The fixtures cover:dpkgwait, then the power-off oncedpkgis done;extendrefusing 0, 13,2hand nothing;08read as eight, not octal;dpkgwait, the 12-hour cap, or the 5-minute warning each failed 1 or 2 fixtures. An unchanged copy failed none.gandalf, piped tobash -swith nothing installed: 18 PASS.systemd-analyze verifyongandalf(units in a temp dir, removed after): the only error is that/usr/local/sbin/homelab-range-poweroffdoesn't exist yet.systemd-analyze securityrates the service 7.0 MEDIUM, as expected for a root unit that must callpoweroffandwall.self-tests.shdiscovers the suite. Locally, 14 other suites fail on this Mac (no docker, BSD tools). The same 14 fail on a cleanorigin/mainworktree, and the diff between the two runs is only+ PASS range-poweroff.sh --self-test (18 fixtures).check_docs.pyOK. Pinnedmarkdownlint-cli20.24.1: 0 issues.shellcheck: clean.lint.sh: ruff, yamllint, shellcheck and actionlint pass. ansible-lint FAILED on the same local runner error as docs(range): write gandalf's 2026-11-22 audit fixes into the runbook #1646, and docker-only checks were skipped.make validatepasses. It was not run, because there is no docker daemon here.🤖 Generated with Claude Code