Add fenced cellular profile migration
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (postgres) (push) Canceled after 0s
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 (client) (push) Canceled after 5m17s
Foundation / checks (checks) (push) Canceled after 5m21s
Foundation / checks (network) (push) Canceled after 3m14s

This commit is contained in:
dingo
2026-10-11 05:12:55 -04:00
parent beffec40d7
commit 66b8088f44
10 changed files with 600 additions and 10 deletions
@@ -112,6 +112,17 @@ struct CellularPublicationFailure {
ObjectError object{};
CellularPreparedCommit prepared;
};
struct CellularProfileMigrationPrepared {
RegionKey key{};
Uuid commit{};
std::vector<std::uint8_t> manifest;
};
struct CellularProfileMigrationFailure {
PublicationError kind{};
LeaseStoreFailure store{};
ObjectError object{};
CellularProfileMigrationPrepared prepared;
};
struct PublishedCellularBatch {
CommittedCheckpoint committed;
};
@@ -220,6 +231,16 @@ resolve_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects, RegionKey key,
const LeaseGrant& lease, std::span<const Sha256Digest> retained_builds,
std::chrono::milliseconds timeout);
// Leased, no-tick representation migration. The v1 payload is restored and
// converted in memory before one immutable v1-to-v2 migration commit is written.
[[nodiscard]] std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_profile_to_v2(Postgres& db, const FilesystemObjectStore& objects,
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
Uuid commit, const Sha256Digest& build,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
retry_cellular_profile_migration(Postgres& db, const CellularProfileMigrationPrepared& prepared,
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
@@ -36,6 +36,18 @@ struct CommittedCheckpoint {
RegionHead head{};
std::vector<std::uint8_t> manifest;
};
struct CellularProfileMigrationRecord {
std::uint64_t source_sequence{};
Uuid source_commit{};
Sha256Digest source_manifest_sha256{}, source_payload_sha256{};
std::vector<std::uint8_t> source_versions;
std::uint64_t target_sequence{};
Uuid target_commit{};
Sha256Digest target_manifest_sha256{}, target_payload_sha256{};
std::vector<std::uint8_t> target_versions;
friend bool operator==(const CellularProfileMigrationRecord&,
const CellularProfileMigrationRecord&) = default;
};
// Schema v8 (ADR-0068): authority is granted only to a retained, unretired build;
// a retired or unknown build is unsupported and must not keep retrying.
@@ -83,6 +95,12 @@ publish_cellular_checkpoint(Postgres& db, std::span<const std::uint8_t> manifest
std::span<const std::uint8_t> decisions,
std::span<const std::uint8_t> actions,
std::span<const std::uint8_t> trace, std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<RegionHead, LeaseStoreFailure>
publish_cellular_profile_migration(Postgres& db, std::span<const std::uint8_t> manifest,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<std::optional<CellularProfileMigrationRecord>, LeaseStoreFailure>
load_cellular_profile_migration(Postgres& db, RegionKey key, const LeaseGrant& lease,
const Uuid& commit, std::chrono::milliseconds timeout);
enum class Resolution : std::uint8_t {
committed, // Exact bytes are durable; receipt holds the head. Grants no authority.