Add M10.8b signed handoff tickets and ticket admission
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (client) (push) Successful in 12m40s
Foundation / checks (postgres) (push) Canceled after 4s
Foundation / checks (network) (push) Successful in 12m53s
Foundation / checks (tsan) (push) Successful in 7m55s
Foundation / checks (checks) (push) Successful in 31m47s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

ADR-0096. A source region's handoff key signs a 160-byte ticket for one probe
transfer, account and destination; it rides the Hello grant slot and is
verified against neighbour keys bound to their regions. SessionControl
admits a ticket once per region, superseding like a grant, with the session
ending at the client's original grant expiry. RegionSessions makes the
destination's durable step first: PostgresHandoffLedger stages and commits
the transfer and moves the account's control, idempotently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-06 18:32:14 -04:00
co-authored by Claude Opus 5.5
parent 6a645ef7e4
commit 0ce51077b1
18 changed files with 1039 additions and 19 deletions
@@ -0,0 +1,33 @@
#pragma once
#include "evo/network/handoff_ticket.hpp"
#include "evo/persistence/probe_store.hpp"
#include "evo/server/pg_slot.hpp"
#include <chrono>
#include <functional>
#include <optional>
#include <utility>
// M10.8b destination side of a ticket login over PostgreSQL (ADR-0096, schema v12). Linux
// only; owned by the region host's thread, on its own connection slot. For a verified ticket:
// stage its transfer under the host's current lease (again after a restart), commit it (the
// authority switch), then take the account's durable control for the session. Every step is
// idempotent, so a retried ticket login after an undecided outcome converges. A transfer that
// is unknown, aborted, for another account or another region is refused.
namespace evo::server {
class PostgresHandoffLedger final : public network::HandoffLedger {
public:
using LeaseSource = std::function<std::optional<persistence::LeaseGrant>()>;
PostgresHandoffLedger(PgSlot& db, persistence::RegionKey key, LeaseSource lease,
std::chrono::milliseconds duration = std::chrono::milliseconds{20000},
std::chrono::milliseconds timeout = std::chrono::milliseconds{2000})
: db_{&db}, key_{key}, lease_{std::move(lease)}, duration_{duration}, timeout_{timeout} {}
[[nodiscard]] std::expected<network::ControlLease, network::HandoffLedgerError>
admit(const network::TicketClaims& ticket, std::uint64_t session) override;
private:
PgSlot* db_;
persistence::RegionKey key_;
LeaseSource lease_;
std::chrono::milliseconds duration_, timeout_;
};
} // namespace evo::server
+16
View File
@@ -1,4 +1,5 @@
#pragma once
#include "evo/network/handoff_ticket.hpp"
#include "evo/network/intent_admission.hpp"
#include "evo/network/probe_motion.hpp"
#include "evo/network/quic_transport.hpp"
@@ -33,6 +34,10 @@
// M10.6 (ADR-0094, EXPERIMENT): once the host sets a motion area, every established session
// has a probe marker; admitted intentions schedule its movement, each poll advances markers
// to the simulated tick, and snapshots carry them. A new epoch starts without markers.
// M10.8b (ADR-0096): a Hello may carry a handoff ticket instead of a grant (same slot,
// another marker). A ticket verified against a neighbour's key for this region opens a
// session for its account after the HandoffLedger durably staged and committed its transfer
// and moved the account's control here.
// With a ControlLedger, control is durable and unique per world: a session that loses its
// durable control (another region accepted a newer grant) closes with `superseded`, and
// one whose control cannot be renewed in time closes with `shutdown`.
@@ -41,6 +46,12 @@ struct IssuerKey {
std::uint32_t key_id{};
network::GrantPublicKey public_key{};
};
// A neighbouring region's handoff public key (ADR-0096): tickets it signs are accepted here.
struct HandoffKey {
std::uint64_t source_region{};
std::uint32_t key_id{};
network::GrantPublicKey public_key{};
};
struct RegionSessionsConfig {
network::quic::ServerConfig transport;
network::ControlConfig control; // `epoch` is the initial ownership epoch.
@@ -57,6 +68,11 @@ struct RegionSessionsConfig {
// Durable action records (10.4b), owned by the host; null keeps outcomes in memory only.
network::ActionLedger* actions{};
network::ReplicationLimits replication{}; // max_sessions follows control.max_sessions.
// M10.8b handoff tickets (ADR-0096): neighbours' keys, and the durable side owned by the
// host. Without keys every ticket is refused (unauthenticated). With a ControlLedger a
// ticket also needs a HandoffLedger (control must move durably with the transfer).
std::vector<HandoffKey> handoff_keys;
network::HandoffLedger* handoff{};
};
// The region host's authority, read once per poll.
struct HostFacts {