Garbage Collection

Collecting the internet's garbage in O(n)

Home infrastructure, and a beagle-stork

For a long time, my home server was managed the way most home servers are “managed”: a mix of packages installed by hand, a few shell scripts I mostly remembered writing, and the quiet hope that nothing would require rebuilding it from scratch. It ran Debian, ZFS, and Podman, and it worked fine right up until you wanted to know why something was configured the way it was, or whether a change on disk would survive a reboot.

Over the last couple of months I’ve been moving the whole thing into an Ansible repository. Not because a single server in the house needs enterprise configuration management, but because I got tired of rediscovering my own past decisions by reading /etc and crontab -l.

Desired state and one-off procedures

The first useful split was separating what the machine should look like from things you only want to do once.

site.yml holds the desired configuration: base system tuning, ZFS snapshots and replication, outgoing mail, UPS monitoring, Samba, Time Machine, and each service’s role. The rule is that ansible-playbook site.yml -K --check --diff against a healthy host should report no changes, and running it again should always be safe.

Top-level playbook (site.yml)
# Desired configuration. Safe to run at any time; `--check --diff` should
# normally report no changes. Never import anything from ops/ here.
- name: Home server
  hosts: homeserver
  roles:
    - { role: admin_scripts, tags: [admin_scripts] }
    - { role: base, tags: [base] }
    - { role: mail, tags: [mail] }
    - { role: ups, tags: [ups] }
    - { role: zfs_backups, tags: [zfs_backups] }
    - { role: audiobookshelf, tags: [audiobookshelf] }
    - { role: jellyfin, tags: [jellyfin] }
    - { role: samba, tags: [samba] }
    - { role: timemachine, tags: [timemachine] }
    - { role: paperless, tags: [paperless] }
    - { role: tsidp, tags: [tsidp] }
    - { role: homebox, tags: [homebox] }
    - { role: forgejo, tags: [forgejo] }
    - { role: satisfactory, tags: [satisfactory] }
    - { role: services_page, tags: [services_page] }

- name: Tailnet policy
  hosts: localhost
  connection: local
  gather_facts: false
  roles:
    - { role: tailnet_policy, tags: [tailnet_policy] }

One-off work (fixing file ownership, moving a Time Machine sparsebundle into a new dataset, removing an old apt-installed service after migrating it to a container) lives in a separate ops/ directory and is never imported into site.yml. Those playbooks assert their preconditions, spell out what they are about to touch, and ask before doing anything destructive. Anything that takes a long time, like copying a big backup bundle, runs as a systemd unit on the server itself rather than over SSH, so closing my laptop doesn’t leave a migration half-finished.

Containers, storage, and finding out when things break

Most services now run as rootless Podman containers managed through systemd quadlets, each under its own nologin user. Paperless-ngx, Homebox, Forgejo, Audiobookshelf, Jellyfin, PhotoStructure, and the Omada controller all live that way now, along with a local tsidp instance. Each gets its own ZFS dataset, snapshotted by sanoid and replicated nightly to a second pool by syncoid.

The unglamorous parts turned out to be the ones worth writing down most. Capping the ZFS ARC so it doesn’t crowd everything else out. Turning off NVMe power-saving states that misbehaved. Telling updatedb to stay off the ZFS pools so a nightly locate crawl stops waking the spinning disks to walk millions of photos and backups. Pinning third-party apt keyrings by SHA256 so a rotated key fails loudly instead of turning into a mysterious apt error later.

Capping the ZFS ARC and disabling NVMe APST (roles/base)
# ZFS read cache ceiling. OpenZFS 2.3+ defaults to nearly all RAM on Linux,
# which starved services and pushed them into swap.
zfs_arc_max_gib: 12

# default_ps_max_latency_us=0 disables NVMe APST: the 990 PRO went silent
# with nothing logged (controller "dead", pool suspended) and came back only
# after a power cycle, the signature of a drive stuck in a deep power state.
kernel_cmdline_extra:
  - nvme_core.default_ps_max_latency_us=0
- name: ZFS ARC cap for future boots
  become: true
  ansible.builtin.copy:
    dest: /etc/modprobe.d/zfs.conf
    content: "options zfs zfs_arc_max={{ zfs_arc_max_gib * 1024 * 1024 * 1024 }}\n"
    owner: root
    group: root
    mode: "0644"

