Complete M7.4b lineage checkpoint profile; M7.4 done
ADR-0062 adds a canonical LineageArchive codec (parents before children, organisms by id, FNV) that decodes by replaying admit/record_birth/ record_death and requires byte-identical re-encoding; it never overwrites an existing archive. LineageRegion binds the environmental producer and consumer accounts to archived organisms with identity high-waters, enforces closure (lifecycle vs deaths, exact living set, tick bounds) and records deaths in the tick that causes them. Checkpoint profile 2 (environmental-lineage-v1, history profile 1) publishes that container; schema v4 admits it with a 4,268,144-byte cap and requires each commit to keep its predecessor's profile, RNG, history and durability declarations. Linux adds provision/publish/recover for the profile on the shared publication path. Qualification found WSL2 stepping CLOCK_REALTIME back ~0.5 s every ~32 s, which made two 1 s-lease tests flaky under ASan. Tests now wait on database-time expiry; ADR-0060 records the slewed-clock requirement. Validated: Windows CTest 57/57; Linux GCC Debug/Release, clang-tidy and ASan/UBSan CTest 57/57 each; PostgreSQL suites 2x Release, 2x analysis, 5x ASan; SQL and C++ mutations each caught. No Docker/Gitea CI, remote store, process kill or deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "evo/persistence/region_lease.hpp"
|
||||
#include "evo/processes/environmental_community.hpp"
|
||||
#include "evo/processes/lineage_region.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
@@ -8,12 +9,19 @@
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
// Region checkpoint manifest v1 and environmental-v1 payload validation (ADR-0061,
|
||||
// schemas/region-commit.md). Portable and storage-free: digests are computed and
|
||||
// objects are stored by the Linux adapters; this only encodes and validates.
|
||||
// Region checkpoint manifest v1 and payload validation for environmental-v1
|
||||
// (ADR-0061) and environmental-lineage-v1 (ADR-0062), schemas/region-commit.md. Portable and
|
||||
// storage-free: digests are computed and objects are stored by the Linux adapters; this only
|
||||
// encodes and validates.
|
||||
namespace evo::persistence {
|
||||
// Encoded as u32 on the wire; values above 255 decode as unknown (0), never truncated.
|
||||
enum class CheckpointProfile : std::uint8_t { unknown = 0, environmental_v1 = 1 };
|
||||
enum class CheckpointProfile : std::uint8_t {
|
||||
unknown = 0,
|
||||
environmental_v1 = 1, // Environmental envelope only; history_profile 0.
|
||||
environmental_lineage_v1 = 2, // LineageRegion container; history_profile 1.
|
||||
};
|
||||
// history_profile 1: lineage archive format 1 with genome schema 1.
|
||||
inline constexpr std::uint32_t lineage_history_profile = 1;
|
||||
// Declared durability, verified at deployment. Development: one volume, no host-loss claim.
|
||||
enum class DurabilityPolicy : std::uint8_t { unknown = 0, single_volume_development = 1 };
|
||||
|
||||
@@ -40,8 +48,8 @@ struct CheckpointManifest {
|
||||
std::uint64_t tick_microseconds{};
|
||||
VersionBundle versions{};
|
||||
Sha256Digest build{}; // Retained immutable build artifact identity.
|
||||
std::uint32_t rng_streams{}; // environmental-v1 rules use no randomness: 0.
|
||||
std::uint32_t history_profile{}; // No lineage/genome state in environmental-v1: 0.
|
||||
std::uint32_t rng_streams{}; // These rules use no randomness: 0.
|
||||
std::uint32_t history_profile{}; // 0 environmental-v1; 1 environmental-lineage-v1.
|
||||
DurabilityPolicy durability{DurabilityPolicy::single_volume_development};
|
||||
std::uint64_t payload_bytes{};
|
||||
Sha256Digest payload_sha256{};
|
||||
@@ -50,6 +58,13 @@ struct CheckpointManifest {
|
||||
|
||||
inline constexpr std::size_t checkpoint_manifest_bytes = 280;
|
||||
inline constexpr std::size_t max_environmental_payload_bytes = std::size_t{1024} * 1024;
|
||||
inline constexpr std::size_t max_lineage_payload_bytes = processes::max_lineage_region_bytes;
|
||||
// Payload cap by profile; zero for an unknown profile.
|
||||
[[nodiscard]] constexpr std::size_t max_payload_bytes(CheckpointProfile profile) noexcept {
|
||||
return profile == CheckpointProfile::environmental_v1 ? max_environmental_payload_bytes
|
||||
: profile == CheckpointProfile::environmental_lineage_v1 ? max_lineage_payload_bytes
|
||||
: 0;
|
||||
}
|
||||
inline constexpr std::uint64_t max_checkpoint_ticks = 64;
|
||||
|
||||
enum class CheckpointError : std::uint8_t {
|
||||
@@ -65,15 +80,17 @@ enum class CheckpointError : std::uint8_t {
|
||||
encode_manifest(const CheckpointManifest& manifest);
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
decode_manifest(std::span<const std::uint8_t> bytes);
|
||||
// Profile, exact versions, zero RNG/history declarations and durability policy.
|
||||
// Profile with its history profile, exact versions, zero RNG and durability policy.
|
||||
[[nodiscard]] bool supported(const CheckpointManifest& manifest) noexcept;
|
||||
|
||||
// Genesis for operator provisioning only; recovery never creates one.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
genesis_manifest(RegionKey key, std::uint64_t frame, Uuid commit, std::uint64_t tick_microseconds,
|
||||
const Sha256Digest& build, std::uint64_t payload_bytes,
|
||||
const Sha256Digest& payload_sha256);
|
||||
const Sha256Digest& payload_sha256,
|
||||
CheckpointProfile profile = CheckpointProfile::environmental_v1);
|
||||
// Next link from the committed predecessor and its manifest digest under a lease.
|
||||
// Profile, versions and quantum are inherited: a region never changes them.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
successor_manifest(const CheckpointManifest& predecessor, const Sha256Digest& predecessor_digest,
|
||||
Uuid commit, const LeaseGrant& lease, std::uint64_t end_tick,
|
||||
@@ -86,4 +103,10 @@ successor_manifest(const CheckpointManifest& predecessor, const Sha256Digest& pr
|
||||
[[nodiscard]] std::expected<std::unique_ptr<processes::EnvironmentalCommunity>, CheckpointError>
|
||||
restore_environmental_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& manifest, std::size_t budget);
|
||||
// environmental-lineage-v1: restores the container (envelope replay audit, archive
|
||||
// replay through its invariants, closure) with the same identity/tick/quantum,
|
||||
// nested envelope format 2 and canonical checks.
|
||||
[[nodiscard]] std::expected<std::unique_ptr<processes::LineageRegion>, CheckpointError>
|
||||
restore_lineage_payload(std::span<const std::uint8_t> payload, const CheckpointManifest& manifest,
|
||||
std::size_t budget);
|
||||
} // namespace evo::persistence
|
||||
|
||||
Reference in New Issue
Block a user