Files
aevolution/include/evo/server/lifecycle/cellular_population_batch.hpp
T
dingo 627411983f
Foundation / checks (ecs) (push) Successful in 2m41s
Foundation / checks (tsan) (push) Failing after 18m12s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 20m41s
Foundation / checks (postgres) (push) Canceled after 20m43s
Foundation / checks (checks) (push) Canceled after 20m49s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (client) (push) Failing after 17m4s
Foundation / postgres-tools (push) Canceled after 0s
M12.3: publish and recover durable exact populations
2026-10-17 17:10:17 -04:00

50 lines
2.5 KiB
C++

#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<CellularCohortMember> 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<CellularPopulationConversion> conversion;
std::vector<CellularPopulationBoundary> 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<CellularPopulation> 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<CellularBatch, CellularPopulationError>
unattended_population_inputs(const CellularLives&, const CellularBatchHeader&);
[[nodiscard]] std::expected<CellularPopulationExecution, CellularPopulationError>
prepare_population_batch(const CellularPopulation& base, CellularBatch biology);
[[nodiscard]] std::expected<CellularPopulationExecution, CellularPopulationError>
prepare_population_conversion(const CellularPopulation& base, CellularBatchHeader header,
CellularPopulationConversion conversion);
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
replay_population_batch(const CellularPopulation& base, const CellularPopulationBatch& batch);
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularPopulationError>
encode_population_batch(const CellularPopulationBatch& batch);
[[nodiscard]] std::expected<CellularPopulationBatch, CellularPopulationError>
decode_population_batch(std::span<const std::uint8_t> bytes);
} // namespace evo::server