mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-19 23:34:24 +01:00
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Has been cancelled
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Has been cancelled
Tests / test (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Every sync payload (food log, banks, budget, catering credential, Body, export keyring) now lives on diet-guard-sync/devices-e2e, sealed with the Argon2id key from the shared crdt-sync passphrase; record ids, tombstones and clocks stay clear. Old plaintext nodes are copied once and never written or deleted. Locked = no pull, no push. - PC: _sync_e2e.open_e2e over crdt-sync 0.11.0, key and copy memo in ~/.local/share/diet_guard/e2e; undecryptable peers are skipped. - Phone/desktop: sync_e2e.dart, crdt_sync_flutter 0.8.1, lock icon in Settings; pullExportKeys goes through the same open. - wake-alarm weigh-ins read from wake-alarm-sync/devices-e2e (own header), on both sides. Todo: fda71ed1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""Repo-relative paths every device pushes its state to.
|
|
|
|
Split out of ``_sync.py`` for file size. These are the wire layout of the
|
|
`kuhyx/syncs` repo, so they are shared by the tick that pushes the food log
|
|
(:mod:`diet_guard._sync`) and the one that pushes the banks and budget
|
|
(:mod:`diet_guard._sync_banks`) -- a second copy of the layout in either
|
|
module is how one of them starts writing where the other does not look.
|
|
|
|
Every device pushes under its own persisted per-install uuid, never a role
|
|
constant; see :mod:`diet_guard._device`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from diet_guard._sync_e2e import DIET_LAYOUT
|
|
|
|
#: The end-to-end encrypted prefix (``diet-guard-sync/devices-e2e``); the old
|
|
#: plaintext ``diet-guard-sync/devices`` is only ever read, by the E2E copy.
|
|
_DEVICES_DIR = DIET_LAYOUT.prefix
|
|
|
|
#: Where per-device revision markers live, used to skip re-reading an
|
|
#: unchanged remote log. Keyed (HMAC) by the encrypting store, and kept out
|
|
#: of the old ``diet-guard-sync/revs`` the copy fingerprints.
|
|
_REVS_DIR = DIET_LAYOUT.revs_path
|
|
|
|
|
|
def _device_log_path(device_id: str) -> str:
|
|
"""Return the repo-relative path a device's full log is pushed to."""
|
|
return f"{_DEVICES_DIR}/{device_id}/food_log.json"
|
|
|
|
|
|
def _device_food_bank_path(device_id: str) -> str:
|
|
"""Return one device's pushed derived-food-bank path."""
|
|
return f"{_DEVICES_DIR}/{device_id}/food_bank.json"
|
|
|
|
|
|
def _device_manual_bank_path(device_id: str) -> str:
|
|
"""Return one device's pushed curated-food-bank path."""
|
|
return f"{_DEVICES_DIR}/{device_id}/food_bank_manual.json"
|
|
|
|
|
|
def _device_budget_path(device_id: str) -> str:
|
|
"""Return the repo-relative path a device's budget is pushed to."""
|
|
return f"{_DEVICES_DIR}/{device_id}/budget.json"
|
|
|
|
|
|
def _device_kuchnia_path(device_id: str) -> str:
|
|
"""Return one device's pushed catering-credential path.
|
|
|
|
Its own document rather than a field on ``budget.json``: the budget is
|
|
written back at default permissions, and a password riding inside it would
|
|
be readable by anything that reads the budget.
|
|
"""
|
|
return f"{_DEVICES_DIR}/{device_id}/kuchnia.json"
|
|
|
|
|
|
def _device_body_path(device_id: str) -> str:
|
|
"""Remote path of ``device_id``'s Body document (profile, weights, workouts)."""
|
|
return f"{_DEVICES_DIR}/{device_id}/body.json"
|