Wire M10.6b probe markers through sessions, evo-server, probe and client
Foundation / checks (checks) (push) Successful in 32m33s
Foundation / checks (client) (push) Successful in 12m28s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (network) (push) Successful in 12m8s
Foundation / checks (postgres) (push) Successful in 40m38s
Foundation / checks (tsan) (push) Successful in 8m4s
Foundation / postgres-tools (push) Successful in 1m36s
Foundation / image (push) Successful in 2m33s
Foundation / server-image (push) Successful in 3m53s

EXPERIMENT (ADR-0094). RegionSessions owns the probe markers: admitted
intentions schedule them, each poll advances them to the simulated tick, and
snapshots carry them. evo-server sets the motion area from the region's
habitat sites; the probe prints its own marker.

The engineering client predicts its marker with the adaptive input lead,
rebases on each snapshot, resends a lost or refused intention, smooths
corrections, draws markers and follows its own with camera and interest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-06 16:07:34 -04:00
co-authored by Claude Opus 5.5
parent ab7e26c02e
commit 96237ca10a
17 changed files with 334 additions and 27 deletions
+16
View File
@@ -184,6 +184,18 @@ std::optional<evo::client::ScreenPoint> parse_point(std::string_view value) {
return std::nullopt;
return evo::client::ScreenPoint{static_cast<double>(x), static_cast<double>(y)};
}
// A probe marker (ADR-0094): the own one larger and amber, others smaller and blue; clipped.
void marker_box(std::vector<evo::render::Rectangle>& out, double x, double y, bool own,
double width, double height) {
const double half = own ? 7 : 4;
const double x0 = std::max(x - half, 0.0), y0 = std::max(y - half, 0.0);
const double x1 = std::min(x + half, width), y1 = std::min(y + half, height);
if (x1 > x0 && y1 > y0)
out.push_back(
{static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(x1 - x0),
static_cast<float>(y1 - y0),
own ? evo::render::Color{250, 190, 40, 255} : evo::render::Color{90, 170, 250, 255}});
}
void outline(std::vector<evo::render::Rectangle>& out, double l, double t, double r, double b,
double width, double height) {
const auto rect = [&](double x0, double y0, double x1, double y1) {
@@ -529,6 +541,10 @@ int main(int argc, char** argv) try {
return 1;
drawn_organisms = static_cast<int>(report->drawn);
const double width = state.logical_width, height = state.logical_height;
if (const auto* remote = host.session(); remote && mode() == Mode::remote)
for (const auto& m : remote->markers())
if (const auto at = camera->world_to_screen({m.x_mm, m.y_mm}))
marker_box(boxes, at->x, at->y, m.own, width, height);
if (const auto* o = selection.organism(orgs)) {
const auto b = evo::render::organism_bounds(*o, *camera);
outline(boxes, b.left - 3, b.top - 3, b.right + 3, b.bottom + 3, width, height);
+13
View File
@@ -1,6 +1,7 @@
#include "panels.hpp"
#include "evo/client/labels.hpp"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <imgui.h>
#include <string>
@@ -355,6 +356,18 @@ void session(const PanelView& v) {
row("Interest", std::to_string(s.focus_x) + ", " + std::to_string(s.focus_y) + ", z " +
std::to_string(s.focus_z) + " (radius 7)");
row("Snapshot bytes", std::to_string(s.snapshot_bytes));
if (s.marker) { // Probe marker (ADR-0094, EXPERIMENT): predicted and smoothed.
char position[64];
std::snprintf(position, sizeof position, "%.2f, %.2f m", s.marker_x_mm / 1000,
s.marker_y_mm / 1000);
row("Probe marker", position);
row("Prediction", std::to_string(s.inputs_pending) + " pending, lead " +
std::to_string(s.lead) + " ticks");
row("Corrections", std::to_string(s.corrections) + ", max error " +
std::to_string(s.max_error_um / 1000) + " mm, " +
std::to_string(s.snaps) + " snaps");
row("Other markers", std::to_string(s.other_markers));
}
ImGui::EndTable();
}
disabled_wrapped("Intentions (newest first; this is the record, toasts expire):");
+111 -11
View File
@@ -10,6 +10,13 @@
// a reconnect loop inside the region's per-account attempt limit. Views come from the
// newest applied snapshot. The camera follows the server's default view until the user
// moves it; from then on it drives the interest (radius 7), at most every 250 ms.
//
// M10.6b (ADR-0094, EXPERIMENT): the session's probe marker is predicted. Each input is
// recorded with the predictor and scheduled `lead` ticks ahead (adapted to refusals); each
// snapshot's own marker rebases the prediction; corrections are smoothed for display. An
// intention that was lost or refused is sent again once nothing is in flight and the
// authority holds another vector. While following, the camera and the interest follow the
// predicted marker (or, before a marker exists, the server's default view).
#include "evo/client/camera.hpp"
#include "evo/client/environment_view.hpp"
#include "evo/client/input.hpp"
@@ -23,8 +30,10 @@
#include <memory>
#include <optional>
#include <string>
#include <vector>
#ifdef EVO_CLIENT_NETWORK
#include "evo/client/motion_prediction.hpp"
#include "evo/client/region_session.hpp"
#include "evo/network/quic_transport.hpp"
#include "evo/world/coordinates.hpp"
@@ -47,6 +56,16 @@ struct RemoteStatus {
std::size_t cells{}, organisms{};
std::int64_t focus_x{}, focus_y{}, focus_z{};
bool focused{};
// The predicted probe marker (ADR-0094).
bool marker{};
double marker_x_mm{}, marker_y_mm{};
std::size_t inputs_pending{}, other_markers{};
std::uint64_t lead{}, corrections{}, max_error_um{}, snaps{};
};
// A probe marker to draw: the own one predicted and smoothed, others as replicated.
struct MarkerView {
double x_mm{}, y_mm{};
bool own{};
};
#ifdef EVO_CLIENT_NETWORK
@@ -56,7 +75,6 @@ static_assert(std::is_same_v<client::GrantRecord, network::WireGrant>,
class RemoteSession {
public:
static constexpr std::uint16_t interest_radius = 7;
static constexpr std::uint64_t intention_lead = 2; // Ticks ahead of the server tick.
// Looks the endpoint up once (blocking); nothing connects until the first step().
static std::optional<RemoteSession> open(const client::ConnectMaterial& m) {
const auto address = network::quic::resolve_ipv4(m.endpoint.host);
@@ -115,8 +133,25 @@ class RemoteSession {
s.focus_y = sent_interest_->y;
s.focus_z = sent_interest_->z;
}
for (const auto& m : markers_)
if (m.own) {
s.marker = true;
s.marker_x_mm = m.x_mm;
s.marker_y_mm = m.y_mm;
} else {
++s.other_markers;
}
s.inputs_pending = predictor_.pending();
s.lead = lead_.lead();
s.corrections = predictor_.stats().corrections;
s.max_error_um = predictor_.stats().max_error_um;
s.snaps = smoother_.snaps();
return s;
}
// Markers to draw this frame (empty without a session or snapshot).
[[nodiscard]] const std::vector<MarkerView>& markers() const noexcept {
return markers_;
}
// Where the camera should be while it follows the server's view: the middle of the
// newest snapshot's square, offered whenever it changes (the first snapshots may still
// be filling in, nearest cells first).
@@ -164,6 +199,7 @@ class RemoteSession {
send(intention);
receipts();
snapshot();
present(now);
if (wanted_ && (!sent_interest_ || *wanted_ != *sent_interest_) &&
now - interest_at_ >= std::chrono::milliseconds{250} && c.set_interest(*wanted_)) {
sent_interest_ = wanted_;
@@ -228,8 +264,11 @@ class RemoteSession {
session_ = w.session;
epoch_ = w.epoch;
sent_tick_.reset(); // New session: resend the current intention.
sent_x_ = sent_y_ = 0;
sent_ = {};
sent_interest_.reset(); // The server starts from its default interest.
predictor_.reset(); // A new session has a new marker.
smoother_.reset();
lead_.reset();
launcher.observe(client::ConnectSignal::welcome);
notify(ui, "Connected to the dev region (fresh baseline).", client::NoticeLevel::info);
std::printf("session welcome session=%llu epoch=%llu tick=%llu\n",
@@ -238,16 +277,23 @@ class RemoteSession {
static_cast<unsigned long long>(w.server_tick));
}
void send(const client::Intention& intention) {
const bool changed = intention.move_x != sent_x_ || intention.move_y != sent_y_;
if (!changed || server_tick_ == 0 || (sent_tick_ && server_tick_ <= *sent_tick_))
const network::motion::Vector want{intention.move_x, intention.move_y};
if (server_tick_ == 0 || (sent_tick_ && server_tick_ <= *sent_tick_) || predictor_.full())
return;
const auto tick = server_tick_ + intention_lead;
// Resend when the authority holds another vector and nothing in flight will change
// it (the last intention was lost or refused).
const auto& authority = predictor_.authority();
const bool stale =
authority && authority->state.vector != want && predictor_.pending() == 0;
if (want == sent_ && !stale)
return;
const auto tick = server_tick_ + lead_.lead();
// Refused until the datagram extension is negotiated: retried next frame.
const auto sequence = client_->send_intention(tick, intention.move_x, intention.move_y);
const auto sequence = client_->send_intention(tick, want.x, want.y);
if (!sequence)
return;
sent_x_ = intention.move_x;
sent_y_ = intention.move_y;
static_cast<void>(predictor_.input({*sequence, tick, want}));
sent_ = want;
sent_tick_ = server_tick_;
const auto entry = next_entry_++;
log_.record({entry, client::OutcomeState::sent, 0, tick});
@@ -267,7 +313,11 @@ class RemoteSession {
if (r.status == network::AdmitStatus::admitted) {
log_.record({it->entry, client::OutcomeState::admitted, 0, it->tick});
it->admitted = true;
lead_.admitted(it->tick, r.server_tick);
} else {
predictor_.rejected(r.sequence); // It never takes effect.
if (r.status == network::AdmitStatus::outside_window)
lead_.too_late(); // Arrived after its tick: schedule further ahead.
log_.record({it->entry, client::OutcomeState::rejected,
static_cast<std::uint8_t>(r.status), it->tick});
pending_.erase(it);
@@ -303,8 +353,15 @@ class RemoteSession {
static_cast<void>(organisms_.accept(std::move(*o)).has_value());
}
}
if (!following_ || v->environment.empty())
return;
others_.clear();
for (const auto& m : v->markers) {
if (m.own)
predictor_.authoritative({v->tick, m.applied_sequence, m.state, m.area});
else
others_.push_back(m);
}
if (!following_ || v->environment.empty() || predictor_.authority())
return; // With a marker, present() follows it instead.
const auto [lx, hx] =
std::minmax_element(v->environment.begin(), v->environment.end(),
[](const auto& a, const auto& b) { return a.voxel.x < b.voxel.x; });
@@ -318,6 +375,36 @@ class RemoteSession {
if (!offered_ || middle.x_mm != offered_->x_mm || middle.y_mm != offered_->y_mm)
recentre_ = offered_ = middle;
}
// The predicted own marker (smoothed) and the others; while following, the camera and
// the interest follow the own marker.
void present(Clock::time_point now) {
const double elapsed =
last_present_ ? std::chrono::duration<double, std::milli>(now - *last_present_).count()
: 0;
last_present_ = now;
markers_.clear();
const auto predicted = predictor_.predict(server_tick_ + lead_.lead());
const auto& authority = predictor_.authority();
if (predicted && authority) {
smoother_.add(predictor_.take_correction());
const auto offset = smoother_.advance(elapsed);
const MarkerView own{static_cast<double>(predicted->x + offset.x) / 1000,
static_cast<double>(predicted->y + offset.y) / 1000, true};
markers_.push_back(own);
if (following_) {
recentre_ = offered_ = client::WorldPoint{own.x_mm, own.y_mm};
wanted_ = network::SessionInterest{cell(predicted->x), cell(predicted->y),
authority->area.z, interest_radius};
}
}
for (const auto& m : others_)
markers_.push_back({static_cast<double>(m.state.x) / 1000,
static_cast<double>(m.state.y) / 1000, false});
}
static std::int64_t cell(std::int64_t um) {
constexpr auto size = network::motion::micrometres_per_cell;
return um >= 0 || um % size == 0 ? um / size : (um / size) - 1;
}
// The connection ended: decide what the launcher hears and pause before the next grant.
void end(Clock::time_point now, client::UiState& ui, client::Launcher& launcher) {
using network::SessionCloseReason;
@@ -329,6 +416,9 @@ class RemoteSession {
pending_.clear();
environment_.mark_stale();
organisms_.mark_stale();
predictor_.reset(); // The marker ended with its session.
others_.clear();
markers_.clear();
client_.reset();
established_ = false;
const bool not_ready =
@@ -373,7 +463,13 @@ class RemoteSession {
std::optional<network::SessionInterest> wanted_, sent_interest_;
std::optional<client::WorldPoint> recentre_, offered_;
std::int64_t slice_z_{};
std::int16_t sent_x_{}, sent_y_{};
network::motion::Vector sent_;
client::MotionPredictor predictor_;
client::CorrectionSmoother smoother_;
client::InputLead lead_;
std::optional<Clock::time_point> last_present_;
std::vector<network::ReplicatedMarker> others_;
std::vector<MarkerView> markers_;
bool established_{}, welcomed_{}, exhausted_{};
bool following_{true}; // The camera follows the server's (default) view.
};
@@ -399,6 +495,9 @@ class RemoteSession {
[[nodiscard]] std::optional<client::WorldPoint> take_recentre() {
return std::nullopt;
}
[[nodiscard]] const std::vector<MarkerView>& markers() const noexcept {
return markers_;
}
void focus(client::WorldPoint) {}
void step(std::chrono::steady_clock::time_point, const client::Intention&, client::UiState&,
client::Launcher&) {}
@@ -407,6 +506,7 @@ class RemoteSession {
client::EnvironmentLayer environment_;
client::OrganismLayer organisms_;
client::OutcomeLog log_;
std::vector<MarkerView> markers_;
};
#endif
} // namespace evo::client_app
+22
View File
@@ -9,6 +9,7 @@
// 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).
// M10.6 (ADR-0094): sessions' probe markers move within the habitat sites' bounding cells.
#include "evo/persistence/postgres.hpp"
#include "evo/persistence/region_lease.hpp"
#include <cstdint>
@@ -149,6 +150,7 @@ template <typename Host> class M10Bridge {
const auto v = sites.front().voxel;
default_interest_ = network::SessionInterest{v.x, v.y, v.z, 7};
sessions_->set_default_interest(*default_interest_);
set_motion_area(sites, v);
}
sessions_->replicate(s.simulated_tick, [&](const network::SessionInterest& in) {
return source(c, in, s.simulated_tick);
@@ -196,6 +198,26 @@ template <typename Host> class M10Bridge {
static const processes::EnvironmentalCommunity& community(const processes::LineageRegion& r) {
return r.community();
}
// Probe markers (ADR-0094, EXPERIMENT) move within the habitat sites' bounding cells of
// the default slice and spawn at the centre of its first site.
template <typename Sites> void set_motion_area(const Sites& sites, world::VoxelAddress first) {
constexpr auto cell = network::motion::micrometres_per_cell;
network::motion::Area area{first.x * cell, first.y * cell, (first.x * cell) + cell - 1,
(first.y * cell) + cell - 1, first.z};
for (const auto& site : sites)
if (site.voxel.z == first.z) {
area.min_x = std::min(area.min_x, site.voxel.x * cell);
area.min_y = std::min(area.min_y, site.voxel.y * cell);
area.max_x = std::max(area.max_x, (site.voxel.x * cell) + cell - 1);
area.max_y = std::max(area.max_y, (site.voxel.y * cell) + cell - 1);
}
if (sessions_->set_motion_area(area, (first.x * cell) + (cell / 2),
(first.y * cell) + (cell / 2)))
std::printf("m10 motion area %lld %lld %lld %lld z=%lld\n",
static_cast<long long>(area.min_x), static_cast<long long>(area.min_y),
static_cast<long long>(area.max_x), static_cast<long long>(area.max_y),
static_cast<long long>(area.z));
}
// 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,
+8
View File
@@ -23,6 +23,8 @@
// resolved HOST ADDRESS (a host name was looked up; IPv4)
// snapshot TICK CELLS ORGANISMS MINX MINY MAXX MAXY Z (each newly applied snapshot;
// --snapshots N waits for N; --interest asks for another focus than the default)
// marker TICK X Y APPLIED (the session's own probe marker in each new snapshot: um
// position after TICK and the newest applied intention sequence; ADR-0094)
// closed REASON TRANSPORT (TRANSPORT names why QUIC ended: untrusted means the server
// answered but failed the pinned CA/name check; idle means nothing answered)
// Statuses, results and reasons are the session-v1 wire values. Exits 0 once every
@@ -332,6 +334,12 @@ int run(const RunOptions& o) {
v->organisms.size(), static_cast<long long>(min_x),
static_cast<long long>(min_y), static_cast<long long>(max_x),
static_cast<long long>(max_y), static_cast<long long>(v->slice_z));
for (const auto& m : v->markers)
if (m.own)
std::printf(
"marker %llu %lld %lld %llu\n", static_cast<unsigned long long>(v->tick),
static_cast<long long>(m.state.x), static_cast<long long>(m.state.y),
static_cast<unsigned long long>(m.applied_sequence));
}
for (const auto& r : c.take_action_receipts())
std::printf("receipt %llu %u %llu\n", static_cast<unsigned long long>(r.action_id),