Add M10.4b durable action records (schema v11)
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 9m30s
Foundation / checks (client) (push) Successful in 12m19s
Foundation / checks (tsan) (push) Successful in 7m43s
Foundation / checks (checks) (push) Successful in 31m29s
Foundation / checks (postgres) (push) Successful in 36m39s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m15s
Foundation / server-image (push) Successful in 20m37s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 9m30s
Foundation / checks (client) (push) Successful in 12m19s
Foundation / checks (tsan) (push) Successful in 7m43s
Foundation / checks (checks) (push) Successful in 31m29s
Foundation / checks (postgres) (push) Successful in 36m39s
Foundation / postgres-tools (push) Successful in 19s
Foundation / image (push) Successful in 2m15s
Foundation / server-image (push) Successful in 20m37s
Each batch's actions are recorded in the same statement as its checkpoint: one region_actions row per (world, account, action id) and the block in an append-only table, compared on exact retries and resolution. The region host attaches actions to the ticks they ride and reports acknowledgements and drops, keeping unknown-outcome batches unresolved. Outcomes come from the durable record via ActionLedger, so crashes before or after a commit, unknown publications and cross-region moves all resolve to one answer; a repeated id keeps its first record instead of stalling a region. ADR-0092. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "evo/persistence/region_batch.hpp"
|
||||
#include <algorithm>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace evo::persistence {
|
||||
namespace {
|
||||
@@ -223,4 +225,39 @@ std::vector<BatchDecision> derive_decisions(std::span<const TraceStep> steps,
|
||||
}
|
||||
return out;
|
||||
}
|
||||
std::expected<std::vector<std::uint8_t>, BatchError>
|
||||
encode_actions(std::span<const ActionRecord> actions, std::uint64_t begin_tick,
|
||||
std::uint64_t end_tick) {
|
||||
if (actions.size() > max_batch_actions)
|
||||
return std::unexpected{BatchError::format};
|
||||
std::vector<ActionRecord> sorted(actions.begin(), actions.end());
|
||||
const auto key = [](const ActionRecord& a) {
|
||||
return std::tuple{a.tick, a.account, a.action_id};
|
||||
};
|
||||
std::ranges::sort(sorted, {}, key);
|
||||
// An action id appears once, whatever its tick.
|
||||
std::vector<std::pair<Uuid, std::uint64_t>> ids;
|
||||
ids.reserve(sorted.size());
|
||||
for (const auto& a : sorted)
|
||||
ids.emplace_back(a.account, a.action_id);
|
||||
std::ranges::sort(ids);
|
||||
if (std::ranges::adjacent_find(ids) != ids.end())
|
||||
return std::unexpected{BatchError::format};
|
||||
std::vector<std::uint8_t> out;
|
||||
out.reserve(sorted.size() * action_record_bytes);
|
||||
for (std::size_t i = 0; i < sorted.size(); ++i) {
|
||||
const auto& a = sorted[i];
|
||||
if (a.account == Uuid{} || a.action_id == 0 || a.kind != 1 || a.tick <= begin_tick ||
|
||||
a.tick > end_tick || (i > 0 && key(sorted[i - 1]) == key(a)))
|
||||
return std::unexpected{BatchError::format};
|
||||
out.insert(out.end(), a.account.begin(), a.account.end());
|
||||
for (unsigned b = 0; b < 8; ++b)
|
||||
out.push_back(static_cast<std::uint8_t>(a.action_id >> (8U * b)));
|
||||
for (unsigned b = 0; b < 8; ++b)
|
||||
out.push_back(static_cast<std::uint8_t>(a.tick >> (8U * b)));
|
||||
out.push_back(static_cast<std::uint8_t>(a.kind));
|
||||
out.push_back(static_cast<std::uint8_t>(a.kind >> 8U));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace evo::persistence
|
||||
|
||||
Reference in New Issue
Block a user