Files
aevolution/include/evo/server/lifecycle/cellular_migration_trace.hpp
T
dingo d3a867a662
Foundation / checks (ecs) (push) Successful in 2m20s
Foundation / checks (deploy) (push) Successful in 4m7s
Foundation / checks (network) (push) Successful in 21m2s
Foundation / checks (client) (push) Successful in 22m21s
Foundation / checks (tsan) (push) Successful in 28m57s
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 38m8s
Foundation / checks (checks) (push) Canceled after 38m19s
feat(persistence): admit durable maturing wildlife migrations
2026-10-19 11:57:00 -04:00

63 lines
3.1 KiB
C++

#pragma once
#include "evo/server/lifecycle/cellular_migration.hpp"
#include <array>
namespace evo::server {
struct CellularMigrationEndpoint {
std::uint64_t region{};
std::array<std::uint8_t, 16> predecessor{}, commit{};
std::array<std::uint8_t, 32> predecessor_digest{};
bool operator==(const CellularMigrationEndpoint&) const = default;
};
struct CellularMigrationRequest {
std::array<std::uint8_t, 16> 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<std::uint64_t> 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<RecordedCellularMigration, CellularMigrationError>
prepare_migration_trace(const CellularLives&, const CellularLives&,
const CellularMigrationRequest&);
[[nodiscard]] std::expected<RecordedPopulationMigration, CellularMigrationError>
prepare_migration_trace(const CellularPopulation&, const CellularPopulation&,
const CellularMigrationRequest&);
[[nodiscard]] std::expected<CellularMigrationExecution, CellularMigrationError>
replay_migration_trace(const CellularLives&, const CellularLives&,
const CellularMigrationRequest& trusted, const CellularMigrationTrace&);
[[nodiscard]] std::expected<CellularPopulationMigrationExecution, CellularMigrationError>
replay_migration_trace(const CellularPopulation&, const CellularPopulation&,
const CellularMigrationRequest& trusted, const CellularMigrationTrace&);
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularMigrationError>
encode_migration_trace(const CellularMigrationTrace&);
[[nodiscard]] std::expected<CellularMigrationTrace, CellularMigrationError>
decode_migration_trace(std::span<const std::uint8_t>);
} // namespace evo::server