#pragma once #include "evo/persistence/checkpoint_store.hpp" namespace evo::persistence { struct PopulationPreparedCommit { RegionKey key{}; Uuid commit{}; std::vector manifest, trace; // Empty trace means a profile transition. }; struct PopulationPublicationFailure { PublicationError kind{}; LeaseStoreFailure store{}; ObjectError object{}; PopulationPreparedCommit prepared; }; struct RecoveredPopulationCheckpoint { CommittedCheckpoint committed; CheckpointManifest manifest; std::unique_ptr state; }; // Explicit no-tick transitions, under the same lease/head fence as publication. [[nodiscard]] std::expected migrate_cellular_to_population(Postgres&, const FilesystemObjectStore&, const LeaseGrant&, const CommittedCheckpoint&, Uuid commit, const Sha256Digest& build, server::CellularTierPolicy, std::chrono::milliseconds timeout, const PublishHooks& hooks = {}); [[nodiscard]] std::expected materialize_population_profile(Postgres&, const FilesystemObjectStore&, const LeaseGrant&, const CommittedCheckpoint&, Uuid commit, const Sha256Digest& build, std::chrono::milliseconds timeout, const PublishHooks& hooks = {}); [[nodiscard]] std::expected publish_population_batch(Postgres&, const FilesystemObjectStore&, const LeaseGrant&, const CommittedCheckpoint&, const server::CellularPopulationBatch&, const server::CellularPopulation& candidate, Uuid commit, const Sha256Digest& build, std::chrono::milliseconds timeout, const PublishHooks& hooks = {}); [[nodiscard]] std::expected retry_population_prepared(Postgres&, const PopulationPreparedCommit&, std::chrono::milliseconds timeout); [[nodiscard]] std::expected resolve_population_prepared(Postgres&, const PopulationPreparedCommit&, std::chrono::milliseconds timeout); [[nodiscard]] std::expected recover_population_checkpoint(Postgres&, const FilesystemObjectStore&, RegionKey, const LeaseGrant&, std::span retained_builds, std::chrono::milliseconds timeout); // Explicit read-only historical recovery. It does not replace the current head // or grant ownership; all ordinary evidence/complete replay checks still apply. [[nodiscard]] std::expected recover_population_commit(Postgres&, const FilesystemObjectStore&, RegionKey, std::uint64_t sequence, const LeaseGrant&, std::span retained_builds, std::chrono::milliseconds timeout); // Used by raw cellular recovery after a population -> individual profile transition. [[nodiscard]] std::expected verify_population_profile_transition(Postgres&, const FilesystemObjectStore&, const LeaseGrant&, const CommittedCheckpoint&, const CheckpointManifest&, std::span payload, std::chrono::milliseconds timeout); } // namespace evo::persistence