Add M10.5b snapshot wiring: sessions, evo-server, client and probe
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m54s
Foundation / checks (client) (push) Successful in 12m40s
Foundation / checks (network) (push) Successful in 11m27s
Foundation / checks (tsan) (push) Successful in 8m6s
Foundation / checks (checks) (push) Successful in 31m54s
Foundation / checks (postgres) (push) Successful in 40m43s
Foundation / server-image (push) Successful in 25s
Foundation / postgres-tools (push) Successful in 1m2s
Foundation / image (push) Successful in 2m32s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m54s
Foundation / checks (client) (push) Successful in 12m40s
Foundation / checks (network) (push) Successful in 11m27s
Foundation / checks (tsan) (push) Successful in 8m6s
Foundation / checks (checks) (push) Successful in 31m54s
Foundation / checks (postgres) (push) Successful in 40m43s
Foundation / server-image (push) Successful in 25s
Foundation / postgres-tools (push) Successful in 1m2s
Foundation / image (push) Successful in 2m32s
RegionSessions owns the replication server: interest and acks per session, a host-set default interest, and per-tick snapshots sized to each connection's datagram limit. evo-server builds each interest's view from the region's own habitat sites (default: the first site, radius 7). RegionSessionClient assembles, acknowledges and presents snapshots and can change its interest; the probe prints them. Loopback and real-process evidence. ADR-0093. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,10 @@ struct Harness {
|
||||
}
|
||||
void pump() {
|
||||
server->poll({ready, epoch, tick}, now_seconds, Clock::now());
|
||||
if (source && tick != replicated) { // One snapshot per simulated tick (ADR-0093).
|
||||
replicated = tick;
|
||||
server->replicate(tick, source);
|
||||
}
|
||||
for (auto& e : server->take_events())
|
||||
events.push_back(std::move(e));
|
||||
for (auto* c : clients)
|
||||
@@ -191,6 +195,8 @@ struct Harness {
|
||||
std::vector<RegionSessionEvent> events;
|
||||
std::uint64_t epoch{5}, now_seconds{start}, tick{100};
|
||||
bool ready{true};
|
||||
std::function<ReplicationSource(const SessionInterest&)> source;
|
||||
std::uint64_t replicated{};
|
||||
};
|
||||
|
||||
bool refused_with(Harness& h, const WireGrant& grant, Reason reason) {
|
||||
@@ -471,6 +477,75 @@ void intentions_and_actions(const Files& f) {
|
||||
CHECK(welcome && reason == Reason::protocol);
|
||||
}
|
||||
|
||||
// M10.5: snapshots over QUIC from a simulated host's 21 x 21 slice.
|
||||
client::EnvironmentCell grid_cell(std::int64_t x, std::int64_t y, std::uint64_t quantity) {
|
||||
client::EnvironmentCell c;
|
||||
c.voxel = {x, y, -7};
|
||||
c.chunk_revision = 40;
|
||||
c.habitat = {{100}, {200}, {0}, {1000}, {500}, {10}};
|
||||
c.volume = {1000ULL * 500 * 10};
|
||||
c.substrate = {1};
|
||||
c.terrain_material = {2};
|
||||
c.terrain_fill = 1000;
|
||||
c.presence[0] = client::FieldPresence::present;
|
||||
c.quantity[0] = quantity;
|
||||
c.presence[1] = client::FieldPresence::missing;
|
||||
c.presence[7] = client::FieldPresence::present;
|
||||
c.quantity[7] = 5;
|
||||
c.moisture_status = world::MoistureStatus::available;
|
||||
c.moisture = {3, 50};
|
||||
return c;
|
||||
}
|
||||
|
||||
void snapshots_over_quic(const Files& f) {
|
||||
Harness h{f};
|
||||
std::uint64_t quantity = 30;
|
||||
h.source = [&](const SessionInterest&) {
|
||||
ReplicationSource s;
|
||||
s.identity = world_id;
|
||||
s.field_revision = h.tick;
|
||||
s.mask = (1U << 0) | (1U << 1) | (1U << 7); // Water requested: moisture is present.
|
||||
for (std::int64_t x = -10; x <= 10; ++x)
|
||||
for (std::int64_t y = -10; y <= 10; ++y)
|
||||
s.environment.push_back(grid_cell(x, y, quantity));
|
||||
return s;
|
||||
};
|
||||
h.server->set_default_interest({0, 0, -7, 30}); // Clamped to radius 7.
|
||||
auto a = h.connect(h.issuer.grant(account(1), 1));
|
||||
CHECK(h.settled(*a) && a->state() == RegionSessionState::established);
|
||||
const auto ticks_until = [&](const std::function<bool()>& done) {
|
||||
for (int i = 0; i < 400 && !done(); ++i) {
|
||||
++h.tick;
|
||||
h.until(done, std::chrono::milliseconds{20});
|
||||
}
|
||||
return done();
|
||||
};
|
||||
// The default interest's 225 cells arrive within the per-tick budget.
|
||||
CHECK(ticks_until([&] { return a->view() && a->view()->environment.size() == 225; }));
|
||||
const auto env = a->environment();
|
||||
CHECK(env && env->cells().size() == 225 && env->revision().identity == world_id);
|
||||
CHECK(std::ranges::all_of(env->cells(), [](const auto& c) {
|
||||
return c.voxel.x >= -7 && c.voxel.x <= 7 && c.voxel.y >= -7 && c.voxel.y <= 7;
|
||||
}));
|
||||
CHECK(a->snapshot_chunks() > 0 && a->snapshot_bytes() > std::uint64_t{225} * 50);
|
||||
// A change reaches the client; acknowledgements keep deltas small.
|
||||
quantity = 31;
|
||||
CHECK(ticks_until([&] {
|
||||
return a->view() && std::ranges::all_of(a->view()->environment,
|
||||
[](const auto& c) { return c.quantity[0] == 31; });
|
||||
}));
|
||||
const auto stats = h.server->replication_stats();
|
||||
CHECK(stats.snapshots > 2 && stats.fresh_baselines < stats.snapshots);
|
||||
// Another interest: only the new square.
|
||||
CHECK(a->set_interest({5, 5, -7, 2}));
|
||||
CHECK(ticks_until([&] { return a->view() && a->view()->environment.size() == 25; }));
|
||||
CHECK(std::ranges::all_of(a->view()->environment, [](const auto& c) {
|
||||
return c.voxel.x >= 3 && c.voxel.x <= 7 && c.voxel.y >= 3 && c.voxel.y <= 7;
|
||||
}));
|
||||
// A snapshot ack datagram is accepted (not a protocol error); the session stays open.
|
||||
CHECK(a->state() == RegionSessionState::established);
|
||||
}
|
||||
|
||||
void durable_control(const Files& f) {
|
||||
FakeLedger ledger;
|
||||
Harness h{f, 4, 64, &ledger};
|
||||
@@ -546,6 +621,7 @@ int main() try {
|
||||
limits(files);
|
||||
durable_control(files);
|
||||
intentions_and_actions(files);
|
||||
snapshots_over_quic(files);
|
||||
std::filesystem::remove_all(files.dir);
|
||||
std::puts("quic session tests passed");
|
||||
return 0;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "evo/network/dev_credentials.hpp"
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "fixtures/server_process.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <fcntl.h>
|
||||
#include <functional>
|
||||
@@ -219,6 +220,25 @@ void end_to_end() {
|
||||
auto server = std::make_unique<Server>(s);
|
||||
auto a = connect(s, *server, s.grant(alice, 1));
|
||||
CHECK(established(*server, *a));
|
||||
// Snapshots of the real region (ADR-0093): the default interest is the first habitat
|
||||
// site with radius 7; every cell lies in one slice and one 15 x 15 square.
|
||||
const auto first_tick = a->server_tick();
|
||||
CHECK(until(*server, *a, [&] { return a->view() && !a->view()->environment.empty(); }));
|
||||
const auto shown = a->environment();
|
||||
CHECK(shown && !shown->cells().empty() && shown->cells().size() <= 225);
|
||||
const auto [min_x, max_x] =
|
||||
std::ranges::minmax(shown->cells(), {}, [](const auto& c) { return c.voxel.x; });
|
||||
const auto [min_y, max_y] =
|
||||
std::ranges::minmax(shown->cells(), {}, [](const auto& c) { return c.voxel.y; });
|
||||
CHECK(max_x.voxel.x - min_x.voxel.x <= 14 && max_y.voxel.y - min_y.voxel.y <= 14);
|
||||
CHECK(std::ranges::all_of(shown->cells(),
|
||||
[&](const auto& c) { return c.voxel.z == shown->slice_z(); }));
|
||||
CHECK(until(*server, *a, [&] { return a->server_tick() >= first_tick + 40; }));
|
||||
std::printf("m10 snapshot report cells=%zu ticks=%llu chunks=%llu bytes=%llu\n",
|
||||
shown->cells().size(),
|
||||
static_cast<unsigned long long>(a->server_tick() - first_tick),
|
||||
static_cast<unsigned long long>(a->snapshot_chunks()),
|
||||
static_cast<unsigned long long>(a->snapshot_bytes()));
|
||||
// Intentions: receipts, then the watermark.
|
||||
// Datagrams may be refused until the QUIC datagram extension is negotiated: retry.
|
||||
std::optional<std::uint64_t> sequence;
|
||||
@@ -298,7 +318,8 @@ void end_to_end() {
|
||||
"--intents", "3",
|
||||
"--actions", "2",
|
||||
"--action-base", "10",
|
||||
"--query", "10"}};
|
||||
"--query", "10",
|
||||
"--snapshots", "3"}};
|
||||
int code = -1;
|
||||
for (const auto end = Clock::now() + 30s; Clock::now() < end && code < 0;) {
|
||||
server->pump();
|
||||
@@ -307,7 +328,8 @@ void end_to_end() {
|
||||
code = p.wait_exit(10s);
|
||||
}
|
||||
CHECK(code == 0 && p.printed("welcome ") && p.printed("intention 1 0") &&
|
||||
p.printed("outcome 10 1 ") && p.printed("outcome 11 1 "));
|
||||
p.printed("outcome 10 1 ") && p.printed("outcome 11 1 ") && p.printed("snapshot ") &&
|
||||
p.printed("snapshot-bytes "));
|
||||
CHECK(!record(bob, 10).empty() && !record(bob, 11).empty());
|
||||
server->child->signal(SIGTERM);
|
||||
CHECK(server->child->wait_exit(30s) == 0);
|
||||
|
||||
Reference in New Issue
Block a user