Queue durable cellular first-life requests
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (postgres) (push) Failing after 51s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 3m4s
Foundation / checks (client) (push) Canceled after 3m37s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (postgres) (push) Failing after 51s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 3m4s
Foundation / checks (client) (push) Canceled after 3m37s
This commit is contained in:
@@ -6464,3 +6464,15 @@ GCC 13.2 strict-warning syntax checks pass for `region_sessions.cpp` and
|
||||
`tests/quic_sessions.cpp`; `git diff --check` passes. QUIC runtime tests, the
|
||||
full network preset, and CI remain pending. No wire layout changed in this
|
||||
subsection.
|
||||
|
||||
## 2026-10-11 — M11.3d-7l host birth request queue
|
||||
|
||||
`CellularRegionHost` now exposes v5 create/query callbacks backed by the durable life reservation
|
||||
store. Exact retries reuse and enqueue the same reservation, the scheduler can read the queued
|
||||
births, and confirmed publication (including resolution of an uncertain commit) removes only the
|
||||
matching queued records. The PostgreSQL integration test now covers reserve, retry deduplication,
|
||||
publication, and born outcome through the host API.
|
||||
|
||||
GCC 13.2 strict-warning syntax checks pass for the host and PostgreSQL integration test, and
|
||||
`git diff --check` passes. PostgreSQL runtime, full presets, and CI remain pending; local `psql`
|
||||
and the POSIX-only migration test environment are unavailable.
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/persistence/checkpoint_store.hpp"
|
||||
#include "evo/persistence/life_reservation_store.hpp"
|
||||
#include "evo/network/session_protocol.hpp"
|
||||
#include "evo/server/lifecycle/cellular_batch.hpp"
|
||||
#include "evo/server/ops.hpp"
|
||||
|
||||
#include <chrono>
|
||||
@@ -46,6 +49,17 @@ class CellularRegionHost {
|
||||
[[nodiscard]] std::expected<persistence::PublishedCellularBatch, CellularHostError>
|
||||
publish(const CellularBatch& batch,
|
||||
std::span<const CellularActionRecord> actions = {});
|
||||
// v5 requests allocate durably, then wait for the scheduler to include the exact
|
||||
// reservation in a profile-4 batch. Repeating the request is idempotent.
|
||||
[[nodiscard]] network::PrimitiveLifeOutcome
|
||||
create_primitive_life(const persistence::Uuid& account, std::uint64_t generation,
|
||||
std::uint64_t request);
|
||||
[[nodiscard]] network::PrimitiveLifeOutcome
|
||||
query_primitive_life(const persistence::Uuid& account, std::uint64_t generation,
|
||||
std::uint64_t request);
|
||||
[[nodiscard]] std::span<const CellularTickIntents::Birth> queued_births() const noexcept {
|
||||
return queued_births_;
|
||||
}
|
||||
[[nodiscard]] std::vector<FinalCellularAction> take_finalized_actions();
|
||||
void drain();
|
||||
[[nodiscard]] std::optional<persistence::LeaseGrant> authority() const;
|
||||
@@ -64,6 +78,11 @@ class CellularRegionHost {
|
||||
void upkeep();
|
||||
void resolve();
|
||||
void refresh();
|
||||
void finalize_births(std::span<const CellularTickIntents::Birth> births);
|
||||
void queue_birth(const CellularTickIntents::Birth& birth);
|
||||
[[nodiscard]] network::PrimitiveLifeOutcome query_birth(
|
||||
const persistence::Uuid& account, std::uint64_t generation, std::uint64_t request,
|
||||
bool enqueue);
|
||||
|
||||
CellularHostConfig config_;
|
||||
CellularConnect connect_;
|
||||
@@ -74,6 +93,7 @@ class CellularRegionHost {
|
||||
std::optional<persistence::CommittedCheckpoint> committed_;
|
||||
std::unique_ptr<Pending> pending_;
|
||||
std::vector<FinalCellularAction> finalized_actions_;
|
||||
std::vector<CellularTickIntents::Birth> queued_births_;
|
||||
HostStatus status_{};
|
||||
};
|
||||
} // namespace evo::server
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "evo/server/cellular_region_host.hpp"
|
||||
|
||||
#include "evo/biology/founder.hpp"
|
||||
#include "evo/persistence/sha256.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -12,6 +13,7 @@ struct CellularRegionHost::Pending {
|
||||
persistence::CellularPreparedCommit prepared;
|
||||
std::unique_ptr<CellularLives> candidate;
|
||||
std::vector<CellularActionRecord> actions;
|
||||
std::vector<CellularTickIntents::Birth> births;
|
||||
};
|
||||
|
||||
namespace {
|
||||
@@ -25,6 +27,29 @@ bool valid(const CellularHostConfig& config) {
|
||||
std::ranges::find(config.retained_builds, config.build) != config.retained_builds.end();
|
||||
}
|
||||
|
||||
network::PrimitiveLifeResult life_result(persistence::LifeRefusal refusal) {
|
||||
switch (refusal) {
|
||||
case persistence::LifeRefusal::none:
|
||||
return network::PrimitiveLifeResult::pending;
|
||||
case persistence::LifeRefusal::insufficient_funding:
|
||||
return network::PrimitiveLifeResult::insufficient_funding;
|
||||
case persistence::LifeRefusal::no_placement:
|
||||
return network::PrimitiveLifeResult::no_placement;
|
||||
case persistence::LifeRefusal::cancelled:
|
||||
return network::PrimitiveLifeResult::cancelled;
|
||||
case persistence::LifeRefusal::existing_life:
|
||||
return network::PrimitiveLifeResult::existing_life;
|
||||
}
|
||||
return network::PrimitiveLifeResult::unknown;
|
||||
}
|
||||
|
||||
std::vector<CellularTickIntents::Birth> births_in(const CellularBatch& batch) {
|
||||
std::vector<CellularTickIntents::Birth> births;
|
||||
for (const auto& tick : batch.ticks)
|
||||
births.insert(births.end(), tick.births.begin(), tick.births.end());
|
||||
return births;
|
||||
}
|
||||
|
||||
std::optional<persistence::Uuid> commit_id(const persistence::CommittedCheckpoint& previous,
|
||||
std::span<const std::uint8_t> trace,
|
||||
std::span<const std::uint8_t> actions) {
|
||||
@@ -238,6 +263,7 @@ void CellularRegionHost::resolve() {
|
||||
committed_ = std::move(*retried);
|
||||
for (const auto& action : pending_->actions)
|
||||
finalized_actions_.push_back({action, committed_->head.sequence});
|
||||
finalize_births(pending_->births);
|
||||
pending_.reset();
|
||||
++status_.commits;
|
||||
status_.committed_sequence = committed_->head.sequence;
|
||||
@@ -296,7 +322,7 @@ CellularRegionHost::publish(const CellularBatch& batch,
|
||||
if (published.error().kind == persistence::PublicationError::unknown) {
|
||||
pending_ = std::make_unique<Pending>(
|
||||
Pending{published.error().prepared, std::move(*candidate),
|
||||
{actions.begin(), actions.end()}});
|
||||
{actions.begin(), actions.end()}, births_in(batch)});
|
||||
status_.phase = HostPhase::resolving;
|
||||
status_.ready = false;
|
||||
++status_.unknown_outcomes;
|
||||
@@ -315,6 +341,8 @@ CellularRegionHost::publish(const CellularBatch& batch,
|
||||
committed_ = published->committed;
|
||||
for (const auto& action : actions)
|
||||
finalized_actions_.push_back({action, committed_->head.sequence});
|
||||
const auto births = births_in(batch);
|
||||
finalize_births(births);
|
||||
++status_.commits;
|
||||
status_.committed_sequence = committed_->head.sequence;
|
||||
status_.committed_tick = committed_->head.end_tick;
|
||||
@@ -323,6 +351,99 @@ CellularRegionHost::publish(const CellularBatch& batch,
|
||||
return *published;
|
||||
}
|
||||
|
||||
void CellularRegionHost::queue_birth(const CellularTickIntents::Birth& birth) {
|
||||
const auto found = std::ranges::find_if(queued_births_, [&](const auto& queued) {
|
||||
return queued.account == birth.account && queued.request == birth.request;
|
||||
});
|
||||
if (found == queued_births_.end())
|
||||
queued_births_.push_back(birth);
|
||||
}
|
||||
|
||||
void CellularRegionHost::finalize_births(std::span<const CellularTickIntents::Birth> births) {
|
||||
for (const auto& birth : births)
|
||||
std::erase_if(queued_births_, [&](const auto& queued) {
|
||||
return queued.account == birth.account && queued.request == birth.request &&
|
||||
queued.generation == birth.generation && queued.identity == birth.identity;
|
||||
});
|
||||
}
|
||||
|
||||
network::PrimitiveLifeOutcome CellularRegionHost::query_birth(
|
||||
const persistence::Uuid& account, std::uint64_t generation, std::uint64_t request,
|
||||
bool enqueue) {
|
||||
using network::PrimitiveLifeResult;
|
||||
const auto unknown = [&] {
|
||||
return network::PrimitiveLifeOutcome{request, PrimitiveLifeResult::unknown, 0, 0};
|
||||
};
|
||||
if (!status_.ready || !authority_.may_begin_commit(LeaseClock::now()) || account ==
|
||||
persistence::Uuid{} || generation == 0 || request == 0 || !database())
|
||||
return unknown();
|
||||
const auto grant = authority_.grant();
|
||||
if (!grant)
|
||||
return unknown();
|
||||
auto queried = persistence::query_primitive_life(*db_, config_.key, *grant, account,
|
||||
generation, request,
|
||||
config_.lease.commit_timeout);
|
||||
if (!queried) {
|
||||
if (queried.error().kind == persistence::LifeReservationError::unknown ||
|
||||
queried.error().kind == persistence::LifeReservationError::store)
|
||||
db_.reset();
|
||||
if (queried.error().kind == persistence::LifeReservationError::fenced) {
|
||||
authority_.fence();
|
||||
status_.ready = false;
|
||||
}
|
||||
return unknown();
|
||||
}
|
||||
if (!queried->has_value())
|
||||
return unknown();
|
||||
const auto& outcome = queried->value();
|
||||
if (outcome.published)
|
||||
return {request, PrimitiveLifeResult::born, outcome.published->identity,
|
||||
outcome.published->commit_sequence};
|
||||
if (outcome.reservation.region != config_.key.region)
|
||||
return unknown();
|
||||
const auto result = life_result(outcome.reservation.refusal);
|
||||
if (result == PrimitiveLifeResult::pending && enqueue)
|
||||
queue_birth({account, request, generation, outcome.reservation.identity});
|
||||
return {request, result, outcome.reservation.identity, 0};
|
||||
}
|
||||
|
||||
network::PrimitiveLifeOutcome CellularRegionHost::create_primitive_life(
|
||||
const persistence::Uuid& account, std::uint64_t generation, std::uint64_t request) {
|
||||
using network::PrimitiveLifeResult;
|
||||
const auto existing = query_birth(account, generation, request, true);
|
||||
if (existing.result != PrimitiveLifeResult::unknown)
|
||||
return existing;
|
||||
if (!status_.ready || !authority_.may_begin_commit(LeaseClock::now()) || !database())
|
||||
return {request, PrimitiveLifeResult::unknown, 0, 0};
|
||||
const auto grant = authority_.grant();
|
||||
if (!grant)
|
||||
return {request, PrimitiveLifeResult::unknown, 0, 0};
|
||||
auto reserved = persistence::reserve_primitive_life(
|
||||
*db_, config_.key, *grant, account, generation, request,
|
||||
biology::founder_life_rules, config_.lease.commit_timeout);
|
||||
if (!reserved) {
|
||||
if (reserved.error().kind == persistence::LifeReservationError::unknown ||
|
||||
reserved.error().kind == persistence::LifeReservationError::store)
|
||||
db_.reset();
|
||||
if (reserved.error().kind == persistence::LifeReservationError::fenced) {
|
||||
authority_.fence();
|
||||
status_.ready = false;
|
||||
}
|
||||
return {request, PrimitiveLifeResult::unknown, 0, 0};
|
||||
}
|
||||
if (reserved->region != config_.key.region)
|
||||
return {request, PrimitiveLifeResult::unknown, reserved->identity, 0};
|
||||
const auto result = life_result(reserved->refusal);
|
||||
if (result == PrimitiveLifeResult::pending)
|
||||
queue_birth({account, request, generation, reserved->identity});
|
||||
return {request, result, reserved->identity, 0};
|
||||
}
|
||||
|
||||
network::PrimitiveLifeOutcome CellularRegionHost::query_primitive_life(
|
||||
const persistence::Uuid& account, std::uint64_t generation, std::uint64_t request) {
|
||||
return query_birth(account, generation, request, true);
|
||||
}
|
||||
|
||||
std::vector<FinalCellularAction> CellularRegionHost::take_finalized_actions() {
|
||||
return std::exchange(finalized_actions_, {});
|
||||
}
|
||||
|
||||
@@ -89,10 +89,12 @@ void cellular_birth_publication_is_durable() {
|
||||
const auto control = claim_account_control(*runtime, key, *authority, account, 1, 1,
|
||||
20'000ms, 5s);
|
||||
CHECK(control);
|
||||
const auto reservation = reserve_primitive_life(*runtime, key, *authority, account,
|
||||
control->generation, 7, 1, 5s);
|
||||
CHECK(reservation && reservation->refusal == LifeRefusal::none &&
|
||||
reservation->region == key.region);
|
||||
const auto requested = host->create_primitive_life(account, control->generation, 7);
|
||||
CHECK(requested.result == evo::network::PrimitiveLifeResult::pending &&
|
||||
requested.life_identity != 0 && host->queued_births().size() == 1);
|
||||
const auto retried = host->create_primitive_life(account, control->generation, 7);
|
||||
CHECK(retried == requested && host->queued_births().size() == 1);
|
||||
const auto reservation = host->queued_births().front();
|
||||
|
||||
CellularBatch batch;
|
||||
const auto predecessor_digest = sha256(host->committed()->manifest);
|
||||
@@ -100,18 +102,23 @@ void cellular_birth_publication_is_durable() {
|
||||
batch.header = {key.world, key.region, 1, host->committed()->head.commit,
|
||||
*predecessor_digest, 0, 1};
|
||||
CellularTickIntents tick;
|
||||
tick.births.push_back({account, 7, control->generation, reservation->identity});
|
||||
tick.births.push_back(reservation);
|
||||
batch.ticks.push_back(tick);
|
||||
auto candidate = replay_cellular_batch(*host->state(), batch);
|
||||
CHECK(candidate && (*candidate)->lives().size() == 1 &&
|
||||
(*candidate)->lives()[0].identity.life == reservation->identity);
|
||||
(*candidate)->lives()[0].identity.life == reservation.identity);
|
||||
auto published = host->publish(batch);
|
||||
CHECK(published && published->committed.head.sequence == 1 &&
|
||||
host->state()->snapshot() == (*candidate)->snapshot());
|
||||
host->state()->snapshot() == (*candidate)->snapshot() &&
|
||||
host->queued_births().empty());
|
||||
const auto host_outcome = host->query_primitive_life(account, control->generation, 7);
|
||||
CHECK(host_outcome.result == evo::network::PrimitiveLifeResult::born &&
|
||||
host_outcome.life_identity == reservation.identity &&
|
||||
host_outcome.commit_sequence == 1);
|
||||
const auto outcome = query_primitive_life(*runtime, key, *authority, account,
|
||||
control->generation, 7, 5s);
|
||||
CHECK(outcome && outcome->has_value() && (*outcome)->published &&
|
||||
(*outcome)->published->identity == reservation->identity &&
|
||||
(*outcome)->published->identity == reservation.identity &&
|
||||
(*outcome)->published->born == 1);
|
||||
host->drain();
|
||||
host.reset();
|
||||
|
||||
Reference in New Issue
Block a user