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

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:
dingo
2026-10-13 19:04:46 -04:00
co-authored by Claude Opus 5.5
parent 02adc35fa2
commit e17ade8cb7
15 changed files with 175 additions and 39 deletions
+7 -6
View File
@@ -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;
+11 -6
View File
@@ -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);
}