Add M10.8c-2 client handoff switch and evo-server handoff configuration
Foundation / checks (deploy) (push) Successful in 3m20s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (client) (push) Failing after 12m9s
Foundation / checks (network) (push) Successful in 13m2s
Foundation / checks (tsan) (push) Successful in 8m7s
Foundation / checks (checks) (push) Successful in 32m1s
Foundation / checks (postgres) (push) Successful in 42m43s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 3m20s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (client) (push) Failing after 12m9s
Foundation / checks (network) (push) Successful in 13m2s
Foundation / checks (tsan) (push) Successful in 8m7s
Foundation / checks (checks) (push) Successful in 32m1s
Foundation / checks (postgres) (push) Successful in 42m43s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
ADR-0096. The engineering client follows a HandoffOffer into the next region with its ticket (no grant, no pause, the view kept) and a Redirect to the probe's owner, picking grants by region claim in rising serial order. evo-server gains --m10-area, --m10-handoff-key and --m10-neighbour (dev only), wiring the PostgreSQL probe and handoff ledgers; the probe tool writes multi-region bundles and reports handoffs and redirects. Refreshes the dev session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+5
-96
@@ -8,6 +8,7 @@
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "evo/server/probe_ledger.hpp"
|
||||
#include "evo/server/region_sessions.hpp"
|
||||
#include "fixtures/fake_handoff_world.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
@@ -628,102 +629,10 @@ void ticket_login(const Files& f) {
|
||||
CHECK(a->state() == RegionSessionState::established && handoff.admitted.size() == 1);
|
||||
}
|
||||
|
||||
// M10.8c (ADR-0096): two regions with adjacent areas in one process, over a fake world
|
||||
// database with the same transfer state machine as schema v12.
|
||||
struct WorldDb {
|
||||
struct Probe {
|
||||
std::uint64_t owner{}, generation{};
|
||||
std::int64_t x{}, y{};
|
||||
std::optional<TransferId> transfer;
|
||||
};
|
||||
enum class State : std::uint8_t { prepared, committed, aborted };
|
||||
struct Transfer {
|
||||
AccountId account;
|
||||
std::uint64_t source{}, destination{}, generation{};
|
||||
std::int64_t x{}, y{};
|
||||
State state{};
|
||||
};
|
||||
std::map<AccountId, Probe> probes;
|
||||
std::map<TransferId, Transfer> transfers;
|
||||
};
|
||||
struct RegionDb final : server::ProbeLedger, HandoffLedger, ControlLedger {
|
||||
RegionDb(WorldDb& w, std::uint64_t r) : world{&w}, region{r} {}
|
||||
std::expected<server::ProbeHome, server::ProbeLedgerError>
|
||||
open(const AccountId& account, std::int64_t x, std::int64_t y, std::int64_t) override {
|
||||
auto [it, created] =
|
||||
world->probes.try_emplace(account, WorldDb::Probe{region, 1, x, y, std::nullopt});
|
||||
const auto& p = it->second;
|
||||
return server::ProbeHome{p.owner, p.generation, p.x, p.y, p.transfer.has_value()};
|
||||
}
|
||||
void save(const AccountId& account, std::uint64_t generation, std::int64_t x, std::int64_t y,
|
||||
std::int64_t) override {
|
||||
auto& p = world->probes.at(account);
|
||||
if (p.owner == region && p.generation == generation && !p.transfer) {
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
++saves;
|
||||
}
|
||||
}
|
||||
std::expected<void, server::ProbeLedgerError>
|
||||
prepare(const AccountId& account, std::uint64_t generation, const TransferId& transfer,
|
||||
std::uint64_t destination, std::int64_t x, std::int64_t y, std::int64_t) override {
|
||||
auto& p = world->probes.at(account);
|
||||
if (p.owner != region || p.generation != generation || p.transfer)
|
||||
return std::unexpected(server::ProbeLedgerError::unavailable);
|
||||
p.transfer = transfer;
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
world->transfers[transfer] = {
|
||||
account, region, destination, generation, x, y, WorldDb::State::prepared};
|
||||
return {};
|
||||
}
|
||||
std::expected<bool, server::ProbeLedgerError> abort(const TransferId& transfer) override {
|
||||
auto& t = world->transfers.at(transfer);
|
||||
if (t.state == WorldDb::State::prepared) {
|
||||
t.state = WorldDb::State::aborted;
|
||||
world->probes.at(t.account).transfer.reset();
|
||||
}
|
||||
return t.state == WorldDb::State::aborted;
|
||||
}
|
||||
std::expected<std::vector<server::IncomingProbe>, server::ProbeLedgerError>
|
||||
incoming() override {
|
||||
std::vector<server::IncomingProbe> out;
|
||||
for (const auto& [id, t] : world->transfers)
|
||||
if (t.destination == region && t.state == WorldDb::State::prepared)
|
||||
out.push_back({id, t.x, t.y});
|
||||
return out;
|
||||
}
|
||||
std::expected<HandoffAdmission, HandoffLedgerError> admit(const TicketClaims& ticket,
|
||||
std::uint64_t) override {
|
||||
const auto found = world->transfers.find(ticket.transfer);
|
||||
if (found == world->transfers.end() || found->second.destination != region ||
|
||||
found->second.account != ticket.account ||
|
||||
found->second.state == WorldDb::State::aborted)
|
||||
return std::unexpected(HandoffLedgerError::refused);
|
||||
auto& t = found->second;
|
||||
auto& p = world->probes.at(t.account);
|
||||
if (t.state == WorldDb::State::prepared) { // Stage and commit: the switch.
|
||||
t.state = WorldDb::State::committed;
|
||||
p = {region, t.generation + 1, t.x, t.y, std::nullopt};
|
||||
}
|
||||
return HandoffAdmission{ControlLease{++control, {}, std::chrono::milliseconds{20000}},
|
||||
p.generation, p.x, p.y};
|
||||
}
|
||||
std::expected<ControlLease, ControlLedgerError> claim(const AccountId&, std::uint64_t,
|
||||
std::uint64_t) override {
|
||||
return ControlLease{++control, {}, std::chrono::milliseconds{20000}};
|
||||
}
|
||||
std::expected<std::chrono::milliseconds, ControlLedgerError> renew(const AccountId&,
|
||||
std::uint64_t) override {
|
||||
return std::chrono::milliseconds{20000};
|
||||
}
|
||||
void release(const AccountId&, std::uint64_t) override {
|
||||
++releases;
|
||||
}
|
||||
WorldDb* world;
|
||||
std::uint64_t region;
|
||||
std::uint64_t control{}, saves{}, releases{};
|
||||
};
|
||||
// M10.8c (ADR-0096): two regions with adjacent areas in one process, over the fake world
|
||||
// database of tests/fixtures/fake_handoff_world.hpp.
|
||||
using evo::test::RegionDb;
|
||||
using evo::test::WorldDb;
|
||||
constexpr std::int64_t m_um = 1'000'000; // One metre (one cell) in micrometres.
|
||||
// Region `id` owns x in [x0, x0 + 10 m), y in [0, 10 m) of slice 0.
|
||||
network::motion::Area area_of(std::int64_t x0) {
|
||||
|
||||
Reference in New Issue
Block a user