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

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:
dingo
2026-10-03 22:53:38 -04:00
co-authored by Claude Opus 5.5
parent e2f6208433
commit 69f3ad7cf8
32 changed files with 1289 additions and 75 deletions
+89 -14
View File
@@ -145,28 +145,60 @@ ActionReceipt IntentAdmission::action(std::uint64_t session, const SessionAction
r.status = AdmitStatus::outside_window;
else if (unresolved_of(*s) >= limits_.max_unresolved)
r.status = AdmitStatus::too_many_unresolved;
else if (ledger_) {
// Committed earlier (another epoch, process or region): never admitted again.
const auto found = lookup(account, m.action_id);
if (found.state == Record::unavailable) {
r.status = AdmitStatus::not_ready; // Uniqueness cannot be confirmed now.
} else if (found.state == Record::committed) {
r.status = AdmitStatus::duplicate;
r.tick = found.outcome.tick;
remember(account, found.outcome);
}
}
if (r.status == AdmitStatus::admitted)
actions_.push_back({{account, m.action_id, m.tick, ActionKind::probe}, Stage::scheduled});
return r;
}
ActionOutcome IntentAdmission::query(std::uint64_t session, const ActionQuery& m) const {
ActionOutcome IntentAdmission::query(std::uint64_t session, const ActionQuery& m,
const AdmissionFacts& facts) {
ActionOutcome o{m.action_id, ActionResult::unknown, 0, 0};
const auto* s = find(session);
if (!s)
return o;
const auto account = s->account;
const auto pending = std::ranges::find_if(actions_, [&](const Action& a) {
return a.carried.account == s->account && a.carried.action_id == m.action_id;
return a.carried.account == account && a.carried.action_id == m.action_id;
});
if (pending != actions_.end()) {
o.result = ActionResult::pending;
o.tick = pending->carried.tick;
// A batch outcome left unknown by a lost authority is decided by the durable record
// once this authority is ready: every earlier epoch's commits are then final.
if (pending->unknown && ledger_ && facts.ready)
if (const auto found = lookup(account, m.action_id);
found.state != Record::unavailable) {
o = found.state == Record::committed
? found.outcome
: ActionOutcome{m.action_id, ActionResult::not_committed, 0, 0};
actions_.erase(pending);
remember(account, o);
}
return o;
}
const auto final = std::ranges::find_if(finals_, [&](const AccountOutcome& f) {
return f.account == s->account && f.outcome.action_id == m.action_id;
return f.account == account && f.outcome.action_id == m.action_id;
});
return final != finals_.end() ? final->outcome : o;
if (final != finals_.end())
return final->outcome;
// No longer in memory: a committed action is still on record.
if (ledger_ && facts.ready)
if (const auto found = lookup(account, m.action_id); found.state == Record::committed) {
remember(account, found.outcome);
return found.outcome;
}
return o;
}
std::vector<std::pair<std::uint64_t, SimulatedThrough>>
@@ -206,23 +238,51 @@ void IntentAdmission::remember(const AccountId& account, const ActionOutcome& ou
finals_.pop_front();
}
std::vector<AccountOutcome> IntentAdmission::committed(std::uint64_t end_tick,
std::vector<AccountOutcome> IntentAdmission::committed(std::span<const CarriedAction> actions,
std::uint64_t commit_sequence) {
std::vector<AccountOutcome> out;
std::erase_if(actions_, [&](const Action& a) {
if (a.stage != Stage::carried || a.carried.tick > end_tick)
return false;
const ActionOutcome o{a.carried.action_id, ActionResult::committed_no_effect,
a.carried.tick, commit_sequence};
out.push_back({a.carried.account, o});
remember(a.carried.account, o);
return true;
});
for (const auto& c : actions) {
ActionOutcome o{c.action_id, ActionResult::committed_no_effect, c.tick, commit_sequence};
// The durable record is the authority: an id carried by two batches (an account that
// moved regions with the action pending) keeps the record of the first commit.
if (ledger_)
if (const auto found = lookup(c.account, c.action_id); found.state == Record::committed)
o = found.outcome;
std::erase_if(actions_, [&](const Action& a) {
return a.carried.account == c.account && a.carried.action_id == c.action_id;
});
out.push_back({c.account, o});
remember(c.account, o);
}
return out;
}
std::vector<AccountOutcome> IntentAdmission::dropped(std::span<const CarriedAction> actions,
bool final) {
std::vector<AccountOutcome> out;
for (const auto& c : actions) {
const auto it = std::ranges::find_if(actions_, [&](const Action& a) {
return a.carried.account == c.account && a.carried.action_id == c.action_id;
});
if (!final) {
if (it != actions_.end())
it->unknown = true;
continue;
}
if (it != actions_.end())
actions_.erase(it);
const ActionOutcome o{c.action_id, ActionResult::not_committed, 0, 0};
out.push_back({c.account, o});
remember(c.account, o);
}
return out;
}
std::vector<AccountOutcome> IntentAdmission::abandon() {
std::vector<AccountOutcome> out;
for (auto& a : actions_)
if (a.stage == Stage::carried)
a.unknown = true; // Decided by a commit report, a drop report or its record.
std::erase_if(actions_, [&](const Action& a) {
if (a.stage != Stage::scheduled)
return false;
@@ -236,6 +296,21 @@ std::vector<AccountOutcome> IntentAdmission::abandon() {
return out;
}
IntentAdmission::Found IntentAdmission::lookup(const AccountId& account,
std::uint64_t action_id) const {
Found f;
if (!ledger_)
return f;
const auto answer = ledger_->find(account, action_id);
if (!answer.has_value())
return f;
const auto& record = answer.value();
f.state = record.has_value() ? Record::committed : Record::absent;
if (record.has_value())
f.outcome = record.value();
return f;
}
std::optional<std::uint64_t> IntentAdmission::session_of(const AccountId& account) const {
const auto it =
std::ranges::find_if(sessions_, [&](const Session& s) { return s.account == account; });