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
+145
View File
@@ -323,6 +323,150 @@ void durable_mutation_reservations_bind_to_the_exact_offer() {
(*departed_replay)->lives()[0].mutation.offer.has_value());
}
// Rules 13 (session v14): emerge, become and exclusions reach the owner's intents and the trace
// check, and a catalog choice with become binds to the revamp offer through its reservation.
std::unique_ptr<CellularLives> revamp_owner() {
const auto endowment = biology::primitive_endowment(biology::primitive_founder_v3);
CHECK(endowment);
auto funding = endowment->body;
funding.energy.value = 2 * (endowment->reserve.energy.value + endowment->construction.value);
for (auto& channel : funding.matter)
channel.value *= 2;
auto primitive =
PrimitiveLives::create({94, 1, 1, 17, funding, {{1'000, 1'000}, {1'000, 4'000}}});
CHECK(primitive);
biology::CellularHabitatConfig config{94, 1, 1, 48'000, 48'000, {}};
config.format = biology::cellular_habitat_deposit_format;
auto habitat = biology::CellularHabitat::create(std::move(config));
CHECK(habitat);
auto created =
CellularLives::create(**primitive, std::move(*habitat), {{48'000, 48'000}, 0, 293'150},
CellularLivesProfile::foraging);
CHECK(created);
auto state = std::move(*created);
CHECK(state->advance_tick(std::span<const CellularLifeIntent>{}));
const auto step = [&](auto next) {
CHECK(next);
state = std::move(*next);
};
step(state->migration_upgrade_candidate());
step(state->maturation_upgrade_candidate());
step(state->inheritance_upgrade_candidate());
step(state->photosynthesis_upgrade_candidate({0, 1, {0}}));
step(state->liquid_upgrade_candidate(
{.currents = {5, 48'000, 48'000, 250, 2, 4, 3'000, 6'000, 60, 300},
.founder = {.thrust_q10 = 20'480,
.reverse_thrust_q10 = 20'480,
.forward_drag_ppm = 95'163,
.lateral_drag_ppm = 95'163,
.turn = 3'276},
.deposits = {.drift_radius_um = 200,
.max_drift_q10 = 100 * 1'024,
.drift_decay_ppm = 95'163,
.merged_cap = 8,
.bubble_radius_um = biology::cellular_mote_radius_um}}));
CellularRevampRules rules{.burn_pj_per_kfg = {2'000, 2'000, 2'000, 2'000},
.step = {.membrane_collection_per_mille_per_point = 2,
.engulf_ratio_milli = 1'500,
.engulf_reserve_percent = 100,
.kill_bubble_per_thousand = 500},
.drip_interval_ticks = 20,
.drip_bubble_pj = 20'000'000,
.drip_bubble_fg = 1'000'000,
.reserve_load_per_thousand = 1'000};
rules.offer_interval_ticks = 40;
step(state->revamp_upgrade_candidate(rules));
LifeRequest request{};
request.account.back() = 2;
request.action = 1;
step(state->birth_candidate(request, {101, 101, 101, 101, {state->tick()}}));
return state;
}
void rules_13_actions_and_choices_bind() {
auto state = revamp_owner();
for (int tick = 0; tick < 40; ++tick) {
const std::array swim{CellularLifeIntent{101, {{1'000, 0}, {}}}};
CHECK(state->advance_tick(swim));
}
const auto& life = state->lives().front();
CHECK(life.identity.life == 101 && life.revamp.offer.count == 3);
const auto tick = state->tick() + 1;
const std::array baseline{CellularLifeIntent{101, {}}};
// Emerge and exclusions travel in the canonical input and must match the trace.
const auto input = network::encode_cellular_action_input(
{tick, 300, 0, false, 0, 0, false, false, false, false, true, 0b0101});
const std::array actions{network::CarriedAction{network::AccountId{life.account}, 90, tick,
network::ActionKind::cellular, input}};
const auto prepared = prepare_cellular_session_tick(*state, tick, baseline, actions);
CHECK(prepared && prepared->intents.lives[0].intent.emerge &&
prepared->intents.lives[0].intent.exclude == 0b0101);
CellularBatch batch;
batch.format_version = cellular_batch_inheritance_format;
batch.header = {state->world(), state->region(), state->frame(), {}, {}, state->tick(), tick};
batch.header.predecessor.fill(1);
batch.header.predecessor_digest.fill(2);
batch.ticks.push_back(prepared->intents);
CHECK(match_cellular_actions_to_trace(*state, batch, prepared->actions));
auto kept = batch;
kept.ticks[0].lives[0].intent.exclude = 0;
CHECK(!match_cellular_actions_to_trace(*state, kept, prepared->actions));
// A catalog choice with become (bit 15 of the stored operator).
persistence::CellularMutationReservation reservation;
reservation.account = life.account;
reservation.action_id = 43;
reservation.region = state->region();
reservation.generation = 7;
reservation.target_tick = tick;
reservation.successor_identity = 9'500;
const auto put_field = [&](std::size_t offset, std::uint64_t value, std::size_t bytes) {
for (std::size_t i = 0; i < bytes; ++i)
reservation.input[offset + i] = static_cast<std::uint8_t>(value >> (i * 8U));
};
const auto chosen = life.revamp.offer.ids.at(0);
put_field(0, tick, 8);
put_field(8, 101, 8);
put_field(16, life.revamp.offer.event_index, 8);
put_field(24, life.revamp.offer.offer_tick, 8);
put_field(32, chosen | 0x8000U, 2);
persistence::RegionHead head{};
head.frame = state->frame();
head.sequence = 3;
head.end_tick = state->tick();
head.commit.fill(0x31);
head.digest.fill(0x41);
auto builder = CellularSessionBatchBuilder::create(*state, head);
CHECK(builder);
const std::array reservations{reservation};
CHECK(builder->append(tick, baseline, {}, {}, reservations));
const auto& selection = builder->batch().ticks.back().mutations.front();
CHECK(selection.become && selection.operator_id == chosen &&
builder->mutation_actions().front().input.become &&
encode_cellular_mutation_input(builder->mutation_actions().front())[33] >= 0x80 &&
match_cellular_mutation_actions_to_trace(*state, builder->batch(),
builder->mutation_actions()));
std::vector<CellularMutationOutcome> outcomes;
const auto replayed = replay_cellular_batch(*state, builder->batch(), outcomes);
CHECK(replayed && (*replayed)->snapshot() == builder->candidate().snapshot() &&
outcomes.size() == 1 && outcomes.front().result == CellularMutationResult::split_applied);
// The player became the offspring.
const auto& lives = builder->candidate().lives();
CHECK(std::ranges::find(lives, life.account, &CellularOwnedLife::account)->identity.life !=
101);
// Become with a decline is refused.
auto declined = reservation;
declined.input[32] = 0;
declined.input[33] = 0x80;
auto refusing = CellularSessionBatchBuilder::create(*state, head);
CHECK(refusing);
const std::array declines{declined};
CHECK(refusing->append(tick, baseline, {}, {}, declines).error() ==
CellularSessionBatchError::mutation);
}
void builder_batches_reserved_birth_after_empty_tick() {
auto primitive = PrimitiveLives::create({93, 1, 1, 17, founder_price(1), {{0, 0}}});
CHECK(primitive);
@@ -414,6 +558,7 @@ void unavailable_birth_does_not_freeze_the_tick() {
int main() try {
actions_bind_to_owned_life_and_preserve_other_inputs();
durable_mutation_reservations_bind_to_the_exact_offer();
rules_13_actions_and_choices_bind();
builder_batches_reserved_birth_after_empty_tick();
unavailable_birth_does_not_freeze_the_tick();
std::puts("cellular session batch: ok");