Add CultMesh peer exchange catalogs

This commit is contained in:
Meta Vens 2026-05-20 01:35:39 +01:00
commit c612eb4307
10 changed files with 718 additions and 1 deletions

View file

@ -71,6 +71,8 @@ Implemented:
`.cultmesh/shard-logs` path beside the cache file
- schema-v0 Verse catalog request/response messages
- CultMesh Verse discovery server bridge over the local Verse catalog
- schema-v0 peer exchange request/response messages
- CultMesh peer cards, peer catalog, and peer exchange server bridge
- client-authority scopes for locally predicted input documents
- predicted and reconciled database change kinds for client-side prediction
- simulation witness observations for mesh-side opinions about frame facts
@ -118,12 +120,14 @@ Not implemented yet:
- Consensus candidates are derived from observations. They may inform the
authoritative commit path, but they are not themselves committed world state
until a shard owner writes them into the log.
- Peer cards are contact candidates. They can advertise roles and authority
lease ids, but they do not grant authority without Verse-specific validation.
## Next Coherent Slice
Add discovery fanout and operational polish:
- add peer-to-peer Verse discovery fetchers and gossip fanout
- add peer exchange clients and periodic gossip fanout
- add snapshot throttling and size limits for public mesh edges
- after that, add simulation-frame rollback/resimulation helpers around
predicted input streams

View file

@ -70,6 +70,8 @@ namespace GameCult.Networking
CultNetSchemaVersions.SimulationConsensusCandidate => Deserialize<CultNetSimulationConsensusCandidateMessage>(payload),
CultNetSchemaVersions.VerseCatalogRequest => Deserialize<CultMeshVerseCatalogRequestMessage>(payload),
CultNetSchemaVersions.VerseCatalogResponse => Deserialize<CultMeshVerseCatalogResponseMessage>(payload),
CultNetSchemaVersions.PeerExchangeRequest => Deserialize<CultMeshPeerExchangeRequestMessage>(payload),
CultNetSchemaVersions.PeerExchangeResponse => Deserialize<CultMeshPeerExchangeResponseMessage>(payload),
CultNetSchemaVersions.SchemaCatalogRequest => Deserialize<CultNetSchemaCatalogRequestMessage>(payload),
CultNetSchemaVersions.SchemaCatalogResponse => Deserialize<CultNetSchemaCatalogResponseMessage>(payload),
_ => throw new MessagePackSerializationException(

View file

@ -123,6 +123,14 @@ namespace GameCult.Networking
/// CultMesh Verse catalog response contract identifier.
/// </summary>
public const string VerseCatalogResponse = "cultmesh.verse_catalog_response.v0";
/// <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";
}
/// <summary>
@ -1077,6 +1085,102 @@ namespace GameCult.Networking
[Key("optionalPluginIds")] public string[] OptionalPluginIds { get; set; } = Array.Empty<string>();
}
/// <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>();
}
/// <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; }
}
/// <summary>
/// Describes one schema exposed through the CultNet schema catalog.
/// </summary>