feat: durable liquid regions (bundle 14, schema 58), cellular-v9 and session v13
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m25s
Foundation / postgres-tools (push) Successful in 1m12s
Foundation / server-image (push) Successful in 4m20s
Foundation / image (push) Successful in 4m54s

ADR-0178. Bundle 14 (rules 12 on owner format 10) is admitted by schema 58
through parser-local normalization to bundle 13, with an exact fenced 13 -> 14
upgrade whose only input, the liquid rules, recovery reads from the target.
Schema 58 also widens the canonical action input: byte 13 bit 0 is brake.

evo-world-clone gains the cellular-v9 opening: cellular-v8 followed by the liquid
upgrade from --tuning FILE (region size must match) and an optional
--current-seed; resumable and idempotent at bundle 14.

Session v13 adds the owner's velocity, heading and the region's current
configuration to its perception, each deposit's world velocity, and a brake on
cellular actions; older sessions keep their layouts. A rules-12 server lists every
pool and the nearest 256 moving bubbles. The client speaks v13, brakes on Space
(rebindable; older controls files take the default), draws currents as drifting
streaks and carries bubbles along their velocities between perceptions.

Tests: protocol v13 round trips and refusals, action-input brake, controls files,
and a PostgreSQL cellular-v9 provisioning test whose player is born, swims and
brakes through the live host. Full local PostgreSQL qualification, the Linux debug
suite and the Windows client suite pass. Refreshes the DEV session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-21 18:08:59 -04:00
co-authored by Claude Opus 5.5
parent 3f82795c18
commit d2f603b582
39 changed files with 1106 additions and 103 deletions
+15
View File
@@ -121,6 +121,7 @@ constexpr std::array<NamedAction, action_count> actions{{
{"pan_up", "Pan up"},
{"pan_down", "Pan down"},
{"toggle_capture", "Toggle UI capture"},
{"brake", "Brake"},
}};
constexpr KeySlots default_slots{{
{4, no_key}, // A
@@ -132,6 +133,7 @@ constexpr KeySlots default_slots{{
{82, no_key}, // Up
{81, no_key}, // Down
{43, no_key}, // Tab
{44, no_key}, // Space
}};
constexpr std::string_view header = "evo-controls";
@@ -327,6 +329,19 @@ std::expected<Bindings, BindingProblem> parse_bindings(std::string_view text) {
return std::unexpected(problem(BindingError::malformed, action));
slot = {*primary, *secondary};
}
// A file written before an action existed (brake, rules 12) takes that action's default
// key when no other action uses it; otherwise Bindings::make reports it as missing. The
// original version-1 actions stay required.
for (auto k = static_cast<std::size_t>(Action::brake); k < action_count; ++k) {
if (seen[k])
continue;
const auto key = default_slots[k].primary;
const bool taken = std::ranges::any_of(slots, [key](const KeySlot& other) {
return other.primary == key || other.secondary == key;
});
if (!taken)
slots[k] = {key, no_key};
}
if (!versioned)
return std::unexpected(problem(BindingError::malformed));
return Bindings::make(slots); // Missing actions have no primary.
+1 -1
View File
@@ -69,6 +69,6 @@ std::expected<Intention, InputError> InputState::sample(std::uint64_t tick) {
const int magnitude = x != 0 && y != 0 ? 707 : 1000;
tick_ = tick;
return Intention{++sequence_, tick, static_cast<std::int16_t>(x * magnitude),
static_cast<std::int16_t>(y * magnitude)};
static_cast<std::int16_t>(y * magnitude), keys_[8]};
}
} // namespace evo::client
+2
View File
@@ -19,6 +19,8 @@ bool runtime_owned = false; // Process main-thread-only contract; no hidden thre
std::optional<Key> held_key(Action action) noexcept {
if (action == Action::toggle_capture)
return std::nullopt;
if (action == Action::brake)
return Key::brake;
return static_cast<Key>(static_cast<std::uint8_t>(action));
}
static_assert(static_cast<int>(Action::pan_down) == static_cast<int>(Key::pan_down));
+8 -5
View File
@@ -308,17 +308,20 @@ 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, bool engulf, bool bud) {
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target, bool engulf, bool bud,
bool brake) {
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 ||
network::cellular_v10_family(m.protocol_version)) &&
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, engulf, bud});
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, engulf, bud,
// A brake needs v13; older sessions never send one.
brake && m.protocol_version == network::session_protocol_v13});
}
bool RegionSessionClient::send_cellular_mutation(std::uint64_t action_id, std::uint64_t tick,
+2 -2
View File
@@ -240,7 +240,7 @@ ActionReceipt IntentAdmission::action(std::uint64_t session, const CellularActio
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.engulf, m.bud});
m.intake_x_um, m.intake_y_um, m.engulf, m.bud, m.brake});
auto* s = find(session);
if (!s)
return {m.action_id, AdmitStatus::unknown_session, facts.server_tick, m.tick};
@@ -282,7 +282,7 @@ std::optional<ActionReceipt> IntentAdmission::admit(std::uint64_t session, const
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.engulf, m.bud});
m.intake_x_um, m.intake_y_um, m.engulf, m.bud, m.brake});
auto* s = find(session);
if (!s)
return ActionReceipt{m.action_id, AdmitStatus::unknown_session, facts.server_tick, m.tick};
+104 -18
View File
@@ -32,9 +32,17 @@ constexpr std::size_t cellular_perception_v12_prefix_bytes =
cellular_perception_v10_prefix_bytes + 8 + 2 + 6;
// v12: organism, photosynthesis per thousand and 6 reserved bytes.
constexpr std::size_t cellular_perceived_producer_bytes = 8 + 2 + 6;
// v13 (rules 12) appends the owner's velocity (2 x i32) and heading (u16), a flags byte
// (bit 0: currents present), a reserved byte, and the current seed and nine u32 fields.
constexpr std::size_t cellular_liquid_block_bytes = 4 + 4 + 2 + 1 + 1 + 8 + (9 * 4);
constexpr std::size_t cellular_perception_v13_prefix_bytes =
cellular_perception_v12_prefix_bytes + cellular_liquid_block_bytes;
constexpr std::size_t cellular_perceived_patch_bytes = 8 + 8 + (4 * 8);
// v11: id, centre, radius, shape, drained flag and five 16-bit amount codes.
constexpr std::size_t cellular_perceived_deposit_bytes = 4 + 4 + 4 + 2 + 1 + 1 + (5 * 2);
// v13: the same plus world velocity as two 16-bit um/s values.
constexpr std::size_t cellular_perceived_liquid_deposit_bytes =
cellular_perceived_deposit_bytes + 4;
constexpr std::size_t intention_receipt_bytes = 8 + 1 + 8;
constexpr std::size_t simulated_bytes = std::size_t{3} * 8;
constexpr std::size_t action_bytes = (std::size_t{3} * 8) + 2 + 8;
@@ -227,8 +235,20 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
!cellular_v10_family(version) && std::holds_alternative<CellularPerception>(message))
return {};
if (const auto* perception = std::get_if<CellularPerception>(&message)) {
// v12 alone carries captured light and producers (ADR-0176).
const bool producers = version == session_protocol_v12;
// v12 and v13 carry captured light and producers (ADR-0176); v13 alone carries
// liquid motion.
const bool producers = cellular_light_version(version);
const bool liquid = version == session_protocol_v13;
if (!liquid && (perception->currents ||
(perception->diagnostics && (perception->diagnostics->velocity_x_q10 ||
perception->diagnostics->velocity_y_q10 ||
perception->diagnostics->heading)) ||
std::ranges::any_of(perception->deposits, [](const auto& d) {
return d.velocity_x_um_s != 0 || d.velocity_y_um_s != 0;
})))
return {};
if (perception->currents && !perception->life_identity)
return {};
if ((!producers && (!perception->producers.empty() ||
(perception->diagnostics && perception->diagnostics->light_pj))) ||
perception->producers.size() > max_cellular_perceived_producers ||
@@ -337,7 +357,8 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
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 : m.engulf ? 2 : m.bud ? 3 : 0); // Target kind.
put(out, 0, 3);
out.push_back(m.brake ? 1 : 0); // v13 flags: bit 0 brake.
put(out, 0, 2);
put(out, m.intake_x_um, 4);
put(out, m.intake_y_um, 4);
return out;
@@ -386,12 +407,15 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
std::vector<std::uint8_t> operator()(const CellularPerception& m) const {
auto out =
header(SessionMessageType::cellular_perception,
(version == session_protocol_v12 ? cellular_perception_v12_prefix_bytes
: cellular_v10_family(version) ? cellular_perception_v10_prefix_bytes
: version == session_protocol_v9 ? cellular_perception_v9_prefix_bytes
: cellular_perception_prefix_bytes) +
(version == session_protocol_v13 ? cellular_perception_v13_prefix_bytes
: version == session_protocol_v12 ? cellular_perception_v12_prefix_bytes
: cellular_v10_family(version) ? cellular_perception_v10_prefix_bytes
: version == session_protocol_v9 ? cellular_perception_v9_prefix_bytes
: cellular_perception_prefix_bytes) +
m.patches.size() * cellular_perceived_patch_bytes +
m.deposits.size() * cellular_perceived_deposit_bytes +
m.deposits.size() * (version == session_protocol_v13
? cellular_perceived_liquid_deposit_bytes
: cellular_perceived_deposit_bytes) +
m.producers.size() * cellular_perceived_producer_bytes,
version);
put(out, m.tick, 8);
@@ -417,11 +441,25 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
for (const auto value :
d ? d->bud_cost_matter_fg : std::array<std::uint64_t, 4>{})
put(out, value, 8);
if (version == session_protocol_v12) {
if (cellular_light_version(version)) {
put(out, d ? d->light_pj : 0, 8);
put(out, m.producers.size(), 2);
put(out, 0, 6);
}
if (version == session_protocol_v13) {
put(out, static_cast<std::uint32_t>(d ? d->velocity_x_q10 : 0), 4);
put(out, static_cast<std::uint32_t>(d ? d->velocity_y_q10 : 0), 4);
put(out, d ? d->heading : 0, 2);
out.push_back(m.currents ? 1 : 0);
out.push_back(0);
const auto c = m.currents.value_or(CellularCurrentsView{});
put(out, c.seed, 8);
for (const auto value :
{c.width_um, c.height_um, c.pitch_um, c.min_count, c.max_count,
c.min_route_width_um, c.max_route_width_um, c.min_speed_um_per_s,
c.max_speed_um_per_s})
put(out, value, 4);
}
} else {
put(out, 0, 5);
}
@@ -442,6 +480,10 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
out.push_back(deposit.drained ? 1 : 0);
for (const auto code : deposit.amount_codes)
put(out, code, 2);
if (version == session_protocol_v13) {
put(out, static_cast<std::uint16_t>(deposit.velocity_x_um_s), 2);
put(out, static_cast<std::uint16_t>(deposit.velocity_y_um_s), 2);
}
}
for (const auto& producer : m.producers) {
put(out, producer.organism, 8);
@@ -679,12 +721,14 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
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)));
// Target kind: 0 none, 1 patch intake, 2 engulf and 3 bud (v10 only, ADR-0124/0125).
if (payload[36] > (cellular_v10_family(wire_version) ? 3 : 1) || payload[37] != 0 ||
payload[38] != 0 || payload[39] != 0)
if (payload[36] > (cellular_v10_family(wire_version) ? 3 : 1) ||
payload[37] > (wire_version == session_protocol_v13 ? 1 : 0) || payload[38] != 0 ||
payload[39] != 0)
return std::unexpected(SessionCodecError::invalid_value);
m.has_intake_target = payload[36] == 1;
m.engulf = payload[36] == 2;
m.bud = payload[36] == 3;
m.brake = payload[37] == 1;
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 ||
@@ -778,16 +822,19 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
const bool without_bud_cost = wire_version == session_protocol_v10 &&
payload.size() == cellular_perception_v9_prefix_bytes +
count * cellular_perceived_patch_bytes;
const bool lit = wire_version == session_protocol_v12;
const auto prefix = lit ? cellular_perception_v12_prefix_bytes
const bool lit = cellular_light_version(wire_version);
const bool liquid = wire_version == session_protocol_v13;
const auto prefix = liquid ? cellular_perception_v13_prefix_bytes
: lit ? cellular_perception_v12_prefix_bytes
: cellular_v10_family(wire_version) && !without_bud_cost
? cellular_perception_v10_prefix_bytes
: wire_version == session_protocol_v9 || without_bud_cost
? cellular_perception_v9_prefix_bytes
: cellular_perception_prefix_bytes;
const bool deposits = cellular_deposit_version(wire_version);
const auto entry =
deposits ? cellular_perceived_deposit_bytes : cellular_perceived_patch_bytes;
const auto entry = liquid ? cellular_perceived_liquid_deposit_bytes
: deposits ? cellular_perceived_deposit_bytes
: cellular_perceived_patch_bytes;
const auto producer_count = lit && payload.size() >= prefix
? static_cast<std::size_t>(get(
payload, cellular_perception_v10_prefix_bytes + 8, 2))
@@ -833,6 +880,14 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
}
if (lit)
d.light_pj = get(payload, cellular_perception_v10_prefix_bytes, 8);
if (liquid) {
constexpr auto at = cellular_perception_v12_prefix_bytes;
d.velocity_x_q10 =
static_cast<std::int32_t>(static_cast<std::uint32_t>(get(payload, at, 4)));
d.velocity_y_q10 = static_cast<std::int32_t>(
static_cast<std::uint32_t>(get(payload, at + 4, 4)));
d.heading = static_cast<std::uint16_t>(get(payload, at + 8, 2));
}
}
d.movement = static_cast<CellularMovementResult>(payload[74]);
d.intake = static_cast<CellularIntakeResult>(payload[75]);
@@ -847,7 +902,7 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
d.intake != CellularIntakeResult::not_reported ||
d.engulf != CellularEngulfResult::not_reported ||
d.bud != CellularBudOutcome::not_reported || d.bud_cost_energy_pj ||
d.light_pj ||
d.light_pj || d.velocity_x_q10 || d.velocity_y_q10 || d.heading ||
std::ranges::any_of(d.bud_cost_matter_fg,
[](std::uint64_t value) { return value != 0; }))
return std::unexpected(SessionCodecError::invalid_value);
@@ -857,6 +912,29 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
return std::unexpected(SessionCodecError::invalid_value);
if (m.diagnostics && !valid_diagnostics(*m.diagnostics))
return std::unexpected(SessionCodecError::invalid_value);
if (liquid) {
constexpr auto at = cellular_perception_v12_prefix_bytes + 10;
const auto flags = payload[at];
CellularCurrentsView c;
c.seed = get(payload, at + 2, 8);
std::array<std::uint32_t, 9> fields{};
for (std::size_t i = 0; i < fields.size(); ++i)
fields.at(i) = static_cast<std::uint32_t>(get(payload, at + 10 + i * 4, 4));
c.width_um = fields[0];
c.height_um = fields[1];
c.pitch_um = fields[2];
c.min_count = fields[3];
c.max_count = fields[4];
c.min_route_width_um = fields[5];
c.max_route_width_um = fields[6];
c.min_speed_um_per_s = fields[7];
c.max_speed_um_per_s = fields[8];
if (flags > 1 || payload[at + 1] != 0 || (flags == 1 && !m.life_identity) ||
(flags == 0 && c != CellularCurrentsView{}))
return std::unexpected(SessionCodecError::invalid_value);
if (flags == 1)
m.currents = c;
}
std::size_t offset = prefix;
if (deposits) {
m.deposits.reserve(count);
@@ -878,6 +956,12 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
for (std::size_t c = 0; c < d.amount_codes.size(); ++c)
d.amount_codes.at(c) =
static_cast<std::uint16_t>(get(payload, offset + 16 + c * 2, 2));
if (liquid) {
d.velocity_x_um_s = static_cast<std::int16_t>(
static_cast<std::uint16_t>(get(payload, offset + 26, 2)));
d.velocity_y_um_s = static_cast<std::int16_t>(
static_cast<std::uint16_t>(get(payload, offset + 28, 2)));
}
m.deposits.push_back(d);
}
if (!m.life_identity && producer_count)
@@ -1083,7 +1167,8 @@ encode_cellular_action_input(const CellularActionInput& input) {
: input.engulf ? 2
: input.bud ? 3
: 0);
put(bytes, 0, 3);
bytes.push_back(input.brake ? 1 : 0); // Flags (schema 58): bit 0 brake.
put(bytes, 0, 2);
put(bytes, input.intake_x_um, 4);
put(bytes, input.intake_y_um, 4);
std::array<std::uint8_t, cellular_action_input_bytes> out{};
@@ -1095,7 +1180,7 @@ 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] > 3 || bytes[13] != 0 || bytes[14] != 0 || bytes[15] != 0)
if (bytes[12] > 3 || bytes[13] > 1 || bytes[14] != 0 || bytes[15] != 0)
return std::unexpected(SessionCodecError::invalid_value);
CellularActionInput input;
input.tick = get(bytes, 0, 8);
@@ -1104,6 +1189,7 @@ decode_cellular_action_input(std::span<const std::uint8_t> bytes) {
input.has_intake_target = bytes[12] == 1;
input.engulf = bytes[12] == 2;
input.bud = bytes[12] == 3;
input.brake = bytes[13] == 1;
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 ||
+28 -6
View File
@@ -362,6 +362,17 @@ migrate_cellular_photosynthesis_profile(Postgres& db, const FilesystemObjectStor
},
cellular_photosynthesis_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure> migrate_cellular_liquid_profile(
Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, Uuid commit, const Sha256Digest& build,
const server::CellularLiquidRules& rules, milliseconds timeout, const PublishHooks& hooks) {
return migrate_rules_profile(
db, objects, lease, predecessor, commit, build, timeout, hooks,
[rules](std::span<const std::uint8_t> payload, const CheckpointManifest& previous) {
return cellular_liquid_upgrade_payload(payload, previous, rules);
},
cellular_liquid_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_profile_to_v2(Postgres& db, const FilesystemObjectStore& objects,
@@ -650,11 +661,13 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
const bool maturation = m.cellular_versions == cellular_v11_versions;
const bool inheritance = m.cellular_versions == cellular_v12_versions;
const bool photosynthesis = m.cellular_versions == cellular_v13_versions;
const auto derive = photosynthesis ? cellular_photosynthesis_upgrade_manifest
: inheritance ? cellular_inheritance_upgrade_manifest
: maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
const bool liquid = m.cellular_versions == cellular_v14_versions;
const auto derive = liquid ? cellular_liquid_upgrade_manifest
: photosynthesis ? cellular_photosynthesis_upgrade_manifest
: inheritance ? cellular_inheritance_upgrade_manifest
: maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
auto expected = derive(*source, *source_digest, m.commit, recorded, m.build, m.payload_bytes,
m.payload_sha256);
if (!expected || *expected != m)
@@ -662,7 +675,16 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
auto bytes = objects.get({source->payload_sha256, source->payload_bytes});
if (!bytes)
return fail(RecoveryError::tail);
if (photosynthesis) {
if (liquid) {
// The declared liquid rules are the upgrade's only input: read them from the target,
// then require the source to re-derive the exact target bytes with them.
auto target = restore_cellular_payload(payload, m);
if (!target)
return fail(RecoveryError::payload);
auto upgraded = cellular_liquid_upgrade_payload(*bytes, *source, (*target)->liquid_rules());
if (!upgraded || !std::ranges::equal(*upgraded, payload))
return fail(RecoveryError::history);
} else if (photosynthesis) {
// The declared light is the upgrade's only input: read it from the target, then
// require the source to re-derive the exact target bytes with it.
auto target = restore_cellular_payload(payload, m);
+27
View File
@@ -224,4 +224,31 @@ cellular_photosynthesis_upgrade_payload(std::span<const std::uint8_t> payload,
return std::unexpected(CheckpointError::payload);
return (*upgraded)->snapshot();
}
std::expected<CheckpointManifest, CheckpointError>
cellular_liquid_upgrade_manifest(const CheckpointManifest& previous,
const Sha256Digest& previous_digest, Uuid commit,
const LeaseGrant& lease, const Sha256Digest& build,
std::uint64_t bytes, const Sha256Digest& digest) {
if (previous.profile != CheckpointProfile::cellular_lives_v1)
return std::unexpected(CheckpointError::unsupported);
return upgrade_manifest(previous, previous_digest, commit, lease, build, bytes, digest,
cellular_v13_versions, cellular_v14_versions);
}
std::expected<std::vector<std::uint8_t>, CheckpointError>
cellular_liquid_upgrade_payload(std::span<const std::uint8_t> payload,
const CheckpointManifest& previous,
const server::CellularLiquidRules& rules) {
if (!supported(previous) || previous.profile != CheckpointProfile::cellular_lives_v1 ||
previous.cellular_versions != cellular_v13_versions)
return std::unexpected(CheckpointError::unsupported);
if (!encode_manifest(previous) || previous.sequence == 0 || previous.end_tick == 0)
return std::unexpected(CheckpointError::chain);
auto state = restore_cellular_payload(payload, previous);
if (!state)
return std::unexpected(state.error());
auto upgraded = (*state)->liquid_upgrade_candidate(rules);
if (!upgraded)
return std::unexpected(CheckpointError::payload);
return (*upgraded)->snapshot();
}
} // namespace evo::persistence
+3 -2
View File
@@ -105,7 +105,8 @@ bool valid_action_input(const CellularActionRecord& action, std::uint64_t begin_
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] <= 3 &&
all_zero(input.subspan(13, 3)) && (input[12] == 1 || all_zero(input.subspan(16, 8)));
input[13] <= 1 && all_zero(input.subspan(14, 2)) &&
(input[12] == 1 || all_zero(input.subspan(16, 8)));
}
bool action_less(const CellularActionRecord& a, const CellularActionRecord& b) {
const auto a_tick = action_tick(a);
@@ -575,7 +576,7 @@ match_cellular_actions_to_trace(const CellularLives& predecessor, const Cellular
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.engulf != (input[12] == 2) ||
intent->intent.bud != (input[12] == 3))
intent->intent.bud != (input[12] == 3) || intent->intent.brake != (input[13] == 1))
return std::unexpected{CellularActionBlockError::mismatch};
}
return {};
@@ -76,6 +76,8 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
owned_intent->intent.engulf = input->engulf;
// ADR-0125: below rules 4 the owner ignores a bud intent.
owned_intent->intent.bud = input->bud;
// Rules 12: below them the owner refuses a brake, so only v13 sessions send one.
owned_intent->intent.brake = input->brake;
CellularActionRecord record;
record.account = action.account.bytes;
record.action_id = action.action_id;
+14 -3
View File
@@ -628,7 +628,7 @@ struct RegionSessions::Impl {
wire_version == network::session_protocol_v9 ||
network::cellular_v10_family(wire_version)) &&
!cellular_actions) ||
wire_version > network::session_protocol_v12)
wire_version > network::session_protocol_v13)
return close(c, SessionCloseReason::unsupported_version, now);
} else if (wire_version != c.protocol_version) {
return close(c, SessionCloseReason::unsupported_version, now);
@@ -954,12 +954,23 @@ bool RegionSessions::send_cellular_perception(const network::AccountId& account,
delivered.patches.clear();
else
delivered.deposits.clear();
// Only v12 carries captured light and visible producers (ADR-0176).
if (c.protocol_version != network::session_protocol_v12) {
// Only v12 and v13 carry captured light and visible producers (ADR-0176).
if (!network::cellular_light_version(c.protocol_version)) {
delivered.producers.clear();
if (delivered.diagnostics)
delivered.diagnostics->light_pj = 0;
}
// Only v13 carries liquid motion (rules 12).
if (c.protocol_version != network::session_protocol_v13) {
delivered.currents.reset();
if (delivered.diagnostics) {
delivered.diagnostics->velocity_x_q10 = 0;
delivered.diagnostics->velocity_y_q10 = 0;
delivered.diagnostics->heading = 0;
}
for (auto& deposit : delivered.deposits)
deposit.velocity_x_um_s = deposit.velocity_y_um_s = 0;
}
if (c.protocol_version == network::session_protocol_v8)
delivered.diagnostics.reset();
if (c.protocol_version == network::session_protocol_v9 && delivered.diagnostics) {