From 432e5443e49a6c5774a7b9a69dcc831d059ef9f8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 14:56:11 +0100 Subject: [PATCH] Verify Python exports and health probes --- packages/cultcache-py/PARITY.md | 13 +++++++------ packages/cultcache-py/src/cultcache_py/verify.py | 8 +++++++- packages/cultcache-py/src/cultmesh_py/client.py | 1 + packages/cultcache-py/tests/test_cultcache.py | 5 ++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/cultcache-py/PARITY.md b/packages/cultcache-py/PARITY.md index 51901e12..4a4544d0 100644 --- a/packages/cultcache-py/PARITY.md +++ b/packages/cultcache-py/PARITY.md @@ -89,8 +89,9 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti. endpoints, apply peer snapshots through a caller-owned database, run lightweight scheduled snapshot and simulation-observation fanout loops, probe peer-card endpoints for hello-level reachability, preserve hello capability - metadata on health results, and upsert results into local catalogs with the - same count-returning ergonomics as the C# discovery clients. + metadata on health results, run immediate scheduled health probes on start, + and upsert results into local catalogs with the same count-returning + ergonomics as the C# discovery clients. - Python CultMesh facade: Exposes C#-matching client entrypoints for Verse discovery, peer exchange, raw CultNet client construction, local nodes, catalogs, sessions, streams, @@ -173,10 +174,10 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti. committed-fact watch points as the C# session facade. - Python package health: `cultcache-py-verify --json` checks the public CultCache/CultNet/CultMesh - export surface, `py.typed` markers, a live local CultMesh framed-wire smoke - over hello/schema/snapshot/shard catalog/shard log, typed peer-error export - availability, peer-advertised mutation contracts, payload schema wire - contracts, and benchmark sanity for + export surface declared by each package `__all__`, `py.typed` markers, a live + local CultMesh framed-wire smoke over hello/schema/snapshot/shard + catalog/shard log, typed peer-error export availability, peer-advertised + mutation contracts, payload schema wire contracts, and benchmark sanity for Python-owned hot paths. - Python/C# public cache baseline: `cultcache_py.compare_csharp` runs Python and C# `CultCache` upsert/get diff --git a/packages/cultcache-py/src/cultcache_py/verify.py b/packages/cultcache-py/src/cultcache_py/verify.py index 359dbc1d..345f2a47 100644 --- a/packages/cultcache-py/src/cultcache_py/verify.py +++ b/packages/cultcache-py/src/cultcache_py/verify.py @@ -168,7 +168,7 @@ def _check_exports() -> dict[str, Any]: missing: dict[str, list[str]] = {} for module_name, names in EXPECTED_EXPORTS.items(): module = importlib.import_module(module_name) - missing_names = [name for name in names if not hasattr(module, name)] + missing_names = [name for name in _expected_module_exports(module, names) if not hasattr(module, name)] if missing_names: missing[module_name] = missing_names return { @@ -178,6 +178,12 @@ def _check_exports() -> dict[str, Any]: } +def _expected_module_exports(module: Any, required_names: tuple[str, ...]) -> tuple[str, ...]: + exported = getattr(module, "__all__", ()) + export_names = tuple(str(name) for name in exported) + return tuple(sorted({*required_names, *export_names})) + + def _check_typed_markers() -> dict[str, Any]: missing = [] for module_name in EXPECTED_EXPORTS: diff --git a/packages/cultcache-py/src/cultmesh_py/client.py b/packages/cultcache-py/src/cultmesh_py/client.py index b95a08ab..b2ae0baf 100644 --- a/packages/cultcache-py/src/cultmesh_py/client.py +++ b/packages/cultcache-py/src/cultmesh_py/client.py @@ -579,6 +579,7 @@ class CultMeshPeerHealthMonitor: verse_id: str, roles: list[str] | None, ) -> None: + self.probe_catalog(catalog, verse_id=verse_id, roles=roles) while not self._stop.wait(self.interval_seconds): self.probe_catalog(catalog, verse_id=verse_id, roles=roles) diff --git a/packages/cultcache-py/tests/test_cultcache.py b/packages/cultcache-py/tests/test_cultcache.py index e4181dbb..55479b22 100644 --- a/packages/cultcache-py/tests/test_cultcache.py +++ b/packages/cultcache-py/tests/test_cultcache.py @@ -3001,7 +3001,10 @@ class CultCacheTests(unittest.TestCase): ) monitor.start(peers, verse_id="mesh", roles=["read-replica"]) deadline = time.monotonic() + 2.0 - while not seen and time.monotonic() < deadline: + while time.monotonic() < deadline: + latest = monitor.latest() + if latest and latest[0].is_reachable: + break time.sleep(0.01) monitor.stop() finally: