#pragma once #include "evo/network/handoff_ticket.hpp" #include "evo/network/session_control.hpp" #include #include #include #include // M10.8c (ADR-0096): the region's durable probe records as the session layer uses them. // Transport-neutral; the host implements it over PostgreSQL (PostgresProbeLedger), tests use // fakes. EXPERIMENT: probes are non-biological engineering entities (ADR-0094). namespace evo::server { struct ProbeHome { std::uint64_t owner{}, generation{}; std::int64_t x{}, y{}; bool frozen{}; // An open transfer: neither this region nor the owner may act yet. }; struct IncomingProbe { network::TransferId transfer{}; std::int64_t x{}, y{}; }; enum class ProbeLedgerError : std::uint8_t { fenced, unavailable }; class ProbeLedger { public: ProbeLedger() = default; ProbeLedger(const ProbeLedger&) = delete; ProbeLedger& operator=(const ProbeLedger&) = delete; virtual ~ProbeLedger() = default; // The account's probe, created here at the position when the world has none. [[nodiscard]] virtual std::expected open(const network::AccountId& account, std::int64_t x, std::int64_t y, std::int64_t z) = 0; // Best effort: the owned, active probe's position (session end). virtual void save(const network::AccountId& account, std::uint64_t generation, std::int64_t x, std::int64_t y, std::int64_t z) = 0; // Freezes the probe at its final position for `destination`. [[nodiscard]] virtual std::expected prepare(const network::AccountId& account, std::uint64_t generation, const network::TransferId& transfer, std::uint64_t destination, std::int64_t x, std::int64_t y, std::int64_t z) = 0; // Abandons a transfer whose client never arrived: true when aborted (the probe is active // here again), false when it had been committed. [[nodiscard]] virtual std::expected abort(const network::TransferId& transfer) = 0; // Open transfers addressed to this region (shown as ghosts). [[nodiscard]] virtual std::expected, ProbeLedgerError> incoming() = 0; // M10.8d: this region's open outgoing transfers prepared more than `age` ago by the // store's clock, whoever prepared them (an earlier process too): recovery aborts them. [[nodiscard]] virtual std::expected, ProbeLedgerError> overdue(std::chrono::seconds age) = 0; protected: ProbeLedger(ProbeLedger&&) = default; ProbeLedger& operator=(ProbeLedger&&) = default; }; } // namespace evo::server