feat(persistence): admit durable retained offspring plans
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 1m11s
Foundation / checks (checks) (push) Canceled after 1m13s
Foundation / checks (postgres) (push) Canceled after 1m8s
Foundation / checks (ecs) (push) Canceled after 1m13s
Foundation / checks (network) (push) Canceled after 1m14s
Foundation / checks (deploy) (push) Canceled after 1m18s

This commit is contained in:
dingo
2026-10-19 15:04:30 -04:00
parent 39509ecd40
commit c60cdf8e19
20 changed files with 850 additions and 46 deletions
+37 -24
View File
@@ -95,7 +95,11 @@ bool prepared_mutations_are_canonical(const CellularPreparedCommit& prepared,
const auto decoded = server::decode_cellular_mutation_action_block(
prepared.mutations, manifest.begin_tick, manifest.end_tick);
if (!decoded || decoded->size() != selections || prepared.results.size() != selections ||
std::ranges::any_of(prepared.results, [](std::uint8_t result) { return result > 3; }))
std::ranges::any_of(prepared.results, [&](std::uint8_t result) {
return manifest.cellular_versions == cellular_v12_versions
? result != 1 && result != 3 && result != 4
: result > 3;
}))
return false;
const auto encoded = server::encode_cellular_mutation_action_block(
*decoded, manifest.begin_tick, manifest.end_tick);
@@ -116,10 +120,8 @@ bool prepared_is_canonical(const CellularPreparedCommit& prepared,
std::unexpected{server::CellularActionBlockError::format}};
const auto encoded_trace = server::encode_cellular_batch(trace);
const auto digest = sha256(prepared.trace);
const bool revision = cellular_revision_bundle(manifest.cellular_versions);
const bool trace_version_matches =
(revision && trace.format_version == server::cellular_batch_format) ||
(!revision && trace.format_version == server::cellular_batch_v2_format);
trace.format_version == cellular_checkpoint_trace_format(manifest.cellular_versions);
return manifest.profile == CheckpointProfile::cellular_lives_v1 && trace_version_matches &&
manifest.key == prepared.key && manifest.commit == prepared.commit &&
manifest.sequence > 0 && manifest.batch.trace_bytes == prepared.trace.size() && digest &&
@@ -240,7 +242,8 @@ retry_cellular_profile_migration(Postgres& db, const CellularProfileMigrationPre
!supported(*manifest) || !encode_manifest(*manifest) ||
!((manifest->profile == CheckpointProfile::cellular_lives_v1 &&
(manifest->cellular_versions == cellular_v2_versions ||
manifest->cellular_versions == cellular_v3_versions)) ||
manifest->cellular_versions == cellular_v3_versions ||
manifest->cellular_versions == cellular_v12_versions)) ||
((manifest->profile == CheckpointProfile::cellular_lives_v1 ||
manifest->profile == CheckpointProfile::cellular_population_v1) &&
(manifest->cellular_versions == cellular_v10_versions ||
@@ -282,7 +285,8 @@ std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_rules_profile(Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, Uuid commit,
const Sha256Digest& build, milliseconds timeout, const PublishHooks& hooks,
bool maturation) {
decltype(&cellular_maturation_upgrade_payload) upgrade_payload,
decltype(&cellular_maturation_upgrade_manifest) derive) {
const auto previous = decode_manifest(predecessor.manifest);
const auto previous_digest = sha256(predecessor.manifest);
if (!previous || !previous_digest || predecessor.head.digest != *previous_digest ||
@@ -294,15 +298,12 @@ migrate_rules_profile(Postgres& db, const FilesystemObjectStore& objects, const
auto source = objects.get({previous->payload_sha256, previous->payload_bytes});
if (!source)
return std::unexpected(migration_failure(PublicationError::predecessor, source.error()));
auto payload = maturation ? cellular_maturation_upgrade_payload(*source, *previous)
: cellular_boundary_upgrade_payload(*source, *previous);
auto payload = upgrade_payload(*source, *previous);
if (!payload)
return std::unexpected(migration_failure(PublicationError::candidate));
const auto digest = sha256(*payload);
if (!digest)
return std::unexpected(migration_failure(PublicationError::digest));
const auto derive =
maturation ? cellular_maturation_upgrade_manifest : cellular_boundary_upgrade_manifest;
auto manifest =
derive(*previous, *previous_digest, commit, lease, build, payload->size(), *digest);
if (!manifest)
@@ -324,7 +325,8 @@ migrate_cellular_boundary_profile(Postgres& db, const FilesystemObjectStore& obj
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
false);
cellular_boundary_upgrade_payload,
cellular_boundary_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_maturation_profile(Postgres& db, const FilesystemObjectStore& objects,
@@ -332,7 +334,18 @@ migrate_cellular_maturation_profile(Postgres& db, const FilesystemObjectStore& o
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
true);
cellular_maturation_upgrade_payload,
cellular_maturation_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_inheritance_profile(Postgres& db, const FilesystemObjectStore& objects,
const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, Uuid commit,
const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
cellular_inheritance_upgrade_payload,
cellular_inheritance_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
@@ -483,9 +496,8 @@ publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects, const
const auto predecessor_digest = sha256(predecessor.manifest);
auto committed_batch = batch;
if (previous)
committed_batch.format_version = cellular_revision_bundle(previous->cellular_versions)
? server::cellular_batch_format
: server::cellular_batch_v2_format;
committed_batch.format_version =
cellular_checkpoint_trace_format(previous->cellular_versions);
const auto trace = server::encode_cellular_batch(committed_batch);
const auto action_block = server::encode_cellular_action_block(actions, batch.header.begin_tick,
batch.header.end_tick);
@@ -621,9 +633,11 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
const LeaseGrant recorded{m.holder, m.epoch, m.frame, milliseconds{0}};
const bool boundary = m.cellular_versions == cellular_v10_versions;
const bool maturation = m.cellular_versions == cellular_v11_versions;
const auto derive = maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
const bool inheritance = m.cellular_versions == cellular_v12_versions;
const auto derive = inheritance ? cellular_inheritance_upgrade_manifest
: maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
auto expected = derive(*source, *source_digest, m.commit, recorded, m.build, m.payload_bytes,
m.payload_sha256);
if (!expected || *expected != m)
@@ -631,9 +645,10 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
auto bytes = objects.get({source->payload_sha256, source->payload_bytes});
if (!bytes)
return fail(RecoveryError::tail);
if (boundary || maturation) {
auto upgraded = maturation ? cellular_maturation_upgrade_payload(*bytes, *source)
: cellular_boundary_upgrade_payload(*bytes, *source);
if (boundary || maturation || inheritance) {
auto upgraded = inheritance ? cellular_inheritance_upgrade_payload(*bytes, *source)
: maturation ? cellular_maturation_upgrade_payload(*bytes, *source)
: cellular_boundary_upgrade_payload(*bytes, *source);
if (!upgraded || !std::ranges::equal(*upgraded, payload))
return fail(RecoveryError::history);
} else {
@@ -712,9 +727,7 @@ recover_cellular_loaded(Postgres& db, const FilesystemObjectStore& objects, Regi
auto trace = server::decode_cellular_batch(*trace_bytes);
if (!trace)
return fail_with(RecoveryError::tail);
const bool revision = cellular_revision_bundle(manifest->cellular_versions);
if ((revision && trace->format_version != server::cellular_batch_format) ||
(!revision && trace->format_version != server::cellular_batch_v2_format))
if (trace->format_version != cellular_checkpoint_trace_format(manifest->cellular_versions))
return fail_with(RecoveryError::tail);
if (trace->header.world != key.world || trace->header.region != key.region ||
trace->header.frame != manifest->frame ||