Files
aevolution/include/evo/persistence/cellular_census_snapshot.hpp
T
dingo dc7c0e1fa1
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 1m13s
Foundation / checks (client) (push) Canceled after 1m14s
Foundation / checks (postgres) (push) Canceled after 1m7s
Foundation / checks (deploy) (push) Canceled after 1m13s
Foundation / checks (ecs) (push) Canceled after 1m13s
Foundation / checks (network) (push) Canceled after 1m14s
feat(ecology): distinguish inherited plans in verified census
2026-10-19 15:06:47 -04:00

98 lines
4.5 KiB
C++

#pragma once
#include "evo/persistence/cellular_history_store.hpp"
#include "evo/persistence/cellular_migration_store.hpp"
#include "evo/server/lifecycle/cellular_census_set.hpp"
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <functional>
#include <span>
#include <vector>
namespace evo::persistence {
struct CellularCensusRegionRequest {
std::uint64_t region{};
LeaseGrant lease{};
const FilesystemObjectStore* objects{}; // Non-owning, valid throughout the call.
};
struct CellularCensusSnapshot {
std::vector<CommittedCheckpoint> cuts; // Sorted regions, exact captured head/manifest pairs.
server::CellularCensusSet census;
};
enum class CellularSnapshotError : std::uint8_t {
invalid_request,
transaction,
history,
census,
coverage,
context,
migration
};
struct RegisteredCellularRegion {
std::uint64_t region{}, frame{};
bool operator==(const RegisteredCellularRegion&) const = default;
};
enum class CellularCoverageError : std::uint8_t {
store,
unknown_world,
bounds,
regions,
frame,
malformed
};
struct CellularCoverageFailure {
CellularCoverageError kind{};
PgFailure cause{}; // Meaningful for store.
};
struct RegisteredCellularCensusSnapshot {
std::vector<RegisteredCellularRegion> catalog; // Exact registry view used for head selection.
CellularCensusSnapshot snapshot;
Uuid history_domain{}; // Schema 51 database namespace captured with catalog and heads.
std::vector<CellularMigrationObservation> migrations; // Schema 52 verified pending handoffs.
};
struct CellularSnapshotFailure {
CellularSnapshotError kind{};
std::uint64_t region{}; // Failed region, or zero for a request/transaction/set error.
PgFailure transaction{}; // Meaningful for transaction.
CellularHistoryFailure history{}; // Meaningful for history.
server::CellularCensusSetError census{}; // Meaningful for census.
CellularCoverageFailure coverage{}; // Meaningful for coverage.
RecoveryFailure migration{}; // Meaningful for migration; no partial result on failure.
};
// Test/fault seam after each head has been captured (zero-based request index).
// Production callers pass nothing. A throwing hook closes the capture connection.
struct CellularCensusSnapshotHooks {
std::function<void(std::size_t)> after_head;
};
// Idle connected session only. Requests: 1..64, nonzero strictly ascending regions
// in one world; all stores nonnull. Capture current heads in a short READ ONLY
// REPEATABLE READ transaction, finish it, then fully replay each immutable cut.
// All cuts must share frame/tick/owner/rules/quantum/projection. No partial census.
// Per-I/O timeout 1..30000 ms; no automatic retry or whole-query latency promise.
// Metadata failures roll back; failed cleanup or an exception closes the session.
// Caller-declared coverage, NOT world/branch completeness or live authority.
[[nodiscard]] std::expected<CellularCensusSnapshot, CellularSnapshotFailure>
load_cellular_census_snapshot(Postgres&, std::uint64_t world,
std::span<const CellularCensusRegionRequest>,
std::span<const Sha256Digest> retained_builds,
std::chrono::milliseconds timeout,
const CellularCensusSnapshotHooks& hooks = {});
// Schema 52: require resources for EVERY registered region of this world,
// including expired/released holders and regions with unavailable checkpoints.
// Capture domain, registry, pending handoffs and heads in the SAME database view.
// Fully verify retained handoff capsules/ghosts after capture. Ghosts add no stock.
// Empty/over-bound registries or any coverage/frame mismatch fail, never zero.
// Completeness is only for registered regions of this connected database view;
// Domain/world identifies this database history, including supported restore forks.
// No other viable-store reconciliation, live authority or terminal extinction.
[[nodiscard]] std::expected<RegisteredCellularCensusSnapshot, CellularSnapshotFailure>
load_registered_cellular_census_snapshot(Postgres&, std::uint64_t world,
std::span<const CellularCensusRegionRequest>,
std::span<const Sha256Digest> retained_builds,
std::chrono::milliseconds timeout,
const CellularCensusSnapshotHooks& hooks = {});
} // namespace evo::persistence