Wire cellular playtest into engineering client
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (ecs) (push) Canceled after 42s
Foundation / checks (network) (push) Canceled after 12s
Foundation / checks (client) (push) Canceled after 52s

This commit is contained in:
dingo
2026-10-11 01:14:40 -04:00
parent 27778def2c
commit 1bba54ebd8
7 changed files with 259 additions and 13 deletions
+121 -6
View File
@@ -2,8 +2,9 @@
// M10.5c remote dev session for the engineering client (ADR-0093, over ADR-0091/0092
// sessions). Without EVO_CLIENT_NETWORK (a build without EVO_BUILD_QUIC) remote mode is
// unavailable. The client only presents copies of replicated snapshots and sends bounded
// intentions; it never predicts. Grant bytes stay inside the session: each is handed to
// one connection and wiped here; never printed, shown or persisted.
// bounded intentions; the explicit cellular trial uses reliable v8 actions and its
// owner-filtered perception view. Grant bytes stay inside the session: each is handed to one
// connection and wiped here; never printed, shown or persisted.
//
// One connection per grant (ADR-0089): a lost or closed session reconnects with the next
// grant of the bundle after a growing pause (2 s .. 30 s, reset by a Welcome), which keeps
@@ -37,6 +38,7 @@
#include "evo/client/organism_view.hpp"
#include "evo/client/outcome_log.hpp"
#include "evo/client/ui_state.hpp"
#include "evo/network/session_protocol.hpp"
#include <chrono>
#include <cstdint>
#include <cstdio>
@@ -87,6 +89,8 @@ struct RemoteStatus {
std::uint64_t region{}, handoffs{}; // Region of the current session; crossings followed.
std::size_t stale_markers{};
bool stale_view{};
bool cellular_trial{};
std::string cellular_action;
};
// A probe marker to draw: the own one predicted and smoothed, others as replicated.
struct MarkerView {
@@ -106,7 +110,8 @@ class RemoteSession {
static constexpr std::uint16_t interest_radius = 7;
static constexpr double silent_ticks = 3; // Extrapolation limit (2) plus the clock's lead.
// Looks the endpoint up once (blocking); nothing connects until the first step().
static std::optional<RemoteSession> open(const client::ConnectMaterial& m) {
static std::optional<RemoteSession> open(const client::ConnectMaterial& m,
bool cellular_trial = false) {
const auto address = network::quic::resolve_ipv4(m.endpoint.host);
if (!address || m.grants.empty())
return std::nullopt;
@@ -117,6 +122,15 @@ class RemoteSession {
session.transport_.authority_pem = m.authority_pem;
session.transport_.authority_pem_file = m.authority_path;
session.grants_ = m.grants;
session.cellular_trial_ = cellular_trial;
session.next_cellular_action_id_ = static_cast<std::uint64_t>(
std::chrono::system_clock::now().time_since_epoch().count());
if (session.next_cellular_action_id_ == 0)
session.next_cellular_action_id_ = 1;
session.cellular_birth_request_id_ =
session.next_cellular_action_id_ ^ 0x43454C4C00000000ULL;
if (session.cellular_birth_request_id_ == 0)
session.cellular_birth_request_id_ = 1;
session.used_.assign(m.grants.size(), false);
// The endpoint typed in the launcher is the first grant's region.
session.target_region_ = grant_region(m.grants.front());
@@ -144,6 +158,20 @@ class RemoteSession {
[[nodiscard]] const client::OutcomeLog& outcomes() const noexcept {
return log_;
}
[[nodiscard]] bool cellular_trial() const noexcept {
return cellular_trial_;
}
[[nodiscard]] const network::CellularPerception* cellular_perception() const noexcept {
return client_ && client_->cellular_perception() ? &*client_->cellular_perception()
: nullptr;
}
[[nodiscard]] const std::string& cellular_action_status() const noexcept {
return cellular_action_status_;
}
void set_cellular_feed_target(
std::optional<std::pair<std::uint32_t, std::uint32_t>> target) noexcept {
cellular_feed_target_ = target;
}
[[nodiscard]] RemoteStatus status() const {
RemoteStatus s;
const bool live = client_ && client_->state() == client::RegionSessionState::established;
@@ -186,6 +214,8 @@ class RemoteSession {
s.interpolation_delay = interpolator_.delay();
s.remote_render_tick = render_tick_;
s.stale_view = stale_view_;
s.cellular_trial = cellular_trial_;
s.cellular_action = cellular_action_status_;
s.inputs_pending = predictor_.pending();
s.lead = lead_.lead();
s.corrections = predictor_.stats().corrections;
@@ -249,13 +279,20 @@ class RemoteSession {
return;
if (!established_)
welcome(ui, launcher);
if (cellular_trial_ && !cellular_birth_request_sent_ &&
c.request_primitive_life(cellular_birth_request_id_))
cellular_birth_request_sent_ = true;
server_tick_ = c.server_tick();
if (server_tick_ != observed_tick_) { // Every watermark or snapshot tick times the clock.
observed_tick_ = server_tick_;
clock_.observe(server_tick_, now);
}
send(intention);
if (cellular_trial_)
send_cellular(intention);
else
send(intention);
receipts();
cellular_results();
snapshot();
present(now);
if (wanted_ && (!sent_interest_ || *wanted_ != *sent_interest_) &&
@@ -325,6 +362,8 @@ class RemoteSession {
if (now < retry_at_)
return false;
client::RegionSessionClientConfig config;
if (cellular_trial_)
config.protocol_version = network::session_protocol_v8;
const auto route = routes_.find(target_region_);
config.transport = route != routes_.end() ? route->second : transport_;
if (ticket_) { // A handoff: the ticket replaces a grant, once.
@@ -430,6 +469,62 @@ class RemoteSession {
pending_.pop_front(); // Its log entry was evicted with it.
pending_.push_back({*sequence, entry, tick, false});
}
void send_cellular(const client::Intention& intention) {
if (server_tick_ == 0 || (sent_tick_ && server_tick_ <= *sent_tick_) ||
next_cellular_action_id_ == 0)
return;
const auto tick = server_tick_ + 1;
if (!client_->send_cellular_action(next_cellular_action_id_, tick, intention.move_x,
intention.move_y, cellular_feed_target_))
return;
++next_cellular_action_id_;
sent_tick_ = server_tick_;
}
void cellular_results() {
for (const auto& receipt : client_->take_primitive_life_receipts())
if (receipt.status != network::AdmitStatus::admitted)
cellular_action_status_ =
"Birth request refused (status " +
std::to_string(static_cast<unsigned>(receipt.status)) + ")";
for (const auto& outcome : client_->take_primitive_life_outcomes()) {
switch (outcome.result) {
case network::PrimitiveLifeResult::born:
cellular_action_status_ = "Cell founded (life " +
std::to_string(outcome.life_identity) + ")";
break;
case network::PrimitiveLifeResult::insufficient_funding:
cellular_action_status_ = "Birth refused: nursery funding is insufficient";
break;
case network::PrimitiveLifeResult::no_placement:
cellular_action_status_ = "Birth refused: no open spawn site";
break;
case network::PrimitiveLifeResult::existing_life:
cellular_action_status_ = "Existing cell is already bound to this account";
break;
case network::PrimitiveLifeResult::cancelled:
cellular_action_status_ = "Birth request cancelled";
break;
case network::PrimitiveLifeResult::pending:
cellular_action_status_ = "Cell birth is being committed";
break;
case network::PrimitiveLifeResult::unknown:
cellular_action_status_ = "Birth outcome is unknown; retrying exact request";
cellular_birth_request_sent_ = false;
break;
}
}
for (const auto& receipt : client_->take_action_receipts())
if (receipt.status != network::AdmitStatus::admitted)
cellular_action_status_ = "Action refused (status " +
std::to_string(static_cast<unsigned>(receipt.status)) +
")";
for (const auto& outcome : client_->take_action_outcomes())
cellular_action_status_ =
outcome.result == network::ActionResult::committed
? "Action committed at tick " + std::to_string(outcome.tick)
: "Action ended without commit (result " +
std::to_string(static_cast<unsigned>(outcome.result)) + ")";
}
void receipts() {
for (const auto& r : client_->take_intention_receipts()) {
const auto it = std::find_if(pending_.begin(), pending_.end(), [&](const Pending& p) {
@@ -577,6 +672,7 @@ class RemoteSession {
stale_view_ = was_established || stale_view_;
predictor_.reset(); // The marker ended with its session.
client_.reset();
cellular_birth_request_sent_ = false;
established_ = false;
// A crossing or a redirect is followed at once: no grant for a handoff, no pause.
if (reason == SessionCloseReason::handed_off && offer && learn_route(offer->destination)) {
@@ -668,12 +764,17 @@ class RemoteSession {
bool stale_view_{};
bool established_{}, welcomed_{}, exhausted_{};
bool following_{true}; // The camera follows the server's (default) view.
bool cellular_trial_{};
std::uint64_t next_cellular_action_id_{}, cellular_birth_request_id_{};
std::optional<std::pair<std::uint32_t, std::uint32_t>> cellular_feed_target_;
std::string cellular_action_status_;
bool cellular_birth_request_sent_{};
};
#else
inline constexpr bool remote_available = false;
class RemoteSession {
public:
static std::optional<RemoteSession> open(const client::ConnectMaterial&) {
static std::optional<RemoteSession> open(const client::ConnectMaterial&, bool = false) {
return std::nullopt;
}
[[nodiscard]] const client::EnvironmentLayer& environment() const noexcept {
@@ -685,8 +786,21 @@ class RemoteSession {
[[nodiscard]] const client::OutcomeLog& outcomes() const noexcept {
return log_;
}
[[nodiscard]] bool cellular_trial() const noexcept {
return false;
}
[[nodiscard]] const network::CellularPerception* cellular_perception() const noexcept {
return nullptr;
}
[[nodiscard]] const std::string& cellular_action_status() const noexcept {
return action_status_;
}
void set_cellular_feed_target(
std::optional<std::pair<std::uint32_t, std::uint32_t>>) noexcept {}
[[nodiscard]] RemoteStatus status() const {
return {"unavailable in this build"};
RemoteStatus status;
status.phase = "unavailable in this build";
return status;
}
[[nodiscard]] std::optional<client::WorldPoint> take_recentre() {
return std::nullopt;
@@ -699,6 +813,7 @@ class RemoteSession {
client::Launcher&) {}
private:
std::string action_status_;
client::EnvironmentLayer environment_;
client::OrganismLayer organisms_;
client::OutcomeLog log_;