mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-10 21:27:14 +01:00
The hook entry was an absolute /home/kuhy/utils path, copied from a config written for ~/.claude where it only ever ran locally. On an Actions runner that is exit code 127 — "No such file or directory" — so gatelock-precommit and crdt-sync-precommit failed on every commit of this refactor while the hook silently checked nothing. Now repo-relative, matching the sibling hooks (`entry: scripts/check_subproject_scope.sh`): pre-commit always runs from the git root, so it resolves the same in both places. Fixing that made the CI configs runnable locally, and `--all-files` then found what per-file runs had missed — ruff pruning imports that exist *for* their re-export. `import crdt_sync` was broken three separate ways (FileSyncStateStore, encode_key, FileCredentialStore). Each affected module now states an explicit __all__ so the autofixer cannot take them again, and the two files that pushed past the cap once __all__ was added are split further: _firebase.py 260 -> 247 + _fberrors 25 _sync.py 257 -> 188 + _syncargs 91 Test patch targets followed the code they patch: gatelock._outputs.shutil -> _xrandr.shutil, gatelock._arbiter.Path -> _claims.Path. gatelock and crdt-sync both pass `pre-commit run --all-files` in full; 389 and 259 tests at 100% branch coverage; the root gate exits 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CFSGeWxHPY5rHUGrPqhcmG
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""The revision string a device publishes alongside its log.
|
|
|
|
Split from :mod:`crdt_sync._sync` so both the push and pull halves can import
|
|
it without importing each other. Pure: a revision is a function of the encoded
|
|
log and nothing else, which is what lets two devices agree on whether they are
|
|
looking at the same bytes.
|
|
|
|
Re-exported from :mod:`crdt_sync._sync`, so existing imports keep working.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
|
|
|
|
def revision_of(encoded_log: str) -> str:
|
|
"""Return the revision of a serialized log: a content hash.
|
|
|
|
A hash rather than the log's maximum HLC because merging a peer's *older*
|
|
record changes the content without raising the maximum -- with three
|
|
devices in one namespace (diet-guard has ``pc``, ``phone`` and
|
|
``desktop``) a clock-based revision can miss a peer's merged state. It is
|
|
also the same value used to suppress no-op pushes, so the two
|
|
optimisations share one mechanism.
|
|
|
|
Parameters
|
|
----------
|
|
encoded_log : str
|
|
The serialized log, exactly as it would be pushed.
|
|
|
|
Returns:
|
|
-------
|
|
str
|
|
A hex SHA-256 digest.
|
|
|
|
"""
|
|
return hashlib.sha256(encoded_log.encode("utf-8")).hexdigest()
|