Repository navigation
fix: draw the address pool from a fixed seed so runs reuse it - #16
Conversation
The pool bounded a single run but every run drew a fresh one, so each HIL pipeline left another --pool worth of devices downstream. After 20 runs at --pool 1024, Home Assistant had 12,318 unique HIL- devices via ESPresense Companion's MQTT discovery, and Spook re-walking every automation on each device-registry change kept the event loop busy. Seed the generator so every run cycles the same addresses, and draw them in order so a smaller pool is a prefix of a larger one. The selftest now asserts the pool is stable instead of asserting it differs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Seeded pool generation and validation ble_flood.py |
address_pool uses a seeded generator to produce a repeatable, duplicate-free pool, with smaller pools matching prefixes of larger pools. random_static_address accepts an optional generator and retains secure random bytes as its default. Tests check pool repeatability, prefix consistency, and different-seed results. |
Possibly related PRs
- ESPresense/ble-loadgen#15: Changes the same
address_poolbehavior with a fixed address sequence, which conflicts with the seeded sequence in this PR.
Priority:
Change: Bug fix
Merge Risk: 
Minimal · up to 96db6
-
No demonstrated issue blocks merging after normal checks.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 1 files.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change that makes BLE address pools repeatable across runs.
No open issues 🎉
What changed in this PR
Makes BLE address pools repeatable across runs, preventing repeated HIL pipelines from continually adding new downstream devices for the same pool size.
Changes:
- Uses a fixed seed to generate stable, unique pool addresses.
- Preserves draw order so smaller pools are prefixes of larger pools.
- Updates selftests for repeatability, prefix consistency, and seed sensitivity; unbounded and iBeacon address generation remain unchanged.
| File | Description |
|---|---|
ble_flood.py |
Adds deterministic address pools, documents their behavior, and updates selftest assertions. |
Review effort: Balanced
Problem
--poolonly capped a single run.address_pool()drew fresh random addresses on every start, and the selftest asserted two pools must differ. Each HIL pipeline (--pool 1024) therefore added up to 1,024 newHIL-<mac>devices downstream.On the bench Home Assistant that reached 12,318 unique
hil-devices over 20 runs through ESPresense Companion MQTT discovery. About 4,300 were still live. Spook re-walking every automation on each device-registry change kept the HA event loop busy.Fix
random.Random(POOL_SEED), so every run cycles the same addresses.--pool 512reuses the first 512 addresses of the 1024 pool.--pool 0) and iBeacon addresses are unchanged and still usesecrets.Testing
python3 ble_flood.py --selftestpasses.🤖 Generated with Claude Code
Summary by CodeRabbit