Carry the engulf intent on v10 sessions and the batch trace
Foundation / checks (ecs) (push) Successful in 2m28s
Foundation / checks (deploy) (push) Successful in 4m6s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 6m47s
Foundation / checks (checks) (push) Canceled after 6m58s
Foundation / checks (client) (push) Canceled after 6m59s
Foundation / checks (tsan) (push) Canceled after 4m28s
Foundation / checks (network) (push) Canceled after 6m58s
Foundation / checks (ecs) (push) Successful in 2m28s
Foundation / checks (deploy) (push) Successful in 4m6s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 6m47s
Foundation / checks (checks) (push) Canceled after 6m58s
Foundation / checks (client) (push) Canceled after 6m59s
Foundation / checks (tsan) (push) Canceled after 4m28s
Foundation / checks (network) (push) Canceled after 6m58s
ADR-0124: byte 12 of the canonical cellular input, the CellularAction wire message and the batch trace record becomes a target kind (0 none, 1 patch, 2 engulf with zero coordinates). Kind 2 exists only on v10, which no server admitted before; cellular servers now admit v10 with v9 behaviour plus engulf, and still refuse a v10 mutation choice until 11.4c. Admission, the session-batch adapter, trace codec, matcher and action-block validator carry the kind. The client session library accepts v10 and an engulf flag, and its send no longer reports a message its version cannot encode as sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ spec:
|
||||
env:
|
||||
- {name: REGION_SESSION, value: "dev"}
|
||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261013T225403-26545:1791942843"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261013T230446-66189:1791943486"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
@@ -30,8 +30,11 @@ must still be resolved correctly.
|
||||
byte 12 of the 24-byte canonical input: 0 none, 1 patch intake at the given
|
||||
patch address, 2 engulf. An engulf intent carries zero coordinates; the server
|
||||
chooses the prey. Clients still send only intentions.
|
||||
- Kind 2 is accepted only on session protocol v11, which otherwise equals v10.
|
||||
Earlier sessions keep refusing it, and their bytes are unchanged.
|
||||
- Kind 2 is accepted only on session protocol v10. v10 was defined for
|
||||
mutation choice (ADR-0121) but no server admitted it yet, so no existing peer
|
||||
changes meaning; v7 to v9 keep refusing kind 2 and their bytes are unchanged.
|
||||
Cellular servers now admit v10 sessions with v9 behaviour plus kind 2; a v10
|
||||
mutation choice is refused until 11.4c wires its publication.
|
||||
|
||||
### Tick order (rules 3)
|
||||
|
||||
@@ -97,7 +100,8 @@ then adds two phases, all in ascending stable life id:
|
||||
## Consequences
|
||||
|
||||
- Biology gains a pure engulf/detritus resolution; the cellular owner, snapshot,
|
||||
manifest bundle, SQL admission, protocol v11, batch trace and recovery change.
|
||||
manifest bundle, SQL admission, v10 session admission, batch trace and
|
||||
recovery change.
|
||||
- Founders are equal in size, so live engulfment needs mutation (11.4) or
|
||||
later growth before it is observable in play.
|
||||
- Size may dominate predation (ADR-0098 risk); 11.9 watches for it, and the
|
||||
|
||||
@@ -428,6 +428,14 @@ scoped change before starting the next segment.
|
||||
inventory. Mutation selection accepts formats 3 and 4. Persistence, protocol
|
||||
and provisioning remain.
|
||||
|
||||
- 11.3f-3 (ADR-0124): engulf travels as target kind 2 in byte 12 of the
|
||||
canonical input, the v10 `CellularAction` and the batch trace, with zero
|
||||
coordinates and never with a patch target. Cellular servers admit v10
|
||||
sessions with v9 behaviour plus kind 2 (a v10 mutation choice is still
|
||||
refused until 11.4c); the client session library offers v10 and an engulf
|
||||
flag, and no longer reports an unencodable message as sent. SQL admission of
|
||||
kind 2 and the rules-3 bundle remain.
|
||||
|
||||
## Exit boundary
|
||||
|
||||
11.3 closes only when the documented segments have evidence and the player-facing
|
||||
|
||||
@@ -7238,4 +7238,23 @@ owner case: engulf-profile genesis, equal-founder `no_eligible_prey`, refused
|
||||
engulf-plus-intake tick, starvation detritus into the patch, per-tick
|
||||
conservation, format-4 round trip and tampered corpse causes); g++-14
|
||||
`-Werror`, clang-tidy-19 (the one remaining `cellular_session_batch.cpp:110`
|
||||
report predates this change) and clang-format 19.1.5.
|
||||
report predates this change) and clang-format 19.1.5.
|
||||
## 2026-10-13 — M11.3f-3 engulf intent on the wire (CI pending)
|
||||
|
||||
Byte 12 of the canonical cellular input, the v10 `CellularAction` and the batch
|
||||
trace intent record is now a target kind (0 none, 1 patch, 2 engulf with zero
|
||||
coordinates). v7-v9 still refuse kind 2. `RegionSessions` admits v10 for
|
||||
cellular servers with v9 behaviour (actions, datagrams, perception); a v10
|
||||
mutation choice still closes with `protocol` until 11.4c. Admission, the
|
||||
session-batch adapter, trace codec, trace/action matcher and action-block
|
||||
validator carry the kind. The client session library accepts v10 and an
|
||||
engulf flag, and its `send` no longer reports an empty (refused) encoding as
|
||||
sent.
|
||||
|
||||
Executed locally: MSVC Debug `ctest` 68/68; client-network build with
|
||||
`cellular-intent-protocol` (new v10 engulf case), `cellular-session-batch`
|
||||
(engulf intent, trace round trip and stripped-flag mismatch) and
|
||||
`quic-sessions` (a v10 client's engulf action admitted and carried; a v7 client
|
||||
cannot send one) passing; `motion-trace-smoke` failed once under `-j 6` load
|
||||
and passed alone. g++-14 `-Werror`, clang-tidy-19 (two existing reports in the
|
||||
mutation test remain) and clang-format 19.1.5.
|
||||
@@ -59,11 +59,13 @@ class RegionSessionClient {
|
||||
// retries and reconnects). False unless established and sent.
|
||||
[[nodiscard]] bool send_action(std::uint64_t action_id, network::ActionKind kind,
|
||||
std::uint64_t tick);
|
||||
// Protocol v7/v8. Reuse the exact same fields and action id after reconnect.
|
||||
// Protocol v7-v10. Reuse the exact same fields and action id after reconnect. `engulf`
|
||||
// (ADR-0124) needs a v10 session and no intake target.
|
||||
[[nodiscard]] bool
|
||||
send_cellular_action(std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x,
|
||||
std::int16_t move_y,
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target = {});
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target = {},
|
||||
bool engulf = false);
|
||||
[[nodiscard]] bool query_action(std::uint64_t action_id);
|
||||
// Primitive profile v5 only. The account and generation are always supplied by the
|
||||
// authenticated session; callers choose only a stable request id.
|
||||
|
||||
@@ -165,11 +165,14 @@ struct CellularIntention {
|
||||
};
|
||||
// Canonical biological input saved with a durable cellular action. Transport session,
|
||||
// epoch and action id are deliberately absent so the same retry survives reconnects.
|
||||
// Byte 12 is the target kind (ADR-0124): 0 none, 1 patch intake, 2 engulf with zero
|
||||
// coordinates. Kind 2 is carried only by v10 sessions.
|
||||
struct CellularActionInput {
|
||||
std::uint64_t tick{};
|
||||
std::int16_t move_x{}, move_y{};
|
||||
bool has_intake_target{};
|
||||
std::uint32_t intake_x_um{}, intake_y_um{};
|
||||
bool engulf{};
|
||||
friend bool operator==(const CellularActionInput&, const CellularActionInput&) = default;
|
||||
};
|
||||
inline constexpr std::size_t cellular_action_input_bytes = 24;
|
||||
@@ -180,6 +183,8 @@ struct CellularAction {
|
||||
std::int16_t move_x{}, move_y{};
|
||||
bool has_intake_target{};
|
||||
std::uint32_t intake_x_um{}, intake_y_um{};
|
||||
// v10 (ADR-0124): engulf a smaller contacted cell; exclusive with an intake target.
|
||||
bool engulf{};
|
||||
friend bool operator==(const CellularAction&, const CellularAction&) = default;
|
||||
};
|
||||
// v10 reliable choice. The server binds these values to the authenticated account and
|
||||
|
||||
@@ -88,10 +88,11 @@ struct RegionSessionClient::Impl {
|
||||
protocol_close("datagram unexpected", static_cast<int>(decoded->index()), bytes.size());
|
||||
}
|
||||
|
||||
// An encoding refused for this session's version (empty) is never sent as success.
|
||||
bool send(const network::SessionMessage& m) {
|
||||
return connection != 0 &&
|
||||
endpoint->send_message(connection, network::encode_session(m, protocol_version))
|
||||
.has_value();
|
||||
const auto bytes = network::encode_session(m, protocol_version);
|
||||
return connection != 0 && !bytes.empty() &&
|
||||
endpoint->send_message(connection, bytes).has_value();
|
||||
}
|
||||
// Ends the session locally; `tell` sends a Close first (best effort).
|
||||
void end(SessionCloseReason why, bool tell) {
|
||||
@@ -171,7 +172,8 @@ RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point
|
||||
config.protocol_version != network::session_protocol_v6 &&
|
||||
config.protocol_version != network::session_protocol_v7 &&
|
||||
config.protocol_version != network::session_protocol_v8 &&
|
||||
config.protocol_version != network::session_protocol_v9)
|
||||
config.protocol_version != network::session_protocol_v9 &&
|
||||
config.protocol_version != network::session_protocol_v10)
|
||||
return std::unexpected(network::quic::EndpointError::configuration);
|
||||
auto endpoint = network::quic::Endpoint::connect(config.transport);
|
||||
if (!endpoint)
|
||||
@@ -274,16 +276,17 @@ bool RegionSessionClient::send_action(std::uint64_t action_id, network::ActionKi
|
||||
|
||||
bool RegionSessionClient::send_cellular_action(
|
||||
std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x, std::int16_t move_y,
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target) {
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target, bool engulf) {
|
||||
auto& m = *impl_;
|
||||
return (m.protocol_version == network::session_protocol_v7 ||
|
||||
m.protocol_version == network::session_protocol_v8 ||
|
||||
m.protocol_version == network::session_protocol_v9) &&
|
||||
m.protocol_version == network::session_protocol_v9 ||
|
||||
m.protocol_version == network::session_protocol_v10) &&
|
||||
m.state == RegionSessionState::established && m.welcome && action_id != 0 && tick != 0 &&
|
||||
m.send(network::CellularAction{m.welcome->session, m.welcome->epoch, action_id, tick,
|
||||
move_x, move_y, intake_target.has_value(),
|
||||
intake_target ? intake_target->first : 0,
|
||||
intake_target ? intake_target->second : 0});
|
||||
intake_target ? intake_target->second : 0, engulf});
|
||||
}
|
||||
|
||||
bool RegionSessionClient::query_action(std::uint64_t action_id) {
|
||||
@@ -291,7 +294,8 @@ bool RegionSessionClient::query_action(std::uint64_t action_id) {
|
||||
return (m.protocol_version == network::session_protocol_version ||
|
||||
m.protocol_version == network::session_protocol_v7 ||
|
||||
m.protocol_version == network::session_protocol_v8 ||
|
||||
m.protocol_version == network::session_protocol_v9) &&
|
||||
m.protocol_version == network::session_protocol_v9 ||
|
||||
m.protocol_version == network::session_protocol_v10) &&
|
||||
m.state == RegionSessionState::established && m.send(network::ActionQuery{action_id});
|
||||
}
|
||||
|
||||
@@ -299,7 +303,8 @@ bool RegionSessionClient::request_primitive_life(std::uint64_t request_id) {
|
||||
auto& m = *impl_;
|
||||
return (m.protocol_version == network::session_protocol_v5 ||
|
||||
m.protocol_version == network::session_protocol_v8 ||
|
||||
m.protocol_version == network::session_protocol_v9) &&
|
||||
m.protocol_version == network::session_protocol_v9 ||
|
||||
m.protocol_version == network::session_protocol_v10) &&
|
||||
m.state == RegionSessionState::established && m.welcome && request_id != 0 &&
|
||||
m.send(network::PrimitiveLifeRequest{m.welcome->session, m.welcome->epoch, request_id});
|
||||
}
|
||||
@@ -308,7 +313,8 @@ bool RegionSessionClient::query_primitive_life(std::uint64_t request_id) {
|
||||
auto& m = *impl_;
|
||||
return (m.protocol_version == network::session_protocol_v5 ||
|
||||
m.protocol_version == network::session_protocol_v8 ||
|
||||
m.protocol_version == network::session_protocol_v9) &&
|
||||
m.protocol_version == network::session_protocol_v9 ||
|
||||
m.protocol_version == network::session_protocol_v10) &&
|
||||
m.state == RegionSessionState::established && request_id != 0 &&
|
||||
m.send(network::PrimitiveLifeQuery{request_id});
|
||||
}
|
||||
@@ -346,7 +352,8 @@ bool RegionSessionClient::set_interest(const network::SessionInterest& interest)
|
||||
return (m.protocol_version == network::session_protocol_version ||
|
||||
m.protocol_version == network::session_protocol_v7 ||
|
||||
m.protocol_version == network::session_protocol_v8 ||
|
||||
m.protocol_version == network::session_protocol_v9) &&
|
||||
m.protocol_version == network::session_protocol_v9 ||
|
||||
m.protocol_version == network::session_protocol_v10) &&
|
||||
m.state == RegionSessionState::established && m.send(interest);
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ ActionReceipt IntentAdmission::action(std::uint64_t session, const CellularActio
|
||||
const SessionAction base{m.session, m.epoch, m.action_id,
|
||||
static_cast<std::uint16_t>(ActionKind::cellular), m.tick};
|
||||
const auto bytes = encode_cellular_action_input(
|
||||
{m.tick, m.move_x, m.move_y, m.has_intake_target, m.intake_x_um, m.intake_y_um});
|
||||
{m.tick, m.move_x, m.move_y, m.has_intake_target, m.intake_x_um, m.intake_y_um, m.engulf});
|
||||
auto* s = find(session);
|
||||
if (!s)
|
||||
return {m.action_id, AdmitStatus::unknown_session, facts.server_tick, m.tick};
|
||||
@@ -280,7 +280,7 @@ std::optional<ActionReceipt> IntentAdmission::admit(std::uint64_t session, const
|
||||
const SessionAction base{m.session, m.epoch, m.action_id,
|
||||
static_cast<std::uint16_t>(ActionKind::cellular), m.tick};
|
||||
const auto bytes = encode_cellular_action_input(
|
||||
{m.tick, m.move_x, m.move_y, m.has_intake_target, m.intake_x_um, m.intake_y_um});
|
||||
{m.tick, m.move_x, m.move_y, m.has_intake_target, m.intake_x_um, m.intake_y_um, m.engulf});
|
||||
auto* s = find(session);
|
||||
if (!s)
|
||||
return ActionReceipt{m.action_id, AdmitStatus::unknown_session, facts.server_tick, m.tick};
|
||||
|
||||
@@ -161,6 +161,11 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
|
||||
return {};
|
||||
if (version != session_protocol_v10 && std::holds_alternative<CellularMutationAction>(message))
|
||||
return {};
|
||||
if (const auto* action = std::get_if<CellularAction>(&message);
|
||||
action && action->engulf &&
|
||||
(version != session_protocol_v10 || action->has_intake_target || action->intake_x_um ||
|
||||
action->intake_y_um))
|
||||
return {};
|
||||
if (version != session_protocol_v8 && version != session_protocol_v9 &&
|
||||
version != session_protocol_v10 && std::holds_alternative<CellularPerception>(message))
|
||||
return {};
|
||||
@@ -241,7 +246,7 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
|
||||
put(out, v, 8);
|
||||
put(out, static_cast<std::uint16_t>(m.move_x), 2);
|
||||
put(out, static_cast<std::uint16_t>(m.move_y), 2);
|
||||
out.push_back(m.has_intake_target ? 1 : 0);
|
||||
out.push_back(m.has_intake_target ? 1 : m.engulf ? 2 : 0); // Target kind.
|
||||
put(out, 0, 3);
|
||||
put(out, m.intake_x_um, 4);
|
||||
put(out, m.intake_y_um, 4);
|
||||
@@ -518,9 +523,12 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
|
||||
m.tick = get(payload, 24, 8);
|
||||
m.move_x = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(payload, 32, 2)));
|
||||
m.move_y = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(payload, 34, 2)));
|
||||
if (payload[36] > 1 || payload[37] != 0 || payload[38] != 0 || payload[39] != 0)
|
||||
// Target kind: 0 none, 1 patch intake, 2 engulf (v10 only, ADR-0124).
|
||||
if (payload[36] > (wire_version == session_protocol_v10 ? 2 : 1) || payload[37] != 0 ||
|
||||
payload[38] != 0 || payload[39] != 0)
|
||||
return std::unexpected(SessionCodecError::invalid_value);
|
||||
m.has_intake_target = payload[36] != 0;
|
||||
m.has_intake_target = payload[36] == 1;
|
||||
m.engulf = payload[36] == 2;
|
||||
m.intake_x_um = static_cast<std::uint32_t>(get(payload, 40, 4));
|
||||
m.intake_y_um = static_cast<std::uint32_t>(get(payload, 44, 4));
|
||||
if (!m.session || !m.epoch || !m.action_id || !m.tick ||
|
||||
@@ -781,7 +789,7 @@ encode_cellular_action_input(const CellularActionInput& input) {
|
||||
put(bytes, input.tick, 8);
|
||||
put(bytes, static_cast<std::uint16_t>(input.move_x), 2);
|
||||
put(bytes, static_cast<std::uint16_t>(input.move_y), 2);
|
||||
bytes.push_back(input.has_intake_target ? 1 : 0);
|
||||
bytes.push_back(input.has_intake_target ? 1 : input.engulf ? 2 : 0); // Target kind.
|
||||
put(bytes, 0, 3);
|
||||
put(bytes, input.intake_x_um, 4);
|
||||
put(bytes, input.intake_y_um, 4);
|
||||
@@ -794,13 +802,14 @@ std::expected<CellularActionInput, SessionCodecError>
|
||||
decode_cellular_action_input(std::span<const std::uint8_t> bytes) {
|
||||
if (bytes.size() != cellular_action_input_bytes)
|
||||
return std::unexpected(SessionCodecError::wrong_length);
|
||||
if (bytes[12] > 1 || bytes[13] != 0 || bytes[14] != 0 || bytes[15] != 0)
|
||||
if (bytes[12] > 2 || bytes[13] != 0 || bytes[14] != 0 || bytes[15] != 0)
|
||||
return std::unexpected(SessionCodecError::invalid_value);
|
||||
CellularActionInput input;
|
||||
input.tick = get(bytes, 0, 8);
|
||||
input.move_x = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(bytes, 8, 2)));
|
||||
input.move_y = static_cast<std::int16_t>(static_cast<std::uint16_t>(get(bytes, 10, 2)));
|
||||
input.has_intake_target = bytes[12] != 0;
|
||||
input.has_intake_target = bytes[12] == 1;
|
||||
input.engulf = bytes[12] == 2;
|
||||
input.intake_x_um = static_cast<std::uint32_t>(get(bytes, 16, 4));
|
||||
input.intake_y_um = static_cast<std::uint32_t>(get(bytes, 20, 4));
|
||||
if (input.tick == 0 ||
|
||||
|
||||
@@ -36,7 +36,7 @@ bool valid_intent(const CellularLifeIntent& life) {
|
||||
const auto& step = life.intent;
|
||||
return life.life_id != 0 && step.movement.x >= -movement_limit &&
|
||||
step.movement.x <= movement_limit && step.movement.y >= -movement_limit &&
|
||||
step.movement.y <= movement_limit;
|
||||
step.movement.y <= movement_limit && !(step.engulf && step.intake_target);
|
||||
}
|
||||
bool valid_ticks(std::span<const CellularTickIntents> ticks) {
|
||||
std::set<std::uint64_t> identities;
|
||||
@@ -83,7 +83,7 @@ bool valid_action_input(const CellularActionRecord& action, std::uint64_t begin_
|
||||
const auto move_y = std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 10, 2)));
|
||||
return !all_zero(action.account) && action.action_id != 0 && tick > begin_tick &&
|
||||
tick <= end_tick && move_x >= -movement_limit && move_x <= movement_limit &&
|
||||
move_y >= -movement_limit && move_y <= movement_limit && input[12] <= 1 &&
|
||||
move_y >= -movement_limit && move_y <= movement_limit && input[12] <= 2 &&
|
||||
all_zero(input.subspan(13, 3)) && (input[12] == 1 || all_zero(input.subspan(16, 8)));
|
||||
}
|
||||
bool action_less(const CellularActionRecord& a, const CellularActionRecord& b) {
|
||||
@@ -137,7 +137,7 @@ void put_intent(std::vector<std::uint8_t>& out, const CellularLifeIntent& life)
|
||||
put(out, life.life_id, 8);
|
||||
put(out, static_cast<std::uint16_t>(life.intent.movement.x), 2);
|
||||
put(out, static_cast<std::uint16_t>(life.intent.movement.y), 2);
|
||||
out.push_back(life.intent.intake_target ? 1 : 0);
|
||||
out.push_back(life.intent.intake_target ? 1 : life.intent.engulf ? 2 : 0); // Target kind.
|
||||
put(out, 0, 3);
|
||||
put(out, life.intent.intake_target ? life.intent.intake_target->x_um : 0, 4);
|
||||
put(out, life.intent.intake_target ? life.intent.intake_target->y_um : 0, 4);
|
||||
@@ -287,7 +287,7 @@ decode_cellular_batch(std::span<const std::uint8_t> bytes) {
|
||||
step.lives.reserve(static_cast<std::size_t>(count));
|
||||
for (std::uint64_t i = 0; i < count; ++i) {
|
||||
const auto record = bytes.subspan(offset, cellular_batch_intent_bytes);
|
||||
if (record[12] > 1 || !all_zero(record.subspan(13, 3)))
|
||||
if (record[12] > 2 || !all_zero(record.subspan(13, 3)))
|
||||
return std::unexpected{CellularBatchError::format};
|
||||
CellularLifeIntent life;
|
||||
life.life_id = get(record, 0, 8);
|
||||
@@ -302,6 +302,7 @@ decode_cellular_batch(std::span<const std::uint8_t> bytes) {
|
||||
} else if (!all_zero(record.subspan(16, 8))) {
|
||||
return std::unexpected{CellularBatchError::format};
|
||||
}
|
||||
life.intent.engulf = record[12] == 2; // ADR-0124 target kind.
|
||||
if (!valid_intent(life) ||
|
||||
(!step.lives.empty() && step.lives.back().life_id >= life.life_id))
|
||||
return std::unexpected{CellularBatchError::format};
|
||||
@@ -492,14 +493,14 @@ match_cellular_actions_to_trace(const CellularLives& predecessor, const Cellular
|
||||
return std::unexpected{CellularActionBlockError::mismatch};
|
||||
const auto input = std::span<const std::uint8_t>{action.input};
|
||||
std::optional<biology::CellularPatchAddress> target;
|
||||
if (input[12] != 0)
|
||||
if (input[12] == 1)
|
||||
target = biology::CellularPatchAddress{static_cast<std::uint32_t>(get(input, 16, 4)),
|
||||
static_cast<std::uint32_t>(get(input, 20, 4))};
|
||||
if (intent->intent.movement.x !=
|
||||
std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 8, 2))) ||
|
||||
intent->intent.movement.y !=
|
||||
std::bit_cast<std::int16_t>(static_cast<std::uint16_t>(get(input, 10, 2))) ||
|
||||
intent->intent.intake_target != target)
|
||||
intent->intent.intake_target != target || intent->intent.engulf != (input[12] == 2))
|
||||
return std::unexpected{CellularActionBlockError::mismatch};
|
||||
}
|
||||
return {};
|
||||
|
||||
@@ -72,6 +72,8 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
|
||||
? std::optional<biology::CellularPatchAddress>{biology::CellularPatchAddress{
|
||||
input->intake_x_um, input->intake_y_um}}
|
||||
: std::nullopt;
|
||||
// ADR-0124: a rules-2 region reports the intent unsupported and ignores it.
|
||||
owned_intent->intent.engulf = input->engulf;
|
||||
CellularActionRecord record;
|
||||
record.account = action.account.bytes;
|
||||
record.action_id = action.action_id;
|
||||
|
||||
@@ -434,7 +434,8 @@ struct RegionSessions::Impl {
|
||||
(config.accept_cellular_actions &&
|
||||
(c.protocol_version == network::session_protocol_v7 ||
|
||||
c.protocol_version == network::session_protocol_v8 ||
|
||||
c.protocol_version == network::session_protocol_v9)))))
|
||||
c.protocol_version == network::session_protocol_v9 ||
|
||||
c.protocol_version == network::session_protocol_v10)))))
|
||||
return close(c, SessionCloseReason::protocol, now);
|
||||
if (const auto* ack = std::get_if<network::SnapshotAck>(&*decoded))
|
||||
return replication.acknowledge(c.session, *ack);
|
||||
@@ -602,9 +603,10 @@ struct RegionSessions::Impl {
|
||||
(wire_version == network::session_protocol_v6 && !cellular_v6) ||
|
||||
((wire_version == network::session_protocol_v7 ||
|
||||
wire_version == network::session_protocol_v8 ||
|
||||
wire_version == network::session_protocol_v9) &&
|
||||
wire_version == network::session_protocol_v9 ||
|
||||
wire_version == network::session_protocol_v10) &&
|
||||
!cellular_actions) ||
|
||||
wire_version > network::session_protocol_v9)
|
||||
wire_version > network::session_protocol_v10)
|
||||
return close(c, SessionCloseReason::unsupported_version, now);
|
||||
} else if (wire_version != c.protocol_version) {
|
||||
return close(c, SessionCloseReason::unsupported_version, now);
|
||||
@@ -629,7 +631,8 @@ struct RegionSessions::Impl {
|
||||
if (const auto* m = std::get_if<network::CellularAction>(&*decoded)) {
|
||||
if (c.protocol_version != network::session_protocol_v7 &&
|
||||
c.protocol_version != network::session_protocol_v8 &&
|
||||
c.protocol_version != network::session_protocol_v9)
|
||||
c.protocol_version != network::session_protocol_v9 &&
|
||||
c.protocol_version != network::session_protocol_v10)
|
||||
return close(c, SessionCloseReason::protocol, now);
|
||||
if (const auto receipt = intents.admit(c.session, *m, admission()))
|
||||
answer(c, *receipt);
|
||||
@@ -898,7 +901,8 @@ bool RegionSessions::send_cellular_perception(const network::AccountId& account,
|
||||
for (const auto& c : m.connections) {
|
||||
if (c.state != Impl::State::established ||
|
||||
(c.protocol_version != network::session_protocol_v8 &&
|
||||
c.protocol_version != network::session_protocol_v9) ||
|
||||
c.protocol_version != network::session_protocol_v9 &&
|
||||
c.protocol_version != network::session_protocol_v10) ||
|
||||
c.account_id != account)
|
||||
continue;
|
||||
auto delivered = perception;
|
||||
@@ -919,7 +923,8 @@ void RegionSessions::clear_cellular_perceptions(std::uint64_t tick) {
|
||||
for (const auto& c : m.connections)
|
||||
if (c.state == Impl::State::established &&
|
||||
(c.protocol_version == network::session_protocol_v8 ||
|
||||
c.protocol_version == network::session_protocol_v9))
|
||||
c.protocol_version == network::session_protocol_v9 ||
|
||||
c.protocol_version == network::session_protocol_v10))
|
||||
m.send(c, cleared);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,45 @@ void v7_reliable_action_is_stable_and_strict() {
|
||||
CHECK(!decode_cellular_action_input(malformed_input));
|
||||
}
|
||||
|
||||
// ADR-0124: target kind 2 (engulf) exists only on v10, without coordinates or a patch.
|
||||
void v10_engulf_action_is_versioned_and_exclusive() {
|
||||
CellularAction engulf{17, 23, 29, 31, 5, -5, false, 0, 0};
|
||||
engulf.engulf = true;
|
||||
const auto bytes = encode_session(SessionMessage{engulf}, session_protocol_v10);
|
||||
CHECK(bytes.size() == session_header_bytes + 48 && bytes[session_header_bytes + 36] == 2);
|
||||
std::uint16_t version{};
|
||||
const auto decoded = decode_session(bytes, &version);
|
||||
CHECK(decoded && version == session_protocol_v10 &&
|
||||
std::get<CellularAction>(*decoded) == engulf);
|
||||
CHECK(encode_session(SessionMessage{engulf}, session_protocol_v9).empty());
|
||||
CHECK(encode_session(SessionMessage{engulf}).empty()); // The default v7 has no engulf.
|
||||
auto with_patch = engulf;
|
||||
with_patch.has_intake_target = true;
|
||||
CHECK(encode_session(SessionMessage{with_patch}, session_protocol_v10).empty());
|
||||
// A v9 decoder refuses kind 2 even with a valid layout.
|
||||
auto as_v9 = bytes;
|
||||
as_v9[4] = static_cast<std::uint8_t>(session_protocol_v9);
|
||||
CHECK(!decode_session(as_v9));
|
||||
// Coordinates are reserved for a patch target.
|
||||
auto placed = bytes;
|
||||
placed[session_header_bytes + 40] = 1;
|
||||
CHECK(!decode_session(placed));
|
||||
// A patch action on v10 is unchanged.
|
||||
const CellularAction feed{17, 23, 30, 31, 0, 0, true, 1'000, 2'000};
|
||||
const auto feed_bytes = encode_session(SessionMessage{feed}, session_protocol_v10);
|
||||
CHECK(std::get<CellularAction>(*decode_session(feed_bytes)) == feed);
|
||||
|
||||
CellularActionInput input{31, 5, -5, false, 0, 0, true};
|
||||
const auto canonical = encode_cellular_action_input(input);
|
||||
CHECK(canonical[12] == 2 && decode_cellular_action_input(canonical) == input);
|
||||
auto coordinated = canonical;
|
||||
coordinated[16] = 1;
|
||||
CHECK(!decode_cellular_action_input(coordinated));
|
||||
auto unknown_kind = canonical;
|
||||
unknown_kind[12] = 3;
|
||||
CHECK(!decode_cellular_action_input(unknown_kind));
|
||||
}
|
||||
|
||||
void v8_perception_is_bounded_and_canonical() {
|
||||
CellularPerception perception{19, 42, {}, std::nullopt};
|
||||
perception.patches = {
|
||||
@@ -223,6 +262,7 @@ int main() {
|
||||
round_trip_and_version_gate();
|
||||
malformed_frames_are_refused();
|
||||
v7_reliable_action_is_stable_and_strict();
|
||||
v10_engulf_action_is_versioned_and_exclusive();
|
||||
v8_perception_is_bounded_and_canonical();
|
||||
v9_perception_carries_only_valid_owner_diagnostics();
|
||||
v10_mutation_choice_is_a_strict_reliable_action();
|
||||
|
||||
@@ -80,6 +80,28 @@ void actions_bind_to_owned_life_and_preserve_other_inputs() {
|
||||
CHECK(prepare_cellular_session_tick(**state, 2, baseline, guessed_actions).error() ==
|
||||
CellularSessionBatchError::unperceived_target);
|
||||
|
||||
// ADR-0124: an engulf action becomes the life's engulf intent, and the trace keeps it.
|
||||
const auto engulf_input = network::encode_cellular_action_input({2, 1, 0, false, 0, 0, true});
|
||||
const network::CarriedAction engulf_action{network::AccountId{controlled.account}, 79, 2,
|
||||
network::ActionKind::cellular, engulf_input};
|
||||
const std::array engulf_actions{engulf_action};
|
||||
const auto engulfing = prepare_cellular_session_tick(**state, 2, baseline, engulf_actions);
|
||||
CHECK(engulfing && engulfing->intents.lives[0].intent.engulf &&
|
||||
!engulfing->intents.lives[0].intent.intake_target);
|
||||
CellularBatch engulf_batch;
|
||||
engulf_batch.header = {(*state)->world(), (*state)->region(), (*state)->frame(), {}, {}, 1, 2};
|
||||
engulf_batch.header.predecessor.fill(1);
|
||||
engulf_batch.header.predecessor_digest.fill(2);
|
||||
engulf_batch.ticks.push_back(engulfing->intents);
|
||||
CHECK(match_cellular_actions_to_trace(**state, engulf_batch, engulfing->actions));
|
||||
const auto engulf_bytes = encode_cellular_batch(engulf_batch);
|
||||
CHECK(engulf_bytes);
|
||||
const auto engulf_decoded = decode_cellular_batch(*engulf_bytes);
|
||||
CHECK(engulf_decoded && *engulf_decoded == engulf_batch);
|
||||
auto stripped = engulf_batch;
|
||||
stripped.ticks[0].lives[0].intent.engulf = false;
|
||||
CHECK(!match_cellular_actions_to_trace(**state, stripped, engulfing->actions));
|
||||
|
||||
CellularBatch batch;
|
||||
batch.header = {(*state)->world(), (*state)->region(), (*state)->frame(), {}, {}, 1, 2};
|
||||
batch.header.predecessor.fill(1);
|
||||
|
||||
+13
-1
@@ -637,7 +637,7 @@ void cellular_v5_spawn_and_v7_action_share_region_sessions(const Files& f) {
|
||||
} actions;
|
||||
FakeLedger control;
|
||||
Harness h{
|
||||
f, 5, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||
f, 6, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||
c.actions = &actions;
|
||||
c.accept_cellular_actions = true;
|
||||
// Like the cellular host, a refusal reports the reserved identity; only a
|
||||
@@ -687,6 +687,18 @@ void cellular_v5_spawn_and_v7_action_share_region_sessions(const Files& f) {
|
||||
CHECK(carried.size() == 1 && carried.front().account == account(0xB7) &&
|
||||
carried.front().kind == ActionKind::cellular);
|
||||
|
||||
// ADR-0124: a v10 session carries an engulf action; a v7 session cannot encode one.
|
||||
auto engulf_client = h.connect(h.issuer.grant(account(0xBB), 1), session_protocol_v10);
|
||||
CHECK(h.settled(*engulf_client) && engulf_client->state() == RegionSessionState::established);
|
||||
CHECK(!action_client->send_cellular_action(56, 102, 0, 0, std::nullopt, true));
|
||||
CHECK(engulf_client->send_cellular_action(66, 102, 0, 0, std::nullopt, true));
|
||||
CHECK(h.until([&] { return !(receipts = engulf_client->take_action_receipts()).empty(); }));
|
||||
CHECK(receipts.front().status == AdmitStatus::admitted);
|
||||
const auto engulfing = h.server->carry(102);
|
||||
CHECK(engulfing.size() == 1 && engulfing.front().account == account(0xBB) &&
|
||||
engulfing.front().cellular_input ==
|
||||
std::optional{encode_cellular_action_input({102, 0, 0, false, 0, 0, true})});
|
||||
|
||||
h.server->set_default_interest({0, 0, 0, 7});
|
||||
h.source = [](const SessionInterest&) {
|
||||
ReplicationSource source;
|
||||
|
||||
Reference in New Issue
Block a user