Show the tether, reachability and dated last push and read on the Census page #141

Merged
aluminum-ice merged 1 commit from census-status-times into main 2026-11-01 20:38:59 +00:00
Owner

What this PR does

The Census page's Status card now says whether the census can work right now, and when it last did:

  • Phone's Bluetooth tether: up or down (or "Connection: any" with tether_only off).
  • Can read and write the census now: yes, or no with the reason the worker last found (paused and why, a DHT error, still joining).
  • Last pushed (this device's report): the UTC date and time with how long ago, and how many storing nodes held it at the check; or "not yet".
  • Last retrieved (the whole census): the UTC date and time with how long ago; or "not yet".

The last push and read used to live only in memory, so after any daemon restart (an update, a reboot) the card showed just "Running." and the data used until the next cycle. They're now kept in a small status.json in the plugin's state folder (0600, like the others) and loaded on the worker's first tick, so they survive restarts and UTC midnight. The page still never touches the network: the tether line reads the daemon's active paths, and the reachability line comes from what the worker last found.

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, the Release workflow (.forgejo/workflows/main.yml), a shipped config default (config.toml / default.conf), or a brand-new lib script.

Notes for review

  • census.py: _when() (UTC date and time plus how long ago), _valid_last() and _save_last() for status.json, saved after each push, check and read; _status_lines() rewritten. _clock() is gone (its only callers were these lines).
  • Tests: four new ones (dates and reachability after a real cycle, the times surviving a restart, a down tether and tether_only off, the formatter and a malformed status.json), and the old "Last read:" assertion updated. 97 census tests pass.
  • Docs: census-setup.md ("Reading the page", and the state-folder note) and the census paragraph of GUIDE_MD.
  • Screenshots: the guide's demo now marks the census as joined (fixture.py), so its Census picture reads "Can read and write the census now: yes" once this ships in a stable release. I rendered the page from this branch on the demo phone and checked it.
  • The beta check's 3.5 lists every file in the state folder with its mode, so status.json simply shows up there.
  • Locally the suite passes except the two tests that depend on this host (the daemon SIGHUP test and the GPS serial-device test); CI runs both.

🤖 Generated with Claude Code

## What this PR does The Census page's Status card now says whether the census can work right now, and when it last did: - **Phone's Bluetooth tether:** up or down (or "Connection: any" with `tether_only` off). - **Can read and write the census now:** yes, or no with the reason the worker last found (paused and why, a DHT error, still joining). - **Last pushed (this device's report):** the UTC date and time with how long ago, and how many storing nodes held it at the check; or "not yet". - **Last retrieved (the whole census):** the UTC date and time with how long ago; or "not yet". The last push and read used to live only in memory, so after any daemon restart (an update, a reboot) the card showed just "Running." and the data used until the next cycle. They're now kept in a small `status.json` in the plugin's state folder (0600, like the others) and loaded on the worker's first tick, so they survive restarts and UTC midnight. The page still never touches the network: the tether line reads the daemon's active paths, and the reachability line comes from what the worker last found. ## 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`, the Release workflow (`.forgejo/workflows/main.yml`), a shipped config default (`config.toml` / `default.conf`), or a brand-new lib script. ## Notes for review - `census.py`: `_when()` (UTC date and time plus how long ago), `_valid_last()` and `_save_last()` for `status.json`, saved after each push, check and read; `_status_lines()` rewritten. `_clock()` is gone (its only callers were these lines). - Tests: four new ones (dates and reachability after a real cycle, the times surviving a restart, a down tether and `tether_only` off, the formatter and a malformed `status.json`), and the old "Last read:" assertion updated. 97 census tests pass. - Docs: `census-setup.md` ("Reading the page", and the state-folder note) and the census paragraph of `GUIDE_MD`. - Screenshots: the guide's demo now marks the census as joined (`fixture.py`), so its Census picture reads "Can read and write the census now: yes" once this ships in a stable release. I rendered the page from this branch on the demo phone and checked it. - The beta check's 3.5 lists every file in the state folder with its mode, so `status.json` simply shows up there. - Locally the suite passes except the two tests that depend on this host (the daemon SIGHUP test and the GPS serial-device test); CI runs both. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Show the tether, reachability and dated last push and read on the Census page
All checks were successful
Lint / lint (push) Successful in 36s
Lint / lint (pull_request) Successful in 37s
Test / test (push) Successful in 35s
Test / test (pull_request) Successful in 37s
bed213914c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch census-status-times 2026-11-01 20:38:59 +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!141
No description provided.