Advertise Python simulation observer role

This commit is contained in:
Meta Vens 2026-06-14 16:57:48 +01:00
commit 5dc2a74fa7
3 changed files with 15 additions and 3 deletions

View file

@ -122,7 +122,10 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti.
instead of silently looking empty. Simulation observation serving is opt-in:
the daemon only advertises `cultnet.simulation_observation.v0` when an
observation hub is attached, and an opt-in launched daemon answers witness
observations with schema-v0 consensus candidates.
observations with schema-v0 consensus candidates. When such a daemon
self-advertises into a Verse, its peer card includes the `simulation-observer`
role so discovery clients can find the peer by the capability it actually
serves.
The daemon CLI snapshot document/byte limits feed the same public server edge;
oversized daemon snapshot responses are returned as structured
`cultnet.error.v0` peer errors rather than partial payloads.

View file

@ -124,7 +124,9 @@ def advertise_self(
return
endpoint = f"cultnet://{server.host}:{server.port}"
shard_ids = tuple(server.node.database.shard_ids())
roles = tuple(args.roles or ("read-replica",))
roles = list(args.roles or ("read-replica",))
if server.observation_hub is not None and "simulation-observer" not in roles:
roles.append("simulation-observer")
verse_catalog.upsert(CultMeshVerseDescriptor(
verse_id=verse_id,
display_name=args.verse_display_name or verse_id,
@ -140,7 +142,7 @@ def advertise_self(
peer_id=server.node.runtime_id,
verse_id=verse_id,
endpoints=(endpoint,),
roles=roles,
roles=tuple(roles),
shard_ids=shard_ids,
))

View file

@ -3606,6 +3606,8 @@ class CultCacheTests(unittest.TestCase):
"2",
"--simulation-quorum-ratio",
"1.0",
"--verse-id",
"simulation-verse",
"--ready-file",
str(ready_path),
],
@ -3624,6 +3626,11 @@ class CultCacheTests(unittest.TestCase):
expected_schema_version="cultnet.hello.v0",
)
self.assertEqual(ready["supportedMessageVersions"], hello_response["supportedMessageVersions"])
discovery_client = CultMesh.create_verse_discovery_client("127.0.0.1", int(ready["port"]), timeout_seconds=2.0)
peers = discovery_client.fetch_peers(verse_id="simulation-verse", roles=["simulation-observer"])
self.assertEqual(peers[0].peer_id, "simulation-daemon-peer")
self.assertIn("simulation-observer", peers[0].roles)
self.assertIn("read-replica", peers[0].roles)
claim_hash = compute_simulation_claim_hash("hit", "alice", "bob", "frame:100")
first = client.request(