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:
@@ -7,6 +7,7 @@
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
@@ -93,6 +94,25 @@ decode_cellular_batch(std::span<const std::uint8_t> bytes);
|
||||
// Every tick must cover its living set; the caller compares the returned snapshot.
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularBatchError>
|
||||
replay_cellular_batch(const CellularLives& base, const CellularBatch& batch);
|
||||
// The same replay, also reporting every mutation selection's final result in trace order
|
||||
// (ADR-0121): the authority for the results a publication binds and recovery compares.
|
||||
struct CellularMutationOutcome {
|
||||
std::uint64_t tick{}, life_id{}, successor_id{};
|
||||
CellularMutationResult result{};
|
||||
friend bool operator==(const CellularMutationOutcome&,
|
||||
const CellularMutationOutcome&) = default;
|
||||
};
|
||||
[[nodiscard]] std::expected<std::unique_ptr<CellularLives>, CellularBatchError>
|
||||
replay_cellular_batch(const CellularLives& base, const CellularBatch& batch,
|
||||
std::vector<CellularMutationOutcome>& mutation_outcomes);
|
||||
// The canonical 34-byte reserved choice (schema v29): tick, life, event and offer tick as
|
||||
// u64 and the operator as u16, little-endian.
|
||||
inline constexpr std::size_t cellular_mutation_input_bytes = 34;
|
||||
[[nodiscard]] std::array<std::uint8_t, cellular_mutation_input_bytes>
|
||||
encode_cellular_mutation_input(const CellularMutationActionRecord& action);
|
||||
[[nodiscard]] std::optional<CellularMutationActionRecord>
|
||||
decode_cellular_mutation_input(const std::array<std::uint8_t, 16>& account, std::uint64_t action_id,
|
||||
std::span<const std::uint8_t> input);
|
||||
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularActionBlockError>
|
||||
encode_cellular_action_block(std::span<const CellularActionRecord> actions,
|
||||
std::uint64_t begin_tick, std::uint64_t end_tick);
|
||||
|
||||
Reference in New Issue
Block a user