Admit v10 mutation choices through the cellular host and sessions
The region host checks a choice against the committed offer, reserves the successor for the next tick, and publishes it with that tick's batch; the owner's v10 session gets the receipt and final outcome. Schema v35 now refuses a checkpoint that skips a reserved choice, and the host reloads pending reservations after uncertainty, refusal or recovery (ADR-0121). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,31 @@ struct FinalCellularAction {
|
||||
std::uint64_t commit_sequence{};
|
||||
friend bool operator==(const FinalCellularAction&, const FinalCellularAction&) = default;
|
||||
};
|
||||
// v10 mutation choice admission (ADR-0121). `admitted` means the successor identity is
|
||||
// durably reserved for `tick`, the next simulated tick; the choice publishes with it.
|
||||
enum class CellularMutationAdmission : std::uint8_t {
|
||||
admitted,
|
||||
not_ready, // No current authority, or an uncertain reservation is being reconciled.
|
||||
invalid, // Not this account's life, or not its outstanding offer and candidate.
|
||||
busy, // Another choice of this account is still waiting for its tick.
|
||||
final, // This action already published; `outcome` repeats its result.
|
||||
conflict // The action id was used for different bytes or an earlier tick.
|
||||
};
|
||||
struct FinalCellularMutation {
|
||||
persistence::Uuid account{};
|
||||
std::uint64_t action_id{}, tick{}, commit_sequence{};
|
||||
CellularMutationResult result{};
|
||||
friend bool operator==(const FinalCellularMutation&, const FinalCellularMutation&) = default;
|
||||
};
|
||||
struct CellularMutationReply {
|
||||
CellularMutationAdmission status{};
|
||||
std::uint64_t tick{};
|
||||
std::optional<FinalCellularMutation> outcome;
|
||||
};
|
||||
// The wire forms (v10): an applied choice is `committed`; a durable refusal (life died,
|
||||
// insufficient funding) is `committed_no_effect`, and the owner's view shows the cell.
|
||||
[[nodiscard]] network::AdmitStatus admit_status(CellularMutationAdmission admission) noexcept;
|
||||
[[nodiscard]] network::ActionOutcome action_outcome(const FinalCellularMutation& mutation) noexcept;
|
||||
|
||||
// Single-writer profile-4 authority. The caller supplies a complete bounded trace;
|
||||
// the host replays it from its recovered state and advances only on a confirmed head.
|
||||
@@ -58,7 +83,20 @@ class CellularRegionHost {
|
||||
// Acquires/renews authority, recovers fully, or resolves the exact pending commit.
|
||||
const HostStatus& step();
|
||||
[[nodiscard]] std::expected<persistence::PublishedCellularBatch, CellularPublishFailure>
|
||||
publish(const CellularBatch& batch, std::span<const CellularActionRecord> actions = {});
|
||||
publish(const CellularBatch& batch, std::span<const CellularActionRecord> actions = {},
|
||||
std::span<const CellularMutationActionRecord> mutation_actions = {});
|
||||
// Revalidates the exact outstanding offer and candidate against the committed state,
|
||||
// then reserves the successor for the next tick. Exact repeats are idempotent.
|
||||
[[nodiscard]] CellularMutationReply select_mutation(const persistence::Uuid& account,
|
||||
std::uint64_t generation,
|
||||
std::uint64_t action_id,
|
||||
const CellularMutationActionInput& input);
|
||||
// Reserved choices for the next tick, in reservation order; pass them to the builder.
|
||||
[[nodiscard]] std::span<const persistence::CellularMutationReservation>
|
||||
queued_mutations() const noexcept {
|
||||
return queued_mutations_;
|
||||
}
|
||||
[[nodiscard]] std::vector<FinalCellularMutation> take_finalized_mutations();
|
||||
// v5 requests allocate durably, then wait for the scheduler to include the exact
|
||||
// reservation in a profile-4 batch. Repeating the request is idempotent.
|
||||
[[nodiscard]] network::PrimitiveLifeOutcome
|
||||
@@ -95,6 +133,9 @@ class CellularRegionHost {
|
||||
void refresh();
|
||||
void finalize_births(std::span<const CellularTickIntents::Birth> births);
|
||||
void queue_birth(const CellularTickIntents::Birth& birth);
|
||||
void reload_mutations();
|
||||
void finalize_mutations(std::span<const CellularMutationActionRecord> actions,
|
||||
std::span<const std::uint8_t> results);
|
||||
[[nodiscard]] network::PrimitiveLifeOutcome query_birth(const persistence::Uuid& account,
|
||||
std::uint64_t generation,
|
||||
std::uint64_t request, bool enqueue);
|
||||
@@ -109,6 +150,11 @@ class CellularRegionHost {
|
||||
std::unique_ptr<Pending> pending_;
|
||||
std::vector<FinalCellularAction> finalized_actions_;
|
||||
std::vector<CellularTickIntents::Birth> queued_births_;
|
||||
std::vector<persistence::CellularMutationReservation> queued_mutations_;
|
||||
// A reservation may exist that the queue does not show; reload before publishing.
|
||||
bool mutations_uncertain_{};
|
||||
std::vector<FinalCellularMutation> finalized_mutations_;
|
||||
std::vector<FinalCellularMutation> recent_mutations_; // Bounded, for exact repeats.
|
||||
HostStatus status_{};
|
||||
};
|
||||
} // namespace evo::server
|
||||
|
||||
Reference in New Issue
Block a user