feat(cellular): session v14, bundle 15 and rules-13 wildlife
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s

Session v14 carries the rules-13 revamp: a body block in the owner's view
(members, emergence threshold, exclusions, Emerge open, payable energy,
mass and the 20 traits), become, emerge and channel exclusions on actions,
become on mutation choices, catalog offers (id, chance, cost) and the
emerged ending. Older sessions never see a v14 field. The client shows
Stay / Become offspring offers named from the shared catalog, continuing
as a bud, the organism and its Emerge button, kept channels, the body and
the emerged end screen.

Bundle 15 (rules 13 on owner format 11) is durable: schema 60 admits it
raw-only, stores become as bit 15 of the choice's operator, widens the
action input and mutation results, and publishes the 14 -> 15 revamp
profile migration. evo-world-clone opens cellular-v10 (cellular-v9 plus the
revamp upgrade from --revamp-tuning), resumable and recoverable.

Wildlife counts reserve matter as energy, waits for the bud fee, grows
organisms one short of emerging, and hunts by the region step's rules-13
engulf test. The play summary adds organisms, offers and the spent pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-26 07:31:32 -04:00
co-authored by Claude Opus 5.5
parent f454e038a1
commit 4bc5d5eee7
48 changed files with 1602 additions and 174 deletions
+26 -8
View File
@@ -78,6 +78,10 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
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;
// Rules 13 (v14): below them the owner refuses each of these.
owned_intent->intent.become = input->become;
owned_intent->intent.emerge = input->emerge;
owned_intent->intent.exclude = input->exclude;
CellularActionRecord record;
record.account = action.account.bytes;
record.action_id = action.action_id;
@@ -101,7 +105,10 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
const auto life_id = little_endian(bytes, 8, 8);
const auto event_index = little_endian(bytes, 16, 8);
const auto offer_tick = little_endian(bytes, 24, 8);
const auto operator_id = static_cast<std::uint16_t>(little_endian(bytes, 32, 2));
const auto stored_operator = static_cast<std::uint16_t>(little_endian(bytes, 32, 2));
const auto operator_id = static_cast<std::uint16_t>(stored_operator & 0x7FFFU);
const bool become = (stored_operator & 0x8000U) != 0;
const bool revamp = state.rules_version() >= cellular_lives_revamp_rules;
// ADR-0121 amendment (schema 59): the reservation's tick is the earliest the choice
// may bind at; the queue binds it at the first tick simulated after admission.
if (reservation.account == persistence::Uuid{} || reservation.action_id == 0 ||
@@ -114,7 +121,17 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
const auto life =
std::ranges::find(state.lives(), life_id,
[](const CellularOwnedLife& value) { return value.identity.life; });
if (life != state.lives().end()) {
if ((become && (!revamp || operator_id == 0)))
return std::unexpected{CellularSessionBatchError::mutation};
if (life != state.lives().end() && revamp) {
// Rules 13: the catalog offer the life holds; operator 0 declines it.
const auto& offer = life->revamp.offer;
const auto end = offer.ids.begin() + offer.count;
if (life->account != reservation.account || offer.count == 0 ||
offer.event_index != event_index || offer.offer_tick != offer_tick ||
(operator_id != 0 && std::ranges::find(offer.ids.begin(), end, operator_id) == end))
return std::unexpected{CellularSessionBatchError::mutation};
} else if (life != state.lives().end()) {
if (life->account != reservation.account || life->mutation.event_index != event_index ||
life->mutation.offer_tick != offer_tick)
return std::unexpected{CellularSessionBatchError::mutation};
@@ -136,12 +153,13 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
previous.action_id == reservation.action_id;
}))
return std::unexpected{CellularSessionBatchError::duplicate_mutation};
prepared.intents.mutations.push_back(
{life_id, event_index, offer_tick, reservation.successor_identity, operator_id});
prepared.mutation_actions.push_back({reservation.account,
reservation.action_id,
tick,
{life_id, event_index, offer_tick, operator_id}});
prepared.intents.mutations.push_back({life_id, event_index, offer_tick,
reservation.successor_identity, operator_id, become});
prepared.mutation_actions.push_back(
{reservation.account,
reservation.action_id,
tick,
{life_id, event_index, offer_tick, operator_id, become}});
}
std::ranges::sort(prepared.intents.mutations, {}, &CellularMutationSelection::life_id);
std::ranges::sort(prepared.mutation_actions, [](const auto& left, const auto& right) {
+24 -6
View File
@@ -152,12 +152,21 @@ struct RegionSessions::Impl {
}
// Reliable owner-only v10 messages, to the account's established v10 session.
bool send_to_v10_owner(const network::AccountId& account,
const network::SessionMessage& message) {
const network::SessionMessage& message, bool named_offer = false) {
for (const auto& c : connections) {
if (c.state != State::established ||
!network::cellular_v10_family(c.protocol_version) || c.account_id != account)
continue;
// Rules 13 offers name catalog mutations (v14); operator offers are v10-v13's.
if (std::holds_alternative<network::CellularMutationOffer>(message) &&
named_offer != (c.protocol_version == network::session_protocol_v14))
return false;
auto delivered = message;
// An emerged ending reads as unrecorded before v14.
if (auto* ended = std::get_if<network::CellularLifeEnded>(&delivered);
ended && ended->cause == network::CellularDeathReason::emerged &&
c.protocol_version != network::session_protocol_v14)
ended->cause = network::CellularDeathReason::unrecorded;
// ADR-0176: before v12 an offer cannot name photosynthesis; its other choices
// stay valid, so those candidates alone are withheld.
if (auto* offer = std::get_if<network::CellularMutationOffer>(&delivered))
@@ -628,7 +637,7 @@ struct RegionSessions::Impl {
wire_version == network::session_protocol_v9 ||
network::cellular_v10_family(wire_version)) &&
!cellular_actions) ||
wire_version > network::session_protocol_v13)
wire_version > network::session_protocol_v14)
return close(c, SessionCloseReason::unsupported_version, now);
} else if (wire_version != c.protocol_version) {
return close(c, SessionCloseReason::unsupported_version, now);
@@ -960,8 +969,17 @@ bool RegionSessions::send_cellular_perception(const network::AccountId& account,
if (delivered.diagnostics)
delivered.diagnostics->light_pj = 0;
}
// Only v13 carries liquid motion (rules 12).
if (c.protocol_version != network::session_protocol_v13) {
// Only v14 carries the rules-13 body block.
if (c.protocol_version != network::session_protocol_v14 && delivered.diagnostics) {
auto& d = *delivered.diagnostics;
d.members = d.emerge_members = 0;
d.exclude = 0;
d.can_emerge = false;
d.payable_energy_pj = d.total_mass_fg = 0;
d.traits = {};
}
// Only v13 and v14 carry liquid motion (rules 12).
if (!network::cellular_liquid_version(c.protocol_version)) {
delivered.currents.reset();
if (delivered.diagnostics) {
delivered.diagnostics->velocity_x_q10 = 0;
@@ -995,8 +1013,8 @@ bool RegionSessions::send_life_ended(const network::AccountId& account,
}
bool RegionSessions::send_mutation_offer(const network::AccountId& account,
const network::CellularMutationOffer& offer) {
return impl_->send_to_v10_owner(account, offer);
const network::CellularMutationOffer& offer, bool named) {
return impl_->send_to_v10_owner(account, offer, named);
}
void RegionSessions::clear_cellular_perceptions(std::uint64_t tick) {