Queue births in cellular tick batches
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 40s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 1m9s
Foundation / checks (client) (push) Canceled after 1m53s
Foundation / checks (ecs) (push) Canceled after 1m48s

This commit is contained in:
dingo
2026-10-11 00:51:05 -04:00
parent bb6e00ebca
commit 704ce0f2c8
5 changed files with 109 additions and 8 deletions
+6
View File
@@ -327,6 +327,12 @@ scoped change before starting the next segment.
integration test covers empty-genesis birth, durable request outcome and
restart recovery. CI/PostgreSQL execution remains pending, and the live v5
request scheduler still has to feed these records before 11.3e is playable.
- 11.3d-7j: `CellularSessionBatchBuilder::append` now accepts reserved birth
records, sorts and validates them, applies the tick's existing-life inputs,
then builds each birth on a detached candidate at the end tick. A failed birth
leaves the builder unchanged. Tests cover empty-region birth replay and
duplicate request refusal. The server still needs to route v5 requests into
this queue and run/publish the scheduler tick.
## Exit boundary
+15
View File
@@ -6437,3 +6437,18 @@ environment lacks `psql`. The Windows `bash.exe` shim is access-denied, so the
migration scripts could not be syntax-checked here. CTest, sanitizer checks,
and CI have not run for this segment. The migration-test source itself cannot
compile locally because its fixture requires POSIX `poll.h`.
## 2026-10-11 — M11.3d-7j queued birth batch building
`CellularSessionBatchBuilder` accepts reserved birth records for a scheduled
tick. It canonicalizes their order, advances existing lives first, and applies
each birth only to a detached candidate. Failed funding, placement, or duplicate
identity validation does not partially advance the builder. The focused session
batch test covers successful empty-region birth replay, duplicate birth refusal,
and unchanged state after refusal.
The focused session-batch executable was manually compiled and run with GCC
13.2 in debug and `-O2 -DNDEBUG`; both pass. `git diff --check` passes. CTest,
sanitizers and CI are pending. The existing unrelated initializer warning in
`cellular_region_step.cpp:29` is demoted for these manual builds. This builder
is not yet wired into an `evo-server` cellular tick loop.
@@ -18,6 +18,8 @@ enum class CellularSessionBatchError : std::uint8_t {
action,
life,
duplicate_action,
duplicate_birth,
invalid_birth,
unperceived_target,
head,
batch_full,
@@ -47,7 +49,8 @@ class CellularSessionBatchBuilder {
create(const CellularLives& committed_state, const persistence::RegionHead& committed_head);
[[nodiscard]] std::expected<void, CellularSessionBatchError>
append(std::uint64_t tick, std::span<const CellularLifeIntent> baseline,
std::span<const network::CarriedAction> actions);
std::span<const network::CarriedAction> actions,
std::span<const CellularTickIntents::Birth> births = {});
[[nodiscard]] const CellularBatch& batch() const noexcept { return batch_; }
[[nodiscard]] std::span<const CellularActionRecord> actions() const noexcept {
return actions_;
+46 -4
View File
@@ -101,7 +101,8 @@ CellularSessionBatchBuilder::create(const CellularLives& committed_state,
std::expected<void, CellularSessionBatchError>
CellularSessionBatchBuilder::append(std::uint64_t tick,
std::span<const CellularLifeIntent> baseline,
std::span<const network::CarriedAction> actions) {
std::span<const network::CarriedAction> actions,
std::span<const CellularTickIntents::Birth> births) {
if (batch_.ticks.size() >= max_cellular_batch_ticks)
return std::unexpected{CellularSessionBatchError::batch_full};
if (actions_.size() + actions.size() > max_cellular_action_records)
@@ -115,10 +116,51 @@ CellularSessionBatchBuilder::append(std::uint64_t tick,
previous.action_id == action.action_id;
}) != actions_.end())
return std::unexpected{CellularSessionBatchError::duplicate_action};
if (!working_->advance_tick(prepared->intents.lives))
if (births.size() > biology::max_cellular_tick_lives)
return std::unexpected{CellularSessionBatchError::invalid_birth};
prepared->intents.births.assign(births.begin(), births.end());
std::ranges::sort(prepared->intents.births, [](const auto& left, const auto& right) {
if (left.account != right.account)
return left.account < right.account;
return left.request < right.request;
});
for (std::size_t i = 0; i < prepared->intents.births.size(); ++i) {
const auto& birth = prepared->intents.births[i];
if (std::ranges::all_of(birth.account, [](std::uint8_t value) { return value == 0; }) ||
birth.request == 0 || birth.generation == 0 || birth.identity == 0)
return std::unexpected{CellularSessionBatchError::invalid_birth};
if (i > 0 && prepared->intents.births[i - 1].account == birth.account)
return std::unexpected{CellularSessionBatchError::duplicate_birth};
for (const auto& previous_tick : batch_.ticks)
if (std::ranges::any_of(previous_tick.births, [&](const auto& previous) {
return previous.account == birth.account ||
previous.identity == birth.identity;
}))
return std::unexpected{CellularSessionBatchError::duplicate_birth};
}
auto next = CellularLives::restore(working_->snapshot(), working_->world(),
working_->region(), working_->frame(), working_->tick());
if (!next || !(*next)->advance_tick(prepared->intents.lives))
return std::unexpected{CellularSessionBatchError::biology};
batch_.ticks.push_back(std::move(prepared->intents));
batch_.header.end_tick = tick;
for (const auto& birth : prepared->intents.births) {
const LifeRequest request{birth.account, birth.request};
const LifeAllocation allocation{birth.identity, birth.identity, birth.identity,
birth.identity, {tick}};
auto created = (*next)->birth_candidate(request, allocation);
if (!created)
return std::unexpected{CellularSessionBatchError::invalid_birth};
*next = std::move(*created);
}
auto next_batch = batch_;
next_batch.ticks.push_back(std::move(prepared->intents));
next_batch.header.end_tick = tick;
if (!encode_cellular_batch(next_batch))
return std::unexpected{CellularSessionBatchError::invalid_birth};
working_ = std::move(*next);
batch_ = std::move(next_batch);
actions_.insert(actions_.end(), prepared->actions.begin(), prepared->actions.end());
return {};
}
+38 -3
View File
@@ -107,11 +107,11 @@ void actions_bind_to_owned_life_and_preserve_other_inputs() {
CHECK(builder->actions().size() == 1 && builder->actions()[0] == prepared->actions[0]);
const auto replayed = replay_cellular_batch(**state, builder->batch());
CHECK(replayed && (*replayed)->snapshot() == builder->candidate().snapshot());
const auto repeated_input = network::encode_cellular_action_input({3, 0, 0, false, 0, 0});
const network::CarriedAction repeated{network::AccountId{controlled.account}, 77, 3,
const auto repeated_input = network::encode_cellular_action_input({4, 0, 0, false, 0, 0});
const network::CarriedAction repeated{network::AccountId{controlled.account}, 77, 4,
network::ActionKind::cellular, repeated_input};
const std::array repeated_actions{repeated};
CHECK(builder->append(3, next_baseline, repeated_actions).error() ==
CHECK(builder->append(4, next_baseline, repeated_actions).error() ==
CellularSessionBatchError::duplicate_action);
CHECK(builder->append(5, next_baseline, {}).error() == CellularSessionBatchError::tick);
@@ -144,10 +144,45 @@ void actions_bind_to_owned_life_and_preserve_other_inputs() {
CHECK(prepare_cellular_session_tick(**state, 2, baseline, malformed_actions).error() ==
CellularSessionBatchError::action);
}
void builder_batches_reserved_birth_after_empty_tick() {
auto primitive = PrimitiveLives::create({93, 1, 1, 17, founder_price(1), {{0, 0}}});
CHECK(primitive);
auto habitat = biology::CellularHabitat::create({93, 1, 1, 1'000, 1'000, {}});
CHECK(habitat);
auto state = CellularLives::create(**primitive, std::move(*habitat),
{{1'000, 1'000}, 0, 293'150});
CHECK(state && (*state)->lives().empty());
persistence::RegionHead head{};
head.frame = 1;
head.commit.fill(1);
head.digest.fill(2);
auto builder = CellularSessionBatchBuilder::create(**state, head);
CHECK(builder);
CellularTickIntents::Birth birth{};
birth.account.back() = 8;
birth.request = 13;
birth.generation = 4;
birth.identity = 901;
const std::array births{birth};
const std::span<const CellularLifeIntent> no_lives{};
CHECK(builder->append(1, no_lives, {}, births));
CHECK(builder->candidate().tick() == 1 && builder->candidate().lives().size() == 1 &&
builder->batch().ticks[0].births == std::vector{birth} && (*state)->lives().empty());
const auto replayed = replay_cellular_batch(**state, builder->batch());
CHECK(replayed && (*replayed)->snapshot() == builder->candidate().snapshot());
const auto snapshot = builder->candidate().snapshot();
const std::array next_lives{CellularLifeIntent{901, {}}};
CHECK(builder->append(2, next_lives, {}, births).error() ==
CellularSessionBatchError::duplicate_birth);
CHECK(builder->candidate().snapshot() == snapshot && builder->batch().ticks.size() == 1);
}
} // namespace
int main() try {
actions_bind_to_owned_life_and_preserve_other_inputs();
builder_batches_reserved_birth_after_empty_tick();
std::puts("cellular session batch: ok");
} catch (const std::exception& e) {
std::fprintf(stderr, "%s\n", e.what());