hsync-common 1.1.2__tar.gz → 1.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {hsync_common-1.1.2 → hsync_common-1.1.4}/PKG-INFO +1 -1
  2. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/constants.py +1 -1
  3. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/_store_base.py +38 -0
  4. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/sqlstore.py +55 -1
  5. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/tombstone_store.py +4 -0
  6. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/version_store.py +5 -0
  7. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/__init__.py +4 -1
  8. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/pairing.py +6 -3
  9. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/rest/openapi.json +1 -1
  10. {hsync_common-1.1.2 → hsync_common-1.1.4}/pyproject.toml +1 -1
  11. {hsync_common-1.1.2 → hsync_common-1.1.4}/LICENSE +0 -0
  12. {hsync_common-1.1.2 → hsync_common-1.1.4}/README.md +0 -0
  13. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/__init__.py +0 -0
  14. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/clock.py +0 -0
  15. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/compression.py +0 -0
  16. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/defaults.py +0 -0
  17. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/delta/__init__.py +0 -0
  18. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/delta/decision.py +0 -0
  19. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/delta/literals.py +0 -0
  20. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/delta/reconstruct.py +0 -0
  21. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/delta/rolling_checksum.py +0 -0
  22. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/delta/token_store.py +0 -0
  23. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/disk.py +0 -0
  24. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/endpoint.py +0 -0
  25. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/env.py +0 -0
  26. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/exceptions.py +0 -0
  27. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/format.py +0 -0
  28. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/fs.py +0 -0
  29. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/hashing.py +0 -0
  30. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/ids.py +0 -0
  31. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/ignore.py +0 -0
  32. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/labels.py +0 -0
  33. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/listing.py +0 -0
  34. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/logger.py +0 -0
  35. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/__init__.py +0 -0
  36. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/_util.py +0 -0
  37. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/arbitration.py +0 -0
  38. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/delta.py +0 -0
  39. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/dir.py +0 -0
  40. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/event.py +0 -0
  41. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/file.py +0 -0
  42. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/folder.py +0 -0
  43. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/sentinel.py +0 -0
  44. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/symlink.py +0 -0
  45. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/sync_action.py +0 -0
  46. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/tombstone.py +0 -0
  47. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/models/version.py +0 -0
  48. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/path_validation.py +0 -0
  49. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/permissions.py +0 -0
  50. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/capabilities.py +0 -0
  51. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/events.py +0 -0
  52. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/causal-resolution-scenarios.json +0 -0
  53. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/causal-tombstone-scenarios.json +0 -0
  54. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/delta-apply-metadata.json +0 -0
  55. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/delta-instructions.json +0 -0
  56. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/delta-signatures.json +0 -0
  57. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ntp-targets-scenarios.json +0 -0
  58. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-election-scenarios.json +0 -0
  59. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-pairing-scenarios.json +0 -0
  60. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-rendezvous-trust-scenarios.json +0 -0
  61. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-sources-request.json +0 -0
  62. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-sources-response.json +0 -0
  63. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-txt-record.json +0 -0
  64. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-txt-seeder-record.json +0 -0
  65. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-auth-failed.json +0 -0
  66. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-auth-ok.json +0 -0
  67. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-auth-required.json +0 -0
  68. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-auth.json +0 -0
  69. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-file-progress.json +0 -0
  70. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-hello-master.json +0 -0
  71. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-hello-slave.json +0 -0
  72. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-ack-ok.json +0 -0
  73. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-ack-rejected.json +0 -0
  74. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-ack-resync.json +0 -0
  75. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-delta-delete.json +0 -0
  76. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-delta-upsert.json +0 -0
  77. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-empty-snapshot.json +0 -0
  78. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/p2p-wss-inventory-snapshot.json +0 -0
  79. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-ack.json +0 -0
  80. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-fingerprint.json +0 -0
  81. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-query.json +0 -0
  82. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-register.json +0 -0
  83. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-attach.json +0 -0
  84. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-connect.json +0 -0
  85. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-error.json +0 -0
  86. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-incoming.json +0 -0
  87. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-listen.json +0 -0
  88. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-listening.json +0 -0
  89. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-ok.json +0 -0
  90. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-relay-ping.json +0 -0
  91. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/rendezvous-response.json +0 -0
  92. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-auth-error.json +0 -0
  93. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-auth-ok.json +0 -0
  94. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-auth-request.json +0 -0
  95. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-file-event.json +0 -0
  96. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-ping.json +0 -0
  97. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-pong.json +0 -0
  98. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures/ws-presence.json +0 -0
  99. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/fixtures.py +0 -0
  100. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/handshake.py +0 -0
  101. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/p2p/sources-schema.json +0 -0
  102. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/p2p/txt-schema.json +0 -0
  103. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/p2p/wss-schema.json +0 -0
  104. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/p2p.py +0 -0
  105. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/peer_download.py +0 -0
  106. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/rdv_tokens.py +0 -0
  107. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/rendezvous.py +0 -0
  108. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/rest.py +0 -0
  109. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/schemas.py +0 -0
  110. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/tls_trust.py +0 -0
  111. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/transfer_progress.py +0 -0
  112. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/protocol/ws/ws-schema.json +0 -0
  113. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/ratelimit.py +0 -0
  114. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/runtime.py +0 -0
  115. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/ssl_utils.py +0 -0
  116. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/state_paths.py +0 -0
  117. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/text.py +0 -0
  118. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/time_utils.py +0 -0
  119. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/tls_context.py +0 -0
  120. {hsync_common-1.1.2 → hsync_common-1.1.4}/hsync_common/upnp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hsync-common
