#pragma once #include "evo/persistence/population_checkpoint_store.hpp" #include "evo/server/lifecycle/cellular_census.hpp" #include #include #include #include #include #include namespace evo::persistence { inline constexpr std::size_t max_cellular_history_page = 8; struct CellularCensusHistoryEntry { CommittedCheckpoint committed; server::CellularCensus census; }; struct CellularCensusHistoryPage { RegionKey key{}; RegionHead watermark{}; // Exact immutable regional upper cut, not world coverage. std::vector entries; std::optional next_sequence; }; enum class CellularHistoryError : std::uint8_t { invalid_request, cut_mismatch, recovery }; struct CellularHistoryFailure { CellularHistoryError kind{}; RecoveryFailure recovery{}; // Meaningful only for recovery. }; // Read-only forward history from the existing atomic biological commit journal. // Inclusive first_sequence, at most eight consecutive commits, pinned upper cut. // Full historical replay precedes every census. Any missing/unsupported/false // evidence fails the ENTIRE page; there is no zero/skip/older-head fallback. // Requires an idle connection: caller-owned transactions (including read-only // transactions) are refused so pending writer changes cannot appear durable. // Current grant is used by existing fenced evidence readers; output confers no // live authority, recovery-branch identity or world completeness. Per-I/O timeout. [[nodiscard]] std::expected load_cellular_census_history(Postgres&, const FilesystemObjectStore&, RegionKey, const LeaseGrant&, const RegionHead& watermark, std::uint64_t first_sequence, std::size_t limit, std::span retained_builds, std::chrono::milliseconds timeout); } // namespace evo::persistence