Tell the owner what its engulf and bud did, and why its cell died

M11.8 server half (ADR-0129): v10 diagnostics report the tick's engulf and bud
results in two reserved bytes, and v10 type 27 tells the owner its life ended with
the cause (starved or engulfed). The bridge fills both from the owner's tick
feedback and corpses; v9 views are unchanged. Client presentation stays with the
maintainer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-14 07:57:37 -04:00
co-authored by Claude Opus 5.5
parent e74bdf286b
commit 69e3866fd9
14 changed files with 312 additions and 8 deletions
+58
View File
@@ -238,6 +238,10 @@ class CellularBridge {
diagnostics.intake = network::CellularIntakeResult::out_of_contact;
break;
}
// ADR-0129 (v10): what an engulf or bud intention did this tick.
diagnostics.engulf = engulf_result(feedback->engulf);
diagnostics.bud = feedback->bud ? bud_outcome(*feedback->bud)
: network::CellularBudOutcome::not_requested;
}
view.diagnostics = diagnostics;
view.patches.reserve(perceived->size());
@@ -257,8 +261,61 @@ class CellularBridge {
return std::ranges::find(state.lives(), sent.account,
&server::CellularOwnedLife::account) == state.lives().end();
});
announce_endings(state);
replicated_tick_ = tick;
}
// ADR-0129: an owned life seen at the last replication and now a corpse is announced to
// its owner once, with its recorded cause.
void announce_endings(const server::CellularLives& state) {
for (const auto& [account, life_id] : owned_) {
if (std::ranges::find(state.lives(), life_id, [](const server::CellularOwnedLife& l) {
return l.identity.life;
}) != state.lives().end())
continue;
const auto corpse =
std::ranges::find(state.corpses(), life_id, &server::CellularOwnedCorpse::life_id);
if (corpse == state.corpses().end())
continue;
const auto cause = corpse->cause == biology::CellularDeathCause::starved
? network::CellularDeathReason::starved
: corpse->cause == biology::CellularDeathCause::engulfed
? network::CellularDeathReason::engulfed
: network::CellularDeathReason::unrecorded;
static_cast<void>(sessions_->send_life_ended(network::AccountId{account},
{corpse->died_tick, life_id, cause}));
}
owned_.clear();
for (const auto& life : state.lives())
if (life.account != server::LifeAccount{})
owned_.emplace_back(life.account, life.identity.life);
}
static network::CellularEngulfResult engulf_result(biology::CellularEngulfStatus status) {
switch (status) {
case biology::CellularEngulfStatus::not_requested:
return network::CellularEngulfResult::not_requested;
case biology::CellularEngulfStatus::engulfed:
return network::CellularEngulfResult::engulfed;
case biology::CellularEngulfStatus::no_eligible_prey:
return network::CellularEngulfResult::no_eligible_prey;
case biology::CellularEngulfStatus::unsupported:
return network::CellularEngulfResult::unsupported;
}
return network::CellularEngulfResult::not_reported;
}
static network::CellularBudOutcome bud_outcome(server::CellularBudResult result) {
switch (result) {
case server::CellularBudResult::budded:
return network::CellularBudOutcome::budded;
case server::CellularBudResult::life_died:
case server::CellularBudResult::not_able:
return network::CellularBudOutcome::not_able;
case server::CellularBudResult::insufficient_funding:
return network::CellularBudOutcome::insufficient_funding;
case server::CellularBudResult::no_placement:
return network::CellularBudOutcome::no_placement;
}
return network::CellularBudOutcome::not_reported;
}
// 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) {
@@ -311,6 +368,7 @@ class CellularBridge {
friend bool operator==(const SentOffer&, const SentOffer&) = default;
};
std::vector<SentOffer> offers_; // Last offer view sent to each owner.
std::vector<std::pair<server::LifeAccount, std::uint64_t>> owned_; // At last replication.
bool shutdown_{};
};
} // namespace evo::server_app