Add primitive life calls to the session client
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
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 (checks) (push) Canceled after 2m43s
Foundation / checks (network) (push) Canceled after 39s
Foundation / checks (client) (push) Canceled after 2m49s

This commit is contained in:
dingo
2026-10-10 20:52:32 -04:00
parent 0bb8b50c9c
commit 3277b8f3cd
7 changed files with 193 additions and 56 deletions
+79 -5
View File
@@ -20,7 +20,8 @@
// endian). This is the load bundle `evo-load --grants FILE --grants-per-bot COUNT` uses.
// 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]
// [--protocol v4|v5] [--intents N] [--actions N --action-base ID] [--query ID]...
// [--new-life ID]... [--life-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
@@ -35,8 +36,8 @@
// handoff REGION ENDPOINT | redirect REGION ENDPOINT (v4, ADR-0096; then closed)
// 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
// action is final and every query answered, 1 on timeout, 3 when the server closes.
// Statuses/results follow the selected protocol version. Exits 0 once every requested
// operation is answered, 1 on timeout, 3 when the server closes.
// evo-session-probe run --connect HOST:PORT --server-name NAME --ca FILE --grants FILE
// [--grant N] [options as above]
// M10.9 (ADR-0097): logs in with grant N (from 0) of an existing bundle instead of
@@ -173,10 +174,12 @@ struct RunOptions {
std::string host, server_name, ca, issuer_key, grants_file;
std::uint64_t grant_index{};
std::uint16_t port{};
std::uint16_t protocol_version{session_protocol_version};
std::uint64_t world{}, frame{}, region{}, serial{}, lifetime{60}, intents{}, actions{},
action_base{1}, timeout_ms{20000};
std::optional<AccountId> account;
std::vector<std::uint64_t> queries;
std::vector<std::uint64_t> life_requests, life_queries;
std::vector<std::uint64_t> more_regions; // grants: further --region values.
std::optional<SessionInterest> interest;
std::uint64_t snapshots{};
@@ -316,6 +319,7 @@ int run(const RunOptions& o) {
config.transport.authority_pem = read(o.ca);
config.transport.authority_pem_file = o.ca;
config.grant = *grant;
config.protocol_version = o.protocol_version;
auto made = client::RegionSessionClient::connect(std::move(config), Clock::now());
if (!made) {
std::puts("error connect");
@@ -324,9 +328,15 @@ int run(const RunOptions& o) {
auto& c = **made;
const auto deadline = Clock::now() + std::chrono::milliseconds{o.timeout_ms};
bool welcomed = false, queried = false;
auto life_retry_at = Clock::time_point{};
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());
std::set<std::uint64_t> pending_life_requests(o.life_requests.begin(), o.life_requests.end());
std::set<std::uint64_t> pending_life_queries(o.life_queries.begin(), o.life_queries.end());
const auto life_request_count = pending_life_requests.size();
const auto life_query_count = pending_life_queries.size();
std::set<std::uint64_t> sent_life_requests, sent_life_queries;
for (std::uint64_t i = 0; i < o.actions; ++i)
pending_actions.insert(o.action_base + i);
while (Clock::now() < deadline) {
@@ -372,6 +382,22 @@ int run(const RunOptions& o) {
for (const auto query : o.queries)
(void)c.query_action(query);
}
const auto life_now = Clock::now();
if (life_now >= life_retry_at) {
bool sent_life = false;
for (const auto request : o.life_requests)
if (!sent_life_requests.contains(request) && c.request_primitive_life(request)) {
sent_life_requests.insert(request);
sent_life = true;
}
for (const auto query : o.life_queries)
if (!sent_life_queries.contains(query) && c.query_primitive_life(query)) {
sent_life_queries.insert(query);
sent_life = true;
}
if (sent_life)
life_retry_at = life_now + std::chrono::milliseconds{250};
}
for (const auto& r : c.take_intention_receipts())
std::printf("intention %llu %u\n", static_cast<unsigned long long>(r.sequence),
static_cast<unsigned>(r.status));
@@ -416,10 +442,42 @@ int run(const RunOptions& o) {
out.result == ActionResult::not_committed)
pending_actions.erase(out.action_id);
}
for (const auto& receipt : c.take_primitive_life_receipts())
std::printf("life-receipt %llu %u %llu\n",
static_cast<unsigned long long>(receipt.request_id),
static_cast<unsigned>(receipt.status),
static_cast<unsigned long long>(receipt.server_tick));
for (const auto& out : c.take_primitive_life_outcomes()) {
std::printf("life-outcome %llu %u %llu %llu\n",
static_cast<unsigned long long>(out.request_id),
static_cast<unsigned>(out.result),
static_cast<unsigned long long>(out.life_identity),
static_cast<unsigned long long>(out.commit_sequence));
const bool unresolved = out.result == PrimitiveLifeResult::pending ||
(out.result == PrimitiveLifeResult::unknown &&
pending_life_requests.contains(out.request_id));
if (pending_life_requests.contains(out.request_id)) {
if (unresolved)
sent_life_requests.erase(out.request_id); // Exact request retry is idempotent.
else
pending_life_requests.erase(out.request_id);
}
if (pending_life_queries.contains(out.request_id)) {
if (out.result == PrimitiveLifeResult::pending)
sent_life_queries.erase(out.request_id);
else
pending_life_queries.erase(out.request_id); // Unknown is a query answer.
}
if (unresolved)
life_retry_at =
std::max(life_retry_at, Clock::now() + std::chrono::milliseconds{250});
}
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) &&
snapshots >= o.snapshots) {
pending_life_requests.empty() && pending_life_queries.empty() &&
sent_life_requests.size() == life_request_count &&
sent_life_queries.size() == life_query_count && 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()));
@@ -470,8 +528,16 @@ int main(int argc, char** argv) {
o.grant_index = *n;
else if (flag == "--account")
ok = (o.account = account_of(value)).has_value();
else if (flag == "--protocol" && value == "v4")
o.protocol_version = session_protocol_version;
else if (flag == "--protocol" && value == "v5")
o.protocol_version = session_protocol_v5;
else if (flag == "--query" && n)
o.queries.push_back(*n);
else if (flag == "--new-life" && n && *n != 0)
o.life_requests.push_back(*n);
else if (flag == "--life-query" && n && *n != 0)
o.life_queries.push_back(*n);
else if (n && flag == "--world")
o.world = *n;
else if (n && flag == "--frame")
@@ -525,5 +591,13 @@ int main(int argc, char** argv) {
stderr);
return 2;
}
if ((o.protocol_version == session_protocol_v5 &&
(o.intents != 0 || o.actions != 0 || !o.queries.empty() || o.interest ||
o.snapshots != 0)) ||
(o.protocol_version == session_protocol_version &&
(!o.life_requests.empty() || !o.life_queries.empty()))) {
std::fputs("error incompatible session protocol options\n", stderr);
return 2;
}
return run(o);
}