3
- Version: 1.1.2
3
+ Version: 1.1.4
4
4
  Summary: HSYNC Common - shared models, constants, and compression utilities
5
5
  License-Expression: BSD-3-Clause
6
6
  License-File: LICENSE
@@ -18,7 +18,7 @@ from typing import Final, Literal
18
18
  # Single source of truth for the HSYNC application version, shared by client,
19
19
  # server, desktop and Android. The wire-protocol versions live separately in
20
20
  # hsync_common.protocol.handshake (PROTOCOL_VERSION_*).
21
- HSYNC_VERSION = "1.1.2"
21
+ HSYNC_VERSION = "1.1.4"
22
22
 
23
23
  # =============================================================================
24
24
  # HTTP Headers (wire protocol)
@@ -24,6 +24,7 @@ Consumers: ``hsync-common`` store classes only (not a public API).
24
24
 
25
25
  from __future__ import annotations
26
26
 
27
+ import itertools
27
28
  import sqlite3
28
29
  import time
29
30
  from pathlib import Path
@@ -31,6 +32,16 @@ from pathlib import Path
31
32
  from ._util import tombstone_key
32
33
  from .sqlstore import StateDb, get_state_db
33
34
 
35
+ # Node-global clock counter name in the installation DB (see
36
+ # ``StateDb.next_counter``). Every persisted clock raises it, so a node's mint
37
+ # can always reserve a value it has never published before — the node-scope
38
+ # anti-aliasing invariant (ADR-0022).
39
+ VCLOCK_COUNTER = "vclock"
40
+
41
+ # Fallback for stores without a SQLite backend (in-memory/test stores): a
42
+ # process-local sequence keeps reservations strictly increasing within the run.
43
+ _fallback_counter = itertools.count(1)
44
+
34
45
 
35
46
  class CausalStoreBase[T]:
36
47
  """In-memory path→entry map with a lazily opened installation DB handle."""
@@ -74,6 +85,33 @@ class CausalStoreBase[T]:
74
85
  self._db = get_state_db(self.db_path)
75
86
  return self._db
76
87
 
88
+ # ── node-global clock counter (ADR-0022) ────────────────────────
89
+ def next_clock_counter(self) -> int:
90
+ """Reserve a value this node has never minted for any path (ADR-0022).
91
+
92
+ The installation ``counters`` floor stays above every counter this node
93
+ ever published, so a path that lost both its version row and its
94
+ deletion marker cannot re-mint a counter it already published — the only
95
+ way a fresh version could be proven a stale ancestor of a peer's marker.
96
+ Without a backend (in-memory/test store) a process-local sequence is
97
+ used. Consumers: ``hsync-client`` (``sync_state._mint_clock``), the
98
+ ``hsync-server`` mirror and ``hsync-android``.
99
+ """
100
+ db = self._backend()
101
+ if db is None:
102
+ return next(_fallback_counter)
103
+ return db.next_counter(VCLOCK_COUNTER)
104
+
105
+ def raise_clock_counter(self, value: int) -> None:
106
+ """Raise the installation clock floor to at least *value*.
107
+
108
+ Consumers: the stores' own ``record`` methods, so every persisted clock
109
+ keeps the floor honest without an extra call from the sync engine.
110
+ """
111
+ db = self._backend()
112
+ if db is not None:
113
+ db.raise_counter(VCLOCK_COUNTER, value)
114
+
77
115
  # ── dirty tracking ──────────────────────────────────────────────
