Send the owner its outstanding mutation offer over v10

Session protocol v10 adds type 26: the life's earned offer with its unranked
candidates in operator order and each successor's capability value,
maintenance and total mass. The cellular bridge sends it when the offer or the
owner's session changes and clears a consumed offer; the client keeps the
latest one for the maintainer's choice UI (ADR-0121, 11.4d server half).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-13 23:07:50 -04:00
co-authored by Claude Opus 5.5
parent 187b1a7b98
commit f77956e579
16 changed files with 314 additions and 17 deletions
+32
View File
@@ -247,9 +247,35 @@ class CellularBridge {
view.patches.push_back(visible);
}
(void)sessions_->send_cellular_perception(network::AccountId{life.account}, view);
send_offer(life, tick);
}
std::erase_if(offers_, [&](const SentOffer& sent) {
return std::ranges::find(state.lives(), sent.account,
&server::CellularOwnedLife::account) == state.lives().end();
});
replicated_tick_ = tick;
}
// 11.4d: the owner's outstanding offer is sent reliably when it changes or the owner's
// session changes; an empty view clears an offer that was consumed.
void send_offer(const server::CellularOwnedLife& life, std::uint64_t tick) {
const network::AccountId account{life.account};
const auto session = sessions_->holder(account);
const auto& progress = life.mutation;
const SentOffer current{life.account, session.value_or(0), life.identity.life,
progress.offer ? progress.event_index : 0,
progress.offer ? progress.offer_tick : 0};
auto sent = std::ranges::find(offers_, life.account, &SentOffer::account);
if (sent != offers_.end() && *sent == current)
return;
if (!session || (!progress.offer && sent == offers_.end()))
return; // Nothing to show, or no one to show it to.
if (!sessions_->send_mutation_offer(account, server::offer_view(life, tick)))
return; // Not a v10 owner (or the stream refused): retried on a later tick.
if (sent != offers_.end())
*sent = current;
else
offers_.push_back(current);
}
void shutdown() {
sessions_->shutdown(std::chrono::steady_clock::now());
}
@@ -275,6 +301,12 @@ class CellularBridge {
std::unique_ptr<server::RegionSessions> sessions_;
std::optional<server::SessionWindow> window_;
std::optional<std::uint64_t> replicated_tick_;
struct SentOffer {
server::LifeAccount account{};
std::uint64_t session{}, life{}, event_index{}, offer_tick{};
friend bool operator==(const SentOffer&, const SentOffer&) = default;
};
std::vector<SentOffer> offers_; // Last offer view sent to each owner.
bool shutdown_{};
};
} // namespace evo::server_app