diet-guard/diet_guard/tests
Krzysztof kuhy Rudnicki 3a9db8a3ab feat(sync): add prune-peers to remove device dirs nothing writes to
Every install mints a uuid and pushes under it, and nothing ever cleans those
directories up. This remote holds 25: two live devices and 23 that stopped
writing. Each dead one still costs a round trip in the log pull and in each of
the three bank syncs -- roughly 400ms per peer per tick -- so they dominate
what is left of the background tick.

Diagnosis first, since the obvious theory was wrong. These are not the residue
of phone reinstalls: seventeen of them are frozen at the *same* instant
(2026-08-13T16:45:04) holding near-identical ~400-record copies of one log,
which is the signature of repeated fresh-install runs, not organic use. That
also means `adb install -r` preserving SharedPreferences was never the issue,
so no Android backup change is warranted on this evidence.

Dry-run by default, and the safety rails are the point:

* `plan_prune` only reads; it is what the default run prints.
* A device is prunable only when every record it holds is already held by a
  device being kept. Against the live remote that is 20 devices and **zero**
  records lost -- verified before writing the command, not after.
* `pc`/`phone`/`desktop` are never proposed: they carry pre-migration history
  and `SYNC_LEGACY_DEVICE_ID` still names one as this device's own former path.
* `--apply` refuses without `--backup-dir`, and every peer's raw bytes are
  written to disk before a single delete.

