Add the census plugin #130
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/census-plugin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this PR does
Adds the
censusplugin: an opt-in, anonymous, serverless count of active Kestrels kept in the public BitTorrent DHT (BEP 44 mutable items). Each enabled device adds a 20-byte report once an hour and reads everyone's reports back:It also adds
tools/census-report/, a desktop script that reads the same public slots and prints the census as plain tables (optionally CSV), so you can see which releases are in the field without a device.What leaves the device:
remote-trainplugin'sremote-trainingservice; never the host's details);No capture data, network names or locations.
tether_onlyis on by default, so census traffic goes out only over the phone's Bluetooth tether (the socket is bound tobnep0). The plugin pauses while the tether is down.Plugin:
plugins/census.py:poll_hours;censusservice, the card and the page.plugins/_census_dht.py: a small read-only DHT client (bencode with caps, BEP 42, a KRPC client with rate limits, node pool, bootstrap, lookups, BEP 44 get and put).plugins/_census_proto.py: thekestrel-census/1format and theTallythat the plugin and the desktop report share.tether_only, while the tether is up). Their addresses are saved and tried first on later joins, so the DNS lookup is rare.~pi/.local/state/kestrel-census/(directory0700, files0600), written atomically. A malformed file is rebuilt, never fatal.Docs:
docs/user-guide/census-setup.md;docs/developer/census-protocol.md(the format);GUIDE_MD;managing-plugins.md,user-guides.md,architecture.md(versioned interfaces),remote-training.md,plugin-development.md(services table),SECURITY.md(scope),deferred.md(IPv6, a DHT plugin library, the census on the e-ink face) andCLAUDE.md(nineteen plugins, the census, the tools row, the two bootstrap routers on the allowed list).Tests:
test_census.py;test_census_report.py.All of them run against an in-process fake DHT on RFC 5737 addresses with a fake clock, and none touches the network. They cover the client, the format, what this device reports, every gate, rollover, restart survival, corrupt state, the data budget, link loss mid-write, check-after-write, the DNS order, the totals, the card wording (including the zero case), page escaping, and the report end to end.
Checklist
make lint(ansible--syntax-check,yamllint,shellcheck --severity=error, and the real-data check). The Lint workflow runs this on the PR.make test(thekestrel_pipytest suite and the real-data check's tests). The Test workflow runs this on the PR..envfiles, 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.docs/, and the on-device operator guide (GUIDE_MDinkestrel_pi/userguide.py) where it applies.Release impact
kestrel_pipackage,plugins/*.py, systemd units, the journald drop-in, a lib script already in the engine'sLIB_SCRIPTS, or the CLI.config.txt/cmdline, kernel modules, the base image or partition size,builder/config.json,builder/config.yml, theMakefile,.forgejo/workflows/, a shipped config default (config.toml/default.conf), or a brand-new lib script.No new packages are needed: Ed25519 comes from
cryptography, which the image already has. There's noconfig.tomltable and no Makefile change, because the report's tests live underkestrel_pi/tests. The rest of the diff (tools/, the docs,.gitignore) isn't shipped.Notes for review
census.py;_tick,_gate,_writeand_readin the same file;_census_proto.py.bnep0, the first write 5–30 minutes in, the page, and the pause when the tether drops.🤖 Generated with Claude Code
WIP: Add the census pluginto Add the census plugin