Send a life identity on the wire only with a born outcome
Foundation / checks (checks) (push) Successful in 40m57s
Foundation / checks (deploy) (push) Successful in 3m59s
Foundation / checks (ecs) (push) Successful in 2m19s
Foundation / checks (network) (push) Successful in 19m0s
Foundation / checks (postgres) (push) Successful in 43m16s
Foundation / checks (tsan) (push) Successful in 9m41s
Foundation / checks (client) (push) Successful in 13m43s
Foundation / postgres-tools (push) Successful in 18s
Foundation / server-image (push) Successful in 3m0s
Foundation / image (push) Successful in 3m15s
Foundation / checks (checks) (push) Successful in 40m57s
Foundation / checks (deploy) (push) Successful in 3m59s
Foundation / checks (ecs) (push) Successful in 2m19s
Foundation / checks (network) (push) Successful in 19m0s
Foundation / checks (postgres) (push) Successful in 43m16s
Foundation / checks (tsan) (push) Successful in 9m41s
Foundation / checks (client) (push) Successful in 13m43s
Foundation / postgres-tools (push) Successful in 18s
Foundation / server-image (push) Successful in 3m0s
Foundation / image (push) Successful in 3m15s
A fresh client launch sends a new birth request. For an account that already has a cell, the cellular host reports existing_life with the reserved identity, and RegionSessions forwarded it although the codec accepts an identity only with born. The client closed with protocol and retried with the next grant until the account was rate-limited, so no account with a cell could log in from a new launch. Clear the identity and commit on every other result at the session boundary, and test that an existing_life refusal arrives valid while the session stays open. The client now names the cause of a protocol close on stderr, which is how this was found. Record it in ADR-0123. Also refresh the dev session window (3 h). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ spec:
|
|||||||
env:
|
env:
|
||||||
- {name: REGION_SESSION, value: "dev"}
|
- {name: REGION_SESSION, value: "dev"}
|
||||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261013T202231-51334:1791933751"}
|
- {name: REGION_SESSION_WINDOW, value: "dev-20261013T205109-48305:1791935469"}
|
||||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||||
ports:
|
ports:
|
||||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||||
|
|||||||
@@ -96,6 +96,15 @@ region in DEV. Bringing one up exposed four gaps:
|
|||||||
- Other births stay queued until the account returns.
|
- Other births stay queued until the account returns.
|
||||||
- Restarting the pod cleared the in-memory queue. The reservation is
|
- Restarting the pod cleared the in-memory queue. The reservation is
|
||||||
durable, and the client's query re-queues it.
|
durable, and the client's query re-queues it.
|
||||||
|
- **A refused life request no longer breaks the session.** The cellular host
|
||||||
|
reports the reserved identity on a pending or refused request.
|
||||||
|
`RegionSessions` forwarded it unchanged, and the codec rejects any identity
|
||||||
|
or commit on a non-born outcome. The client closed with `protocol` and
|
||||||
|
retried with the next grant until the account was rate-limited. The client
|
||||||
|
picks a new birth request per launch, so every account that already had a
|
||||||
|
cell was refused as `existing_life` and could not log in from a fresh
|
||||||
|
launch. The session layer now sends the identity and commit only with
|
||||||
|
`born`.
|
||||||
- **Grants for region 3 must be minted with `--region 3 --lifetime 300` or
|
- **Grants for region 3 must be minted with `--region 3 --lifetime 300` or
|
||||||
less.** Longer probe sessions require a separate, reviewed change to the
|
less.** Longer probe sessions require a separate, reviewed change to the
|
||||||
cellular grant ceiling; this ADR does not make it.
|
cellular grant ceiling; this ADR does not make it.
|
||||||
|
|||||||
@@ -7194,4 +7194,16 @@ failed again every 20 s, refusing logins with `shutdown`. A restart of
|
|||||||
`Deployment/evo-region` (permitted by the agent contract) cleared the
|
`Deployment/evo-region` (permitted by the agent contract) cleared the
|
||||||
in-memory queue, and the region held `ready 1` at epoch 8 from 20:20:44 UTC.
|
in-memory queue, and the region held `ready 1` at epoch 8 from 20:20:44 UTC.
|
||||||
`serve_cellular` now includes, and ticks for, only births whose account holds
|
`serve_cellular` now includes, and ticks for, only births whose account holds
|
||||||
a session. Checked locally: g++-14 `-Werror`, clang-tidy-19 and clang-format.
|
a session. Checked locally: g++-14 `-Werror`, clang-tidy-19 and clang-format.
|
||||||
|
Logins from a fresh client launch then failed in a loop: welcome, then the
|
||||||
|
client closed with `protocol`. A diagnostic in `RegionSessionClient` (now
|
||||||
|
kept: protocol closes name their cause on stderr) showed
|
||||||
|
`message decode detail=6 bytes=33`, a primitive-life outcome the codec
|
||||||
|
rejects. A new client launch sends a new birth request; for an account that
|
||||||
|
already has a cell, the cellular host reports `existing_life` with the
|
||||||
|
reserved identity, and `RegionSessions` forwarded it although the codec allows
|
||||||
|
an identity only with `born`. The session layer now clears identity and commit
|
||||||
|
on every other result. `quic_sessions` adds an `existing_life` refusal that
|
||||||
|
must arrive valid while the session stays established. Locally (MSVC, client
|
||||||
|
preset) the case failed with the same 33-byte decode error before the fix and
|
||||||
|
passed after it.
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "evo/client/region_session.hpp"
|
#include "evo/client/region_session.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstdio>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace evo::client {
|
namespace evo::client {
|
||||||
@@ -41,13 +42,21 @@ struct RegionSessionClient::Impl {
|
|||||||
void seen_tick(std::uint64_t tick) {
|
void seen_tick(std::uint64_t tick) {
|
||||||
server_tick = std::max(server_tick, tick);
|
server_tick = std::max(server_tick, tick);
|
||||||
}
|
}
|
||||||
|
// A protocol close names its cause on stderr: which channel, the codec or assembly
|
||||||
|
// error, or the message alternative and version that was not expected here.
|
||||||
|
void protocol_close(const char* where, int detail, std::size_t bytes) {
|
||||||
|
std::fprintf(stderr, "session protocol close: %s detail=%d bytes=%zu state=%d\n", where,
|
||||||
|
detail, bytes, static_cast<int>(state));
|
||||||
|
end(SessionCloseReason::protocol, true);
|
||||||
|
}
|
||||||
// Datagrams: receipts and watermarks only, after Welcome.
|
// Datagrams: receipts and watermarks only, after Welcome.
|
||||||
void datagram(std::span<const std::uint8_t> bytes) {
|
void datagram(std::span<const std::uint8_t> bytes) {
|
||||||
if (state != RegionSessionState::established)
|
if (state != RegionSessionState::established)
|
||||||
return;
|
return;
|
||||||
const auto decoded = network::decode_session(bytes);
|
const auto decoded = network::decode_session(bytes);
|
||||||
if (!decoded)
|
if (!decoded)
|
||||||
return end(SessionCloseReason::protocol, true);
|
return protocol_close("datagram decode", static_cast<int>(decoded.error()),
|
||||||
|
bytes.size());
|
||||||
if (const auto* m = std::get_if<network::IntentionReceipt>(&*decoded)) {
|
if (const auto* m = std::get_if<network::IntentionReceipt>(&*decoded)) {
|
||||||
seen_tick(m->server_tick);
|
seen_tick(m->server_tick);
|
||||||
return keep(intention_receipts, *m);
|
return keep(intention_receipts, *m);
|
||||||
@@ -59,8 +68,8 @@ struct RegionSessionClient::Impl {
|
|||||||
if (!snapshots)
|
if (!snapshots)
|
||||||
return; // Before Welcome (channels are not ordered): the next tick resends.
|
return; // Before Welcome (channels are not ordered): the next tick resends.
|
||||||
const auto accepted = snapshots->accept(*m);
|
const auto accepted = snapshots->accept(*m);
|
||||||
if (!accepted)
|
if (!accepted) // Malformed snapshot.
|
||||||
return end(SessionCloseReason::protocol, true); // Malformed snapshot.
|
return protocol_close("snapshot", static_cast<int>(accepted.error()), bytes.size());
|
||||||
if (const auto ack = accepted.value_or(std::nullopt); ack && connection != 0)
|
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.
|
// A lost ack only means the next delta is against an older baseline.
|
||||||
(void)endpoint
|
(void)endpoint
|
||||||
@@ -76,7 +85,7 @@ struct RegionSessionClient::Impl {
|
|||||||
simulated = *m;
|
simulated = *m;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
end(SessionCloseReason::protocol, true);
|
protocol_close("datagram unexpected", static_cast<int>(decoded->index()), bytes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool send(const network::SessionMessage& m) {
|
bool send(const network::SessionMessage& m) {
|
||||||
@@ -100,7 +109,8 @@ struct RegionSessionClient::Impl {
|
|||||||
std::uint16_t wire_version{};
|
std::uint16_t wire_version{};
|
||||||
const auto decoded = network::decode_session(bytes, &wire_version);
|
const auto decoded = network::decode_session(bytes, &wire_version);
|
||||||
if (!decoded)
|
if (!decoded)
|
||||||
return end(SessionCloseReason::protocol, true);
|
return protocol_close("message decode", static_cast<int>(decoded.error()),
|
||||||
|
bytes.size());
|
||||||
if (wire_version != protocol_version)
|
if (wire_version != protocol_version)
|
||||||
return end(SessionCloseReason::unsupported_version, true);
|
return end(SessionCloseReason::unsupported_version, true);
|
||||||
if (const auto* m = std::get_if<network::SessionClose>(&*decoded))
|
if (const auto* m = std::get_if<network::SessionClose>(&*decoded))
|
||||||
@@ -146,7 +156,8 @@ struct RegionSessionClient::Impl {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end(SessionCloseReason::protocol, true);
|
protocol_close("message unexpected",
|
||||||
|
static_cast<int>(decoded->index()) * 100 + wire_version, bytes.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ using network::SessionCloseReason;
|
|||||||
using network::SessionGrantError;
|
using network::SessionGrantError;
|
||||||
using Clock = std::chrono::steady_clock;
|
using Clock = std::chrono::steady_clock;
|
||||||
|
|
||||||
|
// The wire outcome names a life only once it is born; the codec refuses an identity or
|
||||||
|
// commit on any other result. A host may report a pending or refused request's reserved
|
||||||
|
// identity, which stays server-side.
|
||||||
|
network::PrimitiveLifeOutcome wire_outcome(network::PrimitiveLifeOutcome outcome) {
|
||||||
|
if (outcome.result != network::PrimitiveLifeResult::born) {
|
||||||
|
outcome.life_identity = 0;
|
||||||
|
outcome.commit_sequence = 0;
|
||||||
|
}
|
||||||
|
return outcome;
|
||||||
|
}
|
||||||
|
|
||||||
SessionCloseReason reason_for(ControlError e) {
|
SessionCloseReason reason_for(ControlError e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case ControlError::wrong_environment:
|
case ControlError::wrong_environment:
|
||||||
@@ -651,14 +662,16 @@ struct RegionSessions::Impl {
|
|||||||
: network::AdmitStatus::admitted;
|
: network::AdmitStatus::admitted;
|
||||||
send(c, network::PrimitiveLifeReceipt{m->request_id, status, facts.simulated_tick});
|
send(c, network::PrimitiveLifeReceipt{m->request_id, status, facts.simulated_tick});
|
||||||
if (status == network::AdmitStatus::admitted)
|
if (status == network::AdmitStatus::admitted)
|
||||||
send(c, config.create_primitive_life(c.account_id, c.generation, m->request_id));
|
send(c, wire_outcome(config.create_primitive_life(c.account_id, c.generation,
|
||||||
|
m->request_id)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (const auto* m = std::get_if<network::PrimitiveLifeQuery>(&*decoded)) {
|
if (const auto* m = std::get_if<network::PrimitiveLifeQuery>(&*decoded)) {
|
||||||
if (c.generation == 0)
|
if (c.generation == 0)
|
||||||
return send(c, network::PrimitiveLifeOutcome{
|
return send(c, network::PrimitiveLifeOutcome{
|
||||||
m->request_id, network::PrimitiveLifeResult::unknown, 0, 0});
|
m->request_id, network::PrimitiveLifeResult::unknown, 0, 0});
|
||||||
return send(c, config.query_primitive_life(c.account_id, c.generation, m->request_id));
|
return send(c, wire_outcome(config.query_primitive_life(c.account_id, c.generation,
|
||||||
|
m->request_id)));
|
||||||
}
|
}
|
||||||
close(c, SessionCloseReason::protocol, now);
|
close(c, SessionCloseReason::protocol, now);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-1
@@ -640,8 +640,13 @@ void cellular_v5_spawn_and_v7_action_share_region_sessions(const Files& f) {
|
|||||||
f, 5, 64, &control, [&](server::RegionSessionsConfig& c) {
|
f, 5, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||||
c.actions = &actions;
|
c.actions = &actions;
|
||||||
c.accept_cellular_actions = true;
|
c.accept_cellular_actions = true;
|
||||||
|
// Like the cellular host, a refusal reports the reserved identity; only a
|
||||||
|
// born outcome may carry it on the wire.
|
||||||
c.create_primitive_life = [](const AccountId&, std::uint64_t, std::uint64_t request) {
|
c.create_primitive_life = [](const AccountId&, std::uint64_t, std::uint64_t request) {
|
||||||
return PrimitiveLifeOutcome{request, PrimitiveLifeResult::born, 901, 5};
|
return request == 45
|
||||||
|
? PrimitiveLifeOutcome{request, PrimitiveLifeResult::existing_life, 902,
|
||||||
|
0}
|
||||||
|
: PrimitiveLifeOutcome{request, PrimitiveLifeResult::born, 901, 5};
|
||||||
};
|
};
|
||||||
c.query_primitive_life = [](const AccountId&, std::uint64_t, std::uint64_t request) {
|
c.query_primitive_life = [](const AccountId&, std::uint64_t, std::uint64_t request) {
|
||||||
return PrimitiveLifeOutcome{request, PrimitiveLifeResult::pending, 0, 0};
|
return PrimitiveLifeOutcome{request, PrimitiveLifeResult::pending, 0, 0};
|
||||||
@@ -666,6 +671,13 @@ void cellular_v5_spawn_and_v7_action_share_region_sessions(const Files& f) {
|
|||||||
CHECK(h.until(
|
CHECK(h.until(
|
||||||
[&] { return !(birth_outcomes = spawn_client->take_primitive_life_outcomes()).empty(); }));
|
[&] { return !(birth_outcomes = spawn_client->take_primitive_life_outcomes()).empty(); }));
|
||||||
CHECK(birth_outcomes.front() == PrimitiveLifeOutcome{44, PrimitiveLifeResult::born, 901, 5});
|
CHECK(birth_outcomes.front() == PrimitiveLifeOutcome{44, PrimitiveLifeResult::born, 901, 5});
|
||||||
|
// A later client's new request is refused; the session stays open with a valid outcome.
|
||||||
|
CHECK(spawn_client->request_primitive_life(45));
|
||||||
|
CHECK(h.until(
|
||||||
|
[&] { return !(birth_outcomes = spawn_client->take_primitive_life_outcomes()).empty(); }));
|
||||||
|
CHECK(birth_outcomes.front() ==
|
||||||
|
PrimitiveLifeOutcome{45, PrimitiveLifeResult::existing_life, 0, 0} &&
|
||||||
|
spawn_client->state() == RegionSessionState::established);
|
||||||
|
|
||||||
CHECK(action_client->send_cellular_action(55, 101, 0, 0));
|
CHECK(action_client->send_cellular_action(55, 101, 0, 0));
|
||||||
std::vector<ActionReceipt> receipts;
|
std::vector<ActionReceipt> receipts;
|
||||||
|
|||||||
Reference in New Issue
Block a user