- name: Read live ZFS ARC cap
  ansible.builtin.slurp:
    src: /sys/module/zfs/parameters/zfs_arc_max
  register: arc_max_live

- name: ZFS ARC cap now
  become: true
  ansible.builtin.shell: echo {{ zfs_arc_max_gib * 1024 * 1024 * 1024 }} > /sys/module/zfs/parameters/zfs_arc_max
  when: (arc_max_live.content | b64decode | trim | int) != (zfs_arc_max_gib * 1024 * 1024 * 1024)

- name: Extra kernel parameters for future boots
  become: true
  ansible.builtin.copy:
    dest: /etc/default/grub.d/home-infra.cfg
    content: |
      GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT {{ kernel_cmdline_extra | join(' ') }}"
    owner: root
    group: root
    mode: "0644"
  notify: Update grub

# The boot parameter only applies at the next boot; this disables APST on the
# running controllers now (a latency tolerance of 0 turns APST off).
- name: Find NVMe controllers' APST latency tolerance
  ansible.builtin.find:
    paths: /sys/class/nvme
    file_type: link
  register: nvme_controllers
  when: "'nvme_core.default_ps_max_latency_us=0' in kernel_cmdline_extra"

- name: Read APST latency tolerance
  ansible.builtin.slurp:
    src: "{{ item.path }}/power/pm_qos_latency_tolerance_us"
  loop: "{{ nvme_controllers.files | default([]) }}"
  register: nvme_apst

- name: Disable APST on running NVMe controllers
  become: true
  ansible.builtin.shell: echo 0 > {{ item.source }}
  loop: "{{ nvme_apst.results | default([]) }}"
  when: (item.content | b64decode | trim) != "0"

Every systemd unit, both system and user, gets an OnFailure hook that emails its journal through msmtp when it fails. A home server doesn’t have a pager rotation, and without failure mail a broken backup job or an expired iCloud 2FA session will happily fail in silence for months.

Failure notification template and script (notify-failure@.service, notify-unit-failure)
# Use from any unit with: OnFailure=notify-failure@%n.service
[Unit]
Description=Email failure notice for %i

[Service]
Type=oneshot
ExecStart=/usr/local/bin/notify-unit-failure %i
#!/usr/bin/env bash
set -euo pipefail

journal_scope=()
hint_scope=''
if [[ ${1:-} == --user ]]; then
  journal_scope=(--user)
  hint_scope='--user '
  shift
fi

unit=$1
host=$(hostname)

if ! log=$(journalctl "${journal_scope[@]}" -u "$unit" -n 100 --no-pager 2>&1); then
  log="journalctl failed for $unit:
$log"
fi

{
  printf 'To: root\n'
  printf 'Subject: %s failed on %s\n' "$unit" "$host"
  printf 'Content-Type: text/plain; charset=utf-8\n\n'
  printf '%s failed on %s at %s.\n\nsystemctl %sstatus %s; journalctl %s-u %s\n\n' \
    "$unit" "$host" "$(date '+%F %T %Z')" "$hint_scope" "$unit" "$hint_scope" "$unit"
  printf '%s\n' "$log"
} | /usr/sbin/sendmail -t

Making it usable for everyone else in the house

Self-hosting for yourself is one thing; self-hosting for a household is mostly a UX problem. Nobody else wants to remember port numbers, manage six separate passwords, or click through self-signed certificate warnings just to look up a scanned document or listen to an audiobook.

Two Tailscale pieces made most of that go away. First, web apps are published as Tailscale Services (svc:<name>) rather than hanging off random ports on the host, so every app gets a normal HTTPS URL on the tailnet. Second, tsidp acts as an OIDC identity provider for the apps that support it, including Paperless, Homebox, Forgejo, and Audiobookshelf, so signing in in a browser uses your Tailscale identity with no password to remember. (There is still a documented break-glass procedure for when tsidp itself is down, because locking yourself out of your own document archive is a rite of passage I’d rather skip.)

Tailscale Service unit (paperless-tailscale.service)
# Managed by home-infra (roles/paperless).
[Unit]
Description=Paperless Tailscale Service
# tailscale-online.target runs `tailscale wait`: at boot `tailscale serve` fails until
# tailscaled is connected ("unexpected state: NoState").
Wants=tailscale-online.target
After=network.target tailscale-online.target

