feat(lifecycle): rules 13 mutation splits, stay-or-become and litter
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m22s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m6s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m22s
Foundation / postgres-tools (push) Successful in 22s
Foundation / server-image (push) Successful in 4m21s
Foundation / image (push) Successful in 5m6s
Phase 4 of the cellular revamp build plan (ADR-0179), server half. - A chosen mutation now splits the cell (Cellular_reproduction_plan.md section 4): split_cell divides body and reserve per channel by the tuned share, each cell develops the largest body its own genome builds from its part, and the rest joins its reserve, conserving every channel. Both plans carry the mutation; only the offspring expresses it. A split is refused, spending nothing and keeping the offer, below the tuned growth, without room beside the cell or at the region's organism cap. - Stay or become: a choice (trace mutation byte 34) or a bud (step intent bit 2 of byte 13) can hand control to the offspring; the parent becomes wildlife. Ownership now follows the account under rules 13, so validation and plan history accept a founder that became wildlife (ADR-0163 succession). - Buds under rules 13: litter replaces the 25% twin (whole hundreds plus a chance, up to the tuned maximum, sharing one investment), the tuned bud fee is charged once and reclaimed, and births stop at the organism cap. - New results split_applied and split_refused; owners below rules 13 refuse a become. The revamp tuning file gains the reproduction keys. Tests cover the split's conservation and refusals, stay and become splits with exact restore, a refused second split, the cap, become validation and the litter count. Refreshes the DEV session window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+77
-1
@@ -14,7 +14,7 @@ void check(bool condition, std::source_location location = std::source_location:
|
||||
if (!condition)
|
||||
throw std::runtime_error("budding line " + std::to_string(location.line()));
|
||||
}
|
||||
#define CHECK(expression) check(static_cast<bool>(expression))
|
||||
#define CHECK(...) check(static_cast<bool>(__VA_ARGS__))
|
||||
constexpr std::uint32_t temperate = 293'150;
|
||||
|
||||
Genome founder() {
|
||||
@@ -145,8 +145,84 @@ void the_shown_bud_cost_is_exactly_what_funding_takes() {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Rules 13 (ADR-0179): a split divides body and reserve, each cell builds the largest body its
|
||||
// part covers under its own genome, and every channel is conserved.
|
||||
Genome founder6(std::uint64_t id = 9) {
|
||||
const auto genome = primitive_founder(id, id, primitive_founder_v6);
|
||||
CHECK(genome);
|
||||
return *genome;
|
||||
}
|
||||
bool split_conserves(const Inventory& body, const Inventory& reserve, const SplitTransition& s) {
|
||||
for (std::size_t c = 0; c < body.matter.size(); ++c)
|
||||
if (body.matter[c].value + reserve.matter[c].value !=
|
||||
s.parent_body.matter[c].value + s.parent_reserve.matter[c].value +
|
||||
s.child_body.matter[c].value + s.child_reserve.matter[c].value)
|
||||
return false;
|
||||
return reserve.energy.value == s.parent_reserve.energy.value + s.child_reserve.energy.value &&
|
||||
s.parent_body.energy.value == 0 && s.child_body.energy.value == 0;
|
||||
}
|
||||
void a_split_halves_and_conserves() {
|
||||
const auto parent = founder6();
|
||||
const auto grown = metabolic_budget(parent, {1000, 0}, {temperate, {}});
|
||||
CHECK(grown);
|
||||
const Inventory reserve{{2'000'001},
|
||||
{Femtograms{301}, Femtograms{7}, Femtograms{0}, Femtograms{1'000}}};
|
||||
const auto split =
|
||||
split_cell(parent, parent, {1000, 0}, grown->body, reserve, temperate, 500, 1000);
|
||||
CHECK(split && split_conserves(grown->body, reserve, *split));
|
||||
// Half the body builds a cell under half full size (membrane follows surface, not volume);
|
||||
// the two halves are equal but for rounding.
|
||||
CHECK(split->parent_growth.realized_per_thousand >= 300 &&
|
||||
split->parent_growth.realized_per_thousand < 500 &&
|
||||
split->child_growth == split->parent_growth);
|
||||
CHECK(split->child_reserve.energy.value == 1'000'000 &&
|
||||
split->parent_reserve.energy.value == 1'000'001);
|
||||
// A different child plan develops its own body from its half.
|
||||
GenomeDraft larger;
|
||||
larger.schema_version = genome_schema_v7;
|
||||
larger.id = 10;
|
||||
larger.origin_event = 10;
|
||||
larger.development_version = 7;
|
||||
larger.parents = {parent.id()};
|
||||
for (const auto& record : parent.capabilities())
|
||||
larger.capabilities.push_back(record);
|
||||
for (auto& record : larger.capabilities)
|
||||
if (record.kind == Capability::target_size)
|
||||
record.parameter = 8'400'000;
|
||||
larger.movement_arrangement = parent.movement_arrangement();
|
||||
larger.cellular_traits = parent.cellular_traits();
|
||||
const auto child = Genome::create(larger);
|
||||
CHECK(child);
|
||||
const auto mutated =
|
||||
split_cell(parent, *child, {1000, 0}, grown->body, reserve, temperate, 500, 1000);
|
||||
CHECK(mutated && split_conserves(grown->body, reserve, *mutated) &&
|
||||
mutated->child_growth.realized_per_thousand <
|
||||
mutated->parent_growth.realized_per_thousand);
|
||||
}
|
||||
void a_split_refuses_without_changing_anything() {
|
||||
const auto parent = founder6();
|
||||
const auto grown = metabolic_budget(parent, {1000, 0}, {temperate, {}});
|
||||
CHECK(grown);
|
||||
CHECK(split_cell(parent, parent, {999, 0}, grown->body, {}, temperate, 500, 1000).error() ==
|
||||
BuddingError::not_grown);
|
||||
CHECK(split_cell(parent, parent, {1000, 1}, grown->body, {}, temperate, 500, 1000).error() ==
|
||||
BuddingError::not_grown);
|
||||
CHECK(split_cell(parent, parent, {1000, 0}, grown->body, {}, temperate, 0, 1000).error() ==
|
||||
BuddingError::no_capability);
|
||||
// A sliver of the body builds no cell.
|
||||
CHECK(split_cell(parent, parent, {1000, 0}, grown->body, {}, temperate, 1, 1000).error() ==
|
||||
BuddingError::insufficient_funding);
|
||||
// A lower minimum lets a half-grown cell split.
|
||||
const auto half = metabolic_budget(parent, {600, 0}, {temperate, {}});
|
||||
CHECK(half && split_cell(parent, parent, {600, 0}, half->body, {}, temperate, 500, 500));
|
||||
CHECK(split_cell(parent, founder(), {1000, 0}, grown->body, {}, temperate, 500, 1000).error() ==
|
||||
BuddingError::incompatible_genome);
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
a_split_halves_and_conserves();
|
||||
a_split_refuses_without_changing_anything();
|
||||
a_grown_parent_funds_the_largest_bud_its_investment_builds();
|
||||
every_short_channel_refuses_and_spends_nothing();
|
||||
only_a_grown_undamaged_reproducing_parent_buds();
|
||||
|
||||
Reference in New Issue
Block a user