Foundation / checks (ecs) (push) Successful in 2m26s
Foundation / checks (deploy) (push) Successful in 4m12s
Foundation / checks (network) (push) Successful in 20m57s
Foundation / checks (client) (push) Successful in 22m9s
Foundation / checks (tsan) (push) Successful in 28m49s
Foundation / checks (postgres) (push) Successful in 1h5m2s
Foundation / checks (checks) (push) Successful in 1h17m42s
Foundation / postgres-tools (push) Successful in 1m10s
Foundation / server-image (push) Successful in 3m51s
Foundation / image (push) Successful in 4m54s
114 lines
6.2 KiB
C++
114 lines
6.2 KiB
C++
#pragma once
|
|
|
|
#include "evo/persistence/checkpoint_store.hpp"
|
|
#include "evo/server/lifecycle/cellular_migration_trace.hpp"
|
|
|
|
namespace evo::persistence {
|
|
struct CellularMigrationObservation {
|
|
server::CellularMigrationTrace trace;
|
|
bool staged{}; // Ghost/capsules are verified evidence, never additional owned stock.
|
|
};
|
|
struct CellularMigrationPrepared {
|
|
RegionKey key{}; // Source region.
|
|
std::vector<std::uint8_t> trace;
|
|
};
|
|
struct CellularMigrationFreeze {
|
|
server::CellularMigrationTrace trace;
|
|
bool aborted{};
|
|
};
|
|
struct CellularMigrationFailure {
|
|
PublicationError kind{};
|
|
LeaseStoreFailure store{};
|
|
ObjectError object{};
|
|
CellularMigrationPrepared prepared; // Exact request after unknown/rejection.
|
|
};
|
|
// Verify both complete cuts and the paired biology, retain a verified destination
|
|
// replay capsule in the source namespace, then freeze the exact source head.
|
|
// Neither candidate is published or activated by this operation.
|
|
// Durable migration remains bundle 10/trace 1; portable trace 2 is refused.
|
|
[[nodiscard]] std::expected<CellularMigrationFreeze, CellularMigrationFailure>
|
|
prepare_cellular_migration_freeze(Postgres&, const FilesystemObjectStore& source_objects,
|
|
const FilesystemObjectStore& destination_objects,
|
|
const LeaseGrant& source_lease, const CommittedCheckpoint& source,
|
|
const CommittedCheckpoint& destination,
|
|
const server::CellularMigrationRequest&,
|
|
std::chrono::milliseconds timeout,
|
|
const PublishHooks& hooks = {});
|
|
[[nodiscard]] std::expected<CellularMigrationFreeze, CellularMigrationFailure>
|
|
retry_cellular_migration_freeze(Postgres&, const LeaseGrant&, const CellularMigrationPrepared&,
|
|
std::chrono::milliseconds timeout);
|
|
// Current source authority only. No timeout/lease-expiry auto-abort. The result
|
|
// repeats a retained abort and cannot reopen an old preparation.
|
|
[[nodiscard]] std::expected<CellularMigrationFreeze, LeaseStoreFailure>
|
|
abort_cellular_migration_freeze(Postgres&, RegionKey, const LeaseGrant&, const Uuid& request,
|
|
std::chrono::milliseconds timeout);
|
|
// Fenced lookup AND complete capsule replay. An empty result means no freeze;
|
|
// missing/corrupt evidence is an error, never implicit permission to advance.
|
|
[[nodiscard]] std::expected<std::optional<CellularMigrationFreeze>, RecoveryFailure>
|
|
load_cellular_migration_freeze(Postgres&, const FilesystemObjectStore&, RegionKey,
|
|
const LeaseGrant&, std::chrono::milliseconds timeout);
|
|
|
|
struct CellularMigrationStagePrepared {
|
|
RegionKey key{}; // Destination region.
|
|
std::vector<std::uint8_t> trace;
|
|
VerifiedObject ghost;
|
|
};
|
|
struct CellularMigrationStage {
|
|
CellularMigrationFreeze freeze;
|
|
VerifiedObject ghost; // Read-only evidence, never an ownership receipt.
|
|
};
|
|
struct CellularMigrationStageFailure {
|
|
PublicationError kind{};
|
|
LeaseStoreFailure store{};
|
|
ObjectError object{};
|
|
CellularMigrationStagePrepared prepared;
|
|
};
|
|
// Replay the retained pair, retain a source capsule and verified destination
|
|
// ghost in the destination namespace, then freeze its unchanged exact head.
|
|
[[nodiscard]] std::expected<CellularMigrationStage, CellularMigrationStageFailure>
|
|
stage_cellular_migration(Postgres&, const FilesystemObjectStore& source_objects,
|
|
const FilesystemObjectStore& destination_objects,
|
|
const LeaseGrant& destination_lease, const CommittedCheckpoint& source,
|
|
const CommittedCheckpoint& destination,
|
|
const server::CellularMigrationTrace&, std::chrono::milliseconds timeout,
|
|
const PublishHooks& hooks = {});
|
|
[[nodiscard]] std::expected<CellularMigrationStage, CellularMigrationStageFailure>
|
|
retry_cellular_migration_stage(Postgres&, const LeaseGrant&, const CellularMigrationStagePrepared&,
|
|
std::chrono::milliseconds timeout);
|
|
// Fresh destination authority; complete local capsule and ghost replay.
|
|
[[nodiscard]] std::expected<std::optional<CellularMigrationStage>, RecoveryFailure>
|
|
load_cellular_migration_stage(Postgres&, const FilesystemObjectStore&, RegionKey, const LeaseGrant&,
|
|
std::chrono::milliseconds timeout);
|
|
struct CellularMigrationCommitPrepared {
|
|
Uuid request{};
|
|
std::vector<std::uint8_t> source_manifest, destination_manifest;
|
|
};
|
|
struct CellularMigrationCommitted {
|
|
CommittedCheckpoint source, destination;
|
|
};
|
|
struct CellularMigrationCommitFailure {
|
|
PublicationError kind{};
|
|
LeaseStoreFailure store{};
|
|
ObjectError object{};
|
|
CellularMigrationCommitPrepared prepared;
|
|
};
|
|
[[nodiscard]] std::expected<CellularMigrationCommitted, CellularMigrationCommitFailure>
|
|
publish_cellular_migration(Postgres&, const FilesystemObjectStore& source_objects,
|
|
const FilesystemObjectStore& destination_objects,
|
|
const LeaseGrant& source_lease, const LeaseGrant& destination_lease,
|
|
const CommittedCheckpoint& source,
|
|
const CommittedCheckpoint& destination,
|
|
const server::CellularMigrationTrace&, const Sha256Digest& build,
|
|
std::chrono::milliseconds timeout, const PublishHooks& hooks = {});
|
|
// Both CURRENT fences are separate from the retained manifests' original writers.
|
|
[[nodiscard]] std::expected<CellularMigrationCommitted, CellularMigrationCommitFailure>
|
|
retry_cellular_migration_commit(Postgres&, const LeaseGrant& source_lease,
|
|
const LeaseGrant& destination_lease,
|
|
const CellularMigrationCommitPrepared&,
|
|
std::chrono::milliseconds timeout);
|
|
// True: full paired receipt/replay verified. False: this is another no-tick kind.
|
|
[[nodiscard]] std::expected<bool, RecoveryFailure> verify_cellular_migration_checkpoint(
|
|
Postgres&, const FilesystemObjectStore&, const LeaseGrant&, const CommittedCheckpoint&,
|
|
std::span<const std::uint8_t> payload, std::chrono::milliseconds timeout);
|
|
} // namespace evo::persistence
|