Publish mutation choices atomically with their checkpoint

ADR-0121, schema v35. A checkpoint whose trace carries mutation
selections publishes with its canonical mutation block and one result
byte per choice. SQL checks the block's order, matches each record to
one reserved choice of this region and to its trace selection (tick,
life, offer, operator, successor identity), binds it to the commit with
its result, refuses a choice already bound elsewhere and checks exact
retries. The four-argument publisher becomes an internal helper behind
a wrapper that refuses traces with selections.

C++ publication takes the results from its own replay rather than a
caller, prepared commits carry block and results through retry and
resolution, and recovery rebuilds the bound choices and requires the
replay's results to match. A PostgreSQL test feeds a v4 cell to its
first offer, publishes a reserved choice, recovers it and restarts a
host. Host and session admission follow in 11.4c-2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-13 19:23:39 -04:00
co-authored by Claude Opus 5.5
parent bf5c626f19
commit 1bbac48543
14 changed files with 897 additions and 28 deletions
@@ -143,6 +143,31 @@ struct CellularBirthBinding {
[[nodiscard]] std::expected<std::vector<CellularBirthBinding>, LeaseStoreFailure>
load_cellular_publication_births(Postgres& db, RegionKey key, const LeaseGrant& lease,
const Uuid& commit, std::chrono::milliseconds timeout);
// Schema v35 (ADR-0121): a checkpoint whose trace carries mutation selections publishes
// with its canonical mutation block (64-byte records) and one result byte per record.
[[nodiscard]] std::expected<RegionHead, LeaseStoreFailure> publish_cellular_mutation_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::span<const std::uint8_t> mutations, std::span<const std::uint8_t> results,
std::chrono::milliseconds timeout);
[[nodiscard]] std::expected<ResolvedCommit, LeaseStoreFailure> resolve_cellular_mutation_commit(
Postgres& db, RegionKey key, const Uuid& commit, 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::span<const std::uint8_t> mutations,
std::span<const std::uint8_t> results, std::chrono::milliseconds timeout);
// The mutation choices bound to one commit, ordered (tick, account, action): the 16-byte
// account, action id, 34-byte reserved input and final result.
struct CellularMutationPublication {
std::array<std::uint8_t, 16> account{};
std::uint64_t action_id{};
std::array<std::uint8_t, 34> input{};
std::uint8_t result{};
friend bool operator==(const CellularMutationPublication&,
const CellularMutationPublication&) = default;
};
[[nodiscard]] std::expected<std::vector<CellularMutationPublication>, LeaseStoreFailure>
load_cellular_mutation_publications(Postgres& db, RegionKey key, const LeaseGrant& lease,
const Uuid& commit, std::chrono::milliseconds timeout);
// The committed record of an account's action in the lease's world (schema v11), under the
// caller's exact lease. Nothing when the action was never committed.
struct CommittedAction {