Wire M10.8c-1 region handoff: protocol v4, durable probes, crossing, ghosts
Foundation / checks (deploy) (push) Successful in 3m29s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (client) (push) Successful in 12m51s
Foundation / checks (network) (push) Successful in 13m0s
Foundation / checks (tsan) (push) Successful in 7m50s
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 32m4s
Foundation / checks (postgres) (push) Canceled after 19m13s

ADR-0096. Session protocol v4 (v3 is deployed and frozen) adds HandoffOffer,
SessionRedirect, close reasons handed_off and moved, and ghost marker records.
Sessions use the durable probe record: logins open it where it was saved
(redirected when it lives elsewhere), and session ends save it. A marker
crossing into a neighbour's area is frozen, prepared, its control released
and a signed ticket offered; uncommitted transfers are aborted after the
ticket's lifetime. The destination shows arriving probes as ghosts (schema
v13 incoming_probe_transfers) and opens the marker where it crossed.

Refreshes the dev session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-06 21:24:42 -04:00
co-authored by Claude Opus 5.5
parent 97a3756e46
commit a7a3d12283
39 changed files with 1315 additions and 68 deletions
+34 -5
View File
@@ -4,6 +4,7 @@
#include <cstdint>
#include <expected>
#include <span>
#include <string>
#include <variant>
#include <vector>
@@ -17,9 +18,12 @@
namespace evo::network {
inline constexpr std::uint32_t session_magic = 0x4E535645; // Bytes "EVSN".
// v2 (M10.5, ADR-0093): v1 plus interest, snapshot chunks and snapshot acks.
// v3 (M10.6, ADR-0094): v2 plus probe marker records inside snapshot chunks; no new message
// types. v1 and v2 were deployed to evolution-dev and are frozen; only v3 is accepted.
inline constexpr std::uint16_t session_protocol_version = 3;
// v3 (M10.6, ADR-0094): v2 plus probe marker records inside snapshot chunks.
// v4 (M10.8c, ADR-0096): v3 plus HandoffOffer and SessionRedirect (stream), close reasons
// handed_off and moved, and ghost marker records. v1-v3 were deployed to evolution-dev and
// are frozen; only v4 is accepted.
inline constexpr std::uint16_t session_protocol_version = 4;
inline constexpr std::size_t session_address_bytes = 64; // Endpoint or server name field.
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;
@@ -39,7 +43,9 @@ enum class SessionMessageType : std::uint8_t {
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).
snapshot_ack, // Client -> server, datagram: newest complete snapshot (v2).
handoff_offer, // Server -> client, stream: continue at another region (v4).
redirect // Server -> client, stream: the account's probe is elsewhere (v4).
};
// Admission answers for intentions and actions (wire 0..10).
enum class AdmitStatus : std::uint8_t {
@@ -80,6 +86,8 @@ enum class SessionCloseReason : std::uint8_t {
timeout, // No Hello before the deadline.
unsupported_version,
shutdown,
handed_off, // v4: the probe crossed to another region; a HandoffOffer preceded this.
moved, // v4: the account's probe is owned by another region (a Redirect may precede).
connection_lost = 255
};
enum class SessionCodecError : std::uint8_t {
@@ -184,10 +192,31 @@ struct SnapshotAck {
std::uint64_t epoch{}, tick{};
friend bool operator==(const SnapshotAck&, const SnapshotAck&) = default;
};
// A region's public address as a client dials it: "host:port" and the certificate name,
// printable ASCII (no spaces), 1-64 characters each.
struct RegionAddress {
std::uint64_t region{};
std::string endpoint, server_name;
friend bool operator==(const RegionAddress&, const RegionAddress&) = default;
};
// v4 (ADR-0096): the session's probe crossed into `destination`; log in there with `ticket`
// (a handoff ticket, used in Hello's grant slot). The source then closes with handed_off.
struct HandoffOffer {
std::array<std::uint8_t, 16> transfer{};
RegionAddress destination;
WireGrant ticket{};
friend bool operator==(const HandoffOffer&, const HandoffOffer&) = default;
};
// v4: at login, the account's probe is owned by `owner`; log in there with a grant for it.
struct SessionRedirect {
RegionAddress owner;
friend bool operator==(const SessionRedirect&, const SessionRedirect&) = default;
};
using SessionMessage =
std::variant<SessionHello, SessionWelcome, SessionRefresh, SessionRefreshResult, SessionClose,
SessionIntention, IntentionReceipt, SimulatedThrough, SessionAction, ActionReceipt,
ActionOutcome, ActionQuery, SessionInterest, SnapshotChunk, SnapshotAck>;
ActionOutcome, ActionQuery, SessionInterest, SnapshotChunk, SnapshotAck,
HandoffOffer, SessionRedirect>;
[[nodiscard]] std::vector<std::uint8_t> encode_session(const SessionMessage& message);
// Exactly one message; any other length for its type rejects.