From d7b42f2be955e9299252a1bcb5aecdf77fa710c1 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 12 Oct 2026 04:10:38 -0400 Subject: [PATCH] Use valid cellular birth path in publication test --- docs/engineering/VALIDATION.md | 7 ++++++ tests/cellular_publication_tests.cpp | 34 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 048ea7e..370188b 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -7093,3 +7093,10 @@ on the newly created host; host recovery and lease acquisition happen during `step()`. The test now checks readiness first, matching the established restart test. PostgreSQL CI and Harbor image publication must rerun before a playtest image is available. + +CI run #328 passed that recovery check, then reached a second obsolete fixture +that constructed a tick-0 cellular genesis from a primitive life born at tick 1. +`CellularLives::create` correctly rejects that impossible chronology. The test +now provisions an empty v1 genesis and publishes its first life through the +allocator-backed control and birth path, retaining the action publication and +restart assertions. PostgreSQL CI and Harbor image publication remain pending. diff --git a/tests/cellular_publication_tests.cpp b/tests/cellular_publication_tests.cpp index 521190f..b336853 100644 --- a/tests/cellular_publication_tests.cpp +++ b/tests/cellular_publication_tests.cpp @@ -361,22 +361,14 @@ void run_cellular_publication_tests() { constexpr RegionKey key{9756, 1}; - auto endowed = evo::biology::primitive_endowment(); - CHECK(endowed); - auto funding = endowed->body; - funding.energy.value = endowed->reserve.energy.value + endowed->construction.value; - auto primitive = PrimitiveLives::create({key.world, key.region, 1, 17, funding, {{0, 0}}}); + auto primitive = PrimitiveLives::create({key.world, key.region, 1, 17, {}, {{0, 0}}}); CHECK(primitive); - LifeRequest founder; - founder.account = filled<16>(0x43); - founder.action = 7; - CHECK((*primitive)->spawn(founder, {1, 101, 201, 301, {0}})); auto habitat = evo::biology::CellularHabitat::create({key.world, key.region, 1, 1'000, 1'000, {}}); CHECK(habitat); auto opening = CellularLives::create(**primitive, std::move(*habitat), {{1'000, 1'000}, 0, 293'150}); - CHECK(opening && (*opening)->lives().size() == 1); + CHECK(opening && (*opening)->lives().empty()); const auto payload = (*opening)->snapshot(); const auto payload_digest = sha256(payload); @@ -391,6 +383,9 @@ void run_cellular_publication_tests() { CHECK(objects && (*objects)->put(payload)); CHECK(owner->query("SELECT evolution.provision_region_checkpoint($1::bytea)", std::array{hex(*genesis_bytes)}, 5s)); + CHECK(owner->query("INSERT INTO evolution.life_allocators VALUES(9756,1000) " + "ON CONFLICT DO NOTHING", + {}, 5s)); const auto connect = [&]() -> std::expected, PgFailure> { return Postgres::connect({env("PGHOST"), {}, @@ -406,6 +401,17 @@ void run_cellular_publication_tests() { CHECK(made_host); auto host = std::move(*made_host); CHECK(host->step().ready); + const auto authority = host->authority(); + CHECK(authority); + auto runtime = connect_as(env("EVO_PG_RUNTIME_USER")); + const auto account = filled<16>(0x43); + const auto control = + claim_account_control(*runtime, key, checked_value(authority), account, 1, 1, 20'000ms, + 5s); + CHECK(control); + const auto requested = host->create_primitive_life(account, control->generation, 7); + CHECK(requested.result == evo::network::PrimitiveLifeResult::pending && + requested.life_identity != 0 && host->queued_births().size() == 1); const auto committed = host->committed(); CHECK(committed); const auto& committed_value = checked_value(committed); @@ -416,12 +422,11 @@ void run_cellular_publication_tests() { key.world, key.region, 1, committed_value.head.commit, checked_value(predecessor_digest), 0, 2}; batch.ticks.resize(2); - for (auto& tick : batch.ticks) - tick.lives.push_back({(*opening)->lives()[0].identity.life, {}}); + batch.ticks.front().births.push_back(host->queued_births().front()); const auto replay = replay_cellular_batch(*host->state(), batch); CHECK(replay); CellularActionRecord action; - action.account = founder.account; + action.account = account; action.action_id = 77; action.input[0] = 1; // Tick 1, neutral movement, no patch target. const std::array actions{action}; @@ -440,10 +445,11 @@ void run_cellular_publication_tests() { CellularRegionHost::create(config, connect, std::move(*restarted_objects)); CHECK(made_restarted); auto restarted = std::move(*made_restarted); + CHECK(restarted->step().ready); const auto restarted_committed = restarted->committed(); CHECK(restarted_committed); const auto& restarted_committed_value = checked_value(restarted_committed); - CHECK(restarted->step().ready && restarted->state()->tick() == 2 && + CHECK(restarted->state()->tick() == 2 && restarted->state()->snapshot() == (**replay).snapshot() && restarted_committed_value.head.sequence == 1); restarted->drain();