Nothing has been deleted; this commit only adds the tool.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LJ5YnA3CERitQ57HjMu2Qz
2026-08-21 13:28:04 +02:00
..
__init__.py feat(diet_guard): add meal-logging screen-lock gate with trigger fix 2026-06-10 22:32:39 +02:00
_gate_fixtures.py Let the PC gate set the eating window and meal count 2026-08-16 15:02:35 +02:00
_gate_focus_probe.py Split the six Python gate files; guard the fake-tk patch set 2026-08-15 20:08:03 +02:00
_gate_keyboard_probe.py Split the six Python gate files; guard the fake-tk patch set 2026-08-15 20:08:03 +02:00
_gate_layout_probe.py Split the six Python gate files; guard the fake-tk patch set 2026-08-15 20:08:03 +02:00
_gate_measurement.py Split the six Python gate files; guard the fake-tk patch set 2026-08-15 20:08:03 +02:00
_sync_fakes.py Split _sync.py and its tests; extract the gate fixtures from conftest 2026-08-15 18:51:18 +02:00
_tk_fakes_canvas.py Split _state.py and _tk_fakes.py; make the food-log redirect fail closed 2026-08-15 20:21:26 +02:00
_tk_fakes_containers.py Split _state.py and _tk_fakes.py; make the food-log redirect fail closed 2026-08-15 20:21:26 +02:00
_tk_fakes.py Make _FakeTclError subclass the real tkinter.TclError 2026-08-15 20:24:11 +02:00
conftest.py perf(cli): publish off-thread so logging a meal returns immediately 2026-08-21 13:22:26 +02:00
test_averages_report.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_averages.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_budget_history_io.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_budget_history.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_budget.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_calendar_averages.py Show weekly and monthly average intake on both devices 2026-08-09 14:59:40 +02:00
test_calendar_view.py Migrate diet_guard to gatelock v0.2.0 per-output locking 2026-07-25 16:56:13 +02:00
test_cli_averages.py Show weekly and monthly average intake on both devices 2026-08-09 14:59:40 +02:00
test_cli_gate.py perf(gate): narrow the pre-lock pull and defer the heavy imports 2026-08-21 12:58:44 +02:00
test_cli_sync.py Migrate sync to shared crdt_sync library (Python + Dart) 2026-07-10 23:49:43 +02:00
test_cli.py perf(cli): publish off-thread so logging a meal returns immediately 2026-08-21 13:22:26 +02:00
test_daystatus.py Split _state.py and _tk_fakes.py; make the food-log redirect fail closed 2026-08-15 20:21:26 +02:00
test_estimator.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_foodbank_manual.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_foodbank_rebuild.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_foodbank.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_fuzzy.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_gate_layout_fits.py Fit the meal gate on 1366x768 with a full day logged, and stop the auto-scroll 2026-08-03 16:00:13 +02:00
test_gate_tk_modules.py Make _FakeTclError subclass the real tkinter.TclError 2026-08-15 20:24:11 +02:00
test_gate.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_gatelock_calendar.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_gatelock_dashboard.py perf(gate): unfreeze "Fetch from sync" and bound the interactive timeout 2026-08-21 13:07:37 +02:00
test_gatelock_fanout.py Split the three gate test files; assert fake_tk really swaps tkinter 2026-08-15 20:12:13 +02:00
test_gatelock_form.py Split the three gate test files; assert fake_tk really swaps tkinter 2026-08-15 20:12:13 +02:00
test_gatelock_groups.py Split the three gate test files; assert fake_tk really swaps tkinter 2026-08-15 20:12:13 +02:00
test_gatelock_keyboard.py Split the six Python gate files; guard the fake-tk patch set 2026-08-15 20:08:03 +02:00
test_gatelock_mealflow.py Split the three gate test files; assert fake_tk really swaps tkinter 2026-08-15 20:12:13 +02:00
test_gatelock_scheduleedit.py Let the PC gate set the eating window and meal count 2026-08-16 15:02:35 +02:00
test_gatelock.py Split the three gate test files; assert fake_tk really swaps tkinter 2026-08-15 20:12:13 +02:00
test_main.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_mcp_averages.py Make PC sync event-driven; retire the 15-min timer 2026-08-15 19:21:30 +02:00
test_mcp.py Make PC sync event-driven; retire the 15-min timer 2026-08-15 19:21:30 +02:00
test_meal_schedule_store.py Read the meal schedule from a forward-only history (Python) 2026-08-16 14:28:22 +02:00
test_meal_schedule.py Derive meal slots from an eating window and a meal count 2026-08-16 14:21:12 +02:00
test_portions.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_prune_peers.py feat(sync): add prune-peers to remove device dirs nothing writes to 2026-08-21 13:28:04 +02:00
test_resolve.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_slots.py Read the meal schedule from a forward-only history (Python) 2026-08-16 14:28:22 +02:00
test_state_redirect.py Register the _hmac_key fixture; guard the redirect so it fails locally 2026-08-15 21:19:35 +02:00
test_state_sync.py Split _state.py and _tk_fakes.py; make the food-log redirect fail closed 2026-08-15 20:21:26 +02:00
test_state_today.py Split _state.py and _tk_fakes.py; make the food-log redirect fail closed 2026-08-15 20:21:26 +02:00
test_state.py Split _state.py and _tk_fakes.py; make the food-log redirect fail closed 2026-08-15 20:21:26 +02:00
test_sync_backend.py perf(gate): unfreeze "Fetch from sync" and bound the interactive timeout 2026-08-21 13:07:37 +02:00
test_sync_banks_mirror.py perf(sync): hoist the device listing and stop the curated-bank 404 storm 2026-08-21 13:16:08 +02:00
test_sync_banks.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_sync_budget.py Sync the meal schedule as sched: fields on the budget record 2026-08-16 14:49:08 +02:00
test_sync_device_id.py perf(sync): hoist the device listing and stop the curated-bank 404 storm 2026-08-21 13:16:08 +02:00
test_sync_events.py perf(cli): publish off-thread so logging a meal returns immediately 2026-08-21 13:22:26 +02:00
test_sync_merge_banks.py Split _sync.py and its tests; extract the gate fixtures from conftest 2026-08-15 18:51:18 +02:00
test_sync_merge_budget.py Split _sync.py and its tests; extract the gate fixtures from conftest 2026-08-15 18:51:18 +02:00
test_sync_merge_schedule.py Sync the meal schedule as sched: fields on the budget record 2026-08-16 14:49:08 +02:00
test_sync_merge.py Split _sync.py and its tests; extract the gate fixtures from conftest 2026-08-15 18:51:18 +02:00
test_sync_pull.py perf(sync): hoist the device listing and stop the curated-bank 404 storm 2026-08-21 13:16:08 +02:00
test_sync_refresh.py perf(gate): narrow the pre-lock pull and defer the heavy imports 2026-08-21 12:58:44 +02:00
test_sync.py Split the last seven Python files; extend the redirect guard to all five paths 2026-08-15 20:37:05 +02:00
test_test_guard.py Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00