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:
@@ -6,6 +6,7 @@
|
||||
#include <deque>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -45,11 +46,32 @@ struct AccountOutcome {
|
||||
ActionOutcome outcome;
|
||||
};
|
||||
enum class IntentConfigError : std::uint8_t { invalid };
|
||||
// Durable action records (10.4b): the region host implements it over its lease (schema v11);
|
||||
// tests use fakes. `find` answers with the committed outcome, nothing when the action was
|
||||
// never committed, or `unavailable` when it cannot decide.
|
||||
enum class ActionLedgerError : std::uint8_t { unavailable };
|
||||
class ActionLedger {
|
||||
public:
|
||||
ActionLedger() = default;
|
||||
ActionLedger(const ActionLedger&) = delete;
|
||||
ActionLedger& operator=(const ActionLedger&) = delete;
|
||||
virtual ~ActionLedger() = default;
|
||||
[[nodiscard]] virtual std::expected<std::optional<ActionOutcome>, ActionLedgerError>
|
||||
find(const AccountId& account, std::uint64_t action_id) = 0;
|
||||
|
||||
protected:
|
||||
ActionLedger(ActionLedger&&) = default;
|
||||
ActionLedger& operator=(ActionLedger&&) = default;
|
||||
};
|
||||
|
||||
class IntentAdmission {
|
||||
public:
|
||||
[[nodiscard]] static std::expected<IntentAdmission, IntentConfigError>
|
||||
create(IntentLimits limits);
|
||||
// Durable lookups for duplicates and unresolved actions; null keeps memory only.
|
||||
void attach(ActionLedger* ledger) noexcept {
|
||||
ledger_ = ledger;
|
||||
}
|
||||
// Session lifecycle, driven by session control (after Welcome, on any close).
|
||||
[[nodiscard]] bool open(std::uint64_t session, const AccountId& account);
|
||||
void close(std::uint64_t session);
|
||||
@@ -59,18 +81,26 @@ class IntentAdmission {
|
||||
const AdmissionFacts& facts);
|
||||
[[nodiscard]] ActionReceipt action(std::uint64_t session, const SessionAction& m,
|
||||
const AdmissionFacts& facts);
|
||||
// What this process knows about an action of the session's account.
|
||||
[[nodiscard]] ActionOutcome query(std::uint64_t session, const ActionQuery& m) const;
|
||||
// An action of the session's account: final, pending or unknown. With a ledger, an action
|
||||
// whose batch outcome was unknown is decided from its durable record once this authority
|
||||
// is ready, and an action no longer in memory is looked up.
|
||||
[[nodiscard]] ActionOutcome query(std::uint64_t session, const ActionQuery& m,
|
||||
const AdmissionFacts& facts);
|
||||
// Watermarks to send after the host simulated through facts.server_tick.
|
||||
[[nodiscard]] std::vector<std::pair<std::uint64_t, SimulatedThrough>>
|
||||
simulated(const AdmissionFacts& facts);
|
||||
// Scheduled actions whose tick is <= `tick`: they ride that tick's batch from now on.
|
||||
[[nodiscard]] std::vector<CarriedAction> carry(std::uint64_t tick);
|
||||
// A commit covering ticks up to `end_tick` is durable: its carried actions are final.
|
||||
[[nodiscard]] std::vector<AccountOutcome> committed(std::uint64_t end_tick,
|
||||
// These carried actions are durable in `commit_sequence`; `tick` is the tick each rode.
|
||||
// With a ledger, each outcome is taken from the action's durable record.
|
||||
[[nodiscard]] std::vector<AccountOutcome> committed(std::span<const CarriedAction> actions,
|
||||
std::uint64_t commit_sequence);
|
||||
// The host dropped these carried actions. Final: never committed. Otherwise their batch's
|
||||
// outcome was unknown: they stay pending until their durable record decides them.
|
||||
[[nodiscard]] std::vector<AccountOutcome> dropped(std::span<const CarriedAction> actions,
|
||||
bool final);
|
||||
// Authority lost or epoch advanced: actions never carried are final (not_committed);
|
||||
// carried ones stay unresolved until a durable record decides them (10.4b).
|
||||
// carried ones stay pending until committed, dropped or decided by their record.
|
||||
[[nodiscard]] std::vector<AccountOutcome> abandon();
|
||||
// The current session of an account, for delivering outcomes.
|
||||
[[nodiscard]] std::optional<std::uint64_t> session_of(const AccountId& account) const;
|
||||
@@ -92,8 +122,16 @@ class IntentAdmission {
|
||||
struct Action {
|
||||
CarriedAction carried;
|
||||
Stage stage{};
|
||||
bool unknown{}; // Carried in a batch whose outcome was unknown when authority was lost.
|
||||
};
|
||||
explicit IntentAdmission(IntentLimits limits) : limits_{limits} {}
|
||||
// A ledger answer flattened: unavailable (or no ledger), absent, or committed.
|
||||
enum class Record : std::uint8_t { unavailable, absent, committed };
|
||||
struct Found {
|
||||
Record state{Record::unavailable};
|
||||
ActionOutcome outcome;
|
||||
};
|
||||
[[nodiscard]] Found lookup(const AccountId& account, std::uint64_t action_id) const;
|
||||
Session* find(std::uint64_t session);
|
||||
const Session* find(std::uint64_t session) const;
|
||||
void count_window(Session& s, std::uint64_t server_tick) const;
|
||||
@@ -103,5 +141,6 @@ class IntentAdmission {
|
||||
std::vector<Session> sessions_;
|
||||
std::vector<Action> actions_;
|
||||
std::deque<AccountOutcome> finals_;
|
||||
ActionLedger* ledger_{};
|
||||
};
|
||||
} // namespace evo::network
|
||||
|
||||
Reference in New Issue
Block a user