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

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:
dingo
2026-10-06 10:47:47 -04:00
co-authored by Claude Opus 5.5
parent e640b6d3a3
commit 33e91458e7
15 changed files with 428 additions and 23 deletions
+64 -4
View File
@@ -7,6 +7,8 @@
// scheduled for upcoming ticks are submitted to the host, which commits them with the batch
// of the tick they ride; the host's action acknowledgements and drops become outcomes.
// Session control and action records use their own connection under the host's lease.
// M10.5 (ADR-0093): once per simulated tick every session's snapshot is built from the
// region's own stores for its interest (default: the region's first habitat site, radius 7).
#include "evo/persistence/postgres.hpp"
#include "evo/persistence/region_lease.hpp"
#include <cstdint>
@@ -14,6 +16,8 @@
#include <string>
#ifdef EVO_SERVER_M10
#include "evo/client/environment_view.hpp"
#include "evo/processes/lineage_region.hpp"
#include "evo/server/pg_slot.hpp"
#include "evo/server/postgres_action_ledger.hpp"
#include "evo/server/postgres_control_ledger.hpp"
@@ -61,9 +65,9 @@ template <typename Host> class M10Bridge {
if (!window)
return fail(window.error() == server::SessionWindow::Error::expired
? "error m10-window-expired"
: window.error() == server::SessionWindow::Error::too_long
? "error m10-window-too-long"
: "error m10-window");
: window.error() == server::SessionWindow::Error::too_long
? "error m10-window-too-long"
: "error m10-window");
const auto colon = o.listen.rfind(':');
std::uint16_t port = 0;
if (colon == std::string::npos ||
@@ -129,6 +133,19 @@ template <typename Host> class M10Bridge {
const server::HostFacts facts{s.ready && s.phase == server::HostPhase::running, s.epoch,
s.simulated_tick};
sessions_->poll(facts, wall_seconds(), std::chrono::steady_clock::now());
if (facts.ready && host.state() != nullptr && s.simulated_tick > replicated_) {
replicated_ = s.simulated_tick;
const auto& c = community(*host.state());
if (!default_interest_)
if (const auto& sites = c.resources().fields().sites(); !sites.empty()) {
const auto v = sites.front().voxel;
default_interest_ = network::SessionInterest{v.x, v.y, v.z, 7};
sessions_->set_default_interest(*default_interest_);
}
sessions_->replicate(s.simulated_tick, [&](const network::SessionInterest& in) {
return source(c, in, s.simulated_tick);
});
}
if (facts.ready)
for (const auto& a : sessions_->carry(s.simulated_tick + m10_carry_ahead_ticks)) {
const persistence::ActionRecord record{a.account.bytes, a.action_id, a.tick,
@@ -164,6 +181,44 @@ template <typename Host> class M10Bridge {
}
private:
static const processes::EnvironmentalCommunity&
community(const processes::EnvironmentalCommunity& c) {
return c;
}
static const processes::EnvironmentalCommunity& community(const processes::LineageRegion& r) {
return r.community();
}
// A read-only copy of the region's stores within one interest: the habitat sites of its
// square in its slice. The region has no placed individuals: organisms stay empty.
network::ReplicationSource source(const processes::EnvironmentalCommunity& c,
const network::SessionInterest& in, std::uint64_t tick) {
network::ReplicationSource src;
src.mask = world::all_environment_fields;
const auto& fields = c.resources().fields();
std::vector<world::VoxelAddress> footprint;
for (const auto& site : fields.sites()) {
const auto v = site.voxel;
if (v.z == in.z && v.x >= in.x - in.radius && v.x <= in.x + in.radius &&
v.y >= in.y - in.radius && v.y <= in.y + in.radius &&
footprint.size() < world::max_environment_footprint)
footprint.push_back(v);
}
if (footprint.empty())
return src;
const auto view = world::query_environment(fields, c.resources().terrain(), tick, footprint,
world::all_environment_fields);
if (!view) {
if (!warned_)
std::printf("m10 view-unavailable %u\n", static_cast<unsigned>(view.error()));
warned_ = true;
return src;
}
src.identity = view->identity();
src.field_revision = view->field_revision();
if (const auto cells = client::present_environment(*view, in.z))
src.environment.assign(cells->cells().begin(), cells->cells().end());
return src;
}
static network::CarriedAction carried(const persistence::ActionRecord& r) {
network::CarriedAction a;
a.account.bytes = r.account;
@@ -193,6 +248,9 @@ template <typename Host> class M10Bridge {
std::unique_ptr<server::RegionSessions> sessions_; // Destroyed first: uses the ledgers.
std::optional<server::SessionWindow> window_;
bool window_closed_{};
std::uint64_t replicated_{};
std::optional<network::SessionInterest> default_interest_;
bool warned_{};
};
#else
inline constexpr bool m10_available = false;
@@ -205,7 +263,9 @@ template <typename Host> class M10Bridge {
[[nodiscard]] bool enabled() const noexcept {
return false;
}
[[nodiscard]] bool accepting(std::uint64_t) const noexcept { return false; }
[[nodiscard]] bool accepting(std::uint64_t) const noexcept {
return false;
}
void after_step() {}
void shutdown() {}
};