Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m12s
Foundation / checks (network) (push) Successful in 20m57s
Foundation / checks (client) (push) Successful in 22m9s
Foundation / checks (tsan) (push) Successful in 28m49s
Foundation / checks (postgres) (push) Successful in 1h5m2s
Foundation / checks (checks) (push) Successful in 1h17m42s
Foundation / postgres-tools (push) Successful in 1m10s
Foundation / server-image (push) Successful in 3m51s
Foundation / image (push) Successful in 4m54s
63 lines
3.1 KiB
C++
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.
|
|
// Portable trace 2 does not extend the durable bundle-10/trace-1 allowlist.
|
|
[[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
|