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";
///
/// typed-selection snapshot request contract identifier (docs/cultnet-selection-cut.md).
///
public const string SnapshotRequestV1 = "cultnet.snapshot_request.v1";
///
/// typed-selection database subscription request contract identifier (docs/cultnet-selection-cut.md).
///
public const string DatabaseSubscribeV1 = "cultnet.database_subscribe.v1";
///
/// typed-selection snapshot response contract identifier (docs/cultnet-selection-cut.md).
///
public const string SnapshotResponseRawV1 = "cultnet.snapshot_response_raw.v1";
///
/// 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 session identity request contract identifier.
public const string SessionOpen = "cultmesh.session_open.v2";
/// CultMesh verified session identity response contract identifier.
public const string SessionAccepted = "cultmesh.session_accepted.v2";
///
/// 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";
///
/// CultMesh content chunk request contract identifier.
///
public const string ContentChunkRequest = "cultmesh.content_chunk_request.v1";
///
/// CultMesh content chunk response contract identifier.
///
public const string ContentChunkResponse = "cultmesh.content_chunk_response.v1";
///
/// CultMesh ephemeral body read request contract identifier.
///
public const string BodyReadRequest = "cultmesh.body_read_request.v1";
///
/// CultMesh ephemeral body read response contract identifier.
///
public const string BodyReadResponse = "cultmesh.body_read_response.v1";
}
///
/// 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; }
///
/// Gets or sets the machine-readable refusal code (R-N), e.g. selection_invalid,
/// cursor_stale, cursor_invalid, reference_outside_target, unowned_schema, write_not_authorized, unsupported_schema_version. Additive to
/// cultnet.error.v0; a v0 peer that does not know this field ignores it.
///
[Key("code")] public string? Code { get; set; }
///
/// Gets or sets the code-specific structured detail (R-N). Additive to cultnet.error.v0.
///
[Key("details")] public CultNetErrorDetails? Details { get; set; }
///
/// Builds the wire error for a door refusal (R-N): code selection_invalid, details
/// { field, value }.
///
public static CultNetErrorMessage ForSelectionInvalid(CultNetSelectionInvalidException ex) =>
new CultNetErrorMessage
{
Error = $"selection_invalid: {ex.Message}",
Code = "selection_invalid",
Details = new CultNetErrorDetails { Field = ex.Field, Value = ex.Value }
};
///
/// Builds the wire error for a write no shard owns: code unowned_schema, details { field: "schemaId", value }.
///
public static CultNetErrorMessage ForUnownedSchema(CultNetUnownedSchemaException ex) =>
new CultNetErrorMessage
{
Error = $"unowned_schema: {ex.Message}",
Code = "unowned_schema",
Details = new CultNetErrorDetails { Field = "schemaId", Value = ex.SchemaId }
};
///
/// Builds the wire error for a peer write its authority refused: code write_not_authorized, details
/// { field: "recordKey", value }.
///
public static CultNetErrorMessage ForRemoteWriteRefused(CultNetRemoteWriteRequest request, string? reason) =>
new CultNetErrorMessage
{
Error = string.IsNullOrWhiteSpace(reason) ? "write_not_authorized" : $"write_not_authorized: {reason}",
Code = "write_not_authorized",
Details = new CultNetErrorDetails { Field = "recordKey", Value = request.RecordKey.Value }
};
///
/// Builds the wire error for a message whose schemaVersion this peer does not speak: code
/// unsupported_schema_version, details { field: "schemaVersion", value }.
///
public static CultNetErrorMessage ForUnsupportedSchemaVersion(string? schemaVersion) =>
new CultNetErrorMessage
{
Error = $"unsupported_schema_version: {schemaVersion}",
Code = "unsupported_schema_version",
Details = new CultNetErrorDetails { Field = "schemaVersion", Value = schemaVersion }
};
///
/// Builds the wire error for a cursor refusal (R-N): code cursor_stale with details
/// { asOf, current }, or code cursor_invalid with no details.
///
public static CultNetErrorMessage ForCursor(CultNetSelectionCursorException ex) =>
new CultNetErrorMessage
{
Error = $"{ex.Code}: {ex.Message}",
Code = ex.Code,
Details = ex.Code == "cursor_stale"
? new CultNetErrorDetails { AsOf = ex.AsOf, Current = ex.Current }
: null
};
///
/// Builds the wire error for a selection that selects a document variant, which CultNet does not carry yet: code
/// variant_unsupported, details { field: "subscriptionId", value } when a subscription was ended by it.
///
public static CultNetErrorMessage ForVariantUnsupported(string message, string? subscriptionId = null) =>
new CultNetErrorMessage
{
Error = message,
Code = "variant_unsupported",
Details = subscriptionId == null ? null : new CultNetErrorDetails { Field = "subscriptionId", Value = subscriptionId }
};
///
/// Builds the wire error for an out-of-target reference refusal (R-N): code
/// reference_outside_target, no details.
///
public static CultNetErrorMessage ForReferenceOutsideTarget(CultNetSelectionReferenceOutsideTargetException ex) =>
new CultNetErrorMessage
{
// ex.Message already begins "reference_outside_target: " (the exception's own
// constructor prefixes it) - this used to prefix it a second time, so a peer received
// "reference_outside_target: reference_outside_target: ...". Rust's ForReferenceOutsideTarget
// (packages/cultnet-rs) emits the single-prefixed form; this now matches it.
Error = ex.Message,
Code = "reference_outside_target"
};
}
///
/// Code-specific structured detail carried on (R-N). Fields are
/// populated only for the code that defines them; every field is otherwise omitted (nil on the wire).
///
[MessagePackObject]
public class CultNetErrorDetails
{
/// The selection field that failed (selection_invalid).
[Key("field")] public string? Field { get; set; }
/// The offending value, when there is one string worth naming (selection_invalid).
[Key("value")] public string? Value { get; set; }
/// The cursor's own minted asOf (cursor_stale).
[Key("asOf")] public ulong? AsOf { get; set; }
/// The answering server's current asOf (cursor_stale).
[Key("current")] public ulong? Current { 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 stable schema family name when the publisher has a typed descriptor.
///
[Key("schemaName")] public string? SchemaName { get; set; }
///
/// Gets or sets the portable versioned schema contract when the publisher has a typed descriptor.
///
[Key("schemaVersion")] public string? SchemaVersion { get; set; }
///
/// Gets or sets the canonical schema content hash when the publisher has a typed descriptor.
///
[Key("schemaContentHash")] public string? SchemaContentHash { get; set; }
///
/// 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;
///
/// Gets or sets the stable consumer runtime identity used for subscription diagnostics and body-plane demand.
///
[Key("consumerRuntimeId")] public string? ConsumerRuntimeId { get; set; }
///
/// Gets or sets logical hot-body identities needed by this exact state subscription.
///
[Key("bodyIds")] public string[]? BodyIds { get; set; }
///
/// Gets or sets body transports the consumer can open, ordered by consumer preference.
///
[Key("supportedBodyTransports")] public string[]? SupportedBodyTransports { get; set; }
}
///
/// CultNet message requesting a document snapshot through a typed selection (docs/cultnet-selection-cut.md).
///
[MessagePackObject]
public class CultNetSnapshotRequestV1Message : ICultNetSchemaMessage
{
/// Gets or sets the schema version.
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotRequestV1;
/// Gets or sets the message id.
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
/// Gets or sets the selection.
[Key("selection")] public CultNetSelection Selection { get; set; } = new CultNetSelection();
/// 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; }
}
///
/// Requests a live database subscription through a typed selection (docs/cultnet-selection-cut.md).
///
[MessagePackObject]
public class CultNetDatabaseSubscribeV1Message : ICultNetSchemaMessage
{
/// Gets or sets the schema version.
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseSubscribeV1;
/// 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 the selection.
[Key("selection")] public CultNetSelection Selection { get; set; } = new CultNetSelection();
/// Gets or sets whether the server should send a matching snapshot before live changes.
[Key("includeSnapshot")] public bool IncludeSnapshot { get; set; } = true;
/// Gets or sets the stable consumer runtime identity used for subscription diagnostics and body-plane demand.
[Key("consumerRuntimeId")] public string? ConsumerRuntimeId { get; set; }
/// Gets or sets logical hot-body identities needed by this exact state subscription.
[Key("bodyIds")] public string[]? BodyIds { get; set; }
/// Gets or sets body transports the consumer can open, ordered by consumer preference.
[Key("supportedBodyTransports")] public string[]? SupportedBodyTransports { get; set; }
}
///
/// CultNet message returning a typed selection's page (docs/cultnet-selection-cut.md).
///
[MessagePackObject]
public class CultNetSnapshotResponseRawV1Message : ICultNetSchemaMessage
{
/// Gets or sets the schema version.
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotResponseRawV1;
/// Gets or sets the message id.
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
/// Gets or sets the number of rows on this page.
[Key("matched")] public uint Matched { get; set; }
/// Gets or sets the snapshot this page is exact as of.
[Key("asOf")] public ulong AsOf { get; set; }
/// Gets or sets the cursor for the next page, absent on the last page.
[Key("next")] public string? Next { get; set; }
/// Gets or sets the headers, present under header projection.
[Key("headers")] public CultNetRawDocumentHeader[]? Headers { get; set; }
/// Gets or sets the documents, present under document projection.
[Key("documents")] public CultNetRawDocumentRecord[]? Documents { get; set; }
/// Gets or sets the edges a hop-bearing selection traversed.
[Key("edges")] public CultNetEdge[]? Edges { get; set; }
/// 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; }
}
///
/// 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 an identity-bound CultMesh session before application traffic begins.
[MessagePackObject]
public class CultMeshSessionOpenMessage : ICultNetSchemaMessage
{
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SessionOpen;
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
[Key("sourceRuntimeId")] public string SourceRuntimeId { get; set; } = string.Empty;
[Key("verseId")] public string VerseId { get; set; } = string.Empty;
[Key("authorityRuntimeId")] public string AuthorityRuntimeId { get; set; } = string.Empty;
[Key("protocolId")] public string ProtocolId { get; set; } = string.Empty;
[Key("routeGeneration")] public string RouteGeneration { get; set; } = string.Empty;
[Key("clientNonce")] public string ClientNonce { get; set; } = string.Empty;
}
/// Accepts or rejects a CultMesh session with the server's actual identity.
[MessagePackObject]
public class CultMeshSessionAcceptedMessage : ICultNetSchemaMessage
{
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SessionAccepted;
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
[Key("accepted")] public bool Accepted { get; set; }
[Key("verseId")] public string VerseId { get; set; } = string.Empty;
[Key("authorityRuntimeId")] public string AuthorityRuntimeId { get; set; } = string.Empty;
[Key("protocolId")] public string ProtocolId { get; set; } = string.Empty;
[Key("routeGeneration")] public string RouteGeneration { get; set; } = string.Empty;
[Key("clientNonce")] public string ClientNonce { get; set; } = string.Empty;
[Key("providerKeyId")] public string ProviderKeyId { get; set; } = string.Empty;
[Key("providerSignature")] public string ProviderSignature { get; set; } = string.Empty;
[Key("error")] public string? Error { get; set; }
}
///
/// 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 exact authoritative-runtime route bindings. This is the
/// routing authority; the parallel legacy arrays are projections only.
///
[Key("authorityRoutes")] public CultMeshAuthorityRouteMessage[] AuthorityRoutes { 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 one authority-bound CultMesh route.
[MessagePackObject]
public class CultMeshAuthorityRouteMessage
{
[Key("authorityRuntimeId")] public string AuthorityRuntimeId { get; set; } = string.Empty;
[Key("endpoint")] public string Endpoint { get; set; } = string.Empty;
[Key("protocolIds")] public string[] ProtocolIds { get; set; } = Array.Empty();
[Key("priority")] public int Priority { get; set; }
[Key("generation")] public string Generation { get; set; } = string.Empty;
[Key("certificate")] public CultMeshRouteCertificateMessage? Certificate { get; set; }
}
[MessagePackObject]
public class CultMeshRouteCertificateMessage
{
[Key("providerKeyId")] public string ProviderKeyId { get; set; } = string.Empty;
[Key("providerPublicKeyX")] public string ProviderPublicKeyX { get; set; } = string.Empty;
[Key("providerPublicKeyY")] public string ProviderPublicKeyY { get; set; } = string.Empty;
[Key("odinKeyId")] public string OdinKeyId { get; set; } = string.Empty;
[Key("issuedAtUnixMilliseconds")] public long IssuedAtUnixMilliseconds { get; set; }
[Key("expiresAtUnixMilliseconds")] public long ExpiresAtUnixMilliseconds { get; set; }
[Key("signature")] public string Signature { get; set; } = string.Empty;
}
///
/// 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();
}
///
/// Requests one bounded content-addressed chunk over a managed CultMesh content session.
///
[MessagePackObject]
public class CultMeshContentChunkRequestMessage : ICultNetSchemaMessage
{
/// Gets or sets the wire schema identity.
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ContentChunkRequest;
/// Gets or sets the request correlation identity.
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
/// Gets or sets the canonical SHA-256 chunk identity.
[Key("chunkHash")] public string ChunkHash { get; set; } = string.Empty;
/// Gets or sets the optional canonical CultCache record key.
[Key("recordKey")] public string RecordKey { get; set; } = string.Empty;
/// Gets or sets the manifest-bound expected payload size.
[Key("expectedSizeBytes")] public int ExpectedSizeBytes { get; set; }
}
///
/// Returns one bounded content-addressed chunk without publishing it as snapshot state.
///
[MessagePackObject]
public class CultMeshContentChunkResponseMessage : ICultNetSchemaMessage
{
/// Gets or sets the wire schema identity.
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ContentChunkResponse;
/// Gets or sets the matching request correlation identity.
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
/// Gets or sets whether a validated chunk is present.
[Key("found")] public bool Found { get; set; }
/// Gets or sets the canonical SHA-256 chunk identity.
[Key("chunkHash")] public string ChunkHash { get; set; } = string.Empty;
/// Gets or sets the payload byte count.
[Key("sizeBytes")] public int SizeBytes { get; set; }
/// Gets or sets the bounded content payload.
[Key("payload")] public byte[] Payload { get; set; } = Array.Empty();
/// Gets or sets a typed-boundary failure description when the chunk is unavailable.
[Key("error")] public string Error { get; set; } = string.Empty;
}
///
/// Requests one immutable body generation from its capability owner. Body bytes travel on this
/// dedicated plane; they are never database snapshot records.
///
[MessagePackObject]
public class CultMeshBodyReadRequestMessage : ICultNetSchemaMessage
{
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.BodyReadRequest;
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
[Key("capabilityToken")] public string CapabilityToken { get; set; } = string.Empty;
[Key("bodyId")] public string BodyId { get; set; } = string.Empty;
[Key("bodySchemaId")] public string BodySchemaId { get; set; } = string.Empty;
[Key("layoutVersion")] public int LayoutVersion { get; set; }
[Key("producerEpoch")] public long ProducerEpoch { get; set; }
[Key("sequence")] public long Sequence { get; set; }
[Key("expectedSizeBytes")] public long ExpectedSizeBytes { get; set; }
[Key("semanticHash")] public string SemanticHash { get; set; } = string.Empty;
}
/// Returns one bounded immutable body generation directly to its subscriber.
[MessagePackObject]
public class CultMeshBodyReadResponseMessage : ICultNetSchemaMessage
{
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.BodyReadResponse;
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
[Key("found")] public bool Found { get; set; }
[Key("capabilityToken")] public string CapabilityToken { get; set; } = string.Empty;
[Key("bodyId")] public string BodyId { get; set; } = string.Empty;
[Key("producerEpoch")] public long ProducerEpoch { get; set; }
[Key("sequence")] public long Sequence { get; set; }
[Key("sizeBytes")] public long SizeBytes { get; set; }
[Key("semanticHash")] public string SemanticHash { get; set; } = string.Empty;
[Key("payload")] public byte[] Payload { get; set; } = Array.Empty();
[Key("error")] public string Error { get; set; } = string.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();
}
}