From 8a9a318d78a0942aeb2a3e152e0fea9a4a01dd66 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 11 Oct 2026 14:14:52 -0400 Subject: [PATCH] Guard cellular host optional results --- docs/engineering/VALIDATION.md | 8 ++++++++ src/server/cellular_region_host.cpp | 18 +++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 7bec4c5..7e9858a 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -6940,3 +6940,11 @@ new optional-return expression wrapped at line 499. It has been kept on one line to follow the 100-column clang-format configuration. PostgreSQL analysis continued independently, but was superseded before completion by the format fix push so the full matrix could rerun on one commit. + +CI run #294 passed the main, client, deploy, ECS, network and TSan jobs, but the +PostgreSQL-enabled analysis reached `src/server/cellular_region_host.cpp` and +reported unchecked optionals at the cellular publish grant and life-query result, +plus an intentionally best-effort lease release expressed as a discarded value. +The image jobs were skipped because that matrix job failed. The host now passes +safe grant/outcome values after presence checks and captures the shutdown release +result using the existing RegionHost convention. diff --git a/src/server/cellular_region_host.cpp b/src/server/cellular_region_host.cpp index 63ac5fa..f7f9eba 100644 --- a/src/server/cellular_region_host.cpp +++ b/src/server/cellular_region_host.cpp @@ -297,7 +297,9 @@ const HostStatus& CellularRegionHost::step() { std::expected CellularRegionHost::publish(const CellularBatch& batch, std::span actions) { - if (!status_.ready || !state_ || !committed_ || !authority_.may_begin_commit(LeaseClock::now())) + const auto grant = authority_.grant(); + if (!status_.ready || !state_ || !committed_ || !grant || + !authority_.may_begin_commit(LeaseClock::now())) return std::unexpected{CellularHostError::not_ready}; auto candidate = replay_cellular_batch(*state_, batch); if (!candidate) @@ -310,8 +312,8 @@ CellularRegionHost::publish(const CellularBatch& batch, if (!commit) return std::unexpected{CellularHostError::invalid_batch}; auto published = persistence::publish_cellular_batch( - *db_, *objects_, *authority_.grant(), *committed_, batch, **candidate, *commit, - config_.build, config_.lease.commit_timeout, {}, actions); + *db_, *objects_, grant.value_or(persistence::LeaseGrant{}), *committed_, batch, **candidate, + *commit, config_.build, config_.lease.commit_timeout, {}, actions); if (!published) { if (published.error().kind == persistence::PublicationError::unknown) { pending_ = std::make_unique(Pending{published.error().prepared, @@ -389,7 +391,7 @@ network::PrimitiveLifeOutcome CellularRegionHost::query_birth(const persistence: } if (!queried->has_value()) return unknown(); - const auto& outcome = queried->value(); + const auto outcome = queried->value_or(persistence::PrimitiveLifeOutcome{}); if (outcome.published) return {request, PrimitiveLifeResult::born, outcome.published->identity, outcome.published->commit_sequence}; @@ -449,9 +451,11 @@ void CellularRegionHost::drain() { status_.phase = HostPhase::draining; pending_.reset(); const auto grant = authority_.grant(); - if (grant && authority_.may_originate(LeaseClock::now()) && database()) - static_cast(persistence::release_region_lease(*db_, config_.key, *grant, - config_.lease.renew_timeout)); + if (grant && authority_.may_originate(LeaseClock::now()) && database()) { + // Best effort during shutdown; the lease expires if release cannot be confirmed. + [[maybe_unused]] const auto released = persistence::release_region_lease( + *db_, config_.key, *grant, config_.lease.renew_timeout); + } authority_.fence(); state_.reset(); committed_.reset();