Advertise Python local server mutation surfaces

This commit is contained in:
Meta Vens 2026-06-14 05:48:41 +01:00
commit 23adf5c182
4 changed files with 42 additions and 2 deletions

View file

@ -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.

View file

@ -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:

View file

@ -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"},
},

View file

@ -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"])