Expose Python peer health capabilities

This commit is contained in:
Meta Vens 2026-06-14 14:30:15 +01:00
commit 115e4505e4
3 changed files with 26 additions and 3 deletions

View file

@ -88,9 +88,9 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti.
fan out raw snapshot fetches and simulation observations to peer-card
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, and upsert results into
local catalogs with the same count-returning ergonomics as the C# discovery
clients.
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.
- Python CultMesh facade:
Exposes C#-matching client entrypoints for Verse discovery, peer exchange,
raw CultNet client construction, local nodes, catalogs, sessions, streams,

View file

@ -492,6 +492,9 @@ class CultMeshPeerHealth:
checked_at: datetime
is_reachable: bool
runtime_id: str | None = None
runtime_kind: str | None = None
display_name: str | None = None
supported_message_versions: tuple[str, ...] = ()
error: str | None = None
@ -589,6 +592,13 @@ class CultMeshPeerHealthMonitor:
checked_at=checked_at,
is_reachable=True,
runtime_id=str(response.get("runtimeId") or ""),
runtime_kind=_optional_string(response.get("runtimeKind")),
display_name=_optional_string(response.get("displayName")),
supported_message_versions=tuple(
str(value)
for value in response.get("supportedMessageVersions") or ()
if value is not None
),
)
except Exception as error:
return CultMeshPeerHealth(
@ -625,3 +635,10 @@ def _distinct_non_empty(values: list[str]) -> list[str]:
clean.append(value)
seen.add(value)
return clean
def _optional_string(value: Any) -> str | None:
if value is None:
return None
text = str(value)
return text if text else None

View file

@ -2930,7 +2930,13 @@ class CultCacheTests(unittest.TestCase):
by_peer = {result.peer_id: result for result in results}
self.assertTrue(by_peer["health-peer"].is_reachable)
self.assertEqual(by_peer["health-peer"].runtime_id, "health-peer")
self.assertEqual(by_peer["health-peer"].runtime_kind, "python")
self.assertEqual(by_peer["health-peer"].display_name, "health-peer")
self.assertIn("cultnet.hello.v0", by_peer["health-peer"].supported_message_versions)
self.assertIn("cultnet.error.v0", by_peer["health-peer"].supported_message_versions)
self.assertFalse(by_peer["closed-peer"].is_reachable)
self.assertIsNone(by_peer["closed-peer"].runtime_kind)
self.assertEqual(by_peer["closed-peer"].supported_message_versions, ())
self.assertTrue(by_peer["closed-peer"].error)
self.assertEqual({peer_id for peer_id, _ in seen}, {"health-peer", "closed-peer"})
self.assertEqual(len(monitor.latest()), 2)