#pragma once #include "evo/server/lifecycle/cellular_migration.hpp" #include namespace evo::server { struct CellularMigrationEndpoint { std::uint64_t region{}; std::array predecessor{}, commit{}; std::array predecessor_digest{}; bool operator==(const CellularMigrationEndpoint&) const = default; }; struct CellularMigrationRequest { std::array request{}; CellularMigrationEndpoint source, destination; std::uint64_t genome{}; bool operator==(const CellularMigrationRequest&) const = default; }; enum class CellularMigrationRepresentation : std::uint8_t { individual = 1, population = 2 }; struct CellularMigrationTrace { CellularMigrationRepresentation representation{CellularMigrationRepresentation::individual}; std::uint64_t world{}, frame{}, tick{}; CellularMigrationRequest request; accounting::Inventory transferred; std::vector members; // Trace 1 retains rules 8; trace 2 requires rules 9. Both require owner 7. std::uint32_t format_version{1}; bool operator==(const CellularMigrationTrace&) const = default; }; inline constexpr std::size_t migration_trace_header_bytes = 256; inline constexpr std::size_t max_migration_trace_bytes = migration_trace_header_bytes + 8 * biology::max_cellular_tick_lives + 8; struct RecordedCellularMigration { CellularMigrationTrace trace; CellularMigrationExecution execution; }; struct RecordedPopulationMigration { CellularMigrationTrace trace; CellularPopulationMigrationExecution execution; }; // Portable recorded pair, not a receipt or ownership grant. The I/O adapter must // establish the trusted request against BOTH immutable predecessor manifests and // digest-checked payloads, then fence/commit both results before activation. // Durable admission is separate (ADR-0161/schema 54); a trace grants no authority. [[nodiscard]] std::expected prepare_migration_trace(const CellularLives&, const CellularLives&, const CellularMigrationRequest&); [[nodiscard]] std::expected prepare_migration_trace(const CellularPopulation&, const CellularPopulation&, const CellularMigrationRequest&); [[nodiscard]] std::expected replay_migration_trace(const CellularLives&, const CellularLives&, const CellularMigrationRequest& trusted, const CellularMigrationTrace&); [[nodiscard]] std::expected replay_migration_trace(const CellularPopulation&, const CellularPopulation&, const CellularMigrationRequest& trusted, const CellularMigrationTrace&); [[nodiscard]] std::expected, CellularMigrationError> encode_migration_trace(const CellularMigrationTrace&); [[nodiscard]] std::expected decode_migration_trace(std::span); } // namespace evo::server