#pragma once #include "evo/server/lifecycle/cellular_batch.hpp" #include "evo/server/lifecycle/cellular_population.hpp" namespace evo::server { struct CellularPopulationBoundary { std::uint64_t sequence{}; std::vector members; bool operator==(const CellularPopulationBoundary&) const = default; }; struct CellularPopulationConversion { std::uint64_t genome{}; bool to_cohort{}; bool operator==(const CellularPopulationConversion&) const = default; }; struct CellularPopulationBatch { CellularBatchHeader header; // Exactly one: 1..64 unattended biological ticks, or a no-tick whole-group conversion. CellularBatch biology; std::optional conversion; std::vector boundaries; bool operator==(const CellularPopulationBatch&) const = default; }; inline constexpr std::size_t population_batch_header_bytes = 136; inline constexpr std::size_t max_population_batch_bytes = population_batch_header_bytes + max_cellular_batch_bytes + max_cellular_batch_ticks * (16 + 16 * biology::max_cellular_tick_lives); struct CellularPopulationExecution { CellularPopulationBatch batch; std::unique_ptr state; }; // Build an unattended interval from a detached biological copy. Controlled cells // receive frozen-only intentions; the unchanged wildlife controller supplies the // rest. The returned recorded intentions replay without rerunning that controller. [[nodiscard]] std::expected unattended_population_inputs(const CellularLives&, const CellularBatchHeader&); [[nodiscard]] std::expected prepare_population_batch(const CellularPopulation& base, CellularBatch biology); [[nodiscard]] std::expected prepare_population_conversion(const CellularPopulation& base, CellularBatchHeader header, CellularPopulationConversion conversion); [[nodiscard]] std::expected, CellularPopulationError> replay_population_batch(const CellularPopulation& base, const CellularPopulationBatch& batch); [[nodiscard]] std::expected, CellularPopulationError> encode_population_batch(const CellularPopulationBatch& batch); [[nodiscard]] std::expected decode_population_batch(std::span bytes); } // namespace evo::server