From 97b338eb33a703fcb49f09466c732436471a7791 Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 20 Oct 2026 11:27:59 -0400 Subject: [PATCH] fix(session): tag rules 10/11 session batches with the inheritance trace format CellularSessionBatchBuilder left every batch at cellular_batch_format, but replay accepts only the inheritance format on owners that retain offspring plans (format >= 8, rules 10 and 11). On DEV region 9 (bundle 13) every player tick, including a queued birth, was refused at publication as an invalid batch, so births stayed pending forever. The builder now declares the same format the unattended interval path already uses. The PostgreSQL suite provisions cellular-v8 and drives a birth and an ordinary tick through the host and session builder, as evo-server does. Co-Authored-By: Claude Opus 5.5 --- CMakeLists.txt | 3 +- .../region/dev-session-route/listener.yaml | 2 +- src/server/session/cellular_session_batch.cpp | 5 ++ tests/region_store_tests.cpp | 77 +++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index caea94e..5754c01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,7 +338,8 @@ if(EVO_BUILD_POSTGRES) # M10.8d: two evo-server processes handing probes over (ADR-0096). target_sources(evo-postgres-tests PRIVATE tests/region_m10_session_tests.cpp tests/region_handoff_process_tests.cpp) - target_link_libraries(evo-postgres-tests PRIVATE evo_session_client) + target_link_libraries(evo-postgres-tests PRIVATE evo_session_client + evo_cellular_session_adapter) target_compile_definitions(evo-postgres-tests PRIVATE EVO_POSTGRES_M10=1) add_dependencies(evo-postgres-tests evo-session-probe evo-load) endif() diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index eced5f4..cb7dea3 100644 --- a/deploy/kubernetes/region/dev-session-route/listener.yaml +++ b/deploy/kubernetes/region/dev-session-route/listener.yaml @@ -12,7 +12,7 @@ spec: env: - {name: REGION_SESSION, value: "dev"} - {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"} - - {name: REGION_SESSION_WINDOW, value: "dev-20261020T113649-63c77b5a:1792510609"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261020T152057-af0e1753:1792524057"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} ports: # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. diff --git a/src/server/session/cellular_session_batch.cpp b/src/server/session/cellular_session_batch.cpp index 189ce8d..bcc1631 100644 --- a/src/server/session/cellular_session_batch.cpp +++ b/src/server/session/cellular_session_batch.cpp @@ -163,6 +163,11 @@ CellularSessionBatchBuilder::create(const CellularLives& committed_state, committed_state.frame(), committed_head.commit, committed_head.digest, committed_state.tick(), committed_state.tick()}; + // Owners that retain offspring plans (rules 10 and 11) replay only the inheritance + // trace format, exactly as their unattended intervals are written. + if (committed_state.format_version() >= cellular_lives_inheritance_format && + cellular_retained_plans(committed_state.rules_version())) + builder.batch_.format_version = cellular_batch_inheritance_format; return builder; } diff --git a/tests/region_store_tests.cpp b/tests/region_store_tests.cpp index 15072c4..123159f 100644 --- a/tests/region_store_tests.cpp +++ b/tests/region_store_tests.cpp @@ -2,8 +2,13 @@ // the object volume's free-space reserve, a genuinely failing write, the // check-store probe (retention across runs, missing-volume refusal, privilege // boundary) and a server whose volume is full. Run by tools/ci/postgres-check.sh. +#include "evo/persistence/account_control_store.hpp" #include "evo/persistence/checkpoint_store.hpp" #include "evo/persistence/region_checkpoint.hpp" +#ifdef EVO_POSTGRES_M10 +#include "evo/server/cellular_region_host.hpp" +#include "evo/server/cellular_session_batch.hpp" +#endif #include "evo/server/lifecycle/primitive_lives.hpp" #include "fixtures/server_process.hpp" #include @@ -651,6 +656,78 @@ void cellular_v8_provisioning_declares_light() { const auto manifest = decode_manifest(head->manifest); CHECK(manifest && manifest->cellular_versions == cellular_v13_versions && manifest->history_profile == cellular_revision_history_profile); +#ifdef EVO_POSTGRES_M10 + // A player's birth on the provisioned head takes the live server's path: host + // reservation, session batch builder, host publication. + using namespace evo::server; + const auto connect = [&]() -> std::expected, PgFailure> { + return Postgres::connect({env("PGHOST"), + {}, + env("PGPORT"), + env("PGDATABASE"), + env("EVO_PG_RUNTIME_USER"), + {}, + {}}, + 5s); + }; + CHECK(db->query("INSERT INTO evolution.life_allocators VALUES(9775,1000)", {}, 5s)); + Sha256Digest digest{}; + digest.fill(0xEE); + auto objects = FilesystemObjectStore::open(r.root, r.key, max_cellular_lives_bytes); + CHECK(objects); + auto made = + CellularRegionHost::create({r.key, 9, {}, digest, {digest}}, connect, std::move(*objects)); + CHECK(made); + auto host = std::move(*made); + CHECK(host->step().ready && host->state()); + auto runtime = connect(); + CHECK(runtime); + Uuid account{}; + account[0] = 0x8E; + account.back() = 0x13; + const auto control = + claim_account_control(**runtime, r.key, *host->authority(), account, 1, 1, 20'000ms, 5s); + CHECK(control); + const auto requested = host->create_primitive_life(account, control->generation, 5); + CHECK(requested.result == evo::network::PrimitiveLifeResult::pending && + host->queued_births().size() == 1); + const std::vector births(host->queued_births().begin(), host->queued_births().end()); + auto builder = CellularSessionBatchBuilder::create(*host->state(), host->committed()->head); + CHECK(builder); + const auto appended = + builder->append_with_birth_refusals(host->state()->tick() + 1, {}, {}, births, {}); + if (!appended) + throw std::runtime_error( + "bundle 13 birth append failed: " + std::to_string(static_cast(appended.error())) + + " lives " + + std::to_string( + builder->last_lives_error() ? static_cast(*builder->last_lives_error()) : -1)); + CHECK(builder->refused_births().empty()); + // Rules 11 replays only the inheritance trace format; the builder must declare it. + CHECK(builder->batch().format_version == cellular_batch_inheritance_format); + const auto published = + host->publish(builder->batch(), builder->actions(), builder->mutation_actions()); + if (!published) { + const auto& failure = published.error(); + std::string message = "bundle 13 birth publish failed: kind " + + std::to_string(static_cast(failure.kind)); + if (failure.publication) + message += " publication " + std::to_string(static_cast(*failure.publication)); + if (failure.store && failure.store->cause.sqlstate[0] != '\0') + message += " sqlstate " + std::string(failure.store->cause.sqlstate.data(), 5); + throw std::runtime_error(message); + } + CHECK(host->query_primitive_life(account, control->generation, 5).result == + evo::network::PrimitiveLifeResult::born); + // The player's next ordinary session tick publishes too. + std::vector baseline; + for (const auto& life : host->state()->lives()) + baseline.push_back({life.identity.life, {}}); + std::ranges::sort(baseline, {}, &CellularLifeIntent::life_id); + auto next = CellularSessionBatchBuilder::create(*host->state(), host->committed()->head); + CHECK(next && next->append(host->state()->tick() + 1, baseline, {})); + CHECK(host->publish(next->batch(), next->actions(), next->mutation_actions())); +#endif } void cellular_provisioning_survives_a_build_promotion() {