fix(lifecycle): a bud's fee comes on top of its cost, or the bud is refused
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m28s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m1s

DEV region 14 stalled at tick 6068 with a conservation error. The bud fee was
checked against the reserve before funding the bud, then deducted with a clamp
after: a parent whose reserve covered the bud but not the fee as well paid less
than the fee while the region reclaimed all of it, creating matter. The fee
was zero until the budding playtest tuning, so it never showed.

Funding now requires the reserve left after the bud to cover the fee; a parent
that cannot is refused for insufficient funding, and the fee is subtracted
exactly. No committed tick changes: a short-fee bud never committed. The
regression runs seeded wildlife under the DEV fee until a bud (it failed with
the conservation error before this fix).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-26 12:46:00 -04:00
co-authored by Claude Opus 5.5
parent 467402e404
commit 8a48e405fd
3 changed files with 63 additions and 11 deletions
+15 -7
View File
@@ -3242,8 +3242,18 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
for (std::size_t c = 0; surplus && c < cost->matter.size(); ++c)
surplus = parent->reserve.matter[c].value / 2 >= cost->matter[c].value;
}
const auto transition = biology::fund_offspring(*expressed, *genome, parent->growth,
parent->reserve, temperature, copies);
auto transition = biology::fund_offspring(*expressed, *genome, parent->growth,
parent->reserve, temperature, copies);
// Rules 13: the fee comes on top of the bud, so what the reserve keeps after funding
// it must still pay the fee; otherwise the bud is refused like any unaffordable one.
if (transition && revamp_rules && !twin) {
bool covered = transition->parent_reserve.energy.value >= fee.energy.value;
for (std::size_t c = 0; c < fee.matter.size(); ++c)
covered = covered &&
transition->parent_reserve.matter[c].value >= fee.matter[c].value;
if (!covered)
transition = std::unexpected{biology::BuddingError::insufficient_funding};
}
if (revamp_rules && !twin && parent->account != LifeAccount{}) {
using S = biology::CellularSignal;
auto& a = activity_of(request.life_id);
@@ -3290,11 +3300,9 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
parent->reserve = transition->parent_reserve;
if (revamp_rules && !twin) {
// The fee, once per bud action, returns to the region; then control, if asked.
for (std::size_t c = 0; c < fee.matter.size(); ++c)
parent->reserve.matter[c].value -=
std::min(parent->reserve.matter[c].value, fee.matter[c].value);
parent->reserve.energy.value -=
std::min(parent->reserve.energy.value, fee.energy.value);
// Funding checked that the reserve still covers it.
if (!subtract_inventory(parent->reserve, fee))
return std::unexpected{CellularLivesError::conservation};
reclaims.emplace_back(fee, parent->position);
}
CellularOwnedLife bud{};