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
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:
@@ -3,6 +3,7 @@
|
||||
#include "evo/network/session_protocol.hpp"
|
||||
#include "evo/persistence/checkpoint_store.hpp"
|
||||
#include "evo/persistence/life_reservation_store.hpp"
|
||||
#include "evo/persistence/population_checkpoint_store.hpp"
|
||||
#include "evo/server/lifecycle/cellular_batch.hpp"
|
||||
#include "evo/server/ops.hpp"
|
||||
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace evo::server {
|
||||
@@ -24,6 +26,7 @@ struct CellularHostConfig {
|
||||
persistence::LeasePolicy lease{};
|
||||
persistence::Sha256Digest build{};
|
||||
std::vector<persistence::Sha256Digest> retained_builds;
|
||||
std::optional<CellularTierPolicy> population_policy{}; // Opt-in profile-5 entry.
|
||||
};
|
||||
enum class CellularHostError : std::uint8_t {
|
||||
configuration,
|
||||
@@ -74,7 +77,7 @@ struct CellularMutationReply {
|
||||
[[nodiscard]] network::CellularMutationOffer
|
||||
offer_view(const CellularLives& state, const CellularOwnedLife& life, std::uint64_t tick);
|
||||
|
||||
// Single-writer profile-4 authority. The caller supplies a complete bounded trace;
|
||||
// Single-writer profile-4/5 authority. The caller supplies a complete bounded trace;
|
||||
// the host replays it from its recovered state and advances only on a confirmed head.
|
||||
class CellularRegionHost {
|
||||
public:
|
||||
@@ -87,6 +90,9 @@ class CellularRegionHost {
|
||||
|
||||
// Acquires/renews authority, recovers fully, or resolves the exact pending commit.
|
||||
const HostStatus& step();
|
||||
// Explicit no-tick fenced transition. Uncertain publication pauses the host.
|
||||
[[nodiscard]] std::expected<void, CellularPublishFailure> set_population_mode(bool enabled);
|
||||
[[nodiscard]] bool population_mode() const noexcept;
|
||||
[[nodiscard]] std::expected<persistence::PublishedCellularBatch, CellularPublishFailure>
|
||||
publish(const CellularBatch& batch, std::span<const CellularActionRecord> actions = {},
|
||||
std::span<const CellularMutationActionRecord> mutation_actions = {});
|
||||
@@ -140,6 +146,9 @@ class CellularRegionHost {
|
||||
void upkeep();
|
||||
void resolve();
|
||||
void refresh();
|
||||
bool recover_state(const persistence::LeaseGrant&);
|
||||
[[nodiscard]] std::expected<persistence::PublishedCellularBatch, CellularPublishFailure>
|
||||
publish_population(const CellularBatch&);
|
||||
void finalize_births(std::span<const CellularTickIntents::Birth> births);
|
||||
void queue_birth(const CellularTickIntents::Birth& birth);
|
||||
void reload_mutations();
|
||||
@@ -158,7 +167,46 @@ class CellularRegionHost {
|
||||
std::unique_ptr<persistence::FilesystemObjectStore> objects_;
|
||||
std::unique_ptr<persistence::Postgres> db_;
|
||||
persistence::LeaseAuthority authority_;
|
||||
std::unique_ptr<CellularLives> state_;
|
||||
// Exactly one owner. The common interface is a const biological view, never
|
||||
// a second independently spendable cellular copy alongside a population.
|
||||
struct OwnedState {
|
||||
std::unique_ptr<CellularLives> individual;
|
||||
std::unique_ptr<CellularPopulation> population;
|
||||
OwnedState() = default;
|
||||
OwnedState(std::unique_ptr<CellularLives> state) : individual(std::move(state)) {}
|
||||
OwnedState(std::unique_ptr<CellularPopulation> state) : population(std::move(state)) {}
|
||||
OwnedState& operator=(std::unique_ptr<CellularLives> state) {
|
||||
population.reset();
|
||||
individual = std::move(state);
|
||||
return *this;
|
||||
}
|
||||
OwnedState& operator=(std::unique_ptr<CellularPopulation> state) {
|
||||
individual.reset();
|
||||
population = std::move(state);
|
||||
return *this;
|
||||
}
|
||||
void reset() {
|
||||
individual.reset();
|
||||
population.reset();
|
||||
}
|
||||
const CellularLives* get() const {
|
||||
return population ? &population->state() : individual.get();
|
||||
}
|
||||
const CellularLives* operator->() const {
|
||||
return get();
|
||||
}
|
||||
const CellularLives& operator*() const {
|
||||
return *get();
|
||||
}
|
||||
explicit operator bool() const {
|
||||
return get() != nullptr;
|
||||
}
|
||||
};
|
||||
[[nodiscard]] std::expected<persistence::CommittedCheckpoint, CellularPublishFailure>
|
||||
accept_population_publication(
|
||||
std::expected<persistence::CommittedCheckpoint, persistence::PopulationPublicationFailure>,
|
||||
OwnedState candidate);
|
||||
OwnedState state_;
|
||||
std::optional<persistence::CommittedCheckpoint> committed_;
|
||||
std::unique_ptr<Pending> pending_;
|
||||
std::vector<FinalCellularAction> finalized_actions_;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace evo::server {
|
||||
struct CellularPopulationBatch;
|
||||
// ADR-0139: exact local cohorts retain individuals, never mean reserves or samples.
|
||||
// The single owned CellularLives store backs BOTH representations, exactly once.
|
||||
struct CellularCohortMember {
|
||||
@@ -72,6 +73,8 @@ class CellularPopulation {
|
||||
std::span<const CellularMutationSelection> selections = {});
|
||||
|
||||
private:
|
||||
friend std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
|
||||
execute_population_batch(const CellularPopulation&, CellularPopulationBatch&, bool);
|
||||
explicit CellularPopulation(std::unique_ptr<CellularLives> state, CellularTierPolicy policy);
|
||||
void apply_policy();
|
||||
std::unique_ptr<CellularLives> state_;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/server/lifecycle/cellular_batch.hpp"
|
||||
#include "evo/server/lifecycle/cellular_population.hpp"
|
||||
|
||||
namespace evo::server {
|
||||
struct CellularPopulationBoundary {
|
||||
std::uint64_t sequence{};
|
||||
std::vector<CellularCohortMember> members;
|
||||
bool operator==(const CellularPopulationBoundary&) const = default;
|
||||
};
|
||||
struct CellularPopulationConversion {
|
||||
std::uint64_t genome{};
|
||||
bool to_cohort{};
|
||||
bool operator==(const CellularPopulationConversion&) const = default;
|
||||
};
|
||||
struct CellularPopulationBatch {
|
||||
CellularBatchHeader header;
|
||||
// Exactly one: 1..64 unattended biological ticks, or a no-tick whole-group conversion.
|
||||
CellularBatch biology;
|
||||
std::optional<CellularPopulationConversion> conversion;
|
||||
std::vector<CellularPopulationBoundary> boundaries;
|
||||
bool operator==(const CellularPopulationBatch&) const = default;
|
||||
};
|
||||
inline constexpr std::size_t population_batch_header_bytes = 136;
|
||||
inline constexpr std::size_t max_population_batch_bytes =
|
||||
population_batch_header_bytes + max_cellular_batch_bytes +
|
||||
max_cellular_batch_ticks * (16 + 16 * biology::max_cellular_tick_lives);
|
||||
struct CellularPopulationExecution {
|
||||
CellularPopulationBatch batch;
|
||||
std::unique_ptr<CellularPopulation> state;
|
||||
};
|
||||
// Build an unattended interval from a detached biological copy. Controlled cells
|
||||
// receive frozen-only intentions; the unchanged wildlife controller supplies the
|
||||
// rest. The returned recorded intentions replay without rerunning that controller.
|
||||
[[nodiscard]] std::expected<CellularBatch, CellularPopulationError>
|
||||
unattended_population_inputs(const CellularLives&, const CellularBatchHeader&);
|
||||
[[nodiscard]] std::expected<CellularPopulationExecution, CellularPopulationError>
|
||||
prepare_population_batch(const CellularPopulation& base, CellularBatch biology);
|
||||
[[nodiscard]] std::expected<CellularPopulationExecution, CellularPopulationError>
|
||||
prepare_population_conversion(const CellularPopulation& base, CellularBatchHeader header,
|
||||
CellularPopulationConversion conversion);
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
|
||||
replay_population_batch(const CellularPopulation& base, const CellularPopulationBatch& batch);
|
||||
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularPopulationError>
|
||||
encode_population_batch(const CellularPopulationBatch& batch);
|
||||
[[nodiscard]] std::expected<CellularPopulationBatch, CellularPopulationError>
|
||||
decode_population_batch(std::span<const std::uint8_t> bytes);
|
||||
} // namespace evo::server
|
||||
Reference in New Issue
Block a user