From a1439581d9cd31a1c10348e2195c618bb30402e2 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 12 Oct 2026 00:34:56 -0400 Subject: [PATCH] Fix cellular profile migration test fixture --- docs/engineering/VALIDATION.md | 12 +++++++++++ tests/cellular_publication_tests.cpp | 31 +++++++++++++++++++--------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 6006ca3..02be9bd 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -7045,3 +7045,15 @@ post-publish assertion, so dependent image jobs remained blocked. The assertion did not expose the sanitized database error category/SQLSTATE; the cellular host publish result now carries those diagnostics to the test without server messages or credentials. Validation of the diagnostic and migration 30 remains pending. + +CI run #321 exposed the exact PostgreSQL error: PL/pgSQL's local record `b` +shadowed the `b` aliases in the duplicate-birth queries in migration 23. The +fix is a forward migration 31 so existing migration checksums remain intact. +Run #322 compiled the PostgreSQL targets and passed the earlier publication +test after migration 31, then exposed an obsolete test fixture that created a +non-empty profile-4 tick-0 genesis from a primitive life. ADR-0100 and ADR-0114 +require empty genesis and allocator-backed births at a committed tick. The +fixture now creates empty legacy-v1 genesis, publishes its first life through +the normal control and birth path, then tests the v1-to-v2-to-v3 no-tick +migrations while carrying that living state. PostgreSQL integration cannot be +run in the local Windows environment, so this correction is awaiting CI. diff --git a/tests/cellular_publication_tests.cpp b/tests/cellular_publication_tests.cpp index bf3e2aa..51316cf 100644 --- a/tests/cellular_publication_tests.cpp +++ b/tests/cellular_publication_tests.cpp @@ -193,20 +193,17 @@ void cellular_profile_migration_is_durable_and_recovers_without_a_tick() { auto endowment = primitive_endowment(); CHECK(endowment); auto funding = endowment->body; - funding.energy.value = endowment->reserve.energy.value + endowment->construction.value; + funding.energy.value += endowment->reserve.energy.value + endowment->construction.value; + for (std::size_t index = 0; index < funding.matter.size(); ++index) + funding.matter[index].value += endowment->reserve.matter[index].value; auto primitive = PrimitiveLives::create({key.world, key.region, 1, 17, funding, {{0, 0}}}); CHECK(primitive); - LifeRequest founder; - founder.account = filled<16>(0x5A); - founder.action = 9; - CHECK((*primitive)->spawn(founder, {1, 101, 201, 301, {0}})); auto habitat = CellularHabitat::create({key.world, key.region, 1, 1'000, 1'000, {}}); CHECK(habitat); auto current = CellularLives::create(**primitive, std::move(*habitat), {{1'000, 1'000}, 0, 293'150}); - CHECK(current); + CHECK(current && (*current)->lives().empty()); auto legacy_bytes = (*current)->snapshot(); - legacy_bytes.erase(legacy_bytes.begin() + 220 + 168, legacy_bytes.begin() + 220 + 480); constexpr std::uint64_t legacy_magic = 0x3130564C43564541ULL; for (unsigned index = 0; index < 8; ++index) legacy_bytes[index] = static_cast(legacy_magic >> (index * 8U)); @@ -223,6 +220,9 @@ void cellular_profile_migration_is_durable_and_recovers_without_a_tick() { auto provisioned = provision_cellular_region(*owner, **objects, key, 1, **legacy, filled<16>(0x50), build, 5s); CHECK(provisioned); + CHECK(owner->query("INSERT INTO evolution.life_allocators VALUES(9755,1000) " + "ON CONFLICT DO NOTHING", + {}, 5s)); const auto connect = [&]() -> std::expected, PgFailure> { return Postgres::connect({env("PGHOST"), {}, @@ -249,17 +249,28 @@ void cellular_profile_migration_is_durable_and_recovers_without_a_tick() { const auto& predecessor_value = checked_value(predecessor); CHECK(predecessor_value.head.sequence == 0); + auto runtime = connect_as(env("EVO_PG_RUNTIME_USER")); + const auto account = filled<16>(0x5A); + const auto control = + claim_account_control(*runtime, key, authority_value, account, 1, 1, 20'000ms, 5s); + CHECK(control); + const auto requested = host->create_primitive_life(account, control->generation, 9); + CHECK(requested.result == evo::network::PrimitiveLifeResult::pending && + requested.life_identity != 0 && host->queued_births().size() == 1); + CellularBatch batch; const auto predecessor_digest = sha256(predecessor_value.manifest); CHECK(predecessor_digest); batch.header = { key.world, key.region, 1, predecessor_value.head.commit, checked_value(predecessor_digest), 0, 1}; - batch.ticks.resize(1); - for (const auto& life : host->state()->lives()) - batch.ticks[0].lives.push_back({life.identity.life, {}}); + CellularTickIntents tick; + tick.births.push_back(host->queued_births().front()); + batch.ticks.push_back(tick); const auto published = host->publish(batch); CHECK(published && published->committed.head.sequence == 1); + CHECK(host->state()->lives().size() == 1 && + host->state()->lives().front().identity.born.value == 1); auto migrated = migrate_cellular_profile_to_v2(*owner, **migration_objects, authority_value, published->committed, filled<16>(0x51), build, 5s);