diet-guard/diet_guard/tests
Krzysztof kuhy Rudnicki e6322f7f3e Serialise the relay's log writers
The narrow pull, the log write and the publish each read, merge and write
the food log. Run at once (a publish in flight while a second request
logs) they lose the append: the phone is told "logged" and the only copy
is gone. The new race test lost an entry before this change (1 of 2) and
keeps both after it; the shared temp-file name of the log writer also
collided between threads.

One asyncio lock now covers the pull, "resolve slot + log" and the
publish. A request arriving during a publish waits for it (up to one full
tick); the model call stays outside the lock.

Also: a test that the relay unlocks the header diet_guard's devices store
wrote (same key, a blob sealed by one opens on the other), the skill
returns grams 0 for nothing to estimate (parse fails closed, nothing is
logged), and the doc's session note is corrected: the pull and publish
refresh the gate's session file as the CLI's publish does.

Failure paths: a lost append is now impossible in-process (fail closed by
waiting); the pull failure, locked key, estimator and cleanup paths are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWZHWP4KZ6x5TcXDBFC
2026-11-17 21:21:05 +01:00
..
__init__.py feat(diet_guard): add meal-logging screen-lock gate with trigger fix 2026-06-10 22:32:39 +02:00
_claude_fakes.py Add the Claude meal estimator 2026-11-17 21:05:41 +01:00
_claude_redirects.py Add Claude relay seams and entry points 2026-11-17 21:02:35 +01:00
_claude_worker_fakes.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
_gate_fixtures.py Zero gatelock startup grace in tests 2026-11-16 09:37:20 +01: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 gate + CLI: fill today's empty slots from catering in one confirmed step 2026-10-10 13:12:15 +02:00
_gate_layout_probe.py gate + CLI: fill today's empty slots from catering in one confirmed step 2026-10-10 13:12:15 +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
_kuchnia_fakes.py Catering: answer the panel's CSRF 403 at login; kuchnia --log publishes 2026-10-17 12:42:13 +02:00
_state_redirects.py Add Claude relay seams and entry points 2026-11-17 21:02:35 +01:00
_sync_fakes.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
_tk_fakes_canvas.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +02:00
_tk_fakes_containers.py gate: HH:MM spinboxes instead of comboboxes for the meal schedule 2026-10-10 20:13:03 +02:00
_tk_fakes.py gate: HH:MM spinboxes instead of comboboxes for the meal schedule 2026-10-10 20:13:03 +02:00
conftest.py Gate: stand down inside declared holds 2026-11-03 20:27:11 +01:00
test_activity_sources.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +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_body_calc.py Ideal weight: drop Broca family and Hamwi 2026-11-01 18:54:38 +01:00
test_body_parity.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +02:00
test_body_report.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +02:00
test_body_store.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +02:00
test_body_sync.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_budget_history_io.py Grade against 3.14 too, not just run on it 2026-08-29 11:35:06 +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 Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_calendar_view.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_claude_estimate.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_claude_log.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_claude_relay_contract.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_claude_relay_header.py Serialise the relay's log writers 2026-11-17 21:21:05 +01:00
test_claude_relay.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_claude_schema.py Add the Claude meal estimator 2026-11-17 21:05:41 +01:00
test_claude_sdk.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_claude_seams.py Add Claude relay seams and entry points 2026-11-17 21:02:35 +01:00
test_claude_worker_cleanup.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_claude_worker_race.py Serialise the relay's log writers 2026-11-17 21:21:05 +01:00
test_claude_worker.py Add the Claude relay worker 2026-11-17 21:15:08 +01:00
test_cli_averages.py Show weekly and monthly average intake on both devices 2026-08-09 14:59:40 +02:00
test_cli_body.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +02:00
test_cli_future_ate.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_cli_gate.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_cli_sync.py Refresh the phone weight from run_sync, where the PC's event-driven sync actually passes 2026-09-17 09:53:59 +02:00
test_cli.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +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_no_words_static.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gate_no_words.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gate_schedule_move.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_gate_tk_modules.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_gate.py Sick days: diet stands down only when the day does not keep it 2026-10-16 15:12:59 +02:00
test_gatelock_body_glyphs.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_body.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_calendar_schedule.py gate: HH:MM spinboxes instead of comboboxes for the meal schedule 2026-10-10 20:13:03 +02:00
test_gatelock_calendar.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_credit.py Close the open gate when a phone meal arrives 2026-11-16 09:18:07 +01:00
test_gatelock_dashboard.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_fanout.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_fillall_gate.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_fillall.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_form.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01: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 Take gatelock 0.8.1: colour reads through LockConfig.palette 2026-09-12 19:59:44 +02:00
test_gatelock_mealflow.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock_peerpull.py Close the open gate when a phone meal arrives 2026-11-16 09:18:07 +01:00
test_gatelock_scheduleedit.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_gatelock.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_hold.py Gate: stand down inside declared holds 2026-11-03 20:27:11 +01:00
test_kuchnia_autoload.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_kuchnia_cli.py Catering: answer the panel's CSRF 403 at login; kuchnia --log publishes 2026-10-17 12:42:13 +02:00
test_kuchnia_client.py deps: flutter 3.47.7, crdt-sync 0.9.2, freedays 0.3.1, pydantic 2.14.0, ruff 0.17.0 2026-10-10 20:27:52 +02:00
test_kuchnia_credential_store.py feat: sync the catering credential as its own document 2026-08-23 08:12:30 +02:00
test_kuchnia_credential_sync.py feat: carry the catering credential to the phone 2026-08-23 08:25:27 +02:00
test_kuchnia_csrf.py Catering: answer the panel's CSRF 403 at login; kuchnia --log publishes 2026-10-17 12:42:13 +02:00
test_kuchnia_fill.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_kuchnia_gate.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_kuchnia_import.py deps: flutter 3.47.7, crdt-sync 0.9.2, freedays 0.3.1, pydantic 2.14.0, ruff 0.17.0 2026-10-10 20:27:52 +02:00
test_kuchnia_orders.py deps: flutter 3.47.7, crdt-sync 0.9.2, freedays 0.3.1, pydantic 2.14.0, ruff 0.17.0 2026-10-10 20:27:52 +02:00
test_kuchnia_parity.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_kuchnia_parse.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_kuchnia_queue.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00
test_main.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_manual_workout_parse.py Tag manual workouts with source manual 2026-11-10 17:01:52 +01: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_slot.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_mcp.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_meal_schedule_store.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_meal_schedule_vectors.py slots: minute-of-day contract (phase 1 of 3: pure model + shared fixture) 2026-10-10 19:22:43 +02:00
test_meal_schedule.py slots: minute-of-day contract (phase 1 of 3: pure model + shared fixture) 2026-10-10 19:22:43 +02:00
test_phone_weight.py Body tab: weight/body-fat logs, BMI, ideal weight, goal-based kcal target, workouts + Health Connect steps, week planner 2026-09-28 09:03:03 +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 E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_resolve.py Extract diet_guard from testsAndMisc as a standalone repo 2026-06-22 12:18:39 +02:00
test_slot_wire.py slots: minute-of-day contract (phase 1 of 3: pure model + shared fixture) 2026-10-10 19:22:43 +02:00
test_slots_future.py slots: minute-of-day contract (phase 1 of 3: pure model + shared fixture) 2026-10-10 19:22:43 +02:00
test_slots_nearest.py slots: minute-of-day contract (phase 1 of 3: pure model + shared fixture) 2026-10-10 19:22:43 +02:00
test_slots.py slots: minute-of-day contract (phase 1 of 3: pure model + shared fixture) 2026-10-10 19:22:43 +02:00
test_state_entry_id.py Add the Claude relay worker 2026-11-17 21:15:08 +01: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 slots: never post the schedule combobox list; kuchnia dedup on raw minute 2026-10-10 20:06:16 +02:00
test_state_today.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_state.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_sync_backend.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01: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 E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_sync_budget.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_sync_device_id.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_sync_e2e_copy.py Bring three files back under 250 lines 2026-11-16 09:28:02 +01:00
test_sync_e2e.py Bring three files back under 250 lines 2026-11-16 09:28:02 +01: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_kuchnia.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01: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 slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_sync_merge.py slots: minute-of-day consumers (phase 2 of 3: Python side) 2026-10-10 19:53:39 +02:00
test_sync_pull.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_sync_refresh_race.py Close the open gate when a phone meal arrives 2026-11-16 09:18:07 +01:00
test_sync_refresh.py Bring three files back under 250 lines 2026-11-16 09:28:02 +01:00
test_sync.py E2E-encrypt diet_guard sync and export keys 2026-11-12 10:31:44 +01:00
test_test_guard.py Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
test_textgate_scan_clean.py Replace PC gate text with glyphs 2026-11-09 15:35:34 +01:00