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:
+93
-14
@@ -412,6 +412,85 @@ void session_codec() {
|
||||
CHECK(refused(decode_session(encode_session(w)), SessionCodecError::invalid_value));
|
||||
}
|
||||
}
|
||||
// Scripted durable action records (10.4b).
|
||||
struct FakeActions final : ActionLedger {
|
||||
std::expected<std::optional<ActionOutcome>, ActionLedgerError>
|
||||
find(const AccountId& who, std::uint64_t action_id) override {
|
||||
++lookups;
|
||||
if (unavailable)
|
||||
return std::unexpected(ActionLedgerError::unavailable);
|
||||
for (const auto& [account, outcome] : records)
|
||||
if (account == who && outcome.action_id == action_id)
|
||||
return std::optional{outcome};
|
||||
return std::optional<ActionOutcome>{};
|
||||
}
|
||||
std::vector<std::pair<AccountId, ActionOutcome>> records;
|
||||
bool unavailable{};
|
||||
int lookups{};
|
||||
};
|
||||
|
||||
void durable_actions() {
|
||||
auto a = *IntentAdmission::create(IntentLimits{});
|
||||
FakeActions ledger;
|
||||
a.attach(&ledger);
|
||||
const auto alice = account(1);
|
||||
CHECK(a.open(1, alice));
|
||||
AdmissionFacts f{true, 5, 100};
|
||||
const auto action = [&](std::uint64_t id, std::uint64_t tick) {
|
||||
return a.action(1, SessionAction{1, 5, id, 1, tick}, f);
|
||||
};
|
||||
// Committed by an earlier epoch, process or region: a duplicate with its outcome.
|
||||
const ActionOutcome old{9, ActionResult::committed_no_effect, 40, 3};
|
||||
ledger.records.emplace_back(alice, old);
|
||||
auto r = action(9, 101);
|
||||
CHECK(r.status == AdmitStatus::duplicate && r.tick == 40);
|
||||
CHECK(a.query(1, {9}, f) == old);
|
||||
// Uniqueness that cannot be confirmed is not admitted.
|
||||
ledger.unavailable = true;
|
||||
CHECK(action(10, 101).status == AdmitStatus::not_ready);
|
||||
ledger.unavailable = false;
|
||||
const int before = ledger.lookups;
|
||||
CHECK(action(10, 101).status == AdmitStatus::admitted && ledger.lookups == before + 1);
|
||||
// A refused attempt never costs a lookup.
|
||||
CHECK(action(11, 150).status == AdmitStatus::outside_window && ledger.lookups == before + 1);
|
||||
// Exact commit: the tick reported is the tick the action rode.
|
||||
auto riding = a.carry(101);
|
||||
CHECK(riding.size() == 1);
|
||||
riding[0].tick = 102;
|
||||
auto outcomes = a.committed(riding, 6);
|
||||
CHECK(outcomes.size() == 1 &&
|
||||
outcomes[0].outcome == ActionOutcome{10, ActionResult::committed_no_effect, 102, 6});
|
||||
// A final drop is not_committed; an unknown one stays pending until its record decides.
|
||||
f.server_tick = 108;
|
||||
CHECK(action(12, 109).status == AdmitStatus::admitted);
|
||||
CHECK(action(13, 109).status == AdmitStatus::admitted);
|
||||
riding = a.carry(109);
|
||||
CHECK(riding.size() == 2);
|
||||
outcomes = a.dropped(std::span{riding}.first(1), true);
|
||||
CHECK(outcomes.size() == 1 && outcomes[0].outcome.result == ActionResult::not_committed);
|
||||
CHECK(a.dropped(std::span{riding}.subspan(1), false).empty());
|
||||
f.ready = false; // Recovering: nothing is decided yet.
|
||||
CHECK(a.query(1, {13}, f).result == ActionResult::pending);
|
||||
f.ready = true;
|
||||
ledger.records.emplace_back(alice,
|
||||
ActionOutcome{13, ActionResult::committed_no_effect, 109, 7});
|
||||
CHECK(a.query(1, {13}, f) == ActionOutcome{13, ActionResult::committed_no_effect, 109, 7});
|
||||
// The same for an action whose record is absent once the new authority is ready.
|
||||
f.server_tick = 116;
|
||||
CHECK(action(14, 117).status == AdmitStatus::admitted);
|
||||
riding = a.carry(117);
|
||||
CHECK(a.dropped(riding, false).empty());
|
||||
CHECK(a.query(1, {14}, f) == ActionOutcome{14, ActionResult::not_committed, 0, 0});
|
||||
// Outcomes evicted from memory are found again on record.
|
||||
auto small = IntentLimits{};
|
||||
small.max_finals = 1;
|
||||
auto b = *IntentAdmission::create(small);
|
||||
b.attach(&ledger);
|
||||
CHECK(b.open(1, alice));
|
||||
CHECK(b.query(1, {13}, f).result == ActionResult::committed_no_effect);
|
||||
CHECK(b.query(1, {99}, f).result == ActionResult::unknown);
|
||||
}
|
||||
|
||||
void intent_admission() {
|
||||
IntentLimits limits;
|
||||
limits.max_unresolved = 6;
|
||||
@@ -465,7 +544,7 @@ void intent_admission() {
|
||||
f.server_tick = 200;
|
||||
auto r = action(1, 10, 203);
|
||||
CHECK(r.status == AdmitStatus::admitted && r.tick == 203 && r.server_tick == 200);
|
||||
CHECK(a.query(1, {10}).result == ActionResult::pending);
|
||||
CHECK(a.query(1, {10}, f).result == ActionResult::pending);
|
||||
CHECK(action(1, 0, 203).status == AdmitStatus::invalid_action);
|
||||
CHECK(action(1, 11, 203, 9).status == AdmitStatus::invalid_action);
|
||||
{ // Wire kind 257 must not truncate to a known kind.
|
||||
@@ -481,23 +560,23 @@ void intent_admission() {
|
||||
const auto carried = a.carry(203);
|
||||
CHECK(carried.size() == 1 && carried[0] == CarriedAction{alice, 10, 203, ActionKind::probe});
|
||||
CHECK(a.carry(203).empty()); // Each action is carried once.
|
||||
CHECK(a.committed(202, 7).empty());
|
||||
auto outcomes = a.committed(203, 8);
|
||||
CHECK(a.committed({}, 7).empty());
|
||||
auto outcomes = a.committed(carried, 8);
|
||||
CHECK(outcomes.size() == 1 && outcomes[0].account == alice &&
|
||||
outcomes[0].outcome == ActionOutcome{10, ActionResult::committed_no_effect, 203, 8});
|
||||
CHECK(a.query(1, {10}) == outcomes[0].outcome);
|
||||
CHECK(a.query(2, {10}).result == ActionResult::unknown); // Bob's account has no action 10.
|
||||
CHECK(a.query(1, {10}, f) == outcomes[0].outcome);
|
||||
CHECK(a.query(2, {10}, f).result == ActionResult::unknown); // Bob's account has no action 10.
|
||||
// A reconnect of the same account (new session) sees the same outcome.
|
||||
a.close(1);
|
||||
CHECK(a.query(1, {10}).result == ActionResult::unknown); // Closed session asks nothing.
|
||||
CHECK(a.query(1, {10}, f).result == ActionResult::unknown); // Closed session asks nothing.
|
||||
CHECK(a.open(3, alice) && a.session_of(alice) == 3u);
|
||||
CHECK(a.query(3, {10}) == outcomes[0].outcome);
|
||||
CHECK(a.query(3, {10}, f) == outcomes[0].outcome);
|
||||
f.server_tick = 300;
|
||||
CHECK(action(3, 10, 301).status == AdmitStatus::duplicate); // Never admitted twice.
|
||||
// Unresolved cap counts intentions and actions; abandon finalizes only uncarried actions.
|
||||
CHECK(action(3, 20, 301).status == AdmitStatus::admitted);
|
||||
CHECK(action(3, 21, 308).status == AdmitStatus::admitted);
|
||||
(void)a.carry(301);
|
||||
const auto riding = a.carry(301);
|
||||
for (std::uint64_t i = 0; i < 4; ++i)
|
||||
CHECK(a.intention(3, SessionIntention{3, 5, i + 1, 302 + i, 0, 0}, f).status ==
|
||||
AdmitStatus::admitted);
|
||||
@@ -507,18 +586,17 @@ void intent_admission() {
|
||||
outcomes = a.abandon();
|
||||
CHECK(outcomes.size() == 1 &&
|
||||
outcomes[0].outcome == ActionOutcome{21, ActionResult::not_committed, 0, 0});
|
||||
CHECK(a.query(3, {20}).result == ActionResult::pending); // Carried: awaits its record.
|
||||
CHECK(a.query(3, {20}, f).result == ActionResult::pending); // Carried: awaits its record.
|
||||
CHECK(a.unresolved(3) == 1);
|
||||
CHECK(a.committed(301, 9).size() == 1); // Its batch turned out durable.
|
||||
CHECK(a.committed(riding, 9).size() == 1); // Its batch turned out durable.
|
||||
// Final outcomes are kept within a bound; older ones become unknown here.
|
||||
for (std::uint64_t id = 30; id < 34; ++id) {
|
||||
f.server_tick += 8;
|
||||
CHECK(action(3, id, f.server_tick + 1).status == AdmitStatus::admitted);
|
||||
(void)a.carry(f.server_tick + 1);
|
||||
CHECK(a.committed(f.server_tick + 1, id).size() == 1);
|
||||
CHECK(a.committed(a.carry(f.server_tick + 1), id).size() == 1);
|
||||
}
|
||||
CHECK(a.query(3, {10}).result == ActionResult::unknown);
|
||||
CHECK(a.query(3, {33}).result == ActionResult::committed_no_effect);
|
||||
CHECK(a.query(3, {10}, f).result == ActionResult::unknown);
|
||||
CHECK(a.query(3, {33}, f).result == ActionResult::committed_no_effect);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -528,5 +606,6 @@ void control_tests() {
|
||||
control_rules();
|
||||
session_codec();
|
||||
intent_admission();
|
||||
durable_actions();
|
||||
}
|
||||
} // namespace evo::network_test
|
||||
|
||||
Reference in New Issue
Block a user