Align Python shard catalog epochs

This commit is contained in:
Meta Vens 2026-06-14 05:15:04 +01:00
commit 79918f0fed
4 changed files with 8 additions and 1 deletions

View file

@ -76,6 +76,8 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti.
for snapshot, put, and delete notifications on a connected client stream.
Its schema catalog includes both registered document payload schemas and
shared wire-message descriptors for the CultNet/CultMesh messages it handles.
Its shard catalog advertises the database-owned latest shard epoch so
discovery and shard-log catch-up agree on the same authority.
- Python CultMesh reactive catalogs:
Verse and peer catalogs expose sorted local views, `get(...)`, response
application, and `watch(...)` callbacks for local discovery updates. Verse

View file

@ -447,6 +447,9 @@ class CultMeshDatabase:
def snapshot(self) -> dict[str, dict[str, Any]]:
return self.cache.snapshot()
def shard_epoch(self, shard_id: str) -> int:
return self._latest_shard_epoch(shard_id) or 0
def create_snapshot_response(
self,
*,

View file

@ -311,7 +311,7 @@ class CultMeshLocalServer:
shards.append({
"shardId": "primary",
"ownerRuntimeId": self.node.runtime_id,
"epoch": 0,
"epoch": self.node.database.shard_epoch("primary"),
"isPrimary": True,
"schemaIds": schema_ids,
"keyPrefix": "",

View file

@ -2023,7 +2023,9 @@ class CultCacheTests(unittest.TestCase):
self.assertEqual(typed_snapshot_response.documents[0].record_key, "note:1")
self.assertEqual(typed_snapshot_response.documents[0].schema_id, "mesh.server_note.v1")
self.assertEqual(shard_catalog["shards"][0]["schemaIds"], ["mesh.server_note.v1"])
self.assertEqual(shard_catalog["shards"][0]["epoch"], 1)
self.assertEqual(synced_shards[0].shard_id, "primary")
self.assertEqual(synced_shards[0].epoch, 1)
self.assertEqual(synced_shard_catalog.get("primary"), synced_shards[0])
self.assertEqual(shard_log["entries"][0]["changeKind"], "added")
self.assertEqual(typed_shard_log.last_sequence, 1)