Read the census after the first write, and every 90 minutes #131

Merged
aluminum-ice merged 2 commits from fix/census-first-read into main 2026-11-01 01:17:47 +00:00
Owner

What this PR does

Two changes to when the census plugin reads the census:

  1. The first read of the day comes just after the first write.
  2. It reads every 90 minutes by default, instead of every 4 hours. The poll_hours option (whole hours, default 4) becomes poll_minutes (default 90, allowed 60–1440).

1. The first read.

The first read was scheduled 1–10 minutes after the census started, and the first write 5–30 minutes in, so a device usually read before it had reported. Its own entry then didn't show on its card or page until the next read, about poll_hours (4 by default) later. Now a device that reports, and hasn't written yet that UTC day, reads only after its first write has been checked (the write time, plus the check's 60 s, plus 1–10 minutes). That applies at start-up, after a pause and at midnight. A device that already wrote that day, or one with report off, reads on the usual schedule.

2. 90-minute reads. An entry stays in its slot 60–120 minutes after its device's last write, because writers keep only this hour's and last hour's entries. A 4-hour read, and even a 2-hour one with its ±10% jitter, misses many devices that were online for only an hour or so, so "active today" undercounts. At 90 minutes nearly all of them are caught. With a small census that's about 4.2 MB a day (16 reads), against the 5 MB default daily_mb; reads cost more as slots fill. Renaming the option is safe now: no release has shipped it, and the census has no config.toml table.

  • census.py: _plan_read; the poll_minutes option, with its help text and the 60–1440 clamp.
  • A new test: the first read comes after the first write, the device counts itself (one online, one active), and a restart in an hour it has already written reads on the usual schedule.
  • Tests updated for poll_minutes, and to expect the next read about 90 minutes on.
  • docs/user-guide/census-setup.md and GUIDE_MD: the first read's timing, poll_minutes, and data use of about 4 MB a day while the census is small.

Checklist

  • Lint passes — make lint (ansible --syntax-check, yamllint, shellcheck --severity=error, and the real-data check). The Lint workflow runs this on the PR.
  • Tests pass — make test (the kestrel_pi pytest suite and the real-data check's tests). The Test workflow runs this on the PR.
  • Nothing real: no secrets, no personal information, no real data. This is a public repository. The diff contains no real account passwords or hashes, Wi-Fi passphrases, private keys, API tokens, .env files, real names, personal emails, device serials, and no real captured or device data: SSIDs, MAC addresses, GPS coordinates, capture files, diagnostics bundles, logs, or screenshots of a real device — placeholders only. The real-data check catches MACs, emails, keys and capture files; real SSIDs, coordinates and screenshots are on you.
  • Consent gates intact. Capture and network plugins still ship disabled, enabling them still takes the authorized-use acknowledgment (never pre-ticked or given by code), and the capture whitelist is still enforced.
  • Docs updated in the same PR, if this changes something an operator sees or configures: the README package table, the relevant page under docs/, and the on-device operator guide (GUIDE_MD in kestrel_pi/userguide.py) where it applies.
  • Commit messages are short and imperative.

Release impact

  • App-layer-safe — changes only files the in-place update engine carries: the kestrel_pi package, plugins/*.py, systemd units, the journald drop-in, a lib script already in the engine's LIB_SCRIPTS, or the CLI.
  • Reflash-class — touches a build input the engine does not carry onto a running device: apt or pip packages, boot options / config.txt / cmdline, kernel modules, the base image or partition size, builder/config.json, builder/config.yml, the Makefile, .forgejo/workflows/, a shipped config default (config.toml / default.conf), or a brand-new lib script.

Notes for review

Both came up while planning the beta test. With one device, the first card and page would have shown zero Kestrels for about four hours. Then the 90-minute default, after weighing data use against the 60–120-minute lifetime of an entry.

🤖 Generated with Claude Code

## What this PR does Two changes to when the `census` plugin reads the census: 1. **The first read of the day comes just after the first write.** 2. **It reads every 90 minutes by default, instead of every 4 hours.** The `poll_hours` option (whole hours, default 4) becomes `poll_minutes` (default 90, allowed 60–1440). **1. The first read.** The first read was scheduled 1–10 minutes after the census started, and the first write 5–30 minutes in, so a device usually read before it had reported. Its own entry then didn't show on its card or page until the next read, about `poll_hours` (4 by default) later. Now a device that reports, and hasn't written yet that UTC day, reads only after its first write has been checked (the write time, plus the check's 60 s, plus 1–10 minutes). That applies at start-up, after a pause and at midnight. A device that already wrote that day, or one with `report` off, reads on the usual schedule. **2. 90-minute reads.** An entry stays in its slot 60–120 minutes after its device's last write, because writers keep only this hour's and last hour's entries. A 4-hour read, and even a 2-hour one with its ±10% jitter, misses many devices that were online for only an hour or so, so "active today" undercounts. At 90 minutes nearly all of them are caught. With a small census that's about 4.2 MB a day (16 reads), against the 5 MB default `daily_mb`; reads cost more as slots fill. Renaming the option is safe now: no release has shipped it, and the census has no `config.toml` table. - `census.py`: `_plan_read`; the `poll_minutes` option, with its help text and the 60–1440 clamp. - A new test: the first read comes after the first write, the device counts itself (one online, one active), and a restart in an hour it has already written reads on the usual schedule. - Tests updated for `poll_minutes`, and to expect the next read about 90 minutes on. - `docs/user-guide/census-setup.md` and `GUIDE_MD`: the first read's timing, `poll_minutes`, and data use of about 4 MB a day while the census is small. ## Checklist - [x] **Lint passes** — `make lint` (ansible `--syntax-check`, `yamllint`, `shellcheck --severity=error`, and the real-data check). The **Lint** workflow runs this on the PR. - [x] **Tests pass** — `make test` (the `kestrel_pi` pytest suite and the real-data check's tests). The **Test** workflow runs this on the PR. - [x] **Nothing real: no secrets, no personal information, no real data.** This is a public repository. The diff contains no real account passwords or hashes, Wi-Fi passphrases, private keys, API tokens, `.env` files, real names, personal emails, device serials, and no real captured or device data: SSIDs, MAC addresses, GPS coordinates, capture files, diagnostics bundles, logs, or screenshots of a real device — placeholders only. The real-data check catches MACs, emails, keys and capture files; real SSIDs, coordinates and screenshots are on you. - [x] **Consent gates intact.** Capture and network plugins still ship disabled, enabling them still takes the authorized-use acknowledgment (never pre-ticked or given by code), and the capture whitelist is still enforced. - [x] **Docs updated in the same PR**, if this changes something an operator sees or configures: the README package table, the relevant page under `docs/`, and the on-device operator guide (`GUIDE_MD` in `kestrel_pi/userguide.py`) where it applies. - [x] Commit messages are short and imperative. ## Release impact - [x] **App-layer-safe** — changes only files the in-place update engine carries: the `kestrel_pi` package, `plugins/*.py`, systemd units, the journald drop-in, a lib script already in the engine's `LIB_SCRIPTS`, or the CLI. - [ ] **Reflash-class** — touches a build input the engine does not carry onto a running device: apt or pip packages, boot options / `config.txt` / `cmdline`, kernel modules, the base image or partition size, `builder/config.json`, `builder/config.yml`, the `Makefile`, `.forgejo/workflows/`, a shipped config default (`config.toml` / `default.conf`), or a brand-new lib script. ## Notes for review Both came up while planning the beta test. With one device, the first card and page would have shown zero Kestrels for about four hours. Then the 90-minute default, after weighing data use against the 60–120-minute lifetime of an entry. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Read the census after the first write, so a device counts itself
All checks were successful
Lint / lint (push) Successful in 33s
Test / test (push) Successful in 35s
Test / test (pull_request) Successful in 30s
Lint / lint (pull_request) Successful in 33s
874750c10e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice changed title from Read the census after the first write to Read the census after the first write, and every 90 minutes 2026-11-01 01:14:26 +00:00
Read the census every 90 minutes by default (poll_minutes)
All checks were successful
Lint / lint (push) Successful in 33s
Test / test (push) Successful in 35s
Test / test (pull_request) Successful in 31s
Lint / lint (pull_request) Successful in 34s
0008b45d92
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch fix/census-first-read 2026-11-01 01:17:47 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aluminum-ice/kestrel!131
No description provided.