feat: durable mutation queue (schema 59)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m24s
Foundation / postgres-tools (push) Successful in 1m31s
Foundation / server-image (push) Successful in 4m25s
Foundation / image (push) Successful in 4m50s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m24s
Foundation / postgres-tools (push) Successful in 1m31s
Foundation / server-image (push) Successful in 4m25s
Foundation / image (push) Successful in 4m50s
A mutation choice's reserved tick is now the earliest tick it may bind at, not the only one (ADR-0121 amendment). With write-behind commits, a choice reserved for head + 1 landed in ticks already being simulated or committed: the batch was refused, or the reservation was orphaned for a past tick and stalled the region. Schema 59: a bound record carries the tick it applied at and the rest of its input must equal the reservation's; the "omits a reserved mutation" refusals are removed. Existing rows are unchanged, so an orphaned reservation binds at the next commit that carries it. The host keeps every unbound reservation queued and the open batch binds those the commit in flight does not carry, at its next tick; the earlier hold on new choices is removed. A choice that outlives its life binds as life_died (owner, trace matching and recovery accept it when no life with that ID remains). Recovery takes a bound choice's tick from its trace. Tests: a choice skipped by one checkpoint binds a tick late and recovers; builder late binding, refusal before the earliest tick, and a departed life's life_died outcome. Full local PostgreSQL qualification passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -102,23 +102,29 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
|
||||
const auto event_index = little_endian(bytes, 16, 8);
|
||||
const auto offer_tick = little_endian(bytes, 24, 8);
|
||||
const auto operator_id = static_cast<std::uint16_t>(little_endian(bytes, 32, 2));
|
||||
// ADR-0121 amendment (schema 59): the reservation's tick is the earliest the choice
|
||||
// may bind at; the queue binds it at the first tick simulated after admission.
|
||||
if (reservation.account == persistence::Uuid{} || reservation.action_id == 0 ||
|
||||
reservation.region != state.region() || reservation.generation == 0 ||
|
||||
reservation.successor_identity == 0 || target_tick != tick ||
|
||||
reservation.target_tick != tick || life_id == 0 || event_index == 0 ||
|
||||
offer_tick == 0 || offer_tick >= tick)
|
||||
reservation.successor_identity == 0 || target_tick != reservation.target_tick ||
|
||||
reservation.target_tick > tick || life_id == 0 || event_index == 0 || offer_tick == 0 ||
|
||||
offer_tick >= reservation.target_tick)
|
||||
return std::unexpected{CellularSessionBatchError::mutation};
|
||||
// A life that ended while its choice waited binds the choice as life_died.
|
||||
const auto life =
|
||||
std::ranges::find(state.lives(), reservation.account, &CellularOwnedLife::account);
|
||||
if (life == state.lives().end() || life->identity.life != life_id ||
|
||||
life->mutation.event_index != event_index || life->mutation.offer_tick != offer_tick)
|
||||
return std::unexpected{CellularSessionBatchError::mutation};
|
||||
const auto& offer = life->mutation.offer;
|
||||
if (!offer || (operator_id != 0 && // Operator 0 declines the offer.
|
||||
!std::ranges::any_of(offer->candidates, [&](const auto& candidate) {
|
||||
return candidate.operator_id == operator_id;
|
||||
})))
|
||||
return std::unexpected{CellularSessionBatchError::mutation};
|
||||
std::ranges::find(state.lives(), life_id,
|
||||
[](const CellularOwnedLife& value) { return value.identity.life; });
|
||||
if (life != state.lives().end()) {
|
||||
if (life->account != reservation.account || life->mutation.event_index != event_index ||
|
||||
life->mutation.offer_tick != offer_tick)
|
||||
return std::unexpected{CellularSessionBatchError::mutation};
|
||||
const auto& offer = life->mutation.offer;
|
||||
if (!offer || (operator_id != 0 && // Operator 0 declines the offer.
|
||||
!std::ranges::any_of(offer->candidates, [&](const auto& candidate) {
|
||||
return candidate.operator_id == operator_id;
|
||||
})))
|
||||
return std::unexpected{CellularSessionBatchError::mutation};
|
||||
}
|
||||
|
||||
if (std::ranges::any_of(prepared.intents.mutations,
|
||||
[&](const auto& previous) {
|
||||
|
||||
Reference in New Issue
Block a user