Add primitive object publication and recovery adapter (M11.2c-2d)
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (client) (push) Successful in 12m22s
Foundation / checks (network) (push) Successful in 13m52s
Foundation / checks (tsan) (push) Successful in 8m7s
Foundation / checks (checks) (push) Successful in 33m54s
Foundation / checks (postgres) (push) Successful in 47m38s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m39s
Foundation / server-image (push) Successful in 4m16s

This commit is contained in:
dingo
2026-10-10 11:15:44 -04:00
parent 58aff5adeb
commit 7461d02961
9 changed files with 524 additions and 6 deletions
@@ -1,4 +1,5 @@
#pragma once
#include "evo/persistence/life_reservation_store.hpp"
#include "evo/persistence/object_store.hpp"
#include "evo/persistence/region_batch.hpp"
#include "evo/persistence/region_checkpoint.hpp"
@@ -79,6 +80,26 @@ struct RecoveredLineageCheckpoint {
std::unique_ptr<processes::LineageRegion> state;
std::vector<CommittedDecision> decisions;
};
struct PrimitivePreparedCommit {
RegionKey key{};
Uuid commit{};
std::vector<std::uint8_t> manifest, trace;
};
struct PrimitivePublicationFailure {
PublicationError kind{};
LeaseStoreFailure store{};
ObjectError object{};
PrimitivePreparedCommit prepared;
};
struct PublishedPrimitiveBatch {
CommittedCheckpoint committed;
};
struct RecoveredPrimitiveCheckpoint {
CommittedCheckpoint committed;
CheckpointManifest manifest;
std::unique_ptr<server::PrimitiveLives> state;
std::vector<PrimitiveLifeBinding> bindings;
};
// Owner/operator connection only: uploads a tick-0 state and records genesis.
[[nodiscard]] std::expected<CommittedCheckpoint, PublicationFailure> provision_environmental_region(
@@ -128,6 +149,31 @@ recover_lineage_checkpoint(Postgres& db, const FilesystemObjectStore& objects, R
std::span<const Sha256Digest> retained_builds,
std::size_t restore_budget, std::chrono::milliseconds timeout);
// Primitive-life profile 3 stores a complete creation-only payload. Publication
// replays the canonical birth trace from the verified predecessor before upload,
// then uses schema v16's atomic reservation/control/checkpoint transaction.
[[nodiscard]] std::expected<CommittedCheckpoint, PrimitivePublicationFailure>
provision_primitive_region(Postgres& owner, const FilesystemObjectStore& objects, RegionKey key,
std::uint64_t frame, const server::PrimitiveLives& opening, Uuid commit,
const Sha256Digest& build, std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<PublishedPrimitiveBatch, PrimitivePublicationFailure>
publish_primitive_batch(Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, const server::PrimitiveBatch& batch,
const server::PrimitiveLives& candidate, Uuid commit,
const Sha256Digest& build, std::chrono::milliseconds timeout,
const PublishHooks& hooks = {});
// Retry after an ambiguous response with these exact immutable bytes. The SQL
// function converges exact retries and rejects changed bytes or stale authority.
[[nodiscard]] std::expected<CommittedCheckpoint, PrimitivePublicationFailure>
retry_primitive_prepared(Postgres& db, const PrimitivePreparedCommit& prepared,
std::chrono::milliseconds timeout);
// Read-only recovery adapter. The caller must acquire a fresh region lease before
// using the recovered state or declaring the host ready.
[[nodiscard]] std::expected<RecoveredPrimitiveCheckpoint, RecoveryFailure>
recover_primitive_checkpoint(Postgres& db, const FilesystemObjectStore& objects, RegionKey key,
std::span<const Sha256Digest> retained_builds,
std::chrono::milliseconds timeout);
// After an `unknown` publication: resolve exactly the prepared bytes. A committed
// result yields the final batch; absent may be retried with the same prepared bytes
// only while the lease is still valid; conflict fails closed.