M10.9d: batch durable action lookups (one per poll, one per commit)
Foundation / checks (deploy) (push) Successful in 3m27s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m41s
Foundation / checks (network) (push) Successful in 13m33s
Foundation / checks (tsan) (push) Successful in 7m54s
Foundation / checks (checks) (push) Successful in 32m56s
Foundation / checks (postgres) (push) Successful in 46m10s
Foundation / postgres-tools (push) Successful in 18s
Foundation / image (push) Successful in 2m33s
Foundation / server-image (push) Successful in 4m24s

The fourth dev drill showed a synchronous PostgreSQL round trip per action on the
simulation thread: at admission (uniqueness) and again at commit (first-record rule).
About 12 lookups landed on each commit tick (commit ticks 58-70 ms, session p99 30-39 ms).

- ActionLedger::find_all; persistence::find_region_actions applies the schema v11
  find_region_action to many pairs in one statement (no migration).
- IntentAdmission::admit/verify: actions only the ledger can refuse wait for one verify
  per poll; receipts still go out in the same poll. committed() asks once per commit.
- Tests: deferred_actions (network_control), find_region_actions and find_all (Postgres).
- ADR-0097 fourth run, ADR-0092 amendment, VALIDATION; refresh the dev session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-08 21:35:43 -04:00
co-authored by Claude Opus 5.5
parent 3ee22694cc
commit 07d12a4d82
13 changed files with 430 additions and 45 deletions
+44
View File
@@ -353,6 +353,50 @@ find_region_action(Postgres& db, RegionKey key, const LeaseGrant& lease, const U
return std::optional<CommittedAction>{CommittedAction{*region, *tick, *sequence}};
}
std::expected<std::vector<std::optional<CommittedAction>>, LeaseStoreFailure>
find_region_actions(Postgres& db, RegionKey key, const LeaseGrant& lease,
std::span<const ActionRef> actions, milliseconds timeout) {
std::vector<std::optional<CommittedAction>> out(actions.size());
if (actions.empty())
return out;
// Array literals of canonical uuids and decimal ids: no quoting is needed.
std::string accounts = "{", ids = "{";
for (std::size_t i = 0; i < actions.size(); ++i) {
accounts += (i == 0 ? "" : ",") + uuid_text(actions[i].account);
ids += (i == 0 ? "" : ",") + std::to_string(actions[i].action_id);
}
accounts += "}";
ids += "}";
const std::array<std::string, 6> p{std::to_string(key.world),
std::to_string(key.region),
uuid_text(lease.holder),
std::to_string(lease.epoch),
accounts,
ids};
// The schema v11 function per pair (its lease check included); rows name their pair.
auto rows = db.query("SELECT x.n, f.action_region, f.action_tick, f.action_commit "
"FROM unnest($5::uuid[], $6::numeric[]) WITH ORDINALITY AS x(a, i, n) "
"CROSS JOIN LATERAL evolution.find_region_action($1::evolution.u64, "
"$2::evolution.u64, $3::uuid, $4::evolution.u64, x.a, "
"x.i::evolution.u64) AS f",
p, timeout);
if (!rows)
return std::unexpected{classify(rows.error())};
for (const auto& r : *rows) {
if (r.size() != 4)
return std::unexpected{malformed(false)};
const auto n = parse_integer<std::uint64_t>(r[0]);
const auto region = parse_integer<std::uint64_t>(r[1]);
const auto tick = parse_integer<std::uint64_t>(r[2]);
const auto sequence = parse_integer<std::uint64_t>(r[3]);
if (!n || *n == 0 || *n > actions.size() || out[*n - 1].has_value() || !region || !tick ||
!sequence)
return std::unexpected{malformed(false)};
out[*n - 1] = CommittedAction{*region, *tick, *sequence};
}
return out;
}
namespace {
std::expected<std::vector<CommittedDecision>, LeaseStoreFailure>
decisions_from(const PgRows& rows) {