2026-05-06 11:50:10 +01:00
|
|
|
using System;
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
|
|
|
|
namespace GameCult.Networking
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shared wire-contract identifiers understood by the CultNet family.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class CultNetWireContracts
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// schema v0 contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SchemaV0 = "cultnet.schema.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// game cult networking v0 contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string GameCultNetworkingV0 = "gamecult.networking.v0";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Canonical schema-version strings for the modern CultNet message family.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class CultNetSchemaVersions
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// hello contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string Hello = "cultnet.hello.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// login contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string Login = "cultnet.login.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// register contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string Register = "cultnet.register.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// verify contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string Verify = "cultnet.verify.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// login success contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string LoginSuccess = "cultnet.login_success.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// error contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string Error = "cultnet.error.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// sample change name contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SampleChangeName = "cultnet.sample.change_name.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// sample chat contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SampleChat = "cultnet.sample.chat.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
2026-07-10 11:17:33 +01:00
|
|
|
/// Generic typed service operation request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string OperationRequest = "cultnet.operation_request.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generic typed service operation response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string OperationResponse = "cultnet.operation_response.v0";
|
|
|
|
|
/// <summary>
|
2026-05-08 13:11:01 +01:00
|
|
|
/// document delete contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string DocumentDelete = "cultnet.document_delete.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// document put raw contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string DocumentPutRaw = "cultnet.document_put_raw.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// snapshot request contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SnapshotRequest = "cultnet.snapshot_request.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// snapshot response raw contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SnapshotResponseRaw = "cultnet.snapshot_response_raw.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
CultNet selection cut1, commit 1: the shape, the evaluator, v1 messages
docs/cultnet-selection-cut.md section 2/4/6/7/8: CultNetSelection (schemas,
keys, fields, cites, cited, projection, descending, limit, cursor) with its
door validation (S1), and CultNetSelectionEvaluator: the single-row Matches
fast path (D6) and the full Select (order, hop, cursor, paging). Neither
reflects over a document; both read only through the cache's public surface
(commit 0).
Three v1 messages beside v0 (cultnet.snapshot_request.v1,
cultnet.database_subscribe.v1, cultnet.snapshot_response_raw.v1), their
schema files under contracts/cultnet, registry entries and dispatch arms.
CultNetSchemaAliasMatching goes internal -> public (D4), the one alias
matcher. CultNetDatabase gains LastWriteSequence(schemaId, key), confirmed
at the one append site (AppendMutationLogEntry) that every committed write
takes a shard-log sequence, including a local PutAsync outside any shard.
Three engines deleted, one evaluator wired in their place:
- CultNetDocumentRegistry: CreateRawSnapshotResponse's reflection loop over
cache.AllEntries and MatchesRequestedSchema gone; cache.AllStoredDocuments
replaces the reflection entirely. v0 lowers into a Selection and walks the
evaluator's own pages so a v0 caller still sees its whole matching set
(D3: v0 has no engine of its own). CreateSelectionResponse/SelectPage/
ToRawRecord/CreateSnapshotRequestV1 added.
- CultNetDatabaseServer: CreateChangeMessage/CreateRawDocumentRecord/Matches/
MatchesSchema/InferSchemaName (122 lines) deleted; CreateSubscription lowers
v0 into a Selection and matches through the evaluator.
- CultNetDatabaseSubscriptionServer: CreateAuthorizedChange/CreateChange/
CreateChangeCore/ResolveWireSchemaId/MatchesRequestedSchema/CreateRawRecord
(92 lines) deleted, replaced by CreateMatchedRecord. _projectRecord and
CreateProjectedSnapshot's collapse are commit 2's, per the map's own
deletion line, and are untouched here.
Discrepancy found and fixed (not in the map): CultNetDocumentBinding can
carry a schema id different from its descriptor's own
(CultNetDocumentBinding.ForDocument's schemaId override), which the old
per-engine matchers checked and a descriptor-only evaluator cannot see by
design (it stays decoupled from CultNetDocumentRegistry). Fixed at the two
call sites and in CultNetDocumentRegistry.SelectPage by resolving the
binding's schema id into the effective selection before evaluation
(CultNetSchemaAliasMatching.WithBindingSchemaAlias,
CultNetDocumentRegistry.ExpandSchemaBindingAliases), not in the evaluator.
Found by DatabaseSubscription_FiltersLiveChangesByWireSchemaBinding timing
out; both call sites now pass.
Second discrepancy, reported not fixed: CultNetDatabase.cs:1707 has a fourth,
undocumented copy of schema-matching logic (MatchesRequestedSchema, private,
serving CreateShardSnapshotResponse), which the map's section 1 audit did not
name among "three separate selector engines". Left untouched this commit:
it is out of the map's explicit deletes list and touching it risks shard
snapshot behavior with no budgeted verification.
Verification: dotnet test tests/GameCult.Networking.Tests - 162 passed (150
existing + 12 new), 0 failed; the seven map-named tests all still pass, two
rewritten for the new signatures (CreateChangeMessage now takes
CultNetSelection; CreateChange/CreateAuthorizedChange collapsed into
CreateMatchedRecord, returning CultNetRawDocumentRecord? directly).
tests/GameCult.Mesh.Tests - 252 passed, 1 pre-existing skip, 0 failed (no
Mesh source touched this commit). tests/GameCult.Caching.Tests - unaffected
(188, unchanged from commit 0).
Negative greps: GetProperty|GetField|GetCustomAttribute in
GameCult.Networking - only against the generic `object change` dispatch
(CultNetDatabaseChange<T>) and CultRecordHandle<T> construction, pre-existing
and out of this cut's scope, never against a document's declared values.
_projectRecord survives in CultNetDatabaseSubscriptionServer.cs (expected,
commit 2). CultNetSchemaAliasMatching is the only schema matcher outside the
one reported discrepancy.
scripts/mutate-dotnet.ps1: the caching mutation runner generalized into a
shared dotnet/NUnit harness (Target/TestProject/Entries/ControlFilter),
replacing scripts/mutate-cultnet-selection-caching.ps1 with an entries file
of the same six mutations (re-verified: all six still KILL). It is now
generic to any NUnit project in this repo, not only this campaign's two
targets - a candidate to sit beside tools/eureka-mutations.ps1 as the
dotnet-side counterpart. Nine new networking entries (S3, S5 x2, S7 x2,
S16 x2, S18) all KILLED. Not yet mutation-run: S1, S2, S6, S23 (pinned by
tests, not by a committed mutant); S9-S15 (subscription reconcile lowering,
v0 no-engine-of-its-own); S17, S20 (pinned by tests only). S19/S21/S22 are
cache-layer, covered in commit 0.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 02:31:42 +02:00
|
|
|
/// typed-selection snapshot request contract identifier (docs/cultnet-selection-cut.md).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string SnapshotRequestV1 = "cultnet.snapshot_request.v1";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// typed-selection database subscription request contract identifier (docs/cultnet-selection-cut.md).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string DatabaseSubscribeV1 = "cultnet.database_subscribe.v1";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// typed-selection snapshot response contract identifier (docs/cultnet-selection-cut.md).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string SnapshotResponseRawV1 = "cultnet.snapshot_response_raw.v1";
|
|
|
|
|
/// <summary>
|
2026-05-08 13:11:01 +01:00
|
|
|
/// schema catalog request contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SchemaCatalogRequest = "cultnet.schema_catalog_request.v0";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// schema catalog response contract identifier.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
public const string SchemaCatalogResponse = "cultnet.schema_catalog_response.v0";
|
2026-05-19 17:10:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// database subscription request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string DatabaseSubscribe = "cultnet.database_subscribe.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// database subscription cancel contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string DatabaseUnsubscribe = "cultnet.database_unsubscribe.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// database subscription change contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string DatabaseChangeRaw = "cultnet.database_change_raw.v0";
|
2026-05-19 17:34:49 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// shard catalog request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ShardCatalogRequest = "cultnet.shard_catalog_request.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// shard catalog response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ShardCatalogResponse = "cultnet.shard_catalog_response.v0";
|
2026-05-19 18:01:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// shard mutation log request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ShardLogRequest = "cultnet.shard_log_request.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// shard mutation log response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ShardLogResponse = "cultnet.shard_log_response.v0";
|
2026-05-19 18:39:53 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// simulation observation gossip contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string SimulationObservation = "cultnet.simulation_observation.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// simulation consensus candidate gossip contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string SimulationConsensusCandidate = "cultnet.simulation_consensus_candidate.v0";
|
2026-05-19 21:23:11 +01:00
|
|
|
/// <summary>
|
2026-05-20 23:41:13 +01:00
|
|
|
/// witness artifact bundle document contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string WitnessArtifactBundle = "cultnet.witness_artifact_bundle.v0";
|
|
|
|
|
/// <summary>
|
2026-05-19 21:23:11 +01:00
|
|
|
/// CultMesh Verse catalog request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string VerseCatalogRequest = "cultmesh.verse_catalog_request.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh Verse catalog response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string VerseCatalogResponse = "cultmesh.verse_catalog_response.v0";
|
2026-08-18 17:21:58 +02:00
|
|
|
/// <summary>CultMesh session identity request contract identifier.</summary>
|
2026-08-18 19:02:46 +02:00
|
|
|
public const string SessionOpen = "cultmesh.session_open.v2";
|
2026-08-18 17:21:58 +02:00
|
|
|
/// <summary>CultMesh verified session identity response contract identifier.</summary>
|
2026-08-18 19:02:46 +02:00
|
|
|
public const string SessionAccepted = "cultmesh.session_accepted.v2";
|
2026-05-20 01:35:39 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh peer exchange request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string PeerExchangeRequest = "cultmesh.peer_exchange_request.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh peer exchange response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string PeerExchangeResponse = "cultmesh.peer_exchange_response.v0";
|
2026-07-14 01:13:23 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh content chunk request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ContentChunkRequest = "cultmesh.content_chunk_request.v1";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh content chunk response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ContentChunkResponse = "cultmesh.content_chunk_response.v1";
|
2026-07-19 13:57:06 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh ephemeral body read request contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string BodyReadRequest = "cultmesh.body_read_request.v1";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CultMesh ephemeral body read response contract identifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string BodyReadResponse = "cultmesh.body_read_response.v1";
|
2026-05-06 11:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-11 15:11:53 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Mutation authority owner identifiers advertised through CultNet mutation contracts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class CultNetMutationAuthorities
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The document is inspectable but not writable through CultNet.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string ReadOnly = "readOnly";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The local human operator may submit the corresponding mutation intent.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string LocalUser = "localUser";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A coordinator-owned Epiphany control surface owns the mutation path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string Coordinator = "coordinator";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The runtime itself may write this document directly.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string Runtime = "runtime";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The document should not be mutated through CultNet.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const string Denied = "denied";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Declares how a document or surface may be inspected and mutated over CultNet.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDocumentMutationContract
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the stable document type governed by this contract.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("documentType")] public string DocumentType { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the payload schema version when the contract governs a versioned document payload.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("payloadSchemaVersion")] public string? PayloadSchemaVersion { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the CultNet operations this document accepts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("operations")] public string[] Operations { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets which actor is allowed to drive those operations.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("authority")] public string Authority { get; set; } = CultNetMutationAuthorities.ReadOnly;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the intent document types a client may submit to request mutation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("intentDocumentTypes")] public string[]? IntentDocumentTypes { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the receipt document types emitted after a successful mutation path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("receiptDocumentTypes")] public string[]? ReceiptDocumentTypes { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets freeform notes that explain local mutation guardrails or posture.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("notes")] public string[]? Notes { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-06 11:50:10 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Marker interface for the explicit modern CultNet schema-v0 message family.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version carried by this message.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
string SchemaVersion { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet hello message used to announce a runtime and its supported contracts.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetHelloMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Hello;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the runtime id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("runtimeId")] public string RuntimeId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the runtime kind.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("runtimeKind")] public string RuntimeKind { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the agent id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("agentId")] public string? AgentId { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the role.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("role")] public string? Role { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the display name.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("displayName")] public string? DisplayName { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the supported document types.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("supportedDocumentTypes")] public string[]? SupportedDocumentTypes { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
2026-05-11 15:11:53 +01:00
|
|
|
/// Gets or sets the supported mutation contracts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("supportedMutationContracts")] public CultNetDocumentMutationContract[]? SupportedMutationContracts { get; set; }
|
|
|
|
|
/// <summary>
|
2026-05-08 13:11:01 +01:00
|
|
|
/// Gets or sets the supported message versions.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("supportedMessageVersions")] public string[]? SupportedMessageVersions { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
2026-06-14 21:20:52 +01:00
|
|
|
/// Gets or sets the transport profiles advertised by this peer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("transportProfiles")] public CultNetTransportProfile[]? TransportProfiles { get; set; }
|
|
|
|
|
/// <summary>
|
2026-05-08 13:11:01 +01:00
|
|
|
/// Gets or sets the supports schema catalog.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("supportsSchemaCatalog")] public bool SupportsSchemaCatalog { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-14 21:20:52 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Describes the transports a runtime can speak.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetTransportProfile
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = "cultnet.transport_profile.v0";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the runtime id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("runtimeId")] public string RuntimeId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the transport descriptors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("transports")] public CultNetTransportDescriptor[] Transports { get; set; } = Array.Empty<CultNetTransportDescriptor>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Describes one transport endpoint.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetTransportDescriptor
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the transport id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("transportId")] public string TransportId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the protocol name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("protocol")] public string Protocol { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the host.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("host")] public string? Host { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the port.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("port")] public int? Port { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("path")] public string? Path { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the discovery group.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("discoveryGroup")] public string? DiscoveryGroup { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the wire contracts.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("wireContracts")] public string[]? WireContracts { get; set; }
|
|
|
|
|
/// <summary>
|
2026-06-16 04:01:41 +01:00
|
|
|
/// Gets or sets the transport reconnect policy, when the transport owns reconnect posture.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("reconnectPolicy")] public CultNetReconnectPolicy? ReconnectPolicy { get; set; }
|
|
|
|
|
/// <summary>
|
2026-06-14 21:20:52 +01:00
|
|
|
/// Gets or sets the channels.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("channels")] public CultNetTransportChannel[] Channels { get; set; } = Array.Empty<CultNetTransportChannel>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Describes one transport channel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetTransportChannel
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the channel id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("channelId")] public string ChannelId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the delivery semantics.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("delivery")] public string Delivery { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the ordering semantics.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("ordering")] public string Ordering { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the maximum payload bytes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("maxPayloadBytes")] public int? MaxPayloadBytes { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the maximum fragment bytes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("maxFragmentBytes")] public int? MaxFragmentBytes { get; set; }
|
2026-06-15 15:24:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the maximum pending reliable packet count.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("maxPendingReliablePackets")] public int? MaxPendingReliablePackets { get; set; }
|
2026-06-14 21:20:52 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet login request message.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetLoginMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Login;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the nonce.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("nonce")] public string Nonce { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the auth.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("auth")] public string Auth { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the password.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("password")] public string Password { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet registration request message.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetRegisterMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Register;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the nonce.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("nonce")] public string Nonce { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the email.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("email")] public string Email { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the password.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("password")] public string Password { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("name")] public string Name { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet session verification request message.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetVerifyMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Verify;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the nonce.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("nonce")] public string Nonce { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the session.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("session")] public string Session { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message returned after successful session verification.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetLoginSuccessMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.LoginSuccess;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the nonce.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("nonce")] public string Nonce { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the session.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("session")] public string Session { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet error response message.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetErrorMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.Error;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the error.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("error")] public string Error { get; set; } = string.Empty;
|
2026-05-19 17:34:49 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional shard routing details for authority failures.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("routingHint")] public CultNetShardRoutingHint? RoutingHint { get; set; }
|
Fix batch 3: R-N wire refusal codes, R-P one authorizer id, R-T removal/cites gaps
R-N: cultnet.error.v0 gains additive code/details fields (contracts/cultnet).
CultNetErrorMessage grows ForSelectionInvalid/ForCursor/ForReferenceOutsideTarget
factories; both C# servers (CultNetDatabaseServer for snapshot+live,
CultNetDatabaseSubscriptionServer) use them at every existing catch site, plus
two sites that previously let the exception escape uncaught instead of reaching
the peer (CultNetDatabaseServer's v1 subscribe snapshot branch,
CultNetDatabaseSubscriptionServer's Subscribe around CreateProjectedSnapshot).
CultNetSelectionCursorException now carries AsOf/Current for cursor_stale.
R-P: CultNetDatabaseSubscriptionServer.CreateMatchedRecord (the live fast path)
authorized against descriptor.SchemaId; the snapshot path (CreateProjectedSnapshot)
already authorized against the wire id. Both now call the same
CultNetDocumentRegistry.WireSchemaId (made internal, was private) so one id
reaches the authorizer on the snapshot, live and reconcile paths alike.
R-T(a): CultNetSelectionEvaluator.MatchesSchemaKeysFields no longer reads a
Removed change's (always-null) document against Fields - it matches on
keys/schemas alone and treats a field predicate as unknown instead of throwing
TryGetIndexValue(null).
R-T(b): EnsureWithinDeclaredTarget no longer skips the out-of-target check when
TargetType is null; it checks against every registered leaf (unconstrained is a
real, checked target set, not a bypass). CultCache's ResolveReferenceTarget also
now infers the target from a many reference's CultRecordRef<T> element when no
explicit [CultReference(typeof(...))] is declared, which was the one remaining
source of a null TargetType reaching that check on a real, testable path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 19:44:18 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the machine-readable refusal code (R-N), e.g. <c>selection_invalid</c>,
|
2026-10-28 00:47:24 +01:00
|
|
|
/// <c>cursor_stale</c>, <c>cursor_invalid</c>, <c>reference_outside_target</c>, <c>unowned_schema</c>, <c>write_not_authorized</c>. Additive to
|
Fix batch 3: R-N wire refusal codes, R-P one authorizer id, R-T removal/cites gaps
R-N: cultnet.error.v0 gains additive code/details fields (contracts/cultnet).
CultNetErrorMessage grows ForSelectionInvalid/ForCursor/ForReferenceOutsideTarget
factories; both C# servers (CultNetDatabaseServer for snapshot+live,
CultNetDatabaseSubscriptionServer) use them at every existing catch site, plus
two sites that previously let the exception escape uncaught instead of reaching
the peer (CultNetDatabaseServer's v1 subscribe snapshot branch,
CultNetDatabaseSubscriptionServer's Subscribe around CreateProjectedSnapshot).
CultNetSelectionCursorException now carries AsOf/Current for cursor_stale.
R-P: CultNetDatabaseSubscriptionServer.CreateMatchedRecord (the live fast path)
authorized against descriptor.SchemaId; the snapshot path (CreateProjectedSnapshot)
already authorized against the wire id. Both now call the same
CultNetDocumentRegistry.WireSchemaId (made internal, was private) so one id
reaches the authorizer on the snapshot, live and reconcile paths alike.
R-T(a): CultNetSelectionEvaluator.MatchesSchemaKeysFields no longer reads a
Removed change's (always-null) document against Fields - it matches on
keys/schemas alone and treats a field predicate as unknown instead of throwing
TryGetIndexValue(null).
R-T(b): EnsureWithinDeclaredTarget no longer skips the out-of-target check when
TargetType is null; it checks against every registered leaf (unconstrained is a
real, checked target set, not a bypass). CultCache's ResolveReferenceTarget also
now infers the target from a many reference's CultRecordRef<T> element when no
explicit [CultReference(typeof(...))] is declared, which was the one remaining
source of a null TargetType reaching that check on a real, testable path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 19:44:18 +02:00
|
|
|
/// <c>cultnet.error.v0</c>; a v0 peer that does not know this field ignores it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("code")] public string? Code { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the code-specific structured detail (R-N). Additive to <c>cultnet.error.v0</c>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("details")] public CultNetErrorDetails? Details { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the wire error for a door refusal (R-N): code <c>selection_invalid</c>, details
|
|
|
|
|
/// <c>{ field, value }</c>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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 }
|
|
|
|
|
};
|
|
|
|
|
|
Cut 4 Soul 4c: committed-unlogged wire writes, database serves only what it owns, typed unowned refusal
Q1: HandlePutAsync/HandleDeleteAsync catch a CultNetShardLogException (or an
AggregateException holding one) before the generic catch and answer nothing: the
write committed and was published, so the peer is not told it was refused. It is
logged at warning level. The wire has no committed-with-degraded-log message.
Q2: GetAsync/GetAll/GetByName/GetByIndex, the shard-less snapshot, the selection
and the subscription snapshot serve only rows a shard owns, so read and watch
agree; the CultMesh collections follow through GetAll, and the Mesh untyped
variant fallback checks ownership. The raw cache still holds everything.
Q3: a replica log apply skips a row its shard does not own, as the snapshot path
does, and still records the entry so a chained replica sees no gap.
API: rowFilter is internal (public CreateSelectionResponse and
CreateRawSnapshotResponse signatures restored, internal overloads added);
exception tags on the write methods; Commit's unwrap rule is XML doc; the
unowned refusal answers on the wire with code unowned_schema (schema enum in both
copies, Rust CultNetErrorCode, CultNetErrorMessage.ForUnownedSchema) and put and
delete log it at warning level.
Dispose keeps journal-first; a test now fails if the observer goes first.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 06:14:49 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the wire error for a write no shard owns: code <c>unowned_schema</c>, details <c>{ field: "schemaId", value }</c>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static CultNetErrorMessage ForUnownedSchema(CultNetUnownedSchemaException ex) =>
|
|
|
|
|
new CultNetErrorMessage
|
|
|
|
|
{
|
|
|
|
|
Error = $"unowned_schema: {ex.Message}",
|
|
|
|
|
Code = "unowned_schema",
|
|
|
|
|
Details = new CultNetErrorDetails { Field = "schemaId", Value = ex.SchemaId }
|
|
|
|
|
};
|
|
|
|
|
|
2026-10-28 00:47:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the wire error for a peer write its authority refused: code <c>write_not_authorized</c>, details
|
|
|
|
|
/// <c>{ field: "recordKey", value }</c>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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 }
|
|
|
|
|
};
|
|
|
|
|
|
Fix batch 3: R-N wire refusal codes, R-P one authorizer id, R-T removal/cites gaps
R-N: cultnet.error.v0 gains additive code/details fields (contracts/cultnet).
CultNetErrorMessage grows ForSelectionInvalid/ForCursor/ForReferenceOutsideTarget
factories; both C# servers (CultNetDatabaseServer for snapshot+live,
CultNetDatabaseSubscriptionServer) use them at every existing catch site, plus
two sites that previously let the exception escape uncaught instead of reaching
the peer (CultNetDatabaseServer's v1 subscribe snapshot branch,
CultNetDatabaseSubscriptionServer's Subscribe around CreateProjectedSnapshot).
CultNetSelectionCursorException now carries AsOf/Current for cursor_stale.
R-P: CultNetDatabaseSubscriptionServer.CreateMatchedRecord (the live fast path)
authorized against descriptor.SchemaId; the snapshot path (CreateProjectedSnapshot)
already authorized against the wire id. Both now call the same
CultNetDocumentRegistry.WireSchemaId (made internal, was private) so one id
reaches the authorizer on the snapshot, live and reconcile paths alike.
R-T(a): CultNetSelectionEvaluator.MatchesSchemaKeysFields no longer reads a
Removed change's (always-null) document against Fields - it matches on
keys/schemas alone and treats a field predicate as unknown instead of throwing
TryGetIndexValue(null).
R-T(b): EnsureWithinDeclaredTarget no longer skips the out-of-target check when
TargetType is null; it checks against every registered leaf (unconstrained is a
real, checked target set, not a bypass). CultCache's ResolveReferenceTarget also
now infers the target from a many reference's CultRecordRef<T> element when no
explicit [CultReference(typeof(...))] is declared, which was the one remaining
source of a null TargetType reaching that check on a real, testable path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 19:44:18 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the wire error for a cursor refusal (R-N): code <c>cursor_stale</c> with details
|
|
|
|
|
/// <c>{ asOf, current }</c>, or code <c>cursor_invalid</c> with no details.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
|
2026-09-29 10:12:20 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the wire error for a selection that selects a document variant, which CultNet does not carry yet: code
|
|
|
|
|
/// <c>variant_unsupported</c>, details <c>{ field: "subscriptionId", value }</c> when a subscription was ended by it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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 }
|
|
|
|
|
};
|
|
|
|
|
|
Fix batch 3: R-N wire refusal codes, R-P one authorizer id, R-T removal/cites gaps
R-N: cultnet.error.v0 gains additive code/details fields (contracts/cultnet).
CultNetErrorMessage grows ForSelectionInvalid/ForCursor/ForReferenceOutsideTarget
factories; both C# servers (CultNetDatabaseServer for snapshot+live,
CultNetDatabaseSubscriptionServer) use them at every existing catch site, plus
two sites that previously let the exception escape uncaught instead of reaching
the peer (CultNetDatabaseServer's v1 subscribe snapshot branch,
CultNetDatabaseSubscriptionServer's Subscribe around CreateProjectedSnapshot).
CultNetSelectionCursorException now carries AsOf/Current for cursor_stale.
R-P: CultNetDatabaseSubscriptionServer.CreateMatchedRecord (the live fast path)
authorized against descriptor.SchemaId; the snapshot path (CreateProjectedSnapshot)
already authorized against the wire id. Both now call the same
CultNetDocumentRegistry.WireSchemaId (made internal, was private) so one id
reaches the authorizer on the snapshot, live and reconcile paths alike.
R-T(a): CultNetSelectionEvaluator.MatchesSchemaKeysFields no longer reads a
Removed change's (always-null) document against Fields - it matches on
keys/schemas alone and treats a field predicate as unknown instead of throwing
TryGetIndexValue(null).
R-T(b): EnsureWithinDeclaredTarget no longer skips the out-of-target check when
TargetType is null; it checks against every registered leaf (unconstrained is a
real, checked target set, not a bypass). CultCache's ResolveReferenceTarget also
now infers the target from a many reference's CultRecordRef<T> element when no
explicit [CultReference(typeof(...))] is declared, which was the one remaining
source of a null TargetType reaching that check on a real, testable path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 19:44:18 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Builds the wire error for an out-of-target reference refusal (R-N): code
|
|
|
|
|
/// <c>reference_outside_target</c>, no details.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static CultNetErrorMessage ForReferenceOutsideTarget(CultNetSelectionReferenceOutsideTargetException ex) =>
|
|
|
|
|
new CultNetErrorMessage
|
|
|
|
|
{
|
Land fix batch 3's R-O and R-Q: keyed length-prefixed cursors, replica-apply sequence gap
R-O: CultNetSelectionCursorKey is a per-process (per-CultNetDatabase-instance) 32-byte
random key. CultNetSelectionCursor.ComputeDigest is now an HMAC-SHA256 under that key
instead of an unkeyed SHA-256, so a cursor cannot be forged without the key and does not
verify across a restart (a fresh CultNetDatabase mints a fresh key). The cursor body
(asOf/ordinal/schemaId/recordKey/digest) is length-prefixed (<byte length>:<value>, no
delimiter) instead of joined with a bare "\x01"-separated string, so a record key
carrying any character, U+241F included, round-trips. CultNetSelectionEvaluator.Select/
Page/ComputeDigest take an optional CultNetSelectionCursorKey, defaulting to a
process-wide key generated once so existing callers that never wire up a database still
get a keyed digest. CultNetDatabase gets a CursorKey property (random unless
CultNetDatabaseOptions.CursorKey is supplied) and passes it through
CultNetDatabaseServer.CreateSelectionResponse.
Rust already landed R-O (5aac120) under its own algorithm, deliberately not byte-matching
the reference: its own doc comment says a cursor is never handed across runtimes, so only
collision-freedom and keying are load-bearing, not the wire bytes. That is a real
divergence from this pass's instruction to match Rust's wire encoding exactly - reported
in full in the batch report.
R-Q: the two replica-apply paths (ApplyCommittedPutAsync, ApplyCommittedDelete) recorded
the mutation-log entry but never set _lastWriteSequence, so a row's order/cursor position
looked like "never written" until it was written again locally. Both now set it from the
entry's own sequence, matching AppendMutationLogEntry's local-commit path.
InitializeLogSequencesFromStore rebuilt only _nextLogSequences at startup; it now also
rebuilds _lastWriteSequence by replaying the durable log's Put/Delete entries in sequence
order. CultNetDatabase.ResolveShard is a new public wrapper over the existing shard
resolution; CultNetDocumentRegistry.SelectPage/CreateSelectionResponse take an optional
shardIdOf callback and refuse (reusing CultNetSelectionInvalidException/selection_invalid,
R-N) when a selection's matched rows resolve to more than one shard's log, because asOf is
a single watermark and is not exact for a shard-spanning page.
CultNetDatabaseServer.CreateSelectionResponse wires shardIdOf/cursorKey through from the
database.
Also fixes a defect the Rust Hands found while matching wire bytes:
CultNetErrorMessage.ForReferenceOutsideTarget double-prefixed "reference_outside_target: "
- the exception's own message already carries it. Now prefixed once, matching Rust's
ForReferenceOutsideTarget.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 20:04:22 +02:00
|
|
|
// 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,
|
Fix batch 3: R-N wire refusal codes, R-P one authorizer id, R-T removal/cites gaps
R-N: cultnet.error.v0 gains additive code/details fields (contracts/cultnet).
CultNetErrorMessage grows ForSelectionInvalid/ForCursor/ForReferenceOutsideTarget
factories; both C# servers (CultNetDatabaseServer for snapshot+live,
CultNetDatabaseSubscriptionServer) use them at every existing catch site, plus
two sites that previously let the exception escape uncaught instead of reaching
the peer (CultNetDatabaseServer's v1 subscribe snapshot branch,
CultNetDatabaseSubscriptionServer's Subscribe around CreateProjectedSnapshot).
CultNetSelectionCursorException now carries AsOf/Current for cursor_stale.
R-P: CultNetDatabaseSubscriptionServer.CreateMatchedRecord (the live fast path)
authorized against descriptor.SchemaId; the snapshot path (CreateProjectedSnapshot)
already authorized against the wire id. Both now call the same
CultNetDocumentRegistry.WireSchemaId (made internal, was private) so one id
reaches the authorizer on the snapshot, live and reconcile paths alike.
R-T(a): CultNetSelectionEvaluator.MatchesSchemaKeysFields no longer reads a
Removed change's (always-null) document against Fields - it matches on
keys/schemas alone and treats a field predicate as unknown instead of throwing
TryGetIndexValue(null).
R-T(b): EnsureWithinDeclaredTarget no longer skips the out-of-target check when
TargetType is null; it checks against every registered leaf (unconstrained is a
real, checked target set, not a bypass). CultCache's ResolveReferenceTarget also
now infers the target from a many reference's CultRecordRef<T> element when no
explicit [CultReference(typeof(...))] is declared, which was the one remaining
source of a null TargetType reaching that check on a real, testable path.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 19:44:18 +02:00
|
|
|
Code = "reference_outside_target"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Code-specific structured detail carried on <see cref="CultNetErrorMessage"/> (R-N). Fields are
|
|
|
|
|
/// populated only for the code that defines them; every field is otherwise omitted (nil on the wire).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetErrorDetails
|
|
|
|
|
{
|
|
|
|
|
/// <summary>The selection field that failed (<c>selection_invalid</c>).</summary>
|
|
|
|
|
[Key("field")] public string? Field { get; set; }
|
|
|
|
|
/// <summary>The offending value, when there is one string worth naming (<c>selection_invalid</c>).</summary>
|
|
|
|
|
[Key("value")] public string? Value { get; set; }
|
|
|
|
|
/// <summary>The cursor's own minted asOf (<c>cursor_stale</c>).</summary>
|
|
|
|
|
[Key("asOf")] public ulong? AsOf { get; set; }
|
|
|
|
|
/// <summary>The answering server's current asOf (<c>cursor_stale</c>).</summary>
|
|
|
|
|
[Key("current")] public ulong? Current { get; set; }
|
2026-05-19 17:34:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Describes where a shard write should be routed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardRoutingHint
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard descriptor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shard")] public CultNetShardDescriptorMessage? Shard { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a machine-readable routing reason.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("reason")] public string Reason { get; set; } = string.Empty;
|
2026-05-06 11:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Sample CultNet message used by development clients to change a display name.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSampleChangeNameMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SampleChangeName;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("name")] public string Name { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Sample CultNet chat message used by development clients.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSampleChatMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SampleChat;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the text.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("text")] public string Text { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-10 11:17:33 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Invokes one typed operation on an advertised service.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetOperationRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the wire schema version.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.OperationRequest;
|
|
|
|
|
/// <summary>Gets or sets the correlation id.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the advertised service id.</summary>
|
|
|
|
|
[Key("serviceId")] public string ServiceId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the requested operation.</summary>
|
|
|
|
|
[Key("operation")] public string Operation { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the inner payload schema.</summary>
|
|
|
|
|
[Key("payloadSchema")] public string PayloadSchema { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the inner payload encoding.</summary>
|
|
|
|
|
[Key("payloadEncoding")] public string PayloadEncoding { get; set; } = "messagepack-base64";
|
|
|
|
|
/// <summary>Gets or sets the encoded inner payload.</summary>
|
|
|
|
|
[Key("payload")] public string Payload { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the calling runtime id.</summary>
|
|
|
|
|
[Key("sourceRuntimeId")] public string? SourceRuntimeId { get; set; }
|
|
|
|
|
/// <summary>Gets or sets an optional target runtime id.</summary>
|
|
|
|
|
[Key("targetRuntimeId")] public string? TargetRuntimeId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the correlated result of one typed service operation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetOperationResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the wire schema version.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.OperationResponse;
|
|
|
|
|
/// <summary>Gets or sets the request correlation id.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the advertised service id.</summary>
|
|
|
|
|
[Key("serviceId")] public string ServiceId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the completed operation.</summary>
|
|
|
|
|
[Key("operation")] public string Operation { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the operation status.</summary>
|
|
|
|
|
[Key("status")] public string Status { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the inner payload schema.</summary>
|
|
|
|
|
[Key("payloadSchema")] public string PayloadSchema { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the inner payload encoding.</summary>
|
|
|
|
|
[Key("payloadEncoding")] public string PayloadEncoding { get; set; } = "messagepack-base64";
|
|
|
|
|
/// <summary>Gets or sets the encoded inner payload.</summary>
|
|
|
|
|
[Key("payload")] public string Payload { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets transport-level diagnostics.</summary>
|
|
|
|
|
[Key("diagnostics")] public string[] Diagnostics { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>Gets or sets the responding runtime id.</summary>
|
|
|
|
|
[Key("sourceRuntimeId")] public string? SourceRuntimeId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Raw document record carried over CultNet.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetRawDocumentRecord
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema id.
|
|
|
|
|
/// </summary>
|
2026-05-08 01:13:15 +01:00
|
|
|
[Key("schemaId")] public string SchemaId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
2026-08-18 02:08:49 +02:00
|
|
|
/// Gets or sets the stable schema family name when the publisher has a typed descriptor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaName")] public string? SchemaName { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the portable versioned schema contract when the publisher has a typed descriptor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string? SchemaVersion { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the canonical schema content hash when the publisher has a typed descriptor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaContentHash")] public string? SchemaContentHash { get; set; }
|
|
|
|
|
/// <summary>
|
2026-05-08 13:11:01 +01:00
|
|
|
/// Gets or sets the record key.
|
|
|
|
|
/// </summary>
|
2026-05-08 01:13:15 +01:00
|
|
|
[Key("recordKey")] public string RecordKey { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the stored at.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("storedAt")] public string StoredAt { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the payload encoding.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("payloadEncoding")] public string PayloadEncoding { get; set; } = "messagepack";
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the payload.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("payload")] public byte[] Payload { get; set; } = Array.Empty<byte>();
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the source runtime id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("sourceRuntimeId")] public string? SourceRuntimeId { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the source agent id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("sourceAgentId")] public string? SourceAgentId { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the source role.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("sourceRole")] public string? SourceRole { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the tags.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("tags")] public string[]? Tags { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message requesting deletion of a document record.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDocumentDeleteMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DocumentDelete;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema id.
|
|
|
|
|
/// </summary>
|
2026-05-08 01:13:15 +01:00
|
|
|
[Key("schemaId")] public string SchemaId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the record key.
|
|
|
|
|
/// </summary>
|
2026-05-08 01:13:15 +01:00
|
|
|
[Key("recordKey")] public string RecordKey { get; set; } = string.Empty;
|
2026-05-19 17:34:49 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id the sender targeted.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string? ShardId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard epoch the sender targeted.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
2026-05-06 11:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message carrying one raw document record.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDocumentPutRawMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DocumentPutRaw;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the document.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("document")] public CultNetRawDocumentRecord Document { get; set; } = new CultNetRawDocumentRecord();
|
2026-05-19 17:34:49 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id the sender targeted.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string? ShardId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard epoch the sender targeted.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
2026-05-06 11:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message requesting a document snapshot.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSnapshotRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotRequest;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema ids.
|
|
|
|
|
/// </summary>
|
2026-05-08 01:13:15 +01:00
|
|
|
[Key("schemaIds")] public string[]? SchemaIds { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the record keys.
|
|
|
|
|
/// </summary>
|
2026-05-08 01:13:15 +01:00
|
|
|
[Key("recordKeys")] public string[]? RecordKeys { get; set; }
|
2026-05-19 21:07:46 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id requested for a shard-bounded snapshot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string? ShardId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the expected shard epoch.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
2026-05-06 11:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message returning raw document records from a snapshot request.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSnapshotResponseRawMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotResponseRaw;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the documents.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("documents")] public CultNetRawDocumentRecord[] Documents { get; set; } = Array.Empty<CultNetRawDocumentRecord>();
|
2026-05-19 21:07:46 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id represented by this snapshot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string? ShardId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard epoch represented by this snapshot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard-log sequence represented by this snapshot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardLogSequence")] public long? ShardLogSequence { get; set; }
|
2026-05-06 11:50:10 +01:00
|
|
|
}
|
|
|
|
|
|
2026-05-19 17:10:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Requests a live database subscription.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDatabaseSubscribeMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseSubscribe;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the live subscription id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional schema ids to watch.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaIds")] public string[]? SchemaIds { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional record keys to watch.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("recordKeys")] public string[]? RecordKeys { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets whether the server should send a matching snapshot before live changes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("includeSnapshot")] public bool IncludeSnapshot { get; set; } = true;
|
2026-07-19 03:17:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the stable consumer runtime identity used for subscription diagnostics and body-plane demand.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("consumerRuntimeId")] public string? ConsumerRuntimeId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets logical hot-body identities needed by this exact state subscription.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("bodyIds")] public string[]? BodyIds { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets body transports the consumer can open, ordered by consumer preference.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("supportedBodyTransports")] public string[]? SupportedBodyTransports { get; set; }
|
2026-05-19 17:10:24 +01:00
|
|
|
}
|
|
|
|
|
|
CultNet selection cut1, commit 1: the shape, the evaluator, v1 messages
docs/cultnet-selection-cut.md section 2/4/6/7/8: CultNetSelection (schemas,
keys, fields, cites, cited, projection, descending, limit, cursor) with its
door validation (S1), and CultNetSelectionEvaluator: the single-row Matches
fast path (D6) and the full Select (order, hop, cursor, paging). Neither
reflects over a document; both read only through the cache's public surface
(commit 0).
Three v1 messages beside v0 (cultnet.snapshot_request.v1,
cultnet.database_subscribe.v1, cultnet.snapshot_response_raw.v1), their
schema files under contracts/cultnet, registry entries and dispatch arms.
CultNetSchemaAliasMatching goes internal -> public (D4), the one alias
matcher. CultNetDatabase gains LastWriteSequence(schemaId, key), confirmed
at the one append site (AppendMutationLogEntry) that every committed write
takes a shard-log sequence, including a local PutAsync outside any shard.
Three engines deleted, one evaluator wired in their place:
- CultNetDocumentRegistry: CreateRawSnapshotResponse's reflection loop over
cache.AllEntries and MatchesRequestedSchema gone; cache.AllStoredDocuments
replaces the reflection entirely. v0 lowers into a Selection and walks the
evaluator's own pages so a v0 caller still sees its whole matching set
(D3: v0 has no engine of its own). CreateSelectionResponse/SelectPage/
ToRawRecord/CreateSnapshotRequestV1 added.
- CultNetDatabaseServer: CreateChangeMessage/CreateRawDocumentRecord/Matches/
MatchesSchema/InferSchemaName (122 lines) deleted; CreateSubscription lowers
v0 into a Selection and matches through the evaluator.
- CultNetDatabaseSubscriptionServer: CreateAuthorizedChange/CreateChange/
CreateChangeCore/ResolveWireSchemaId/MatchesRequestedSchema/CreateRawRecord
(92 lines) deleted, replaced by CreateMatchedRecord. _projectRecord and
CreateProjectedSnapshot's collapse are commit 2's, per the map's own
deletion line, and are untouched here.
Discrepancy found and fixed (not in the map): CultNetDocumentBinding can
carry a schema id different from its descriptor's own
(CultNetDocumentBinding.ForDocument's schemaId override), which the old
per-engine matchers checked and a descriptor-only evaluator cannot see by
design (it stays decoupled from CultNetDocumentRegistry). Fixed at the two
call sites and in CultNetDocumentRegistry.SelectPage by resolving the
binding's schema id into the effective selection before evaluation
(CultNetSchemaAliasMatching.WithBindingSchemaAlias,
CultNetDocumentRegistry.ExpandSchemaBindingAliases), not in the evaluator.
Found by DatabaseSubscription_FiltersLiveChangesByWireSchemaBinding timing
out; both call sites now pass.
Second discrepancy, reported not fixed: CultNetDatabase.cs:1707 has a fourth,
undocumented copy of schema-matching logic (MatchesRequestedSchema, private,
serving CreateShardSnapshotResponse), which the map's section 1 audit did not
name among "three separate selector engines". Left untouched this commit:
it is out of the map's explicit deletes list and touching it risks shard
snapshot behavior with no budgeted verification.
Verification: dotnet test tests/GameCult.Networking.Tests - 162 passed (150
existing + 12 new), 0 failed; the seven map-named tests all still pass, two
rewritten for the new signatures (CreateChangeMessage now takes
CultNetSelection; CreateChange/CreateAuthorizedChange collapsed into
CreateMatchedRecord, returning CultNetRawDocumentRecord? directly).
tests/GameCult.Mesh.Tests - 252 passed, 1 pre-existing skip, 0 failed (no
Mesh source touched this commit). tests/GameCult.Caching.Tests - unaffected
(188, unchanged from commit 0).
Negative greps: GetProperty|GetField|GetCustomAttribute in
GameCult.Networking - only against the generic `object change` dispatch
(CultNetDatabaseChange<T>) and CultRecordHandle<T> construction, pre-existing
and out of this cut's scope, never against a document's declared values.
_projectRecord survives in CultNetDatabaseSubscriptionServer.cs (expected,
commit 2). CultNetSchemaAliasMatching is the only schema matcher outside the
one reported discrepancy.
scripts/mutate-dotnet.ps1: the caching mutation runner generalized into a
shared dotnet/NUnit harness (Target/TestProject/Entries/ControlFilter),
replacing scripts/mutate-cultnet-selection-caching.ps1 with an entries file
of the same six mutations (re-verified: all six still KILL). It is now
generic to any NUnit project in this repo, not only this campaign's two
targets - a candidate to sit beside tools/eureka-mutations.ps1 as the
dotnet-side counterpart. Nine new networking entries (S3, S5 x2, S7 x2,
S16 x2, S18) all KILLED. Not yet mutation-run: S1, S2, S6, S23 (pinned by
tests, not by a committed mutant); S9-S15 (subscription reconcile lowering,
v0 no-engine-of-its-own); S17, S20 (pinned by tests only). S19/S21/S22 are
cache-layer, covered in commit 0.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 02:31:42 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message requesting a document snapshot through a typed selection (docs/cultnet-selection-cut.md).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSnapshotRequestV1Message : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the schema version.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotRequestV1;
|
|
|
|
|
/// <summary>Gets or sets the message id.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the selection.</summary>
|
|
|
|
|
[Key("selection")] public CultNetSelection Selection { get; set; } = new CultNetSelection();
|
|
|
|
|
/// <summary>Gets or sets the shard id requested for a shard-bounded snapshot.</summary>
|
|
|
|
|
[Key("shardId")] public string? ShardId { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the expected shard epoch.</summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Requests a live database subscription through a typed selection (docs/cultnet-selection-cut.md).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDatabaseSubscribeV1Message : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the schema version.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseSubscribeV1;
|
|
|
|
|
/// <summary>Gets or sets the request id.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the live subscription id.</summary>
|
|
|
|
|
[Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the selection.</summary>
|
|
|
|
|
[Key("selection")] public CultNetSelection Selection { get; set; } = new CultNetSelection();
|
|
|
|
|
/// <summary>Gets or sets whether the server should send a matching snapshot before live changes.</summary>
|
|
|
|
|
[Key("includeSnapshot")] public bool IncludeSnapshot { get; set; } = true;
|
|
|
|
|
/// <summary>Gets or sets the stable consumer runtime identity used for subscription diagnostics and body-plane demand.</summary>
|
|
|
|
|
[Key("consumerRuntimeId")] public string? ConsumerRuntimeId { get; set; }
|
|
|
|
|
/// <summary>Gets or sets logical hot-body identities needed by this exact state subscription.</summary>
|
|
|
|
|
[Key("bodyIds")] public string[]? BodyIds { get; set; }
|
|
|
|
|
/// <summary>Gets or sets body transports the consumer can open, ordered by consumer preference.</summary>
|
|
|
|
|
[Key("supportedBodyTransports")] public string[]? SupportedBodyTransports { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message returning a typed selection's page (docs/cultnet-selection-cut.md).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSnapshotResponseRawV1Message : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the schema version.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SnapshotResponseRawV1;
|
|
|
|
|
/// <summary>Gets or sets the message id.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the number of rows on this page.</summary>
|
|
|
|
|
[Key("matched")] public uint Matched { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the snapshot this page is exact as of.</summary>
|
|
|
|
|
[Key("asOf")] public ulong AsOf { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the cursor for the next page, absent on the last page.</summary>
|
|
|
|
|
[Key("next")] public string? Next { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the headers, present under header projection.</summary>
|
|
|
|
|
[Key("headers")] public CultNetRawDocumentHeader[]? Headers { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the documents, present under document projection.</summary>
|
|
|
|
|
[Key("documents")] public CultNetRawDocumentRecord[]? Documents { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the edges a hop-bearing selection traversed.</summary>
|
|
|
|
|
[Key("edges")] public CultNetEdge[]? Edges { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the shard id represented by this snapshot.</summary>
|
|
|
|
|
[Key("shardId")] public string? ShardId { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the shard epoch represented by this snapshot.</summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the shard-log sequence represented by this snapshot.</summary>
|
|
|
|
|
[Key("shardLogSequence")] public long? ShardLogSequence { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 17:10:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Cancels a live database subscription.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDatabaseUnsubscribeMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseUnsubscribe;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the live subscription id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Streams one raw document change for a live database subscription.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetDatabaseChangeRawMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.DatabaseChangeRaw;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the live subscription id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("subscriptionId")] public string SubscriptionId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the change kind.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("changeKind")] public string ChangeKind { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the current document for added or updated changes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("document")] public CultNetRawDocumentRecord? Document { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the deleted record key for removed changes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("recordKey")] public string? RecordKey { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the deleted schema id for removed changes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaId")] public string? SchemaId { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 17:34:49 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Describes one shard advertised by a CultNet database node.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardDescriptorMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string ShardId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the owner runtime id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("ownerRuntimeId")] public string OwnerRuntimeId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard authority epoch.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("epoch")] public long Epoch { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets whether the responding node is primary for this shard.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("isPrimary")] public bool IsPrimary { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets schema ids governed by this shard. Empty means all schemas.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaIds")] public string[] SchemaIds { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the record-key prefix governed by this shard.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("keyPrefix")] public string? KeyPrefix { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets endpoints that accept authoritative writes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("primaryEndpoints")] public string[] PrimaryEndpoints { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets authoritative replica endpoints.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("replicaEndpoints")] public string[] ReplicaEndpoints { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets low-latency read replica endpoints.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("readReplicaEndpoints")] public string[] ReadReplicaEndpoints { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets an optional locality label.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("region")] public string? Region { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Requests shard ownership and routing metadata.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardCatalogRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardCatalogRequest;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional schema filters.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaIds")] public string[]? SchemaIds { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional record-key filters.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("recordKeys")] public string[]? RecordKeys { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns shard ownership and routing metadata.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardCatalogResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardCatalogResponse;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets shard descriptors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shards")] public CultNetShardDescriptorMessage[] Shards { get; set; } = Array.Empty<CultNetShardDescriptorMessage>();
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 18:01:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Requests accepted mutation log entries for a shard.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardLogRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardLogRequest;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string ShardId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard epoch expected by the requester.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long? ShardEpoch { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the last sequence already held by the requester.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("afterSequence")] public long AfterSequence { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the maximum number of entries to return.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("limit")] public int? Limit { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns accepted mutation log entries for a shard.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardLogResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ShardLogResponse;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string ShardId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard epoch.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long ShardEpoch { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets mutation log entries.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("entries")] public CultNetShardLogEntryMessage[] Entries { get; set; } = Array.Empty<CultNetShardLogEntryMessage>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets whether the requester must fall back to a shard snapshot.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("resyncRequired")] public bool ResyncRequired { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a machine-readable resync reason.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("reason")] public string? Reason { get; set; }
|
2026-05-19 20:53:45 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the highest sequence compacted out of the retained log.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("compactedThrough")] public long? CompactedThrough { get; set; }
|
2026-05-19 18:01:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Describes one accepted shard mutation for replica catch-up.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetShardLogEntryMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the per-shard sequence.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("sequence")] public long Sequence { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the commit timestamp.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("committedAt")] public string CommittedAt { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the mutation kind.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("changeKind")] public string ChangeKind { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a raw put message for added/updated entries.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("put")] public CultNetDocumentPutRawMessage? Put { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a raw delete message for removed entries.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("delete")] public CultNetDocumentDeleteMessage? Delete { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 18:39:53 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Carries one witness observation about a simulation fact.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSimulationObservationMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SimulationObservation;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the observation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("observation")] public CultNetSimulationObservation Observation { get; set; } = new CultNetSimulationObservation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Carries one deterministic consensus candidate derived from witness observations.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSimulationConsensusCandidateMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SimulationConsensusCandidate;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardId")] public string ShardId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the shard epoch.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardEpoch")] public long ShardEpoch { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the simulation frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("frame")] public long Frame { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the subject id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("subjectId")] public string SubjectId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the claim kind.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("claimKind")] public string ClaimKind { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the selected claim hash.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("claimHash")] public string ClaimHash { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional claim detail.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("claimSummary")] public string? ClaimSummary { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets distinct supporting witnesses.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("witnessCount")] public int WitnessCount { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets supporting witness weight.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("supportWeight")] public double SupportWeight { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets total observed witness weight.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("totalWeight")] public double TotalWeight { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets whether the candidate crossed quorum.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("hasQuorum")] public bool HasQuorum { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets support divided by total observed weight.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("confidence")] public double Confidence { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a wire candidate message from a local candidate.
|
|
|
|
|
/// </summary>
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-18 17:21:58 +02:00
|
|
|
/// <summary>Requests an identity-bound CultMesh session before application traffic begins.</summary>
|
|
|
|
|
[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;
|
2026-08-18 19:02:46 +02:00
|
|
|
[Key("clientNonce")] public string ClientNonce { get; set; } = string.Empty;
|
2026-08-18 17:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Accepts or rejects a CultMesh session with the server's actual identity.</summary>
|
|
|
|
|
[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;
|
2026-08-18 19:02:46 +02:00
|
|
|
[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;
|
2026-08-18 17:21:58 +02:00
|
|
|
[Key("error")] public string? Error { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 21:23:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Requests known CultMesh Verses from a peer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshVerseCatalogRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.VerseCatalogRequest;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional Verse ids to request.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("verseIds")] public string[]? VerseIds { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets an optional transport compatibility filter.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("transportVersion")] public string? TransportVersion { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns known CultMesh Verses.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshVerseCatalogResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.VerseCatalogResponse;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets discovered Verses.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("verses")] public CultMeshVerseDescriptorMessage[] Verses { get; set; } = Array.Empty<CultMeshVerseDescriptorMessage>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Wire representation of a CultMesh Verse.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshVerseDescriptorMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the stable Verse id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("verseId")] public string VerseId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the display name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("displayName")] public string DisplayName { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the authority model name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("authorityModel")] public string AuthorityModel { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets compatibility metadata.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("compatibility")] public CultMeshVerseCompatibilityMessage Compatibility { get; set; } = new CultMeshVerseCompatibilityMessage();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets endpoints that can answer discovery for this Verse.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("discoveryEndpoints")] public string[] DiscoveryEndpoints { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets known authoritative runtime ids.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("authorityRuntimeIds")] public string[] AuthorityRuntimeIds { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
2026-08-18 17:21:58 +02:00
|
|
|
/// Gets or sets exact authoritative-runtime route bindings. This is the
|
|
|
|
|
/// routing authority; the parallel legacy arrays are projections only.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("authorityRoutes")] public CultMeshAuthorityRouteMessage[] AuthorityRoutes { get; set; } = Array.Empty<CultMeshAuthorityRouteMessage>();
|
|
|
|
|
/// <summary>
|
2026-05-19 21:23:11 +01:00
|
|
|
/// Gets or sets the parent Verse id for overlays or branches.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("parentVerseId")] public string? ParentVerseId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets an optional public description.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("description")] public string? Description { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-18 17:21:58 +02:00
|
|
|
/// <summary>Wire representation of one authority-bound CultMesh route.</summary>
|
|
|
|
|
[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<string>();
|
|
|
|
|
[Key("priority")] public int Priority { get; set; }
|
|
|
|
|
[Key("generation")] public string Generation { get; set; } = string.Empty;
|
2026-08-18 19:02:46 +02:00
|
|
|
[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;
|
2026-08-18 17:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-19 21:23:11 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Wire representation of CultMesh Verse compatibility.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshVerseCompatibilityMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the CultMesh transport compatibility version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("transportVersion")] public string TransportVersion { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the stable rules hash.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("rulesHash")] public string RulesHash { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets Verse ids this Verse can transfer from or subscribe to.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("compatibleVerseIds")] public string[] CompatibleVerseIds { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets required plugin ids.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("requiredPluginIds")] public string[] RequiredPluginIds { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional plugin ids.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("optionalPluginIds")] public string[] OptionalPluginIds { get; set; } = Array.Empty<string>();
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 01:35:39 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Requests known peers for a CultMesh Verse.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshPeerExchangeRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.PeerExchangeRequest;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the Verse id to discover peers for.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("verseId")] public string VerseId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets optional role filters.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("roles")] public string[]? Roles { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets peer ids the requester already knows.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("knownPeerIds")] public string[]? KnownPeerIds { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the maximum number of peer cards to return.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("limit")] public int? Limit { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns known peers for a CultMesh Verse.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshPeerExchangeResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.PeerExchangeResponse;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the request id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets peer cards.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("peers")] public CultMeshPeerCardMessage[] Peers { get; set; } = Array.Empty<CultMeshPeerCardMessage>();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-14 01:13:23 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Requests one bounded content-addressed chunk over a managed CultMesh content session.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshContentChunkRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the wire schema identity.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ContentChunkRequest;
|
|
|
|
|
/// <summary>Gets or sets the request correlation identity.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the canonical SHA-256 chunk identity.</summary>
|
|
|
|
|
[Key("chunkHash")] public string ChunkHash { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the optional canonical CultCache record key.</summary>
|
|
|
|
|
[Key("recordKey")] public string RecordKey { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the manifest-bound expected payload size.</summary>
|
|
|
|
|
[Key("expectedSizeBytes")] public int ExpectedSizeBytes { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns one bounded content-addressed chunk without publishing it as snapshot state.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshContentChunkResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Gets or sets the wire schema identity.</summary>
|
|
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.ContentChunkResponse;
|
|
|
|
|
/// <summary>Gets or sets the matching request correlation identity.</summary>
|
|
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets whether a validated chunk is present.</summary>
|
|
|
|
|
[Key("found")] public bool Found { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the canonical SHA-256 chunk identity.</summary>
|
|
|
|
|
[Key("chunkHash")] public string ChunkHash { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>Gets or sets the payload byte count.</summary>
|
|
|
|
|
[Key("sizeBytes")] public int SizeBytes { get; set; }
|
|
|
|
|
/// <summary>Gets or sets the bounded content payload.</summary>
|
|
|
|
|
[Key("payload")] public byte[] Payload { get; set; } = Array.Empty<byte>();
|
|
|
|
|
/// <summary>Gets or sets a typed-boundary failure description when the chunk is unavailable.</summary>
|
|
|
|
|
[Key("error")] public string Error { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-19 13:57:06 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Requests one immutable body generation from its capability owner. Body bytes travel on this
|
|
|
|
|
/// dedicated plane; they are never database snapshot records.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>Returns one bounded immutable body generation directly to its subscriber.</summary>
|
|
|
|
|
[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<byte>();
|
|
|
|
|
[Key("error")] public string Error { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 01:35:39 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Wire representation of a CultMesh peer candidate.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultMeshPeerCardMessage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the stable peer id.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("peerId")] public string PeerId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the Verse id this peer participates in.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("verseId")] public string VerseId { get; set; } = string.Empty;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets reachable endpoints.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("endpoints")] public string[] Endpoints { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets advertised peer roles.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("roles")] public string[] Roles { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets shard ids this peer can serve or observe.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("shardIds")] public string[] ShardIds { get; set; } = Array.Empty<string>();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets an optional region/locality label.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("region")] public string? Region { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the authority lease id, when the card advertises authority.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("authorityLeaseId")] public string? AuthorityLeaseId { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the expiry timestamp for this card.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("expiresAt")] public string? ExpiresAt { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets an optional signature over the card.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Key("signature")] public string? Signature { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Describes one schema exposed through the CultNet schema catalog.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSchemaDescriptor
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaId")] public string SchemaId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the kind.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("kind")] public string Kind { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string? SchemaVersion { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the document type.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("documentType")] public string? DocumentType { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the title.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("title")] public string? Title { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the wire contracts.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("wireContracts")] public string[] WireContracts { get; set; } = Array.Empty<string>();
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the content hash.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("contentHash")] public string ContentHash { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema json.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaJson")] public string? SchemaJson { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message requesting schema catalog entries.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSchemaCatalogRequestMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SchemaCatalogRequest;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the include schema json.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("includeSchemaJson")] public bool IncludeSchemaJson { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema ids.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaIds")] public string[]? SchemaIds { get; set; }
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the kinds.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("kinds")] public string[]? Kinds { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// CultNet message returning schema catalog entries.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class CultNetSchemaCatalogResponseMessage : ICultNetSchemaMessage
|
|
|
|
|
{
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schema version.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemaVersion")] public string SchemaVersion { get; set; } = CultNetSchemaVersions.SchemaCatalogResponse;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the message id.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("messageId")] public string MessageId { get; set; } = string.Empty;
|
2026-05-08 13:11:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the schemas.
|
|
|
|
|
/// </summary>
|
2026-05-06 11:50:10 +01:00
|
|
|
[Key("schemas")] public CultNetSchemaDescriptor[] Schemas { get; set; } = Array.Empty<CultNetSchemaDescriptor>();
|
|
|
|
|
}
|
|
|
|
|
}
|