[Service]
# `tailscale serve` registers the service with tailscaled and exits; the config
# persists in tailscaled. RemainAfterExit keeps the unit active so it reads as up.
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/tailscale serve --service=svc:paperless --https=443 127.0.0.1:8000

Restart=on-failure

[Install]
WantedBy=multi-user.target

On top of that, a small Caddy container serves a static home page listing what’s available, split into Apps, Games, and Infrastructure, with plain-English descriptions of what each thing does. The bottom of the page shows live Time Machine status: each Mac has its own ZFS dataset with a refquota and its own SMB account, and a check script writes out JSON every hour so you can see at a glance when each machine last backed up and how much of its quota it’s using, without getting emailed until the daily check actually finds a problem.

The tailnet policy itself now lives in the same repository, with a check that refuses to push over edits made in the Tailscale admin console and a few tests verifying who can reach what.

Early feedback from the household suggests the UX is at least working. Kindli asked, “Why is it called beagle-stork?” (Tailscale assigns two random words for a tailnet’s domain.) Oliver volunteered, “I totally wasn’t watching Top Gear in class today.” I suppose both of those count as wins for the home server.

Illustration of a beagle-stork: a tricolor beagle head with floppy ears on the long neck, white-and-black feathered body, and tall red legs of a stork, standing in a reedy pond.
Ciconia beaglis (AI-generated SVG by Gemini 4 Neon, medium thinking; notes)

Her verdict after seeing it: “I believe this is a crime against good taste.”

Working with coding agents on a real machine

In my last post, I mentioned spending a lot of time working with coding agents and thinking about the guardrails around them. This repository turned into a pretty good testbed for that.

Agents wrote a lot of the specs, Ansible roles, runbooks, and tests here, and reviewed each other’s branches. The boundary that kept it comfortable was simple: agents never hold sudo. They can run syntax checks, unit tests, and read-only SSH inspections, and then they hand me the --check --diff and apply commands to run in my own terminal with -K, which tells Ansible to prompt interactively for the sudo password.

Writing tests for home-server configuration sounds a little precious until it catches something real. After a reboot, eight of nine tailscale serve units came up failed: at boot they started before tailscaled had finished connecting, exited immediately, and burned through systemd’s restart limit in about a second. Everything still looked like it worked only because tailscaled persists its serve config across restarts. Adding Wants= and After=tailscale-online.target fixed the units, and a forty-line Python test now checks every *-tailscale.service file in the repo so the next service I add won’t repeat the mistake.

Unit test for Tailscale serve units (tests/test_tailscale_serve_units.py)
import pathlib
import unittest

REPO = pathlib.Path(__file__).resolve().parent.parent
SERVE_UNITS = sorted(
    p
    for p in REPO.glob("roles/*/*/*-tailscale.service*")
    if "tailscale serve" in p.read_text()
)


def unit_lines(path, key):
    return [
        line.split("=", 1)[1].split()
        for line in path.read_text().splitlines()
        if line.startswith(f"{key}=")
    ]


class ServeUnitsWaitForTailscale(unittest.TestCase):
    def test_found_the_serve_units(self):
        self.assertGreaterEqual(len(SERVE_UNITS), 8, SERVE_UNITS)

    def test_each_unit_wants_and_orders_after_tailscale_online(self):
        for unit in SERVE_UNITS:
            with self.subTest(unit=unit.relative_to(REPO)):
                wants = [u for line in unit_lines(unit, "Wants") for u in line]
                after = [u for line in unit_lines(unit, "After") for u in line]
                self.assertIn("tailscale-online.target", wants)
                self.assertIn("tailscale-online.target", after)


if __name__ == "__main__":
    unittest.main()

What’s still messy

Not everything on the box is managed this way yet. A few system packages, like Homebridge and Transmission, are still installed by hand. The Satisfactory server is still hand-installed too; Ansible only owns the timer that restarts it at 2am on Sundays so Steam updates it automatically.

The bigger piece still sitting outside Ansible is the router, which runs OPNsense. Right now it is mostly in observation mode after a couple of whole-network lockups led me to turn off Suricata inline IPS on the WAN as the prime suspect, and there is still a planned migration off end-of-life ISC DHCP onto dnsmasq behind Unbound. Longer term, the repo already has notes for replatforming that box to Debian underneath an OpenWrt VM managed with libvirt so the UPS monitoring and services page can live next to the router rather than on the main server, and for keeping an old EdgeRouter preconfigured as a cold standby so a router rebuild or outage becomes a cable swap. None of that happens until I’m confident the lockups are actually gone, since changing two things at once is a reliable way to learn nothing.

