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:
@@ -23,6 +23,8 @@ struct RegionSessionClient::Impl {
|
||||
std::vector<network::IntentionReceipt> intention_receipts;
|
||||
std::vector<network::ActionReceipt> action_receipts;
|
||||
std::vector<network::ActionOutcome> action_outcomes;
|
||||
std::optional<network::SnapshotAssembler> snapshots;
|
||||
std::uint64_t snapshot_chunks{}, snapshot_bytes{};
|
||||
static constexpr std::size_t max_kept = 1024; // Per kind, until taken; oldest dropped.
|
||||
|
||||
template <typename T> static void keep(std::vector<T>& list, const T& item) {
|
||||
@@ -44,6 +46,21 @@ struct RegionSessionClient::Impl {
|
||||
seen_tick(m->server_tick);
|
||||
return keep(intention_receipts, *m);
|
||||
}
|
||||
if (const auto* m = std::get_if<network::SnapshotChunk>(&*decoded)) {
|
||||
++snapshot_chunks;
|
||||
snapshot_bytes += bytes.size();
|
||||
seen_tick(m->tick);
|
||||
if (!snapshots)
|
||||
return; // Before Welcome (channels are not ordered): the next tick resends.
|
||||
const auto accepted = snapshots->accept(*m);
|
||||
if (!accepted)
|
||||
return end(SessionCloseReason::protocol, true); // Malformed snapshot.
|
||||
if (const auto ack = accepted.value_or(std::nullopt); ack && connection != 0)
|
||||
// A lost ack only means the next delta is against an older baseline.
|
||||
(void)endpoint->send_datagram(connection, network::encode_session(*ack))
|
||||
.has_value();
|
||||
return;
|
||||
}
|
||||
if (const auto* m = std::get_if<network::SimulatedThrough>(&*decoded)) {
|
||||
if (!welcome || m->epoch != welcome->epoch)
|
||||
return; // Another epoch's watermark says nothing about this session.
|
||||
@@ -80,6 +97,7 @@ struct RegionSessionClient::Impl {
|
||||
if (state == RegionSessionState::awaiting_welcome) {
|
||||
if (const auto* m = std::get_if<network::SessionWelcome>(&*decoded)) {
|
||||
welcome = *m;
|
||||
snapshots.emplace(world::WorldIdentity{m->world, m->frame}, m->epoch);
|
||||
seen_tick(m->server_tick);
|
||||
state = RegionSessionState::established;
|
||||
return;
|
||||
@@ -206,6 +224,40 @@ std::uint64_t RegionSessionClient::server_tick() const noexcept {
|
||||
return impl_->server_tick;
|
||||
}
|
||||
|
||||
bool RegionSessionClient::set_interest(const network::SessionInterest& interest) {
|
||||
auto& m = *impl_;
|
||||
return m.state == RegionSessionState::established && m.send(interest);
|
||||
}
|
||||
|
||||
const network::ReplicatedView* RegionSessionClient::view() const noexcept {
|
||||
const auto& snapshots = impl_->snapshots;
|
||||
return snapshots ? snapshots->latest() : nullptr;
|
||||
}
|
||||
|
||||
std::expected<client::EnvironmentPresentation, client::ViewError>
|
||||
RegionSessionClient::environment() const {
|
||||
const auto& snapshots = impl_->snapshots;
|
||||
if (!snapshots)
|
||||
return std::unexpected(client::ViewError::empty_slice);
|
||||
return snapshots->environment();
|
||||
}
|
||||
|
||||
std::expected<client::OrganismPresentation, client::ViewError>
|
||||
RegionSessionClient::organisms() const {
|
||||
const auto& snapshots = impl_->snapshots;
|
||||
if (!snapshots)
|
||||
return std::unexpected(client::ViewError::empty_slice);
|
||||
return snapshots->organisms();
|
||||
}
|
||||
|
||||
std::uint64_t RegionSessionClient::snapshot_chunks() const noexcept {
|
||||
return impl_->snapshot_chunks;
|
||||
}
|
||||
|
||||
std::uint64_t RegionSessionClient::snapshot_bytes() const noexcept {
|
||||
return impl_->snapshot_bytes;
|
||||
}
|
||||
|
||||
RegionSessionState RegionSessionClient::state() const noexcept {
|
||||
return impl_->state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user