Compare commits

..

No commits in common. "77468b1efdf37727afeca542dcdab76bc248952b" and "862a11490951b243166a4e66f5416c79e7575cb6" have entirely different histories.

14 changed files with 35 additions and 99 deletions

View File

@ -102,13 +102,8 @@ repos:
additional_dependencies:
- pytest
- requests
# Kept in step with pyproject.toml on purpose: pip refuses two
# different direct URLs for one distribution, so a stale pin here
# becomes an unresolvable hook environment the moment freedays --
# which requires gatelock v0.7.3 -- joins the list.
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.3#subdirectory=gatelock
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.1#subdirectory=crdt-sync
- freedays @ git+https://github.com/kuhyx/utils@freedays-v0.1.0#subdirectory=freedays
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.1#subdirectory=gatelock
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.6.0#subdirectory=crdt-sync
- mcp>=2,<3
- pydantic
# Test suites intentionally use patterns (protected-access, magic-value

View File

@ -104,16 +104,16 @@ class WrapperServer {
return;
}
if (path.startsWith(WrapperPaths.documents)) {
return await _storedFile(
return _storedFile(
request,
'documents',
path.substring(WrapperPaths.documents.length),
);
}
if (path == kSyncAccountPath) {
return await _syncAccount(request);
return _syncAccount(request);
}
return await _static(request, path);
return _static(request, path);
}
/// Serves the shared sync account so a desktop install can self-provision.

View File

