From 23adf5c18279fd2744b2c83dd8d7feb492408a54 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 05:48:41 +0100 Subject: [PATCH] Advertise Python local server mutation surfaces --- packages/cultcache-py/PARITY.md | 2 ++ packages/cultcache-py/src/cultmesh_py/server.py | 16 +++++++++++++++- .../src/cultnet_py/schema_catalog.py | 16 +++++++++++++++- packages/cultcache-py/tests/test_cultcache.py | 10 ++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/packages/cultcache-py/PARITY.md b/packages/cultcache-py/PARITY.md index b78eeb8c..71c65461 100644 --- a/packages/cultcache-py/PARITY.md +++ b/packages/cultcache-py/PARITY.md @@ -79,6 +79,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. + Hello and payload schema descriptors advertise the raw snapshot, put, delete, + and shard-log mutation surfaces the server actually serves. Its shard catalog advertises the database-owned shard ids, schema ids, and latest shard epochs so discovery and shard-log catch-up agree on the same authority. diff --git a/packages/cultcache-py/src/cultmesh_py/server.py b/packages/cultcache-py/src/cultmesh_py/server.py index cf8fe31e..eb21b9fa 100644 --- a/packages/cultcache-py/src/cultmesh_py/server.py +++ b/packages/cultcache-py/src/cultmesh_py/server.py @@ -250,6 +250,15 @@ class CultMeshLocalServer: "runtimeKind": self.runtime_kind, "displayName": self.display_name or self.node.runtime_id, "supportedDocumentTypes": [document.type for document in self.node.documents], + "supportedMutationContracts": [ + { + "documentType": document.type, + "payloadSchemaVersion": document.catalog_entry().schema_version, + "operations": ["snapshot", "documentPut", "documentDelete", "shardLog"], + "authority": "runtime", + } + for document in self.node.documents + ], "supportedMessageVersions": [ "cultnet.hello.v0", "cultnet.schema_catalog_request.v0", @@ -289,7 +298,12 @@ class CultMeshLocalServer: "schemaVersion": entry.schema_version, "documentType": document.type, "title": entry.schema_name, - "wireContracts": ["cultnet.document_put_raw.v0", "cultnet.snapshot_response_raw.v0"], + "wireContracts": [ + "cultnet.document_put_raw.v0", + "cultnet.document_delete.v0", + "cultnet.snapshot_response_raw.v0", + "cultnet.shard_log_response.v0", + ], "contentHash": entry.content_hash, } if include_schema_json: diff --git a/packages/cultcache-py/src/cultnet_py/schema_catalog.py b/packages/cultcache-py/src/cultnet_py/schema_catalog.py index f09fcb21..53631bad 100644 --- a/packages/cultcache-py/src/cultnet_py/schema_catalog.py +++ b/packages/cultcache-py/src/cultnet_py/schema_catalog.py @@ -238,7 +238,21 @@ def wire_message_schema_properties(schema_version: str) -> dict[str, Any]: "agentId": {"type": "string"}, "displayName": {"type": "string"}, "supportedDocumentTypes": string_array, - "supportedMutationContracts": string_array, + "supportedMutationContracts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "documentType": {"type": "string"}, + "payloadSchemaVersion": {"type": "string"}, + "operations": string_array, + "authority": {"type": "string"}, + "intentDocumentTypes": string_array, + "receiptDocumentTypes": string_array, + }, + "additionalProperties": True, + }, + }, "supportedMessageVersions": string_array, "supportsSchemaCatalog": {"type": "boolean"}, }, diff --git a/packages/cultcache-py/tests/test_cultcache.py b/packages/cultcache-py/tests/test_cultcache.py index cc3a7c96..9628cc44 100644 --- a/packages/cultcache-py/tests/test_cultcache.py +++ b/packages/cultcache-py/tests/test_cultcache.py @@ -952,6 +952,11 @@ class CultCacheTests(unittest.TestCase): self.assertIn("resyncRequired", log_schema["required"]) self.assertIn("compactedThrough", log_schema["properties"]) + hello_schema = json.loads(by_version["cultnet.hello.v0"]["schemaJson"]) + mutation_contract = hello_schema["properties"]["supportedMutationContracts"]["items"] + self.assertEqual(mutation_contract["type"], "object") + self.assertIn("operations", mutation_contract["properties"]) + consensus_schema = json.loads(by_version["cultnet.simulation_consensus_candidate.v0"]["schemaJson"]) for required_field in ["witnessCount", "supportWeight", "totalWeight", "hasQuorum", "confidence"]: self.assertIn(required_field, consensus_schema["required"]) @@ -2101,8 +2106,13 @@ class CultCacheTests(unittest.TestCase): self.assertEqual(hello_response["displayName"], "Mesh Server") self.assertIn("cultnet.database_subscribe.v0", hello_response["supportedMessageVersions"]) self.assertIn("cultnet.document_put_raw.v0", hello_response["supportedMessageVersions"]) + self.assertEqual(hello_response["supportedMutationContracts"][0]["documentType"], "mesh.server_note") + self.assertIn("documentDelete", hello_response["supportedMutationContracts"][0]["operations"]) + self.assertIn("shardLog", hello_response["supportedMutationContracts"][0]["operations"]) self.assertEqual(schema_response["schemas"][0]["schemaId"], "mesh.server_note.v1") self.assertIn("schemaJson", schema_response["schemas"][0]) + self.assertIn("cultnet.document_delete.v0", schema_response["schemas"][0]["wireContracts"]) + self.assertIn("cultnet.shard_log_response.v0", schema_response["schemas"][0]["wireContracts"]) wire_descriptors = {schema["schemaVersion"]: schema for schema in wire_schema_response["schemas"]} self.assertEqual(wire_descriptors["cultnet.document_put_raw.v0"]["kind"], "wire_message") self.assertIn("schemaJson", wire_descriptors["cultnet.document_put_raw.v0"])