M12.3: publish and recover durable exact populations
Foundation / checks (ecs) (push) Successful in 2m41s
Foundation / checks (tsan) (push) Failing after 18m12s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 20m41s
Foundation / checks (postgres) (push) Canceled after 20m43s
Foundation / checks (checks) (push) Canceled after 20m49s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (client) (push) Failing after 17m4s
Foundation / postgres-tools (push) Canceled after 0s

This commit is contained in:
dingo
2026-10-17 17:10:17 -04:00
parent d5d10a0cc7
commit 627411983f
35 changed files with 2637 additions and 102 deletions
@@ -0,0 +1,54 @@
#pragma once
#include "evo/persistence/checkpoint_store.hpp"
namespace evo::persistence {
struct PopulationPreparedCommit {
RegionKey key{};
Uuid commit{};
std::vector<std::uint8_t> 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<server::CellularPopulation> state;
};
// Explicit no-tick transitions, under the same lease/head fence as publication.
[[nodiscard]] std::expected<CommittedCheckpoint, PopulationPublicationFailure>
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<CommittedCheckpoint, PopulationPublicationFailure>
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<CommittedCheckpoint, PopulationPublicationFailure>
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<CommittedCheckpoint, PopulationPublicationFailure>
retry_population_prepared(Postgres&, const PopulationPreparedCommit&,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<ResolvedCommit, LeaseStoreFailure>
resolve_population_prepared(Postgres&, const PopulationPreparedCommit&,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<RecoveredPopulationCheckpoint, RecoveryFailure>
recover_population_checkpoint(Postgres&, const FilesystemObjectStore&, RegionKey, const LeaseGrant&,
std::span<const Sha256Digest> retained_builds,
std::chrono::milliseconds timeout);
// Used by raw cellular recovery after a population -> individual profile transition.
[[nodiscard]] std::expected<void, RecoveryFailure>
verify_population_profile_transition(Postgres&, const FilesystemObjectStore&, const LeaseGrant&,
const CommittedCheckpoint&, const CheckpointManifest&,
std::span<const std::uint8_t> payload,
std::chrono::milliseconds timeout);
} // namespace evo::persistence
+21 -1
View File
@@ -5,6 +5,7 @@
#include "evo/processes/lineage_region.hpp"
#include "evo/server/lifecycle/cellular_batch.hpp"
#include "evo/server/lifecycle/cellular_lives.hpp"
#include "evo/server/lifecycle/cellular_population_batch.hpp"
#include "evo/server/lifecycle/primitive_batch.hpp"
#include <cstddef>
#include <cstdint>
@@ -25,12 +26,14 @@ enum class CheckpointProfile : std::uint8_t {
environmental_lineage_v1 = 2, // LineageRegion container; history_profile 1.
primitive_lives_v1 = 3, // Funded creation state; history_profile 2.
cellular_lives_v1 = 4, // Complete cellular state; history_profile 3.
cellular_population_v1 = 5, // Population envelope 1; nested cellular bundle 9.
};
// history_profile 1: lineage archive format 1 with genome schema 1.
inline constexpr std::uint32_t lineage_history_profile = 1;
// Archive format 1, genome schema 2, development 2, founder-life rules 1.
inline constexpr std::uint32_t primitive_history_profile = 2;
inline constexpr std::uint32_t cellular_history_profile = 3;
inline constexpr std::uint32_t population_history_profile = 5;
inline constexpr std::uint32_t cellular_revision_history_profile = 4;
// Declared durability, verified at deployment. Development: one volume, no host-loss claim.
enum class DurabilityPolicy : std::uint8_t { unknown = 0, single_volume_development = 1 };
@@ -119,7 +122,9 @@ inline constexpr std::size_t max_lineage_payload_bytes = processes::max_lineage_
: profile == CheckpointProfile::environmental_lineage_v1 ? max_lineage_payload_bytes
: profile == CheckpointProfile::primitive_lives_v1 ? server::max_primitive_lives_bytes
: profile == CheckpointProfile::cellular_lives_v1 ? server::max_cellular_lives_bytes
: 0;
: profile == CheckpointProfile::cellular_population_v1
? server::max_cellular_population_bytes
: 0;
}
inline constexpr std::uint64_t max_checkpoint_ticks = 64;
@@ -189,4 +194,19 @@ restore_primitive_payload(std::span<const std::uint8_t> payload,
const CheckpointManifest& manifest);
[[nodiscard]] std::expected<std::unique_ptr<server::CellularLives>, CheckpointError>
restore_cellular_payload(std::span<const std::uint8_t> payload, const CheckpointManifest& manifest);
[[nodiscard]] std::expected<std::unique_ptr<server::CellularPopulation>, CheckpointError>
restore_population_payload(std::span<const std::uint8_t> payload,
const CheckpointManifest& manifest);
// Dedicated profile 4/bundle 9 <-> profile 5 transition, no biological tick.
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
population_profile_transition_manifest(const CheckpointManifest& predecessor,
const Sha256Digest& predecessor_digest, Uuid commit,
const LeaseGrant& lease, const Sha256Digest& build,
std::uint64_t payload_bytes,
const Sha256Digest& payload_sha256);
// Population manual conversion may publish at the same tick with a nonempty trace.
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError> population_successor_manifest(
const CheckpointManifest& predecessor, const Sha256Digest& predecessor_digest, Uuid commit,
const LeaseGrant& lease, std::uint64_t end_tick, const Sha256Digest& build,
std::uint64_t payload_bytes, const Sha256Digest& payload_sha256, const BatchDigests& batch);
} // namespace evo::persistence
@@ -217,4 +217,23 @@ pending_region_outbox(Postgres& db, RegionKey key, std::uint32_t limit,
[[nodiscard]] std::expected<bool, LeaseStoreFailure>
acknowledge_region_outbox(Postgres& db, RegionKey key, const BatchDecision& decision,
std::chrono::milliseconds timeout);
struct PopulationEvidence {
std::vector<std::uint8_t> trace;
std::optional<Uuid> source_commit;
Sha256Digest source_manifest_sha256{}, source_payload_sha256{};
};
[[nodiscard]] std::expected<RegionHead, LeaseStoreFailure>
publish_population_checkpoint(Postgres&, std::span<const std::uint8_t> manifest,
std::span<const std::uint8_t> trace,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<RegionHead, LeaseStoreFailure>
publish_population_profile_transition(Postgres&, std::span<const std::uint8_t> manifest,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<ResolvedCommit, LeaseStoreFailure>
resolve_population_commit(Postgres&, RegionKey, const Uuid& commit,
std::span<const std::uint8_t> manifest,
std::span<const std::uint8_t> trace, std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<std::optional<PopulationEvidence>, LeaseStoreFailure>
load_population_evidence(Postgres&, RegionKey, const LeaseGrant&, const Uuid& commit,
std::chrono::milliseconds timeout);
} // namespace evo::persistence