@ -30,7 +30,7 @@ void backgroundCheckCallbackDispatcher() {
if (taskName == syncPushTaskName) {
// Return the push's own success flag so a still-offline / failed push
// is retried with backoff rather than silently dropped.
return await backgroundSyncPush();
return backgroundSyncPush();
}
if (taskName == backgroundCheckTaskName) {
await checkAndNotify();

View File

@ -53,7 +53,7 @@ class IndexedDbDocumentStore implements DocumentStore {
if (value is String) return value;
// Empty IndexedDB: either a first run or a cleared profile. Recover from
// the wrapper's disk copy rather than silently starting from nothing.
return await _readMirror(name);
return _readMirror(name);
}
@override

View File

@ -26,7 +26,7 @@ Future<FirebaseRestClient?> openFirebase() async {
// turned one missing write into "syncs over GitHub and 401s forever":
// the credential that actually authenticates was sitting in the keystore
// the whole time, unused. Ask the store directly before giving up.
return await _clientFromStoredSession();
return _clientFromStoredSession();
}
try {
return await firebaseClientFor(

View File

@ -75,7 +75,7 @@ Future<String?> googleIdToken({
Future<String?> Function()? signInFn,
String serverClientId = kServerClientId,
}) async {
if (signInFn != null) return await signInFn();
if (signInFn != null) return signInFn();
if (serverClientId.isEmpty) {
// A build without --dart-define=GOOGLE_SERVER_CLIENT_ID would otherwise
// fail inside the plugin with a far less obvious message.

View File

@ -23,5 +23,5 @@ class _PrefsPersistence implements LogPersistence {
@override
Future<void> write(String text) async =>
await _prefs.setString(kSyncStateKey, text);
_prefs.setString(kSyncStateKey, text);
}

View File

@ -510,18 +510,18 @@ packages:
dependency: "direct main"
description:
name: permission_handler
sha256: e6bcecadfe40df6b888141f23cbaf6ba6c3da49fb33f6ff887d060dd48544fbd
sha256: e7317eb2eb611d1bf0386b6b974be9c50449f975f19a90a7b8ea013550302b30
url: "https://pub.dev"
source: hosted
version: "13.0.2"
version: "13.0.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: b1ce660f4d0dcaffdf2605a19544c129fb5adda4e6fd039992ae356c4e437039
sha256: d7676c6fcf2f0b92537ec41476a6ead45a00b0d8bbb852395a6f9f33f49d6242
url: "https://pub.dev"
source: hosted
version: "14.1.0"
version: "14.0.0"
permission_handler_apple:
dependency: transitive
description:
@ -836,10 +836,10 @@ packages:
dependency: "direct dev"
description:
name: very_good_analysis
sha256: "0bd5eb8d6be76aa0d71e70cbdae6cac8f784f761170568e3c2214a6948c7f6d3"
sha256: "481af67ab5877af20325251dc215a4ebac7666a1c8cf09198ffd457bc612b33d"
url: "https://pub.dev"
source: hosted
version: "11.0.0"
version: "10.3.0"
vm_service:
dependency: transitive
description:
@ -868,26 +868,26 @@ packages:
dependency: "direct main"
description:
name: workmanager
sha256: "96b09a4a852ec487d29371f27031dab80ce2e260911e2dbe0f904951e22a3956"
sha256: c2c7a3eb984cfcf5623308042fc8270e7e02f5021b34f491ffc0a1ec8e281d5c
url: "https://pub.dev"
source: hosted
version: "0.10.10"
version: "0.10.9"
workmanager_android:
dependency: transitive
description:
name: workmanager_android
sha256: ffe8aa061885370c9363f7ae2d2196d31855217c58e7b15899d915d36c768c4a
sha256: "187d1d34864f57f9e388b33b88c001c494093c53679831a3dec2e8176e8829d1"
url: "https://pub.dev"
source: hosted
version: "0.10.9"
version: "0.10.8"
workmanager_apple:
dependency: transitive
description:
name: workmanager_apple
sha256: "9e0ca0b857df986b37ca964ffa3b21990e1bc0f7935356a9706b47e5b71a7524"
sha256: "15558fb54415a010910c3529eaf8f61f94d23903dac620331895c472602d6f6e"
url: "https://pub.dev"
source: hosted
version: "0.9.11"
version: "0.9.10"
workmanager_linux:
dependency: transitive
description:
@ -900,10 +900,10 @@ packages:
dependency: transitive
description:
name: workmanager_platform_interface
sha256: a1022dca1284d64ba8bbe046edc9089cc5158b3d0e2cf9f68c7cde2fbf89746c
sha256: "378b392db15ee88cd878ab983d3a0b4b1e460cfbb0f096ff74fda2614b1ba172"
url: "https://pub.dev"
source: hosted
version: "0.10.5"
version: "0.10.4"
workmanager_web:
dependency: transitive
description:
@ -937,5 +937,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
dart: ">=3.13.0 <4.0.0"
dart: ">=3.12.2 <4.0.0"
flutter: ">=3.44.0"

View File

@ -2,7 +2,7 @@ name: diet_guard_app
description: "Companion phone app for diet_guard: log meals on the go."
publish_to: 'none'
version: 1.0.78+1
version: 1.0.76+1
environment:
sdk: ^3.12.2
@ -31,7 +31,7 @@ dependencies:
idb_shim: 2.9.8
path: 1.9.1
path_provider: 2.1.6
permission_handler: 13.0.2
permission_handler: 13.0.1
shared_preferences: 2.5.5
# Shared "Sync settings" screen (Firebase + optional local backup), reused
@ -46,7 +46,7 @@ dependencies:
url_launcher: 6.3.2
uuid: 4.6.0
web: 1.1.1
workmanager: 0.10.10
workmanager: 0.10.9
dev_dependencies:
# Generates the Android launcher icons from assets/icon/ (see
@ -58,7 +58,7 @@ dev_dependencies:
# freshness check cannot compare against anything.
plugin_platform_interface: 2.1.8
url_launcher_platform_interface: 2.3.2
very_good_analysis: ^11.0.0
very_good_analysis: ^10.3.0
flutter:
uses-material-design: true

View File

@ -17,8 +17,6 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import freedays
from diet_guard._meal_schedule_store import current_schedule
from diet_guard._slots import missing_slots, slot_label
from diet_guard._state import (
@ -40,15 +38,8 @@ def due_slots(now: datetime | None = None) -> tuple[int, ...]:
Returns:
The slot hours that still need a meal logged (empty == nothing due).
Empty on a shared free day, whatever the schedule says. The pool is read
from a single local file and never the network, so this cannot hang the
systemd-fired gate, and an unreadable pool reads as "not free" -- the
normal rules apply rather than the gate switching itself off.
"""
reference = now if now is not None else now_local()
if freedays.is_free_day(reference.date()):
return ()
return missing_slots(reference, logged_slots_today(), current_schedule())

View File

@ -24,7 +24,6 @@ from contextlib import ExitStack
from typing import TYPE_CHECKING
from unittest.mock import patch
import freedays
import pytest
from diet_guard._estimator import Nutrition
@ -104,14 +103,6 @@ def _isolate_state(tmp_path: Path) -> Iterator[None]:
~20 redirects CPython refuses to compile it.
"""
redirects = [
# The shared free-day pool lives under ~/.local/share, outside every
# diet_guard path below. Without this a real free day on the
# developer's machine would make every "the gate is due" test here
# fail, for a reason that looks nothing like the cause.
patch(
"freedays._api.resolve_paths",
lambda paths: paths or freedays.Paths.under(tmp_path / "freedays"),
),
patch(
"diet_guard._budget.BUDGET_FILE",
tmp_path / ".budget",

View File

@ -6,17 +6,11 @@ here the logged set is mocked and ``now`` is injected to drive each decision.
from __future__ import annotations
from datetime import UTC, date, datetime
from typing import TYPE_CHECKING
from datetime import UTC, datetime
from unittest.mock import patch
import freedays
from diet_guard._gate import due_slots, gate_is_due, gate_message
if TYPE_CHECKING:
from pathlib import Path
def _at(hour: int) -> datetime:
"""Return a fixed local datetime at ``hour``."""
@ -83,36 +77,3 @@ class TestGateMessage:
with _logged(set()):
message = gate_message(_at(17))
assert message == "Log your meals for 08:00, 12:00, 16:00 to unlock."
class TestFreeDays:
"""The shared pool stands the gate down entirely."""
def test_a_free_day_leaves_nothing_due(self, tmp_path: Path) -> None:
with _logged(set()):
assert due_slots(_at(20)), "precondition: slots are due without a free day"
freedays.mark(
_at(20).date(),
paths=freedays.Paths.under(tmp_path / "freedays"),
now=_at(20).date(),
)
assert due_slots(_at(20)) == ()
assert not gate_is_due(_at(20))
def test_a_free_day_on_another_date_changes_nothing(self, tmp_path: Path) -> None:
with _logged(set()):
freedays.mark(
date(2026, 12, 24),
paths=freedays.Paths.under(tmp_path / "freedays"),
now=_at(20).date(),
)
assert due_slots(_at(20))
assert gate_is_due(_at(20))
def test_an_unreadable_pool_leaves_the_gate_armed(self, tmp_path: Path) -> None:
"""Fail closed: a corrupt pool must not switch the gate off."""
pool_dir = tmp_path / "freedays"
pool_dir.mkdir(exist_ok=True)
(pool_dir / "free_days.json").write_text("{ not json", encoding="utf-8")
with _logged(set()):
assert gate_is_due(_at(20))

View File

@ -4,9 +4,8 @@ version = "1.0.0"
description = "Tkinter/systemd log-to-unlock meal gate with calorie/macro budget tracking"
requires-python = ">=3.14"
dependencies = [
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.3#subdirectory=gatelock",
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.2#subdirectory=gatelock",
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.1#subdirectory=crdt-sync",
"freedays @ git+https://github.com/kuhyx/utils@freedays-v0.1.0#subdirectory=freedays",
"requests==2.34.2",
]

View File

@ -4,17 +4,16 @@ bandit==1.9.4
codespell==2.4.3
coverage==7.16.0
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.1#subdirectory=crdt-sync
freedays @ git+https://github.com/kuhyx/utils@freedays-v0.1.0#subdirectory=freedays
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.3#subdirectory=gatelock
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.2#subdirectory=gatelock
mcp==2.1.1
mypy==2.3.1
pre-commit==4.6.2
pydantic==2.13.5
pylint==4.0.8
pylint==4.0.7
pytest==9.1.1
pytest-cov==7.1.0
pytest-randomly==5.0.0
pytest-randomly==4.1.0
pytest-sugar==1.1.1
pytest-xdist==3.8.0
requests==2.34.2
ruff==0.16.6
ruff==0.16.5