Files
aevolution/include/evo/server/lifecycle/cellular_population_batch.hpp
T
dingo 0a8962b57e
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m28s
Foundation / checks (tsan) (push) Failing after 18m22s
Foundation / checks (network) (push) Successful in 20m38s
Foundation / checks (client) (push) Failing after 21m6s
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 46m54s
Foundation / checks (checks) (push) Canceled after 47m3s
M12.4: retain and settle owned population intervals
2026-10-17 17:31:05 -04:00

53 lines
2.7 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;
};
// Lingering controlled cells remain vulnerable. Their permanent death path must
// stay on profile 4; unattended population intervals require full suspension.
[[nodiscard]] bool population_interval_safe(const CellularLives&) noexcept;
// 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