#pragma once #include #include #include #include #include #include namespace ReloadableHost { inline constexpr std::uint32_t kCurrentCheckpointVersion{3}; /// Durable workflow state carried across releases. struct CheckpointState { std::uint64_t counter{0}; std::string workflow; std::uint64_t generation{0}; }; struct CheckpointLimits { std::size_t max_bytes{64ULL * 1024ULL}; std::size_t max_workflow_bytes{4ULL * 1024ULL}; }; /// Encode the current checkpoint schema (bounded). [[nodiscard]] Void::Result::Result> encode_checkpoint(const CheckpointState& state, CheckpointLimits limits = {}); /// Decode a supported checkpoint and migrate it to the current schema. /// /// v1 (counter) and v2 (counter + workflow) are migrated forward with /// defaults for fields they did not have. Corrupt magic, truncation, /// oversized payloads and unknown newer versions are rejected. [[nodiscard]] Void::Result::Result decode_checkpoint(std::span bytes, CheckpointLimits limits = {}); } // namespace ReloadableHost