#pragma once #include "evo/server/lifecycle/cellular_lives.hpp" #include #include #include #include #include #include namespace evo::server { // ADR-0139: exact local cohorts retain individuals, never mean reserves or samples. // The single owned CellularLives store backs BOTH representations, exactly once. struct CellularCohortMember { std::uint64_t life{}, genome{}; auto operator<=>(const CellularCohortMember&) const = default; }; enum class CellularPopulationError : std::uint8_t { unsupported, absent, ineligible }; class CellularPopulation { public: [[nodiscard]] static std::expected, CellularPopulationError> create(std::unique_ptr state); CellularPopulation(const CellularPopulation&) = delete; CellularPopulation& operator=(const CellularPopulation&) = delete; // Read-only biology view: it confers no separate spending rights. [[nodiscard]] const CellularLives& state() const noexcept; [[nodiscard]] std::span members() const noexcept; [[nodiscard]] bool in_cohort(std::uint64_t life) const noexcept; // Convert the WHOLE eligible wildlife genome group. No selectable healthy subset, // resampling, rounding, new identity, healing, age reset or inventory transfer. // Controlled lives are never members. Refusal leaves biology and ownership unchanged. [[nodiscard]] std::expected collapse(std::uint64_t genome); [[nodiscard]] std::expected materialize(std::uint64_t genome); // Only controlled-life intentions/selections are supplied by the host, sorted by ID. // All wildlife, including cohorts, uses the unchanged shared controller and kernel. [[nodiscard]] std::expected advance_tick(std::span controlled, std::span selections = {}); private: explicit CellularPopulation(std::unique_ptr state); std::unique_ptr state_; std::vector members_; // Sorted life IDs, unique ownership tags. }; } // namespace evo::server