Freeze offline cells, linger, suspend and resume them
Foundation / checks (ecs) (push) Successful in 2m15s
Foundation / checks (deploy) (push) Successful in 3m53s
Foundation / checks (tsan) (push) Successful in 9m46s
Foundation / checks (client) (push) Failing after 13m47s
Foundation / checks (network) (push) Successful in 19m5s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 19m34s
Foundation / checks (postgres) (push) Canceled after 19m28s
Foundation / checks (ecs) (push) Successful in 2m15s
Foundation / checks (deploy) (push) Successful in 3m53s
Foundation / checks (tsan) (push) Successful in 9m46s
Foundation / checks (client) (push) Failing after 13m47s
Foundation / checks (network) (push) Successful in 19m5s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 19m34s
Foundation / checks (postgres) (push) Canceled after 19m28s
M11.7 (ADR-0128): a frozen step intent, set by the server for every owned life whose account holds no session, leaves the cell unchanged but engulfable. Owner format 6 / rules 5 track presence: lingering for 200 ticks, then suspended out of the world without aging; an unfrozen intent resumes it in place or at the nearest clear spot within three extents. Bundle v6, schema v38 and the cellular-v4 opening carry it. The server refuses an offline account's carried actions, ticks while anyone lingers, and skips suspended cells in replication and perception. Also fixes the TSan failure of CI run 374: the rules-4 owner test read the bud through a reference into a replaced state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -668,6 +668,11 @@ void rules_four_owner_buds_wildlife() {
|
||||
feeding_bud.bud = true;
|
||||
CHECK(owner.advance_tick(std::array{CellularLifeIntent{1, feeding_bud}}).error() ==
|
||||
CellularLivesError::invalid_intents);
|
||||
// Freezing is rules 5 (ADR-0128).
|
||||
evo::biology::CellularStepIntent frozen{};
|
||||
frozen.frozen = true;
|
||||
CHECK(owner.advance_tick(std::array{CellularLifeIntent{1, frozen}}).error() ==
|
||||
CellularLivesError::invalid_intents);
|
||||
|
||||
const auto parent_genome = owner.lives().front().identity.genome;
|
||||
std::optional<CellularTickExecution> budded;
|
||||
@@ -721,8 +726,10 @@ void rules_four_owner_buds_wildlife() {
|
||||
CHECK(owner.advance_tick(std::array{CellularLifeIntent{1, feed}, controlled->front()}));
|
||||
|
||||
// Wildlife feeds like any cell but never earns a mutation offer.
|
||||
const auto child_x = child.position.x_um / 1000;
|
||||
const auto child_y = child.position.y_um / 1000;
|
||||
// Read the bud from the current state: the tick above replaced the one `child` named.
|
||||
const auto& wildlife = owner.lives()[1];
|
||||
const auto child_x = wildlife.position.x_um / 1000 * 1000;
|
||||
const auto child_y = wildlife.position.y_um / 1000 * 1000;
|
||||
evo::biology::CellularStepIntent child_feed{};
|
||||
child_feed.intake_target = evo::biology::CellularPatchAddress{
|
||||
static_cast<std::uint32_t>(child_x), static_cast<std::uint32_t>(child_y)};
|
||||
@@ -743,6 +750,108 @@ void rules_four_owner_buds_wildlife() {
|
||||
refresh_checksum(rewound);
|
||||
CHECK(!CellularLives::restore(rewound, 93, 1, 7, owner.tick()));
|
||||
}
|
||||
// ADR-0128: an offline owned life freezes, lingers 200 ticks, is suspended without aging,
|
||||
// survives restore, and resumes; a newborn on its spot makes it resume nearby.
|
||||
void rules_five_owner_freezes_lingers_suspends_and_resumes() {
|
||||
auto primitive = PrimitiveLives::create({94, 1, 7, 17, founder_price(3), {{0, 0}, {1'500, 0}}});
|
||||
CHECK(primitive);
|
||||
LifeRequest request{};
|
||||
request.account.back() = 1;
|
||||
request.action = 1;
|
||||
CHECK((*primitive)->spawn(request, {1, 101, 201, 301, {1}}));
|
||||
request.account.back() = 2;
|
||||
CHECK((*primitive)->spawn(request, {2, 102, 202, 302, {1}}));
|
||||
auto habitat = evo::biology::CellularHabitat::create({94, 1, 7, 3'000, 2'000, {}});
|
||||
CHECK(habitat);
|
||||
auto created =
|
||||
CellularLives::create(**primitive, std::move(*habitat), {{3'000, 2'000}, 1, 293'150},
|
||||
CellularLivesProfile::presence);
|
||||
CHECK(created);
|
||||
auto owner = std::move(*created);
|
||||
CHECK(owner->format_version() == cellular_lives_presence_format &&
|
||||
owner->rules_version() == cellular_lives_presence_rules);
|
||||
|
||||
evo::biology::CellularStepIntent frozen{};
|
||||
frozen.frozen = true;
|
||||
// The trace keeps the flag (intent byte 13) and refuses it with anything else.
|
||||
CellularBatch frozen_batch;
|
||||
frozen_batch.header = {94, 1, 7, {}, {}, owner->tick(), owner->tick() + 1};
|
||||
frozen_batch.header.predecessor.fill(1);
|
||||
frozen_batch.header.predecessor_digest.fill(2);
|
||||
frozen_batch.ticks.push_back({{{1, frozen}, {2, {}}}, {}, {}});
|
||||
const auto frozen_bytes = encode_cellular_batch(frozen_batch);
|
||||
CHECK(frozen_bytes);
|
||||
CHECK(decode_cellular_batch(*frozen_bytes) == frozen_batch);
|
||||
auto flag_two = *frozen_bytes;
|
||||
flag_two[cellular_batch_header_bytes + cellular_batch_tick_header_bytes + 13] = 2;
|
||||
CHECK(!decode_cellular_batch(flag_two));
|
||||
// A frozen intent carries nothing else.
|
||||
auto moving = frozen;
|
||||
moving.movement = {100, 0};
|
||||
CHECK(owner->advance_tick(std::array{CellularLifeIntent{1, moving}, CellularLifeIntent{2, {}}})
|
||||
.error() == CellularLivesError::invalid_intents);
|
||||
|
||||
const auto before = owner->lives()[0];
|
||||
CHECK(
|
||||
owner->advance_tick(std::array{CellularLifeIntent{1, frozen}, CellularLifeIntent{2, {}}}));
|
||||
const auto first_frozen = owner->tick();
|
||||
CHECK(owner->lives()[0].presence == CellularPresence::lingering &&
|
||||
owner->lives()[0].frozen_since == first_frozen &&
|
||||
owner->lives()[0].reserve == before.reserve &&
|
||||
owner->lives()[0].position == before.position &&
|
||||
owner->lives()[1].reserve.energy.value < before.reserve.energy.value);
|
||||
// Back within the linger: active again in place.
|
||||
CHECK(owner->advance_tick(std::array{CellularLifeIntent{1, {}}, CellularLifeIntent{2, {}}}));
|
||||
CHECK(owner->lives()[0].presence == CellularPresence::active &&
|
||||
owner->lives()[0].frozen_since == 0);
|
||||
|
||||
// Frozen through the whole linger: suspended after 200 ticks, without aging.
|
||||
CHECK(
|
||||
owner->advance_tick(std::array{CellularLifeIntent{1, frozen}, CellularLifeIntent{2, {}}}));
|
||||
const auto parked = owner->lives()[0];
|
||||
for (std::uint64_t tick = 1; tick <= cellular_linger_ticks; ++tick) {
|
||||
CHECK(owner->lives()[0].presence == CellularPresence::lingering);
|
||||
CHECK(owner->advance_tick(
|
||||
std::array{CellularLifeIntent{1, frozen}, CellularLifeIntent{2, {}}}));
|
||||
CHECK(owner->current_total() == owner->opening_total());
|
||||
}
|
||||
CHECK(owner->lives()[0].presence == CellularPresence::suspended &&
|
||||
owner->lives()[0].reserve == parked.reserve &&
|
||||
owner->lives()[0].position == parked.position &&
|
||||
owner->last_tick_feedback()[0].presence == CellularPresence::suspended);
|
||||
// Suspended lives stay out of the step while frozen.
|
||||
for (int tick = 0; tick < 5; ++tick)
|
||||
CHECK(owner->advance_tick(
|
||||
std::array{CellularLifeIntent{1, frozen}, CellularLifeIntent{2, {}}}));
|
||||
CHECK(owner->lives()[0].reserve == parked.reserve);
|
||||
|
||||
const auto saved = owner->snapshot();
|
||||
auto recovered = CellularLives::restore(saved, 94, 1, 7, owner->tick());
|
||||
CHECK(recovered && (*recovered)->snapshot() == saved &&
|
||||
std::ranges::equal((*recovered)->lives(), owner->lives()));
|
||||
// A lingering presence older than the linger is refused on restore.
|
||||
auto stale = saved;
|
||||
const auto presence_at = std::size_t{220} + std::size_t{2} * 8 + 480 + 8;
|
||||
stale[presence_at] = static_cast<std::uint8_t>(CellularPresence::lingering);
|
||||
refresh_checksum(stale);
|
||||
CHECK(!CellularLives::restore(stale, 94, 1, 7, owner->tick()));
|
||||
|
||||
// A newborn takes the suspended cell's spot (placement ignores suspended cells)...
|
||||
LifeRequest third{};
|
||||
third.account.back() = 3;
|
||||
third.action = 1;
|
||||
auto born = owner->birth_candidate(third, {50, 50, 50, 50, {owner->tick()}});
|
||||
CHECK(born);
|
||||
owner = std::move(*born);
|
||||
CHECK(owner->lives().size() == 3 && owner->lives()[2].position == parked.position);
|
||||
// ...so the resume relocates within three extents, clear of everyone.
|
||||
CHECK(owner->advance_tick(std::array{CellularLifeIntent{1, {}}, CellularLifeIntent{2, {}},
|
||||
CellularLifeIntent{50, {}}}));
|
||||
const auto& resumed = owner->lives()[0];
|
||||
CHECK(resumed.presence == CellularPresence::active && resumed.frozen_since == 0 &&
|
||||
resumed.position != parked.position && !owner->last_tick_feedback()[0].resume_blocked);
|
||||
CHECK(owner->current_total() == owner->opening_total());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
@@ -753,6 +862,7 @@ int main() {
|
||||
owner_advances_and_closes_death_atomically();
|
||||
rules_three_owner_resolves_engulf_and_detritus();
|
||||
rules_four_owner_buds_wildlife();
|
||||
rules_five_owner_freezes_lingers_suspends_and_resumes();
|
||||
std::puts(
|
||||
"PASS cellular lives: feeding, tick ownership, terminal closure, rules 3, budding");
|
||||
} catch (const std::exception& error) {
|
||||
|
||||
@@ -212,7 +212,7 @@ void upgrade_across_migration_and_barrier() {
|
||||
" EVO_PG_RUNTIME_ROLE=evo_runtime_test bash \"$EVO_SOURCE_ROOT/"
|
||||
"tools/migrate-postgres.sh\" > /dev/null") == 0);
|
||||
CHECK(history(*owner_db) == "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,"
|
||||
"25,26,27,28,29,30,31,32,33,34,35,36,37");
|
||||
"25,26,27,28,29,30,31,32,33,34,35,36,37,38");
|
||||
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
|
||||
"c.confrelid = 'evolution.region_commits'::regclass)::text "
|
||||
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
|
||||
|
||||
@@ -535,6 +535,25 @@ void cellular_v3_provisioning_uses_the_budding_bundle() {
|
||||
manifest->history_profile == cellular_revision_history_profile);
|
||||
}
|
||||
|
||||
// ADR-0128: cellular-v4 is the rules-5 presence opening on the v6 bundle.
|
||||
void cellular_v4_provisioning_uses_the_presence_bundle() {
|
||||
const ServerRegion r{{9769, 1}, fresh("cellular-v4-provision-9769")};
|
||||
const std::string build(64, 'e');
|
||||
const std::string commit(32, 'd');
|
||||
const std::string patch = "3000,3000,2,1000,1000,1000,1000,1000";
|
||||
int code = -1;
|
||||
const auto first = provision_cellular(r, "9769", "cellular-v4", build, commit, patch, code);
|
||||
CHECK(code == 0 && has(first, "provisioned world=9769 region=1 sequence=0 tick=0"));
|
||||
const auto older = provision_cellular(r, "9769", "cellular-v3", build, commit, patch, code);
|
||||
CHECK(code == 4);
|
||||
auto db = owner();
|
||||
const auto head = load_region_checkpoint(*db, r.key, 5s);
|
||||
CHECK(head);
|
||||
const auto manifest = decode_manifest(head->manifest);
|
||||
CHECK(manifest && manifest->cellular_versions == cellular_v6_versions &&
|
||||
manifest->history_profile == cellular_revision_history_profile);
|
||||
}
|
||||
|
||||
void cellular_provisioning_survives_a_build_promotion() {
|
||||
const ServerRegion r{{9761, 1}, fresh("cellular-provision-9761")};
|
||||
const auto run = [&](const std::string& build, const std::string& commit,
|
||||
@@ -567,6 +586,7 @@ void run_region_store_tests() {
|
||||
cellular_provisioning_survives_a_build_promotion();
|
||||
cellular_v2_provisioning_uses_the_engulf_bundle();
|
||||
cellular_v3_provisioning_uses_the_budding_bundle();
|
||||
cellular_v4_provisioning_uses_the_presence_bundle();
|
||||
full_volumes_publish_nothing();
|
||||
failing_writes_leave_nothing();
|
||||
check_store_qualifies_the_stores();
|
||||
|
||||
Reference in New Issue
Block a user