78
116
  def _mark_dirty(self, key: str) -> None:
79
117
  """Record that *key*'s current value must be upserted on next save."""
@@ -44,7 +44,7 @@ _db_cache: dict[str, StateDb] = {}
44
44
  # connection, and the overwritten one is never closed (leaked handle).
45
45
  _db_cache_lock = threading.Lock()
46
46
 
47
- SCHEMA_USER_VERSION = 1
47
+ SCHEMA_USER_VERSION = 2
48
48
 
49
49
  # Periodic maintenance cadence for the installation DB (ADR-0025). The
50
50
  # ``retain``/tombstone-TTL pruning deletes rows but, without auto-vacuum, the
@@ -94,6 +94,11 @@ CREATE TABLE IF NOT EXISTS tombstones (
94
94
  vclock TEXT NOT NULL,
95
95
  PRIMARY KEY (folder_id, key)
96
96
  ) WITHOUT ROWID;
97
+
98
+ CREATE TABLE IF NOT EXISTS counters (
99
+ name TEXT PRIMARY KEY,
100
+ value INTEGER NOT NULL
101
+ );
97
102
  """
98
103
 
99
104
 
@@ -337,6 +342,55 @@ class StateDb:
337
342
  )
338
343
  return folder_id
339
344
 
345
+ # ── node-global counters (ADR-0022) ─────────────────────────────
346
+ def next_counter(self, name: str) -> int:
347
+ """Reserve and return the next value of a strictly increasing counter.
348
+
349
+ The increment and the read happen in one reserved transaction, so two
350
+ concurrent reservations — even across processes sharing the installation
351
+ DB — never obtain the same value. Consumers: the version mint's
352
+ no-history branch
353
+ (``hsync-common.models.version_store.SyncStateStore.next_clock_counter``),
354
+ which needs a value that was never minted before.
355
+ """
356
+ with self._lock, self.transaction():
357
+ self._conn.execute(
358
+ """
359
+ INSERT INTO counters (name, value) VALUES (?, 1)
360
+ ON CONFLICT(name) DO UPDATE SET value = counters.value + 1
361
+ """,
362
+ (name,),
363
+ )
364
+ row = self._conn.execute(
365
+ "SELECT value FROM counters WHERE name = ?", (name,)
366
+ ).fetchone()
367
+ return int(row["value"])
368
+
369
+ def raise_counter(self, name: str, value: int) -> None:
370
+ """Raise *name* to at least *value*; never lowers it.
371
+
372
+ Consumers: every persisted clock (``version_store.SyncStateStore.record``,
373
+ ``tombstone_store.TombstoneStore.record_by_key``), so the installation
374
+ floor stays above every counter this node has ever published.
375
+ """
376
+ with self._lock:
377
+ self._conn.execute(
378
+ """
379
+ INSERT INTO counters (name, value) VALUES (?, ?)
380
+ ON CONFLICT(name) DO UPDATE
381
+ SET value = MAX(counters.value, excluded.value)
382
+ """,
383
+ (name, max(int(value), 0)),
384
+ )
385
+
386
+ def counter(self, name: str) -> int:
387
+ """Return the current *name* value (0 when never raised)."""
388
+ with self._lock:
389
+ row = self._conn.execute(
390
+ "SELECT value FROM counters WHERE name = ?", (name,)
391
+ ).fetchone()
392
+ return 0 if row is None else int(row["value"])
393
+
340
394
  # ── maintenance ─────────────────────────────────────────────────
341
395
  def freelist_count(self) -> int:
342
396
  """Return the number of free pages in the database file.
@@ -112,6 +112,10 @@ class TombstoneStore(CausalStoreBase[TombstoneEntry]):
112
112
  vclock=clock,
113
113
  )
114
114
  self._mark_dirty(key)
