Fix CI formatting and tidy findings
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m38s
Foundation / checks (network) (push) Successful in 14m7s
Foundation / checks (tsan) (push) Successful in 8m11s
Foundation / checks (postgres) (push) Failing after 18m3s
Foundation / checks (checks) (push) Successful in 33m8s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-10 14:36:11 -04:00
parent 4f49c54232
commit 67f3545d5b
5 changed files with 59 additions and 50 deletions
+6 -3
View File
@@ -5692,6 +5692,9 @@ retry and world/account exclusivity.
Executed: GCC 13.2 Release/NDEBUG compilation with warnings-as-errors for the new Executed: GCC 13.2 Release/NDEBUG compilation with warnings-as-errors for the new
host translation unit and changed PostgreSQL test translation unit; `git diff host translation unit and changed PostgreSQL test translation unit; `git diff
--check`. Both compilations passed. The local Windows shell cannot configure the --check`. Both compilations passed. The local Windows shell cannot configure the
Linux-only PostgreSQL target, and this turn did not run the PostgreSQL test binary, Linux-only PostgreSQL target, and this turn did not run the PostgreSQL test binary.
clang-format, or clang-tidy. Awaiting CI for the database, migration, host test and CI found clang-format violations in the three new/changed host and test files plus
repository checks; no local runtime pass is claimed. the `performance-move-const-arg` clang-tidy warning on the v17 outcome adapter.
Both were corrected. clang-format 19.1.5 dry-run and clang-tidy 19.1.5 on
`region_lease_store.cpp` pass locally. Awaiting CI rerun for the database,
migration, host test and repository checks; no local runtime pass is claimed.
+9 -8
View File
@@ -40,8 +40,7 @@ struct PrimitiveHostReply {
class PrimitiveRegionHost { class PrimitiveRegionHost {
public: public:
[[nodiscard]] static std::expected<std::unique_ptr<PrimitiveRegionHost>, [[nodiscard]] static std::expected<std::unique_ptr<PrimitiveRegionHost>, PrimitiveHostError>
PrimitiveHostError>
create(PrimitiveHostConfig config, PrimitiveConnect connect, create(PrimitiveHostConfig config, PrimitiveConnect connect,
std::unique_ptr<persistence::FilesystemObjectStore> objects); std::unique_ptr<persistence::FilesystemObjectStore> objects);
PrimitiveRegionHost(const PrimitiveRegionHost&) = delete; PrimitiveRegionHost(const PrimitiveRegionHost&) = delete;
@@ -56,12 +55,15 @@ class PrimitiveRegionHost {
// The caller supplies the authenticated account-control generation. The // The caller supplies the authenticated account-control generation. The
// operation is durable before `born` or a final refusal is returned. // operation is durable before `born` or a final refusal is returned.
[[nodiscard]] PrimitiveHostReply new_life(const persistence::Uuid& account, [[nodiscard]] PrimitiveHostReply new_life(const persistence::Uuid& account,
std::uint64_t generation, std::uint64_t generation, std::uint64_t request,
std::uint64_t request,
std::uint32_t rules); std::uint32_t rules);
[[nodiscard]] std::optional<persistence::LeaseGrant> authority() const; [[nodiscard]] std::optional<persistence::LeaseGrant> authority() const;
[[nodiscard]] const HostStatus& status() const noexcept { return status_; } [[nodiscard]] const HostStatus& status() const noexcept {
[[nodiscard]] const PrimitiveLives* state() const noexcept { return state_.get(); } return status_;
}
[[nodiscard]] const PrimitiveLives* state() const noexcept {
return state_.get();
}
private: private:
struct Pending; struct Pending;
@@ -72,8 +74,7 @@ class PrimitiveRegionHost {
void upkeep(); void upkeep();
void refresh(); void refresh();
[[nodiscard]] PrimitiveHostReply query(const persistence::Uuid& account, [[nodiscard]] PrimitiveHostReply query(const persistence::Uuid& account,
std::uint64_t generation, std::uint64_t generation, std::uint64_t request);
std::uint64_t request);
PrimitiveHostConfig config_; PrimitiveHostConfig config_;
PrimitiveConnect connect_; PrimitiveConnect connect_;
+1 -1
View File
@@ -723,7 +723,7 @@ query_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, const
out.published = out.published =
PrimitiveLifeBinding{account, request_id, *identity, *born, *commit, *sequence}; PrimitiveLifeBinding{account, request_id, *identity, *born, *commit, *sequence};
} }
return std::optional<PrimitiveLifeOutcome>{std::move(out)}; return std::optional<PrimitiveLifeOutcome>{out};
} }
// Schema v12 probe records and handoff (ADR-0096). Shares this file's parsing rules. // Schema v12 probe records and handoff (ADR-0096). Shares this file's parsing rules.
+36 -30
View File
@@ -22,8 +22,8 @@ using persistence::LeaseClock;
using persistence::LeaseStoreError; using persistence::LeaseStoreError;
bool valid(const PrimitiveHostConfig& c) { bool valid(const PrimitiveHostConfig& c) {
return c.key.world != 0 && c.key.region != 0 && c.frame != 0 && return c.key.world != 0 && c.key.region != 0 && c.frame != 0 && persistence::valid(c.lease) &&
persistence::valid(c.lease) && c.build != persistence::Sha256Digest{} && c.build != persistence::Sha256Digest{} &&
std::ranges::find(c.retained_builds, c.build) != c.retained_builds.end(); std::ranges::find(c.retained_builds, c.build) != c.retained_builds.end();
} }
PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservation reservation, PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservation reservation,
@@ -32,8 +32,9 @@ PrimitiveHostReply reply(PrimitiveHostReplyKind kind, persistence::LifeReservati
} }
} // namespace } // namespace
PrimitiveRegionHost::PrimitiveRegionHost(PrimitiveHostConfig config, PrimitiveConnect connect, PrimitiveRegionHost::PrimitiveRegionHost(
std::unique_ptr<persistence::FilesystemObjectStore> objects) PrimitiveHostConfig config, PrimitiveConnect connect,
std::unique_ptr<persistence::FilesystemObjectStore> objects)
: config_{std::move(config)}, connect_{std::move(connect)}, objects_{std::move(objects)}, : config_{std::move(config)}, connect_{std::move(connect)}, objects_{std::move(objects)},
authority_{config_.lease} {} authority_{config_.lease} {}
@@ -44,8 +45,8 @@ PrimitiveRegionHost::create(PrimitiveHostConfig config, PrimitiveConnect connect
std::unique_ptr<persistence::FilesystemObjectStore> objects) { std::unique_ptr<persistence::FilesystemObjectStore> objects) {
if (!valid(config) || !connect || !objects) if (!valid(config) || !connect || !objects)
return std::unexpected{PrimitiveHostError::configuration}; return std::unexpected{PrimitiveHostError::configuration};
return std::unique_ptr<PrimitiveRegionHost>{new PrimitiveRegionHost{ return std::unique_ptr<PrimitiveRegionHost>{
std::move(config), std::move(connect), std::move(objects)}}; new PrimitiveRegionHost{std::move(config), std::move(connect), std::move(objects)}};
} }
bool PrimitiveRegionHost::database() { bool PrimitiveRegionHost::database() {
@@ -166,9 +167,11 @@ void PrimitiveRegionHost::refresh() {
authority_.may_originate(LeaseClock::now()); authority_.may_originate(LeaseClock::now());
status_.epoch = lease ? lease->epoch : 0; status_.epoch = lease ? lease->epoch : 0;
status_.lease_remaining_ms = status_.lease_remaining_ms =
status_.ready ? static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>( status_.ready
authority_.deadline() - LeaseClock::now()).count()) ? static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(
: 0; authority_.deadline() - LeaseClock::now())
.count())
: 0;
} }
const HostStatus& PrimitiveRegionHost::step() { const HostStatus& PrimitiveRegionHost::step() {
@@ -196,8 +199,8 @@ void PrimitiveRegionHost::drain() {
pending_.reset(); pending_.reset();
const auto grant = authority_.grant(); const auto grant = authority_.grant();
if (grant && authority_.may_originate(LeaseClock::now()) && database()) { if (grant && authority_.may_originate(LeaseClock::now()) && database()) {
const auto released = persistence::release_region_lease( const auto released = persistence::release_region_lease(*db_, config_.key, *grant,
*db_, config_.key, *grant, config_.lease.renew_timeout); config_.lease.renew_timeout);
if (!released) if (!released)
db_.reset(); db_.reset();
} }
@@ -216,13 +219,12 @@ std::optional<persistence::LeaseGrant> PrimitiveRegionHost::authority() const {
} }
PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account, PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
std::uint64_t generation, std::uint64_t generation, std::uint64_t request) {
std::uint64_t request) {
if (!database() || !authority_.grant()) if (!database() || !authority_.grant())
return reply(PrimitiveHostReplyKind::unavailable, {}); return reply(PrimitiveHostReplyKind::unavailable, {});
auto outcome = persistence::query_primitive_life(*db_, config_.key, *authority_.grant(), auto outcome =
account, generation, request, persistence::query_primitive_life(*db_, config_.key, *authority_.grant(), account,
config_.lease.commit_timeout); generation, request, config_.lease.commit_timeout);
if (!outcome) { if (!outcome) {
if (outcome.error().kind == persistence::LifeReservationError::unknown || if (outcome.error().kind == persistence::LifeReservationError::unknown ||
outcome.error().kind == persistence::LifeReservationError::store) outcome.error().kind == persistence::LifeReservationError::store)
@@ -244,8 +246,7 @@ PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
} }
PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& account, PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& account,
std::uint64_t generation, std::uint64_t generation, std::uint64_t request,
std::uint64_t request,
std::uint32_t rules) { std::uint32_t rules) {
if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now())) if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now()))
return reply(PrimitiveHostReplyKind::unavailable, {}); return reply(PrimitiveHostReplyKind::unavailable, {});
@@ -304,8 +305,8 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
status_.phase = HostPhase::quarantined; status_.phase = HostPhase::quarantined;
return reply(PrimitiveHostReplyKind::unavailable, reservation); return reply(PrimitiveHostReplyKind::unavailable, reservation);
} }
auto resolved = persistence::retry_primitive_prepared( auto resolved =
*db_, prepared, config_.lease.commit_timeout); persistence::retry_primitive_prepared(*db_, prepared, config_.lease.commit_timeout);
if (!resolved) { if (!resolved) {
if (resolved.error().kind == persistence::PublicationError::unknown) { if (resolved.error().kind == persistence::PublicationError::unknown) {
db_.reset(); db_.reset();
@@ -339,9 +340,9 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
if (existing.kind != PrimitiveHostReplyKind::unknown && if (existing.kind != PrimitiveHostReplyKind::unknown &&
existing.kind != PrimitiveHostReplyKind::pending) existing.kind != PrimitiveHostReplyKind::pending)
return existing; return existing;
auto reserved = persistence::reserve_primitive_life( auto reserved = persistence::reserve_primitive_life(*db_, config_.key, *authority_.grant(),
*db_, config_.key, *authority_.grant(), account, generation, request, rules, account, generation, request, rules,
config_.lease.commit_timeout); config_.lease.commit_timeout);
if (!reserved) { if (!reserved) {
if (reserved.error().kind == persistence::LifeReservationError::unknown) { if (reserved.error().kind == persistence::LifeReservationError::unknown) {
db_.reset(); db_.reset();
@@ -386,7 +387,7 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
auto& source = state_->balances().front(); auto& source = state_->balances().front();
const auto enough = [&] { const auto enough = [&] {
if (source.energy.value < endowed->body.energy.value + endowed->reserve.energy.value + if (source.energy.value < endowed->body.energy.value + endowed->reserve.energy.value +
endowed->construction.value) endowed->construction.value)
return false; return false;
for (std::size_t i = 0; i < source.matter.size(); ++i) for (std::size_t i = 0; i < source.matter.size(); ++i)
if (source.matter[i].value < endowed->body.matter[i].value) if (source.matter[i].value < endowed->body.matter[i].value)
@@ -395,8 +396,7 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
}; };
if (!enough()) if (!enough())
return refuse(persistence::LifeRefusal::insufficient_funding); return refuse(persistence::LifeRefusal::insufficient_funding);
if (committed_->head.end_tick == UINT64_MAX || if (committed_->head.end_tick == UINT64_MAX || committed_->head.sequence == UINT64_MAX) {
committed_->head.sequence == UINT64_MAX) {
status_.phase = HostPhase::quarantined; status_.phase = HostPhase::quarantined;
status_.ready = false; status_.ready = false;
authority_.fence(); authority_.fence();
@@ -412,8 +412,8 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
} }
const auto end_tick = committed_->head.end_tick + 1; const auto end_tick = committed_->head.end_tick + 1;
PrimitiveBatch batch{{config_.key.world, config_.key.region, config_.frame, PrimitiveBatch batch{{config_.key.world, config_.key.region, config_.frame,
committed_->head.commit, *predecessor_digest, committed_->head.commit, *predecessor_digest, committed_->head.end_tick,
committed_->head.end_tick, end_tick}, end_tick},
{{{account, request}, reserved->identity, generation, {end_tick}}}}; {{{account, request}, reserved->identity, generation, {end_tick}}}};
auto candidate = replay_primitive_batch(*state_, batch); auto candidate = replay_primitive_batch(*state_, batch);
if (!candidate) { if (!candidate) {
@@ -432,8 +432,14 @@ PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& accoun
const auto sequence = committed_->head.sequence + 1; const auto sequence = committed_->head.sequence + 1;
for (unsigned i = 0; i < 8; ++i) for (unsigned i = 0; i < 8; ++i)
commit[8 + i] = static_cast<std::uint8_t>((sequence >> (i * 8U)) & 0xffU); commit[8 + i] = static_cast<std::uint8_t>((sequence >> (i * 8U)) & 0xffU);
pending_ = std::make_unique<Pending>(Pending{account, generation, request, *reserved, pending_ = std::make_unique<Pending>(Pending{account,
std::move(batch), std::move(*candidate), commit, {}}); generation,
request,
*reserved,
std::move(batch),
std::move(*candidate),
commit,
{}});
auto published = persistence::publish_primitive_batch( auto published = persistence::publish_primitive_batch(
*db_, *objects_, *authority_.grant(), *committed_, pending_->batch, *pending_->candidate, *db_, *objects_, *authority_.grant(), *committed_, pending_->batch, *pending_->candidate,
pending_->commit, config_.build, config_.lease.commit_timeout); pending_->commit, config_.build, config_.lease.commit_timeout);
+7 -8
View File
@@ -127,19 +127,18 @@ void primitive_host_fenced_spawn() {
5s)); 5s));
CHECK(owner->query("INSERT INTO evolution.life_allocators VALUES(9755,1)", {}, 5s)); CHECK(owner->query("INSERT INTO evolution.life_allocators VALUES(9755,1)", {}, 5s));
auto host_objects = FilesystemObjectStore::open(env("PGHOST"), key, auto host_objects = FilesystemObjectStore::open(env("PGHOST"), key, max_primitive_lives_bytes);
max_primitive_lives_bytes);
CHECK(host_objects); CHECK(host_objects);
const auto pg = PgOptions{env("PGHOST"), {}, env("PGPORT"), env("PGDATABASE"), const auto pg = PgOptions{
env("EVO_PG_RUNTIME_USER"), {}, {}}; env("PGHOST"), {}, env("PGPORT"), env("PGDATABASE"), env("EVO_PG_RUNTIME_USER"), {}, {}};
auto made = PrimitiveRegionHost::create( auto made = PrimitiveRegionHost::create(
{key, 1, {}, build, {build}}, {key, 1, {}, build, {build}}, [pg] { return Postgres::connect(pg, 5s); },
[pg] { return Postgres::connect(pg, 5s); }, std::move(*host_objects)); std::move(*host_objects));
CHECK(made && (*made)->step().ready); CHECK(made && (*made)->step().ready);
auto runtime = connect_as(env("EVO_PG_RUNTIME_USER")); auto runtime = connect_as(env("EVO_PG_RUNTIME_USER"));
const auto account = id<16>(0x73); const auto account = id<16>(0x73);
auto control = claim_account_control(*runtime, key, *(*made)->authority(), account, 1, 1, auto control =
20000ms, 5s); claim_account_control(*runtime, key, *(*made)->authority(), account, 1, 1, 20000ms, 5s);
CHECK(control); CHECK(control);
const auto born = (*made)->new_life(account, control->generation, 1, 1); const auto born = (*made)->new_life(account, control->generation, 1, 1);
CHECK(born.kind == PrimitiveHostReplyKind::born && born.published && CHECK(born.kind == PrimitiveHostReplyKind::born && born.published &&