Add M10.5a session protocol v2 and snapshot replication core
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 1m58s
Foundation / checks (client) (push) Failing after 9m57s
Foundation / checks (network) (push) Successful in 11m17s
Foundation / checks (tsan) (push) Successful in 7m49s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 25m43s
Foundation / checks (postgres) (push) Canceled after 15m44s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 1m58s
Foundation / checks (client) (push) Failing after 9m57s
Foundation / checks (network) (push) Successful in 11m17s
Foundation / checks (tsan) (push) Successful in 7m49s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 25m43s
Foundation / checks (postgres) (push) Canceled after 15m44s
Session protocol v2 adds Interest, SnapshotChunk and SnapshotAck (v1 is refused). ReplicationServer filters by a server-capped client focus and a perception predicate, sends per-tick entity deltas against the acknowledged baseline (kept up to 40 ticks), nearest first within 16 KiB with a slower distant tier, as self-contained datagram chunks. SnapshotAssembler applies complete snapshots to one of two baselines and validates them as presentations. ADR-0093. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,10 @@
|
||||
// 160-byte credentials here. Later M10 segments add message types under a new version.
|
||||
namespace evo::network {
|
||||
inline constexpr std::uint32_t session_magic = 0x4E535645; // Bytes "EVSN".
|
||||
inline constexpr std::uint16_t session_protocol_version = 1;
|
||||
// v2 (M10.5, ADR-0093): v1 plus interest, snapshot chunks and snapshot acks. v1 is frozen
|
||||
// and no longer accepted (it was only ever deployed to evolution-dev, with the probe).
|
||||
inline constexpr std::uint16_t session_protocol_version = 2;
|
||||
inline constexpr std::size_t session_datagram_bytes = 1200; // Whole message, ADR-0089.
|
||||
inline constexpr std::size_t session_header_bytes = 8;
|
||||
inline constexpr std::size_t session_grant_wire_bytes = 160;
|
||||
|
||||
@@ -32,7 +35,10 @@ enum class SessionMessageType : std::uint8_t {
|
||||
action, // Client -> server, stream: discrete action with a stable id.
|
||||
action_receipt, // Server -> client, stream.
|
||||
action_outcome, // Server -> client, stream: final.
|
||||
action_query // Client -> server, stream: resolve an action by id.
|
||||
action_query, // Client -> server, stream: resolve an action by id.
|
||||
interest, // Client -> server, stream: spatial focus (v2).
|
||||
snapshot_chunk, // Server -> client, datagram: part of one snapshot (v2).
|
||||
snapshot_ack // Client -> server, datagram: newest complete snapshot (v2).
|
||||
};
|
||||
// Admission answers for intentions and actions (wire 0..10).
|
||||
enum class AdmitStatus : std::uint8_t {
|
||||
@@ -151,10 +157,36 @@ struct ActionQuery {
|
||||
std::uint64_t action_id{};
|
||||
friend bool operator==(const ActionQuery&, const ActionQuery&) = default;
|
||||
};
|
||||
// The client's spatial focus: one Z slice, a centre and a radius in cells. The server
|
||||
// clamps the radius to its maximum and filters authoritatively (ADR-0093).
|
||||
struct SessionInterest {
|
||||
std::int64_t x{}, y{}, z{};
|
||||
std::uint16_t radius{};
|
||||
friend bool operator==(const SessionInterest&, const SessionInterest&) = default;
|
||||
};
|
||||
// One self-contained part of snapshot `tick`, a delta against snapshot `baseline` (0: a
|
||||
// fresh baseline). `records` are whole entity records (replication.hpp); the snapshot is
|
||||
// complete when all `count` chunks arrived.
|
||||
struct SnapshotChunk {
|
||||
std::uint64_t epoch{}, tick{}, baseline{}, field_revision{}, organism_revision{};
|
||||
std::uint32_t mask{};
|
||||
std::int64_t slice_z{};
|
||||
std::uint8_t index{}, count{};
|
||||
std::vector<std::uint8_t> records;
|
||||
friend bool operator==(const SnapshotChunk&, const SnapshotChunk&) = default;
|
||||
};
|
||||
inline constexpr std::size_t snapshot_chunk_header_bytes = (5 * 8) + 4 + 8 + 2;
|
||||
inline constexpr std::size_t max_snapshot_records_bytes =
|
||||
session_datagram_bytes - session_header_bytes - snapshot_chunk_header_bytes;
|
||||
// The newest snapshot the client assembled completely and applied.
|
||||
struct SnapshotAck {
|
||||
std::uint64_t epoch{}, tick{};
|
||||
friend bool operator==(const SnapshotAck&, const SnapshotAck&) = default;
|
||||
};
|
||||
using SessionMessage =
|
||||
std::variant<SessionHello, SessionWelcome, SessionRefresh, SessionRefreshResult, SessionClose,
|
||||
SessionIntention, IntentionReceipt, SimulatedThrough, SessionAction, ActionReceipt,
|
||||
ActionOutcome, ActionQuery>;
|
||||
ActionOutcome, ActionQuery, SessionInterest, SnapshotChunk, SnapshotAck>;
|
||||
|
||||
[[nodiscard]] std::vector<std::uint8_t> encode_session(const SessionMessage& message);
|
||||
// Exactly one message; any other length for its type rejects.
|
||||
|
||||
Reference in New Issue
Block a user