ADR 0127
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 2m23s
Foundation / checks (tsan) (push) Successful in 10m11s
Foundation / checks (client) (push) Failing after 14m26s
Foundation / checks (network) (push) Successful in 18m54s
Foundation / checks (checks) (push) Successful in 42m9s
Foundation / checks (postgres) (push) Successful in 43m51s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-15 09:32:51 -04:00
parent 0a0f6c3bb1
commit 817a830a8a
20 changed files with 474 additions and 28 deletions
@@ -170,6 +170,21 @@ std::expected<void, CellularSessionBatchError> CellularSessionBatchBuilder::appe
std::span<const network::CarriedAction> actions,
std::span<const CellularTickIntents::Birth> births,
std::span<const persistence::CellularMutationReservation> mutations) {
return append_impl(tick, baseline, actions, births, mutations, false);
}
std::expected<void, CellularSessionBatchError>
CellularSessionBatchBuilder::append_with_birth_refusals(
std::uint64_t tick, std::span<const CellularLifeIntent> baseline,
std::span<const network::CarriedAction> actions,
std::span<const CellularTickIntents::Birth> births,
std::span<const persistence::CellularMutationReservation> mutations) {
return append_impl(tick, baseline, actions, births, mutations, true);
}
std::expected<void, CellularSessionBatchError> CellularSessionBatchBuilder::append_impl(
std::uint64_t tick, std::span<const CellularLifeIntent> baseline,
std::span<const network::CarriedAction> actions,
std::span<const CellularTickIntents::Birth> births,
std::span<const persistence::CellularMutationReservation> mutations, bool allow_refusals) {
if (batch_.ticks.size() >= max_cellular_batch_ticks)
return std::unexpected{CellularSessionBatchError::batch_full};
if (actions_.size() + actions.size() > max_cellular_action_records)
@@ -204,6 +219,11 @@ std::expected<void, CellularSessionBatchError> CellularSessionBatchBuilder::appe
return std::unexpected{CellularSessionBatchError::invalid_birth};
if (i > 0 && prepared->intents.births[i - 1].account == birth.account)
return std::unexpected{CellularSessionBatchError::duplicate_birth};
if (std::ranges::any_of(refused_births_, [&](const auto& previous) {
return previous.birth.account == birth.account ||
previous.birth.identity == birth.identity;
}))
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;
@@ -217,15 +237,26 @@ std::expected<void, CellularSessionBatchError> CellularSessionBatchBuilder::appe
!(*next)->advance_tick_with_mutations(prepared->intents.lives, prepared->intents.mutations))
return std::unexpected{CellularSessionBatchError::biology};
std::vector<CellularTickIntents::Birth> accepted_births;
std::vector<CellularBirthRefusal> refused_births;
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 && allow_refusals &&
(created.error() == CellularLivesError::insufficient_funding ||
created.error() == CellularLivesError::no_placement ||
created.error() == CellularLivesError::life_exists)) {
refused_births.push_back({birth, created.error()});
continue;
}
if (!created)
return std::unexpected{CellularSessionBatchError::invalid_birth};
*next = std::move(*created);
accepted_births.push_back(birth);
}
prepared->intents.births = std::move(accepted_births);
auto next_batch = batch_;
next_batch.ticks.push_back(std::move(prepared->intents));
@@ -245,6 +276,7 @@ std::expected<void, CellularSessionBatchError> CellularSessionBatchBuilder::appe
batch_ = std::move(next_batch);
actions_.insert(actions_.end(), prepared->actions.begin(), prepared->actions.end());
mutation_actions_ = next_mutation_actions;
refused_births_.insert(refused_births_.end(), refused_births.begin(), refused_births.end());
return {};
}
} // namespace evo::server