115
+ if clock:
116
+ # A marker is a published clock too: keep the installation counter
117
+ # floor above it (ADR-0022).
118
+ self.raise_clock_counter(max(clock.values()))
115
119
 
116
120
  # ── maintenance ─────────────────────────────────────────────────
117
121
  def prune(self, now: int | float | None = None) -> int:
@@ -92,6 +92,11 @@ class SyncStateStore(CausalStoreBase[FileVersion]):
92
92
  corrected_mtime=corrected_mtime,
93
93
  )
94
94
  self._mark_dirty(key)
95
+ if vclock:
96
+ # Keep the installation counter floor above every clock this node
97
+ # persists, so a later no-history mint cannot reuse a counter it
98
+ # already published (ADR-0022).
99
+ self.raise_clock_counter(max(vclock.values()))
95
100
 
96
101
  def retain(self, relpaths: list[str]) -> int:
97
102
  """Drop entries for paths not in *relpaths*; return the drop count.
@@ -15,7 +15,6 @@ the drift-check test always agree byte-for-byte; never hand-edit the JSON.
15
15
 
16
16
  from __future__ import annotations
17
17
 
18
- import json
19
18
  from pathlib import Path
20
19
  from typing import Any
21
20
 
@@ -67,11 +66,15 @@ def dump_contract(schema: dict[str, Any]) -> str:
67
66
  Keys are sorted and the output is indented so every committed snapshot is
68
67
  diff-friendly and the exporter/drift-check produce identical bytes.
69
68
  """
69
+ import json
70
+
70
71
  return json.dumps(schema, indent=2, sort_keys=True, ensure_ascii=False) + "\n"
71
72
 
72
73
 
73
74
  def load_contract(path: Path) -> dict[str, Any]:
74
75
  """Load a committed contract snapshot from ``path``."""
76
+ import json
77
+
75
78
  return json.loads(path.read_text(encoding="utf-8"))
76
79
 
77
80
 
@@ -31,9 +31,6 @@ import hmac
31
31
  from collections.abc import Sequence
32
32
  from enum import StrEnum
33
33
 
34
- from hsync_common.endpoint import format_authority, parse_host_port
35
- from hsync_common.hashing import is_sha256_hex
36
-
37
34
  from .p2p import SYNC_DIRECTION_BIDIRECTIONAL
38
35
 
39
36
  __all__ = [
@@ -112,6 +109,8 @@ def parse_fingerprint(value: str | None) -> str | None:
112
109
  Consumers: ``hsync-client`` (rendezvous fingerprint pinning), the rendezvous
113
110
  CLI ``identity show``, and the language-neutral parity test.
114
111
  """
112
+ from hsync_common.hashing import is_sha256_hex
113
+
115
114
  if not value:
116
115
  return None
117
116
  cleaned = value.strip().lower()
@@ -221,6 +220,8 @@ def endpoint_pin_key(host: str, port: int | None) -> str:
221
220
  otherwise — the same form the configuration string uses, so a pin and the
222
221
  endpoint it belongs to compare as strings.
223
222
  """
223
+ from hsync_common.endpoint import format_authority
224
+
224
225
  return format_authority(host, port) if port is not None else host
225
226
 
226
227
 
@@ -236,6 +237,8 @@ def parse_pin_map(raw: str | None, *, strict: bool = False) -> FingerprintPins:
236
237
  ``strict=True`` raises on the first malformed entry (operator input: the CLI
237
238
  and the env loader), while ``strict=False`` drops it (lenient readers).
238
239
  """
240
+ from hsync_common.endpoint import parse_host_port
241
+
239
242
  value = (raw or "").strip()
240
243
  if not value:
241
244
  return {}
@@ -386,7 +386,7 @@
386
386
  },
387
387
  "info": {
388
388
  "title": "HSYNC - HTTP Sync file server",
389
- "version": "1.1.2"
389
+ "version": "1.1.4"
390
390
  },
391
391
  "openapi": "3.1.0",
392
392
  "paths": {
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "hsync-common"
3
- version = "1.1.2"
3
+ version = "1.1.4"
4
4
  description = "HSYNC Common - shared models, constants, and compression utilities"
5
5
  authors = [{name = "Alberto Basso", email = "17047798+albertsdk@users.noreply.github.com"}]
6
6
  license = "BSD-3-Clause"
File without changes
File without changes