Fix optional guards in mutation owner
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (checks) (push) Failing after 2m10s
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 (postgres) (push) Canceled after 3m19s
Foundation / checks (client) (push) Canceled after 5m33s
Foundation / checks (network) (push) Canceled after 3m29s

This commit is contained in:
dingo
2026-10-11 06:41:06 -04:00
parent 7d94024a75
commit 9156e1cc0b
+17 -12
View File
@@ -523,10 +523,10 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
out.put(0, 4);
out.inventory(mutation.offer ? mutation.offer->context.environment.available
: accounting::Inventory{});
const auto count = mutation.offer ? mutation.offer->candidates.size() : 0;
for (std::size_t index = 0; index < biology::max_candidates; ++index) {
if (index < count) {
const auto& candidate = mutation.offer->candidates[index];
if (mutation.offer && index < mutation.offer->candidates.size()) {
const auto& candidates = mutation.offer.value().candidates;
const auto& candidate = candidates[index];
out.put(candidate.operator_id, 2);
out.put(static_cast<std::uint8_t>(candidate.target), 1);
out.put(static_cast<std::uint8_t>(candidate.effect), 1);
@@ -986,11 +986,15 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
state_->lives, selection.life_id, {},
[](const CellularOwnedLife& value) { return value.identity.life; });
if (life == state_->lives.end() || life->identity.life != selection.life_id ||
!life->mutation.offer || life->mutation.event_index != selection.event_index ||
life->mutation.offer_tick != selection.offer_tick ||
life->mutation.offer->parent != life->identity.genome ||
life->mutation.offer->context.event_index != selection.event_index ||
!std::ranges::any_of(life->mutation.offer->candidates,
life->mutation.event_index != selection.event_index ||
life->mutation.offer_tick != selection.offer_tick)
return std::unexpected{CellularLivesError::mutation};
if (!life->mutation.offer.has_value())
return std::unexpected{CellularLivesError::mutation};
const auto& offer = *life->mutation.offer;
if (offer.parent != life->identity.genome ||
offer.context.event_index != selection.event_index ||
!std::ranges::any_of(offer.candidates,
[&](const auto& candidate) {
return candidate.operator_id == selection.operator_id;
}) ||
@@ -1109,11 +1113,12 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
continue;
}
const auto parent = next_archive.find(found->identity.genome);
if (!parent || !found->mutation.offer)
if (!parent || !found->mutation.offer.has_value())
return std::unexpected{CellularLivesError::mutation};
auto transition = biology::fund_mutation(
*parent, found->mutation.offer->context, *found->mutation.offer, selection.operator_id,
selection.successor_id, selection.successor_id, found->reserve);
const auto& offer = *found->mutation.offer;
auto transition =
biology::fund_mutation(*parent, offer.context, offer, selection.operator_id,
selection.successor_id, selection.successor_id, found->reserve);
if (!transition) {
if (transition.error() == biology::MutationError::insufficient_funding) {
mutation_results.push_back({selection.life_id, selection.successor_id,