That feels like about the right line to draw. The goal wasn’t a spotless infrastructure-as-code demo. It was making sure the backups, photos, documents, media, git mirrors, and the networking holding them together are documented, tested, and boring to maintain.

Looking for work, and things worth building

Well, I’ve restarted the blog. Now for the slightly more practical announcement: I’m looking for paid work. Capitalism compels me.

I’ve been building Transpire, turning the emails, PDFs, spreadsheets, data from ERP integrations, and other assorted evidence of supply-chain activity into something people can actually use. You ordered twelve parts, the carrier says delivered, somebody counted eight, and the invoice says twelve. The software should help you deal with that. There are still four parts missing, however green the checkmark might be.

We haven’t found enough paying customers in the time we needed to. I need paid work, and I’d like to keep building software that makes someone’s day better. There’s a lot worth doing with AI inside the software, doing useful work and staying out of the way.

A fair amount of that work has involved coding agents. They write substantial amounts of software, investigate problems, run tests, and review each other’s work. I spend a lot of time figuring out what to ask them to do, questioning what they came back with, and improving the tools they have to work with. Which has turned out to be pretty interesting work in its own right.

The amusing part is how familiar some of this is. Is this benchmark measuring what we think it is? It’s certainly fast, but the database is on a RAM disk, so perhaps we should try it with the part where it actually keeps the data. Does the backup work? Well, have we restored it? I’ve been having these conversations for years. Now some of them are with agents. The questions, and quite often the answers, haven’t changed all that much.

I’ve also been working on the development process itself: the tools and instructions the agents use, how they test their work, and how we figure out whether any of it is helping. If the agents keep writing the same little scripts, perhaps those should be tools they can just use. If they can’t get the application running, they’re going to have a hard time telling whether they broke it. And if they keep ignoring the tools we already have, adding another paragraph of instructions may or may not help. This has become a fairly interesting part of building the product, and I’d like to keep doing it.

Leading engineers is work I enjoy. So is writing software. So is figuring out what we should actually be making. I’ve never really encountered a “purely technical” problem; eventually there are people involved, usually with differing ideas about what the problem was. A role that combines those things would suit me well. A role where I spend all my time managing and none of it building would be a much harder sell.

For those who know me from a different part of my life: I spent nearly fifteen years at Lex Machina, joining when the engineering team was two people and eventually leading a global engineering and product organization of more than thirty. That included building legal analytics systems, growing the team, and taking the company through acquisition and integration. Before that, there was publishing, semantic web work, and a fair amount of XML. There is always more XML.

I’m open to a few shapes this could take: another founder looking for a technical partner, a small team within an established company, or consulting on a problem that needs someone to get properly involved. Consulting might well be through Transpire LLC. The company can still do useful work even if the product hasn’t paid the bills. Interesting people with interesting problems remain a pretty good starting point.

If we’ve worked together before, I’d love to hear from you. If someone comes to mind who I should talk to, introductions would be appreciated. Thoughtful recruiters are welcome too.

My résumé is here, and you can get in touch here.

gc.isReEnabled() === ???

Well, it’s been 12 years, perhaps I should start writing again. So obviously the first thing to do is a bunch of programming work. This blog is no longer in WordPress. Instead it’s running as a Wasm application hosted on edge compute nodes running on Fastly… yeah, okay that’s a bit wonky, but it’s kinda a static site if you look at it sideways? Also did a bit of design work based around the G5 photo I’ve kept as a banner: no more theme, just a global style sheet and some new typography. A few links had broken over the years, so those are mostly fixed. Which I suppose means I have to stop putting off the actual writing. Perhaps I’ll manage more often this time.

Oh, and the source code for the blog and its supporting tooling are available. It’s mostly Astro and some wiring connecting it to Fastly.

Earlier

  1. Years of Devices
  2. time vs data
  3. schema.org as RDFa (Part I)
  4. RDF Database Expectations
  5. Prefixes, not that complicated.
  6. Understanding Microdata, now with more understanding
  7. Trying to understand Microdata? RDFa?
  8. shutdown -r now
  9. Returning a Power Adapter for an External Hard drive
  10. Gratuitous Baby Photos
  11. gc.isenabled() == True