From 2c206e50703ee454e12586a7025a388600aa3fca Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 21 Aug 2026 14:28:14 +0200 Subject: [PATCH] Adopt crdt-sync v0.9.0's bundled sync_log signature sync_log's eleven flat keywords became SyncTarget / LogCodec / RevisionTracking upstream. Call sites and test doubles follow; the hook's own pinned crdt-sync moves to v0.9.0 too, so the gate checks against the API the code actually imports rather than an older tag. No behaviour change. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01VCucBhUkHBBHHbsY7bSdGV --- .pre-commit-config.yaml | 4 +-- CLAUDE.md | 27 +------------------ pyproject.toml | 2 +- requirements.txt | 2 +- screen_locker/_manual_push.py | 25 +++++++++++------ screen_locker/tests/test_manual_push_part2.py | 3 ++- 6 files changed, 24 insertions(+), 39 deletions(-) mode change 100644 => 120000 CLAUDE.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5e21590..b2deb94 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -117,7 +117,7 @@ repos: additional_dependencies: - pytest - 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 + - crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.0#subdirectory=crdt-sync - mcp>=2,<3 - pydantic - id: pylint @@ -132,7 +132,7 @@ repos: additional_dependencies: - pytest - 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 + - crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.0#subdirectory=crdt-sync - mcp>=2,<3 - pydantic diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 158090c..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,26 +0,0 @@ -do NOT run tests unless specifically instructed to do so or before committing -If tests fail on the same issue twice in a row, STOP and ask the user how to proceed instead of continuing to fix and retry. -ALWAYS confirm that the feature you add / bug you fixed behaves as it should by running the program after your changes (not tests!) and inspecting output comparing it with what user wanted, after confirming by yourself ask user if the program behaves as they intended -After running tests fix all coverage gaps and issues, do not ignore unless specifically instructed to do so -You are NOT done until you install the new version on the phone itself (flutter install --debug from the workout_app directory, then adb shell monkey -p com.kuhy.workout_app to launch). - -## NEVER fail silently - -A failure that says nothing is a bug. The PC's workout sync did nothing for -weeks because a missing token `return`ed `[]` and real errors only logged at -`INFO` — nobody could tell "nothing to do" from "it broke". - -- **Swallowed exceptions must say why, loudly.** Every `except` must either - re-`raise` or log at `warning`/`error`/`exception`/`critical` with the - concrete reason. `debug`/`info` do NOT count — an invisible log is a silent - failure with extra steps. Enforced by `scripts/check_silent_failures.py` - (pre-commit hook `no-silent-failures`); ruff's `S110` only catches - `except: pass`, which is the rare case. -- **Guard clauses that abort work must log too.** `if token is None: return` - is a silent no-op. Say what was missing and what it means. -- **Return something meaningful.** Prefer a typed result (e.g. - `_manual_push.PushResult(pushed, record_count, reason)`) over a bare - `None`/`[]`/`False`, so the caller can react instead of guessing. `reason` - should read like a sentence a human can act on. -- **No escape hatch** — `# noqa` is banned repo-wide. If a failure really is - benign, log it at `warning` and move on. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 139d035..93ec88c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires-python = ">=3.10" # also used by diet_guard; here for phone-workout GitHub sync (Workstream C) dependencies = [ "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.1#subdirectory=gatelock", - "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.7.0#subdirectory=crdt-sync", + "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.0#subdirectory=crdt-sync", ] [project.scripts] diff --git a/requirements.txt b/requirements.txt index bd660d7..d097ff2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ bandit>=1.7.0 codespell>=2.2.0 coverage>=7.4.0 -crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.7.0#subdirectory=crdt-sync +crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.9.0#subdirectory=crdt-sync gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.7.1#subdirectory=gatelock mcp>=2,<3 mypy>=1.8.0 diff --git a/screen_locker/_manual_push.py b/screen_locker/_manual_push.py index 5006c89..5c93aa4 100644 --- a/screen_locker/_manual_push.py +++ b/screen_locker/_manual_push.py @@ -32,9 +32,12 @@ from crdt_sync import ( GitHubSyncClient, GitHubSyncError, Hlc, + LogCodec, Record, RemoteSyncError, RepoNotFoundError, + RevisionTracking, + SyncTarget, sync_log, ) @@ -193,14 +196,20 @@ def push_pc_workouts(log_file: Path) -> PushResult: try: with_sync_retry( lambda: sync_log( - client=client, - device_id=identity.device_id, - legacy_device_id=identity.legacy_id, - path_prefix=_DEVICES_PREFIX, - local_log=log, - encode=_encode_log, - decode=_decode_log, - state_store=FileSyncStateStore(SYNC_STATE_FILE), + SyncTarget( + client=client, + device_id=identity.device_id, + legacy_device_id=identity.legacy_id, + path_prefix=_DEVICES_PREFIX, + ), + log, + LogCodec( + decode=_decode_log, + encode=_encode_log, + ), + RevisionTracking( + state_store=FileSyncStateStore(SYNC_STATE_FILE), + ), ), description="push PC workouts", ) diff --git a/screen_locker/tests/test_manual_push_part2.py b/screen_locker/tests/test_manual_push_part2.py index 719ad58..4ee937b 100644 --- a/screen_locker/tests/test_manual_push_part2.py +++ b/screen_locker/tests/test_manual_push_part2.py @@ -164,5 +164,6 @@ class TestPushPcWorkouts: patch.object(_manual_push, "sync_log", MagicMock()) as fake_sync, ): push_pc_workouts(log_file) - pushed = fake_sync.call_args.kwargs["local_log"] + # local_log is the second positional arg since crdt-sync v0.9.0. + pushed = fake_sync.call_args.args[1] assert "runnerup_verified:2026-07-12" in pushed