using System; using MessagePack; namespace GameCult.Networking { /// /// Shared wire-contract identifiers understood by the CultNet family. /// public static class CultNetWireContracts { /// /// schema v0 contract identifier. /// public const string SchemaV0 = "cultnet.schema.v0"; /// /// game cult networking v0 contract identifier. /// public const string GameCultNetworkingV0 = "gamecult.networking.v0"; } /// /// Canonical schema-version strings for the modern CultNet message family. /// public static class CultNetSchemaVersions { /// /// hello contract identifier. /// public const string Hello = "cultnet.hello.v0"; /// /// login contract identifier. /// public const string Login = "cultnet.login.v0"; /// /// register contract identifier. /// public const string Register = "cultnet.register.v0"; /// /// verify contract identifier. /// public const string Verify = "cultnet.verify.v0"; /// /// login success contract identifier. /// public const string LoginSuccess = "cultnet.login_success.v0"; /// /// error contract identifier. /// public const string Error = "cultnet.error.v0"; /// /// sample change name contract identifier. /// public const string SampleChangeName = "cultnet.sample.change_name.v0"; /// /// sample chat contract identifier. /// public const string SampleChat = "cultnet.sample.chat.v0"; /// /// Generic typed service operation request contract identifier. /// public const string OperationRequest = "cultnet.operation_request.v0"; /// /// Generic typed service operation response contract identifier. /// public const string OperationResponse = "cultnet.operation_response.v0"; /// /// document delete contract identifier. /// public const string DocumentDelete = "cultnet.document_delete.v0"; /// /// document put raw contract identifier. /// public const string DocumentPutRaw = "cultnet.document_put_raw.v0"; /// /// snapshot request contract identifier. /// public const string SnapshotRequest = "cultnet.snapshot_request.v0"; /// /// snapshot response raw contract identifier. /// public const string SnapshotResponseRaw = "cultnet.snapshot_response_raw.v0"; /// /// schema catalog request contract identifier. /// public const string SchemaCatalogRequest = "cultnet.schema_catalog_request.v0"; /// /// schema catalog response contract identifier. /// public const string SchemaCatalogResponse = "cultnet.schema_catalog_response.v0"; /// /// database subscription request contract identifier. /// public const string DatabaseSubscribe = "cultnet.database_subscribe.v0"; /// /// database subscription cancel contract identifier. /// public const string DatabaseUnsubscribe = "cultnet.database_unsubscribe.v0"; /// /// database subscription change contract identifier. /// public const string DatabaseChangeRaw = "cultnet.database_change_raw.v0"; /// /// shard catalog request contract identifier. /// public const string ShardCatalogRequest = "cultnet.shard_catalog_request.v0"; /// /// shard catalog response contract identifier. /// public const string ShardCatalogResponse = "cultnet.shard_catalog_response.v0"; /// /// shard mutation log request contract identifier. /// public const string ShardLogRequest = "cultnet.shard_log_request.v0"; /// /// shard mutation log response contract identifier. /// public const string ShardLogResponse = "cultnet.shard_log_response.v0"; /// /// simulation observation gossip contract identifier. /// public const string SimulationObservation = "cultnet.simulation_observation.v0"; /// /// simulation consensus candidate gossip contract identifier. /// public const string SimulationConsensusCandidate = "cultnet.simulation_consensus_candidate.v0"; /// /// witness artifact bundle document contract identifier. /// public const string WitnessArtifactBundle = "cultnet.witness_artifact_bundle.v0"; /// /// CultMesh Verse catalog request contract identifier. /// public const string VerseCatalogRequest = "cultmesh.verse_catalog_request.v0"; /// /// CultMesh Verse catalog response contract identifier. /// public const string VerseCatalogResponse = "cultmesh.verse_catalog_response.v0"; /// /// CultMesh peer exchange request contract identifier. /// public const string PeerExchangeRequest = "cultmesh.peer_exchange_request.v0"; /// /// CultMesh peer exchange response contract identifier. /// public const string PeerExchangeResponse = "cultmesh.peer_exchange_response.v0"; } /// /// Mutation authority owner identifiers advertised through CultNet mutation contracts. /// public static class CultNetMutationAuthorities { /// /// The document is inspectable but not writable through CultNet. /// public const string ReadOnly = "readOnly"; /// /// The local human operator may submit the corresponding mutation intent. /// public const string LocalUser = "localUser"; /// /// A coordinator-owned Epiphany control surface owns the mutation path. /// public const string Coordinator = "coordinator"; /// /// The runtime itself may write this document directly. /// public const string Runtime = "runtime"; /// /// The document should not be mutated through CultNet. /// public const string Denied = "denied"; } /// /// Declares how a document or surface may be inspected and mutated over CultNet. /// [MessagePackObject] public class CultNetDocumentMutationContract { /// /// Gets or sets the stable document type governed by this contract. /// [Key("documentType")] public string DocumentType { get; set; } = string.Empty; /// /// Gets or sets the payload schema version when the contract governs a versioned document payload. /// [Key("payloadSchemaVersion")] public string? PayloadSchemaVersion { get; set; } /// /// Gets or sets the CultNet operations this document accepts. /// [Key("operations")] public string[] Operations { get; set; } = Array.Empty(); /// /// Gets or sets which actor is allowed to drive those operations. /// [Key("authority")] public string Authority { get; set; } = CultNetMutationAuthorities.ReadOnly; /// /// Gets or sets the intent document types a client may submit to request mutation. /// [Key("intentDocumentTypes")] public string[]? IntentDocumentTypes { get; set; } /// /// Gets or sets the receipt document types emitted after a successful mutation path. /// [Key("receiptDocumentTypes")] public string[]? ReceiptDocumentTypes { get; set; } /// /// Gets or sets freeform notes that explain local mutation guardrails or posture. /// [Key("notes")] public string[]? Notes { get; set; } } /// /// Marker interface for the explicit modern CultNet schema-v0 message family. /// public interface ICultNetSchemaMessage { /// /// Gets or sets the schema version carried by this message. /// string SchemaVersion { get; set; } } /// /// CultNet hello message used to announce a runtime and its supported contracts. /// [MessagePackObject] public class CultNetHelloMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Hello; /// /// Gets or sets the runtime id. /// [Key("runtimeId")] public string RuntimeId { get; set; } = string.Empty; /// /// Gets or sets the runtime kind. /// [Key("runtimeKind")] public string RuntimeKind { get; set; } = string.Empty; /// /// Gets or sets the agent id. /// [Key("agentId")] public string? AgentId { get; set; } /// /// Gets or sets the role. /// [Key("role")] public string? Role { get; set; } /// /// Gets or sets the display name. /// [Key("displayName")] public string? DisplayName { get; set; } /// /// Gets or sets the supported document types. /// [Key("supportedDocumentTypes")] public string[]? SupportedDocumentTypes { get; set; } /// /// Gets or sets the supported mutation contracts. /// [Key("supportedMutationContracts")] public CultNetDocumentMutationContract[]? SupportedMutationContracts { get; set; } /// /// Gets or sets the supported message versions. /// [Key("supportedMessageVersions")] public string[]? SupportedMessageVersions { get; set; } /// /// Gets or sets the transport profiles advertised by this peer. /// [Key("transportProfiles")] public CultNetTransportProfile[]? TransportProfiles { get; set; } /// /// Gets or sets the supports schema catalog. /// [Key("supportsSchemaCatalog")] public bool SupportsSchemaCatalog { get; set; } } /// /// Describes the transports a runtime can speak. /// [MessagePackObject] public class CultNetTransportProfile { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = "cultnet.transport_profile.v0"; /// /// Gets or sets the runtime id. /// [Key("runtimeId")] public string RuntimeId { get; set; } = string.Empty; /// /// Gets or sets the transport descriptors. /// [Key("transports")] public CultNetTransportDescriptor[] Transports { get; set; } = Array.Empty(); } /// /// Describes one transport endpoint. /// [MessagePackObject] public class CultNetTransportDescriptor { /// /// Gets or sets the transport id. /// [Key("transportId")] public string TransportId { get; set; } = string.Empty; /// /// Gets or sets the protocol name. /// [Key("protocol")] public string Protocol { get; set; } = string.Empty; /// /// Gets or sets the host. /// [Key("host")] public string? Host { get; set; } /// /// Gets or sets the port. /// [Key("port")] public int? Port { get; set; } /// /// Gets or sets the path. /// [Key("path")] public string? Path { get; set; } /// /// Gets or sets the discovery group. /// [Key("discoveryGroup")] public string? DiscoveryGroup { get; set; } /// /// Gets or sets the wire contracts. /// [Key("wireContracts")] public string[]? WireContracts { get; set; } /// /// Gets or sets the transport reconnect policy, when the transport owns reconnect posture. /// [Key("reconnectPolicy")] public CultNetReconnectPolicy? ReconnectPolicy { get; set; } /// /// Gets or sets the channels. /// [Key("channels")] public CultNetTransportChannel[] Channels { get; set; } = Array.Empty(); } /// /// Describes one transport channel. /// [MessagePackObject] public class CultNetTransportChannel { /// /// Gets or sets the channel id. /// [Key("channelId")] public string ChannelId { get; set; } = string.Empty; /// /// Gets or sets the delivery semantics. /// [Key("delivery")] public string Delivery { get; set; } = string.Empty; /// /// Gets or sets the ordering semantics. /// [Key("ordering")] public string Ordering { get; set; } = string.Empty; /// /// Gets or sets the maximum payload bytes. /// [Key("maxPayloadBytes")] public int? MaxPayloadBytes { get; set; } /// /// Gets or sets the maximum fragment bytes. /// [Key("maxFragmentBytes")] public int? MaxFragmentBytes { get; set; } /// /// Gets or sets the maximum pending reliable packet count. /// [Key("maxPendingReliablePackets")] public int? MaxPendingReliablePackets { get; set; } } /// /// CultNet login request message. /// [MessagePackObject] public class CultNetLoginMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Login; /// /// Gets or sets the nonce. /// [Key("nonce")] public string Nonce { get; set; } = string.Empty; /// /// Gets or sets the auth. /// [Key("auth")] public string Auth { get; set; } = string.Empty; /// /// Gets or sets the password. /// [Key("password")] public string Password { get; set; } = string.Empty; } /// /// CultNet registration request message. /// [MessagePackObject] public class CultNetRegisterMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Register; /// /// Gets or sets the nonce. /// [Key("nonce")] public string Nonce { get; set; } = string.Empty; /// /// Gets or sets the email. /// [Key("email")] public string Email { get; set; } = string.Empty; /// /// Gets or sets the password. /// [Key("password")] public string Password { get; set; } = string.Empty; /// /// Gets or sets the name. /// [Key("name")] public string Name { get; set; } = string.Empty; } /// /// CultNet session verification request message. /// [MessagePackObject] public class CultNetVerifyMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Verify; /// /// Gets or sets the nonce. /// [Key("nonce")] public string Nonce { get; set; } = string.Empty; /// /// Gets or sets the session. /// [Key("session")] public string Session { get; set; } = string.Empty; } /// /// CultNet message returned after successful session verification. /// [MessagePackObject] public class CultNetLoginSuccessMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.LoginSuccess; /// /// Gets or sets the nonce. /// [Key("nonce")] public string Nonce { get; set; } = string.Empty; /// /// Gets or sets the session. /// [Key("session")] public string Session { get; set; } = string.Empty; } /// /// CultNet error response message. /// [MessagePackObject] public class CultNetErrorMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Error; /// /// Gets or sets the error. /// [Key("error")] public string Error { get; set; } = string.Empty; /// /// Gets or sets optional shard routing details for authority failures. /// [Key("routingHint")] public CultNetShardRoutingHint? RoutingHint { get; set; } } /// /// Describes where a shard write should be routed. /// [MessagePackObject] public class CultNetShardRoutingHint { /// /// Gets or sets the shard descriptor. /// [Key("shard")] public CultNetShardDescriptorMessage? Shard { get; set; } /// /// Gets or sets a machine-readable routing reason. /// [Key("reason")] public string Reason { get; set; } = string.Empty; } /// /// Sample CultNet message used by development clients to change a display name. /// [MessagePackObject] public class CultNetSampleChangeNameMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SampleChangeName; /// /// Gets or sets the name. /// [Key("name")] public string Name { get; set; } = string.Empty; } /// /// Sample CultNet chat message used by development clients. /// [MessagePackObject] public class CultNetSampleChatMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SampleChat; /// /// Gets or sets the text. /// [Key("text")] public string Text { get; set; } = string.Empty; } /// /// Invokes one typed operation on an advertised service. /// [MessagePackObject] public class CultNetOperationRequestMessage : ICultNetSchemaMessage { /// Gets or sets the wire schema version. [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.OperationRequest; /// Gets or sets the correlation id. [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// Gets or sets the advertised service id. [Key("serviceId")] public string ServiceId { get; set; } = string.Empty; /// Gets or sets the requested operation. [Key("operation")] public string Operation { get; set; } = string.Empty; /// Gets or sets the inner payload schema. [Key("payloadSchema")] public string PayloadSchema { get; set; } = string.Empty; /// Gets or sets the inner payload encoding. [Key("payloadEncoding")] public string PayloadEncoding { get; set; } = "messagepack-base64"; /// Gets or sets the encoded inner payload. [Key("payload")] public string Payload { get; set; } = string.Empty; /// Gets or sets the calling runtime id. [Key("sourceRuntimeId")] public string? SourceRuntimeId { get; set; } /// Gets or sets an optional target runtime id. [Key("targetRuntimeId")] public string? TargetRuntimeId { get; set; } } /// /// Returns the correlated result of one typed service operation. /// [MessagePackObject] public class CultNetOperationResponseMessage : ICultNetSchemaMessage { /// Gets or sets the wire schema version. [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.OperationResponse; /// Gets or sets the request correlation id. [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// Gets or sets the advertised service id. [Key("serviceId")] public string ServiceId { get; set; } = string.Empty; /// Gets or sets the completed operation. [Key("operation")] public string Operation { get; set; } = string.Empty; /// Gets or sets the operation status. [Key("status")] public string Status { get; set; } = string.Empty; /// Gets or sets the inner payload schema. [Key("payloadSchema")] public string PayloadSchema { get; set; } = string.Empty; /// Gets or sets the inner payload encoding. [Key("payloadEncoding")] public string PayloadEncoding { get; set; } = "messagepack-base64"; /// Gets or sets the encoded inner payload. [Key("payload")] public string Payload { get; set; } = string.Empty; /// Gets or sets transport-level diagnostics. [Key("diagnostics")] public string[] Diagnostics { get; set; } = Array.Empty(); /// Gets or sets the responding runtime id. [Key("sourceRuntimeId")] public string? SourceRuntimeId { get; set; } } /// /// Raw document record carried over CultNet. /// [MessagePackObject] public class CultNetRawDocumentRecord { /// /// Gets or sets the schema id. /// [Key("schemaId")] public string SchemaId { get; set; } = string.Empty; /// /// Gets or sets the record key. /// [Key("recordKey")] public string RecordKey { get; set; } = string.Empty; /// /// Gets or sets the stored at. /// [Key("storedAt")] public string StoredAt { get; set; } = string.Empty; /// /// Gets or sets the payload encoding. /// [Key("payloadEncoding")] public string PayloadEncoding { get; set; } = "messagepack"; /// /// Gets or sets the payload. /// [Key("payload")] public byte[] Payload { get; set; } = Array.Empty(); /// /// Gets or sets the source runtime id. /// [Key("sourceRuntimeId")] public string? SourceRuntimeId { get; set; } /// /// Gets or sets the source agent id. /// [Key("sourceAgentId")] public string? SourceAgentId { get; set; } /// /// Gets or sets the source role. /// [Key("sourceRole")] public string? SourceRole { get; set; } /// /// Gets or sets the tags. /// [Key("tags")] public string[]? Tags { get; set; } } /// /// CultNet message requesting deletion of a document record. /// [MessagePackObject] public class CultNetDocumentDeleteMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DocumentDelete; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the schema id. /// [Key("schemaId")] public string SchemaId { get; set; } = string.Empty; /// /// Gets or sets the record key. /// [Key("recordKey")] public string RecordKey { get; set; } = string.Empty; /// /// Gets or sets the shard id the sender targeted. /// [Key("shardId")] public string? ShardId { get; set; } /// /// Gets or sets the shard epoch the sender targeted. /// [Key("shardEpoch")] public long? ShardEpoch { get; set; } } /// /// CultNet message carrying one raw document record. /// [MessagePackObject] public class CultNetDocumentPutRawMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DocumentPutRaw; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the document. /// [Key("document")] public CultNetRawDocumentRecord Document { get; set; } = new CultNetRawDocumentRecord(); /// /// Gets or sets the shard id the sender targeted. /// [Key("shardId")] public string? ShardId { get; set; } /// /// Gets or sets the shard epoch the sender targeted. /// [Key("shardEpoch")] public long? ShardEpoch { get; set; } } /// /// CultNet message requesting a document snapshot. /// [MessagePackObject] public class CultNetSnapshotRequestMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotRequest; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the schema ids. /// [Key("schemaIds")] public string[]? SchemaIds { get; set; } /// /// Gets or sets the record keys. /// [Key("recordKeys")] public string[]? RecordKeys { get; set; } /// /// Gets or sets the shard id requested for a shard-bounded snapshot. /// [Key("shardId")] public string? ShardId { get; set; } /// /// Gets or sets the expected shard epoch. /// [Key("shardEpoch")] public long? ShardEpoch { get; set; } } /// /// CultNet message returning raw document records from a snapshot request. /// [MessagePackObject] public class CultNetSnapshotResponseRawMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotResponseRaw; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the documents. /// [Key("documents")] public CultNetRawDocumentRecord[] Documents { get; set; } = Array.Empty(); /// /// Gets or sets the shard id represented by this snapshot. /// [Key("shardId")] public string? ShardId { get; set; } /// /// Gets or sets the shard epoch represented by this snapshot. /// [Key("shardEpoch")] public long? ShardEpoch { get; set; } /// /// Gets or sets the shard-log sequence represented by this snapshot. /// [Key("shardLogSequence")] public long? ShardLogSequence { get; set; } } /// /// Requests a live database subscription. /// [MessagePackObject] public class CultNetDatabaseSubscribeMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseSubscribe; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the live subscription id. /// [Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty; /// /// Gets or sets optional schema ids to watch. /// [Key("schemaIds")] public string[]? SchemaIds { get; set; } /// /// Gets or sets optional record keys to watch. /// [Key("recordKeys")] public string[]? RecordKeys { get; set; } /// /// Gets or sets whether the server should send a matching snapshot before live changes. /// [Key("includeSnapshot")] public bool IncludeSnapshot { get; set; } = true; } /// /// Cancels a live database subscription. /// [MessagePackObject] public class CultNetDatabaseUnsubscribeMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseUnsubscribe; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the live subscription id. /// [Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty; } /// /// Streams one raw document change for a live database subscription. /// [MessagePackObject] public class CultNetDatabaseChangeRawMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseChangeRaw; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the live subscription id. /// [Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty; /// /// Gets or sets the change kind. /// [Key("changeKind")] public string ChangeKind { get; set; } = string.Empty; /// /// Gets or sets the current document for added or updated changes. /// [Key("document")] public CultNetRawDocumentRecord? Document { get; set; } /// /// Gets or sets the deleted record key for removed changes. /// [Key("recordKey")] public string? RecordKey { get; set; } /// /// Gets or sets the deleted schema id for removed changes. /// [Key("schemaId")] public string? SchemaId { get; set; } } /// /// Describes one shard advertised by a CultNet database node. /// [MessagePackObject] public class CultNetShardDescriptorMessage { /// /// Gets or sets the shard id. /// [Key("shardId")] public string ShardId { get; set; } = string.Empty; /// /// Gets or sets the owner runtime id. /// [Key("ownerRuntimeId")] public string OwnerRuntimeId { get; set; } = string.Empty; /// /// Gets or sets the shard authority epoch. /// [Key("epoch")] public long Epoch { get; set; } /// /// Gets or sets whether the responding node is primary for this shard. /// [Key("isPrimary")] public bool IsPrimary { get; set; } /// /// Gets or sets schema ids governed by this shard. Empty means all schemas. /// [Key("schemaIds")] public string[] SchemaIds { get; set; } = Array.Empty(); /// /// Gets or sets the record-key prefix governed by this shard. /// [Key("keyPrefix")] public string? KeyPrefix { get; set; } /// /// Gets or sets endpoints that accept authoritative writes. /// [Key("primaryEndpoints")] public string[] PrimaryEndpoints { get; set; } = Array.Empty(); /// /// Gets or sets authoritative replica endpoints. /// [Key("replicaEndpoints")] public string[] ReplicaEndpoints { get; set; } = Array.Empty(); /// /// Gets or sets low-latency read replica endpoints. /// [Key("readReplicaEndpoints")] public string[] ReadReplicaEndpoints { get; set; } = Array.Empty(); /// /// Gets or sets an optional locality label. /// [Key("region")] public string? Region { get; set; } } /// /// Requests shard ownership and routing metadata. /// [MessagePackObject] public class CultNetShardCatalogRequestMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardCatalogRequest; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets optional schema filters. /// [Key("schemaIds")] public string[]? SchemaIds { get; set; } /// /// Gets or sets optional record-key filters. /// [Key("recordKeys")] public string[]? RecordKeys { get; set; } } /// /// Returns shard ownership and routing metadata. /// [MessagePackObject] public class CultNetShardCatalogResponseMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardCatalogResponse; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets shard descriptors. /// [Key("shards")] public CultNetShardDescriptorMessage[] Shards { get; set; } = Array.Empty(); } /// /// Requests accepted mutation log entries for a shard. /// [MessagePackObject] public class CultNetShardLogRequestMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardLogRequest; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the shard id. /// [Key("shardId")] public string ShardId { get; set; } = string.Empty; /// /// Gets or sets the shard epoch expected by the requester. /// [Key("shardEpoch")] public long? ShardEpoch { get; set; } /// /// Gets or sets the last sequence already held by the requester. /// [Key("afterSequence")] public long AfterSequence { get; set; } /// /// Gets or sets the maximum number of entries to return. /// [Key("limit")] public int? Limit { get; set; } } /// /// Returns accepted mutation log entries for a shard. /// [MessagePackObject] public class CultNetShardLogResponseMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardLogResponse; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the shard id. /// [Key("shardId")] public string ShardId { get; set; } = string.Empty; /// /// Gets or sets the shard epoch. /// [Key("shardEpoch")] public long ShardEpoch { get; set; } /// /// Gets or sets mutation log entries. /// [Key("entries")] public CultNetShardLogEntryMessage[] Entries { get; set; } = Array.Empty(); /// /// Gets or sets whether the requester must fall back to a shard snapshot. /// [Key("resyncRequired")] public bool ResyncRequired { get; set; } /// /// Gets or sets a machine-readable resync reason. /// [Key("reason")] public string? Reason { get; set; } /// /// Gets or sets the highest sequence compacted out of the retained log. /// [Key("compactedThrough")] public long? CompactedThrough { get; set; } } /// /// Describes one accepted shard mutation for replica catch-up. /// [MessagePackObject] public class CultNetShardLogEntryMessage { /// /// Gets or sets the per-shard sequence. /// [Key("sequence")] public long Sequence { get; set; } /// /// Gets or sets the commit timestamp. /// [Key("committedAt")] public string CommittedAt { get; set; } = string.Empty; /// /// Gets or sets the mutation kind. /// [Key("changeKind")] public string ChangeKind { get; set; } = string.Empty; /// /// Gets or sets a raw put message for added/updated entries. /// [Key("put")] public CultNetDocumentPutRawMessage? Put { get; set; } /// /// Gets or sets a raw delete message for removed entries. /// [Key("delete")] public CultNetDocumentDeleteMessage? Delete { get; set; } } /// /// Carries one witness observation about a simulation fact. /// [MessagePackObject] public class CultNetSimulationObservationMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SimulationObservation; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the observation. /// [Key("observation")] public CultNetSimulationObservation Observation { get; set; } = new CultNetSimulationObservation(); } /// /// Carries one deterministic consensus candidate derived from witness observations. /// [MessagePackObject] public class CultNetSimulationConsensusCandidateMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SimulationConsensusCandidate; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the shard id. /// [Key("shardId")] public string ShardId { get; set; } = string.Empty; /// /// Gets or sets the shard epoch. /// [Key("shardEpoch")] public long ShardEpoch { get; set; } /// /// Gets or sets the simulation frame. /// [Key("frame")] public long Frame { get; set; } /// /// Gets or sets the subject id. /// [Key("subjectId")] public string SubjectId { get; set; } = string.Empty; /// /// Gets or sets the claim kind. /// [Key("claimKind")] public string ClaimKind { get; set; } = string.Empty; /// /// Gets or sets the selected claim hash. /// [Key("claimHash")] public string ClaimHash { get; set; } = string.Empty; /// /// Gets or sets optional claim detail. /// [Key("claimSummary")] public string? ClaimSummary { get; set; } /// /// Gets or sets distinct supporting witnesses. /// [Key("witnessCount")] public int WitnessCount { get; set; } /// /// Gets or sets supporting witness weight. /// [Key("supportWeight")] public double SupportWeight { get; set; } /// /// Gets or sets total observed witness weight. /// [Key("totalWeight")] public double TotalWeight { get; set; } /// /// Gets or sets whether the candidate crossed quorum. /// [Key("hasQuorum")] public bool HasQuorum { get; set; } /// /// Gets or sets support divided by total observed weight. /// [Key("confidence")] public double Confidence { get; set; } /// /// Creates a wire candidate message from a local candidate. /// public static CultNetSimulationConsensusCandidateMessage FromCandidate( string messageId, CultNetSimulationConsensusCandidate candidate) { if (candidate == null) throw new ArgumentNullException(nameof(candidate)); return new CultNetSimulationConsensusCandidateMessage { MessageId = string.IsNullOrWhiteSpace(messageId) ? Guid.NewGuid().ToString("N") : messageId, ShardId = candidate.ShardId, ShardEpoch = candidate.ShardEpoch, Frame = candidate.Frame, SubjectId = candidate.SubjectId, ClaimKind = candidate.ClaimKind, ClaimHash = candidate.ClaimHash, ClaimSummary = candidate.ClaimSummary, WitnessCount = candidate.WitnessCount, SupportWeight = candidate.SupportWeight, TotalWeight = candidate.TotalWeight, HasQuorum = candidate.HasQuorum, Confidence = candidate.Confidence }; } } /// /// Requests known CultMesh Verses from a peer. /// [MessagePackObject] public class CultMeshVerseCatalogRequestMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.VerseCatalogRequest; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets optional Verse ids to request. /// [Key("verseIds")] public string[]? VerseIds { get; set; } /// /// Gets or sets an optional transport compatibility filter. /// [Key("transportVersion")] public string? TransportVersion { get; set; } } /// /// Returns known CultMesh Verses. /// [MessagePackObject] public class CultMeshVerseCatalogResponseMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.VerseCatalogResponse; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets discovered Verses. /// [Key("verses")] public CultMeshVerseDescriptorMessage[] Verses { get; set; } = Array.Empty(); } /// /// Wire representation of a CultMesh Verse. /// [MessagePackObject] public class CultMeshVerseDescriptorMessage { /// /// Gets or sets the stable Verse id. /// [Key("verseId")] public string VerseId { get; set; } = string.Empty; /// /// Gets or sets the display name. /// [Key("displayName")] public string DisplayName { get; set; } = string.Empty; /// /// Gets or sets the authority model name. /// [Key("authorityModel")] public string AuthorityModel { get; set; } = string.Empty; /// /// Gets or sets compatibility metadata. /// [Key("compatibility")] public CultMeshVerseCompatibilityMessage Compatibility { get; set; } = new CultMeshVerseCompatibilityMessage(); /// /// Gets or sets endpoints that can answer discovery for this Verse. /// [Key("discoveryEndpoints")] public string[] DiscoveryEndpoints { get; set; } = Array.Empty(); /// /// Gets or sets known authoritative runtime ids. /// [Key("authorityRuntimeIds")] public string[] AuthorityRuntimeIds { get; set; } = Array.Empty(); /// /// Gets or sets the parent Verse id for overlays or branches. /// [Key("parentVerseId")] public string? ParentVerseId { get; set; } /// /// Gets or sets an optional public description. /// [Key("description")] public string? Description { get; set; } } /// /// Wire representation of CultMesh Verse compatibility. /// [MessagePackObject] public class CultMeshVerseCompatibilityMessage { /// /// Gets or sets the CultMesh transport compatibility version. /// [Key("transportVersion")] public string TransportVersion { get; set; } = string.Empty; /// /// Gets or sets the stable rules hash. /// [Key("rulesHash")] public string RulesHash { get; set; } = string.Empty; /// /// Gets or sets Verse ids this Verse can transfer from or subscribe to. /// [Key("compatibleVerseIds")] public string[] CompatibleVerseIds { get; set; } = Array.Empty(); /// /// Gets or sets required plugin ids. /// [Key("requiredPluginIds")] public string[] RequiredPluginIds { get; set; } = Array.Empty(); /// /// Gets or sets optional plugin ids. /// [Key("optionalPluginIds")] public string[] OptionalPluginIds { get; set; } = Array.Empty(); } /// /// Requests known peers for a CultMesh Verse. /// [MessagePackObject] public class CultMeshPeerExchangeRequestMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.PeerExchangeRequest; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the Verse id to discover peers for. /// [Key("verseId")] public string VerseId { get; set; } = string.Empty; /// /// Gets or sets optional role filters. /// [Key("roles")] public string[]? Roles { get; set; } /// /// Gets or sets peer ids the requester already knows. /// [Key("knownPeerIds")] public string[]? KnownPeerIds { get; set; } /// /// Gets or sets the maximum number of peer cards to return. /// [Key("limit")] public int? Limit { get; set; } } /// /// Returns known peers for a CultMesh Verse. /// [MessagePackObject] public class CultMeshPeerExchangeResponseMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.PeerExchangeResponse; /// /// Gets or sets the request id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets peer cards. /// [Key("peers")] public CultMeshPeerCardMessage[] Peers { get; set; } = Array.Empty(); } /// /// Wire representation of a CultMesh peer candidate. /// [MessagePackObject] public class CultMeshPeerCardMessage { /// /// Gets or sets the stable peer id. /// [Key("peerId")] public string PeerId { get; set; } = string.Empty; /// /// Gets or sets the Verse id this peer participates in. /// [Key("verseId")] public string VerseId { get; set; } = string.Empty; /// /// Gets or sets reachable endpoints. /// [Key("endpoints")] public string[] Endpoints { get; set; } = Array.Empty(); /// /// Gets or sets advertised peer roles. /// [Key("roles")] public string[] Roles { get; set; } = Array.Empty(); /// /// Gets or sets shard ids this peer can serve or observe. /// [Key("shardIds")] public string[] ShardIds { get; set; } = Array.Empty(); /// /// Gets or sets an optional region/locality label. /// [Key("region")] public string? Region { get; set; } /// /// Gets or sets the authority lease id, when the card advertises authority. /// [Key("authorityLeaseId")] public string? AuthorityLeaseId { get; set; } /// /// Gets or sets the expiry timestamp for this card. /// [Key("expiresAt")] public string? ExpiresAt { get; set; } /// /// Gets or sets an optional signature over the card. /// [Key("signature")] public string? Signature { get; set; } } /// /// Describes one schema exposed through the CultNet schema catalog. /// [MessagePackObject] public class CultNetSchemaDescriptor { /// /// Gets or sets the schema id. /// [Key("schemaId")] public string SchemaId { get; set; } = string.Empty; /// /// Gets or sets the kind. /// [Key("kind")] public string Kind { get; set; } = string.Empty; /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string? SchemaVersion { get; set; } /// /// Gets or sets the document type. /// [Key("documentType")] public string? DocumentType { get; set; } /// /// Gets or sets the title. /// [Key("title")] public string? Title { get; set; } /// /// Gets or sets the wire contracts. /// [Key("wireContracts")] public string[] WireContracts { get; set; } = Array.Empty(); /// /// Gets or sets the content hash. /// [Key("contentHash")] public string ContentHash { get; set; } = string.Empty; /// /// Gets or sets the schema json. /// [Key("schemaJson")] public string? SchemaJson { get; set; } } /// /// CultNet message requesting schema catalog entries. /// [MessagePackObject] public class CultNetSchemaCatalogRequestMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SchemaCatalogRequest; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the include schema json. /// [Key("includeSchemaJson")] public bool IncludeSchemaJson { get; set; } /// /// Gets or sets the schema ids. /// [Key("schemaIds")] public string[]? SchemaIds { get; set; } /// /// Gets or sets the kinds. /// [Key("kinds")] public string[]? Kinds { get; set; } } /// /// CultNet message returning schema catalog entries. /// [MessagePackObject] public class CultNetSchemaCatalogResponseMessage : ICultNetSchemaMessage { /// /// Gets or sets the schema version. /// [Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SchemaCatalogResponse; /// /// Gets or sets the message id. /// [Key("messageId")] public string MessageId { get; set; } = string.Empty; /// /// Gets or sets the schemas. /// [Key("schemas")] public CultNetSchemaDescriptor[] Schemas { get; set; } = Array.Empty(); } }