Fix mutation offer optional checks
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m0s
Foundation / checks (checks) (push) Failing after 11m42s
Foundation / checks (client) (push) Successful in 13m23s
Foundation / checks (network) (push) Failing after 12m15s
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 3m22s
Foundation / checks (tsan) (push) Canceled after 1m38s

This commit is contained in:
dingo
2026-10-11 07:42:37 -04:00
parent e107828532
commit 08ecd14ac4
3 changed files with 15 additions and 6 deletions
+7
View File
@@ -6826,3 +6826,10 @@ CI run 270 compiled the reservation slice and passed all 68 CTests, then failed
the format gate on the wrapped call in `tests/region_checkpoint_tests.cpp`. the format gate on the wrapped call in `tests/region_checkpoint_tests.cpp`.
That call now matches local clang-format output; the follow-up CI run is needed That call now matches local clang-format output; the follow-up CI run is needed
to validate the PostgreSQL migration and remaining jobs. to validate the PostgreSQL migration and remaining jobs.
CI run 271 passed the client, deploy, ECS and network jobs, then the PostgreSQL
image's clang-tidy analysis rejected four unchecked mutation-offer optional
accesses in `cellular_lives.cpp` and `cellular_batch.cpp`. The accesses now use
checked `optional::value()` and the trace matcher checks offer presence before
reading it. The PostgreSQL migration/tests did not run in that job; a fresh CI
run is required to validate the repair and schema v29.
+6 -4
View File
@@ -549,15 +549,17 @@ match_cellular_mutation_actions_to_trace(const CellularLives& predecessor,
const auto& mutations = batch.ticks[tick_index].mutations; const auto& mutations = batch.ticks[tick_index].mutations;
const auto selection = std::ranges::lower_bound(mutations, life->identity.life, {}, const auto selection = std::ranges::lower_bound(mutations, life->identity.life, {},
&CellularMutationSelection::life_id); &CellularMutationSelection::life_id);
if (!life->mutation.offer)
return std::unexpected{CellularActionBlockError::mismatch};
const auto& offer = life->mutation.offer.value();
if (selection == mutations.end() || selection->life_id != life->identity.life || if (selection == mutations.end() || selection->life_id != life->identity.life ||
selection->event_index != action.input.event_index || selection->event_index != action.input.event_index ||
selection->offer_tick != action.input.offer_tick || selection->offer_tick != action.input.offer_tick ||
selection->operator_id != action.input.operator_id || !life->mutation.offer || selection->operator_id != action.input.operator_id ||
life->mutation.event_index != action.input.event_index || life->mutation.event_index != action.input.event_index ||
life->mutation.offer_tick != action.input.offer_tick || life->mutation.offer_tick != action.input.offer_tick ||
life->identity.life != action.input.life_id || life->identity.life != action.input.life_id || offer.parent != life->identity.genome ||
life->mutation.offer->parent != life->identity.genome || !std::ranges::any_of(offer.candidates, [&](const auto& candidate) {
!std::ranges::any_of(life->mutation.offer->candidates, [&](const auto& candidate) {
return candidate.operator_id == action.input.operator_id; return candidate.operator_id == action.input.operator_id;
})) }))
return std::unexpected{CellularActionBlockError::mismatch}; return std::unexpected{CellularActionBlockError::mismatch};
+2 -2
View File
@@ -991,7 +991,7 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
return std::unexpected{CellularLivesError::mutation}; return std::unexpected{CellularLivesError::mutation};
if (!life->mutation.offer.has_value()) if (!life->mutation.offer.has_value())
return std::unexpected{CellularLivesError::mutation}; return std::unexpected{CellularLivesError::mutation};
const auto& offer = *life->mutation.offer; const auto& offer = life->mutation.offer.value();
if (offer.parent != life->identity.genome || if (offer.parent != life->identity.genome ||
offer.context.event_index != selection.event_index || offer.context.event_index != selection.event_index ||
!std::ranges::any_of(offer.candidates, !std::ranges::any_of(offer.candidates,
@@ -1115,7 +1115,7 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
const auto parent = next_archive.find(found->identity.genome); const auto parent = next_archive.find(found->identity.genome);
if (!parent || !found->mutation.offer.has_value()) if (!parent || !found->mutation.offer.has_value())
return std::unexpected{CellularLivesError::mutation}; return std::unexpected{CellularLivesError::mutation};
const auto& offer = *found->mutation.offer; const auto& offer = found->mutation.offer.value();
auto transition = auto transition =
biology::fund_mutation(*parent, offer.context, offer, selection.operator_id, biology::fund_mutation(*parent, offer.context, offer, selection.operator_id,
selection.successor_id, selection.successor_id, found->reserve); selection.successor_id, selection.successor_id, found->reserve);