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:
@@ -6,12 +6,15 @@
|
||||
// evo-session-probe run --connect HOST:PORT --server-name NAME --ca FILE --issuer-key FILE
|
||||
// --world N --frame N --region N --account HEX32 --serial N [--lifetime S]
|
||||
// [--intents N] [--actions N --action-base ID] [--query ID]... [--timeout-ms N]
|
||||
// [--interest X,Y,Z,R] [--snapshots N]
|
||||
// Signs a dev grant for the account and serial, logs in over QUIC, sends N intentions
|
||||
// (one per tick, two ticks ahead) and N probe actions (three ticks ahead), queries the
|
||||
// given action ids, and prints one line per answer:
|
||||
// welcome SESSION EPOCH TICK | intention SEQ STATUS | simulated SEQ TICK
|
||||
// receipt ID STATUS TICK | outcome ID RESULT TICK COMMIT | done
|
||||
// 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)
|
||||
// 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
|
||||
@@ -160,7 +163,24 @@ struct RunOptions {
|
||||
action_base{1}, timeout_ms{20000};
|
||||
std::optional<AccountId> account;
|
||||
std::vector<std::uint64_t> queries;
|
||||
std::optional<SessionInterest> interest;
|
||||
std::uint64_t snapshots{};
|
||||
};
|
||||
std::optional<SessionInterest> interest_of(std::string_view v) {
|
||||
std::array<std::int64_t, 4> parts{};
|
||||
for (std::size_t i = 0; i < parts.size(); ++i) {
|
||||
const auto comma = v.find(',');
|
||||
const auto part = v.substr(0, comma);
|
||||
const auto [end, ec] = std::from_chars(part.data(), part.data() + part.size(), parts.at(i));
|
||||
if (ec != std::errc{} || end != part.data() + part.size() ||
|
||||
(comma == std::string_view::npos) != (i + 1 == parts.size()))
|
||||
return std::nullopt;
|
||||
v.remove_prefix(comma == std::string_view::npos ? v.size() : comma + 1);
|
||||
}
|
||||
if (parts[3] < 0 || parts[3] > 65535)
|
||||
return std::nullopt;
|
||||
return SessionInterest{parts[0], parts[1], parts[2], static_cast<std::uint16_t>(parts[3])};
|
||||
}
|
||||
|
||||
int run(const RunOptions& o) {
|
||||
const auto scalar = read(o.issuer_key);
|
||||
@@ -219,6 +239,7 @@ int run(const RunOptions& o) {
|
||||
const auto deadline = Clock::now() + std::chrono::milliseconds{o.timeout_ms};
|
||||
bool welcomed = false, queried = false;
|
||||
std::uint64_t sent_intents = 0, sent_actions = 0, last_tick = 0, simulated = 0;
|
||||
std::uint64_t seen_snapshot = 0, snapshots = 0;
|
||||
std::set<std::uint64_t> pending_actions, pending_queries(o.queries.begin(), o.queries.end());
|
||||
for (std::uint64_t i = 0; i < o.actions; ++i)
|
||||
pending_actions.insert(o.action_base + i);
|
||||
@@ -253,6 +274,8 @@ int run(const RunOptions& o) {
|
||||
}
|
||||
if (!queried) {
|
||||
queried = true;
|
||||
if (o.interest && !c.set_interest(*o.interest))
|
||||
std::puts("error interest");
|
||||
for (const auto query : o.queries)
|
||||
(void)c.query_action(query);
|
||||
}
|
||||
@@ -264,6 +287,23 @@ int run(const RunOptions& o) {
|
||||
std::printf("simulated %llu %llu\n", static_cast<unsigned long long>(s->sequence),
|
||||
static_cast<unsigned long long>(s->tick));
|
||||
}
|
||||
if (const auto* v = c.view(); v && v->tick != seen_snapshot) {
|
||||
seen_snapshot = v->tick;
|
||||
++snapshots;
|
||||
std::int64_t min_x = 0, min_y = 0, max_x = 0, max_y = 0;
|
||||
for (std::size_t i = 0; i < v->environment.size(); ++i) {
|
||||
const auto& voxel = v->environment[i].voxel;
|
||||
min_x = i == 0 ? voxel.x : std::min(min_x, voxel.x);
|
||||
min_y = i == 0 ? voxel.y : std::min(min_y, voxel.y);
|
||||
max_x = i == 0 ? voxel.x : std::max(max_x, voxel.x);
|
||||
max_y = i == 0 ? voxel.y : std::max(max_y, voxel.y);
|
||||
}
|
||||
std::printf("snapshot %llu %zu %zu %lld %lld %lld %lld %lld\n",
|
||||
static_cast<unsigned long long>(v->tick), v->environment.size(),
|
||||
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& r : c.take_action_receipts())
|
||||
std::printf("receipt %llu %u %llu\n", static_cast<unsigned long long>(r.action_id),
|
||||
static_cast<unsigned>(r.status), static_cast<unsigned long long>(r.tick));
|
||||
@@ -279,7 +319,11 @@ int run(const RunOptions& o) {
|
||||
}
|
||||
std::fflush(stdout);
|
||||
if (sent_actions == o.actions && pending_actions.empty() && pending_queries.empty() &&
|
||||
sent_intents == o.intents && simulated >= std::min<std::uint64_t>(o.intents, 1)) {
|
||||
sent_intents == o.intents && simulated >= std::min<std::uint64_t>(o.intents, 1) &&
|
||||
snapshots >= o.snapshots) {
|
||||
std::printf("snapshot-bytes %llu chunks %llu\n",
|
||||
static_cast<unsigned long long>(c.snapshot_bytes()),
|
||||
static_cast<unsigned long long>(c.snapshot_chunks()));
|
||||
std::puts("done");
|
||||
c.close();
|
||||
return 0;
|
||||
@@ -338,6 +382,10 @@ int main(int argc, char** argv) {
|
||||
o.action_base = *n;
|
||||
else if (n && flag == "--timeout-ms" && *n > 0)
|
||||
o.timeout_ms = *n;
|
||||
else if (n && flag == "--snapshots" && *n <= 100000)
|
||||
o.snapshots = *n;
|
||||
else if (flag == "--interest")
|
||||
ok = (o.interest = interest_of(value)).has_value();
|
||||
else
|
||||
ok = false;
|
||||
}
|
||||
@@ -346,7 +394,8 @@ int main(int argc, char** argv) {
|
||||
std::fputs("usage: evo-session-probe keys --out DIR | run --connect HOST:PORT "
|
||||
"--server-name NAME --ca FILE --issuer-key FILE --world N --frame N "
|
||||
"--region N --account HEX32 --serial N [--lifetime S] [--intents N] "
|
||||
"[--actions N --action-base ID] [--query ID]... [--timeout-ms N]\n",
|
||||
"[--actions N --action-base ID] [--query ID]... [--timeout-ms N] "
|
||||
"[--interest X,Y,Z,R] [--snapshots N]\n",
|
||||
stderr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user