M12.6: capture consistent regional census snapshots
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 2m20s
Foundation / checks (network) (push) Successful in 21m3s
Foundation / checks (client) (push) Successful in 22m14s
Foundation / checks (tsan) (push) Successful in 24m52s
Foundation / checks (postgres) (push) Failing after 36m19s
Foundation / checks (checks) (push) Successful in 1h10m25s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-18 15:56:58 -04:00
parent 82568da9cd
commit 7631f9d2e2
17 changed files with 648 additions and 3 deletions
@@ -0,0 +1,50 @@
#pragma once
#include "evo/persistence/cellular_history_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 };
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.
};
// 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. No partial census on error.
// 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 = {});
} // namespace evo::persistence
+3
View File
@@ -40,6 +40,9 @@ class Postgres {
// True only for a connected, idle session outside an explicit transaction.
// Read-only status inspection; no query, lock or transaction is started.
[[nodiscard]] bool transaction_idle() const noexcept;
// Drop the owned connection and any server-side transaction. Idempotent;
// future queries return closed. No SQL, allocation or automatic reconnect.
void disconnect() noexcept;
[[nodiscard]] std::expected<PgRows, PgFailure> query(const std::string& sql,
std::span<const std::string> parameters,
std::chrono::milliseconds timeout);