Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m23s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 14m44s
Foundation / checks (checks) (push) Canceled after 14m44s
Foundation / checks (network) (push) Canceled after 14m43s
Foundation / checks (postgres) (push) Canceled after 14m42s
Foundation / checks (tsan) (push) Canceled after 14m43s
54 lines
2.8 KiB
C++
54 lines
2.8 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;
|
|
std::uint32_t format_version{1}; // 1: envelope 1/owner 6; 2: envelope 2/owner 7.
|
|
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
|