feat(biology): genome schema 7 traits, founder 6 and development 7
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m27s
Foundation / postgres-tools (push) Successful in 33s
Foundation / server-image (push) Successful in 4m14s
Foundation / image (push) Successful in 4m41s

Phase 1 of the cellular revamp build plan (ADR-0179). Genome schema 7 carries
twenty 16-bit cellular traits after the movement arrangement: density, upkeep
efficiency, growth speed, collection per channel (E/C/N/P/O), burn efficiency
per matter channel, engulf capacity, kill absorption, litter, the body recipe
(C/N/P/O per thousand, summing to 1000) and adhesion. Its membrane is held in
nanometres so it can change in 5% steps of the founder's 1 um. The largest
record still fits the 256-byte bound.

Development 7 and founder 6 serve rules 13: density sets how large a body is
for its mass, the recipe sets the body's composition (intake keeps the founder
shares), upkeep is an essential share no trait reduces plus the rest over upkeep
efficiency (region-declared BodyTuning, trial 25%), the producer speed penalty
is dropped, and the reproduction value is the bud's share of the body with the
construction discount fixed at the founder's level. Founder 6 builds exactly
founder 5's cell. Earlier schemas and development versions are unchanged.

The development and metabolism test mains now print the failing line. Refreshes
the DEV session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-22 18:09:06 -04:00
co-authored by Claude Opus 5.5
parent 0a5cf3e6bd
commit c183021fd5
13 changed files with 389 additions and 42 deletions
+41 -11
View File
@@ -72,14 +72,18 @@ std::expected<DevelopmentRules, DevelopmentError> rules_for(std::uint32_t develo
// Version 5 (ADR-0175) keeps them too; it adds photosynthetic organelles below.
// Version 6 (rules 12) keeps version 5's body; handling comes from the genome's movement
// arrangement (derive_cellular_handling).
if (development_version >= 3 && development_version <= 6) {
// Version 7 (rules 13, ADR-0179) keeps the constants; the genome's cellular traits set
// density, recipe and upkeep efficiency, and the membrane is in nanometres.
if (development_version >= 3 && development_version <= 7) {
return DevelopmentRules{1000, 1200, 10, 15, 13, 60'000, 293'150, 50};
}
return std::unexpected{DevelopmentError::unsupported_rules};
}
std::expected<Phenotype, DevelopmentError>
derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState environment) {
std::expected<Phenotype, DevelopmentError> derive_phenotype(const Genome& genome,
GrowthState growth,
EnvironmentState environment,
const BodyTuning& tuning) {
if (growth.realized_per_thousand > thousand || growth.damage_per_thousand > thousand) {
return std::unexpected{DevelopmentError::invalid_growth};
}
@@ -87,13 +91,23 @@ derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState envi
if (!rules) {
return std::unexpected{rules.error()};
}
// Version 7 reads the schema-7 traits; a version-7 genome without them is unsupported.
const bool v7 = genome.development_version() >= 7;
const auto& traits = genome.cellular_traits();
if (v7 != traits.has_value() || tuning.essential_upkeep_per_thousand > thousand) {
return std::unexpected{DevelopmentError::unsupported_rules};
}
Phenotype phenotype;
// target_size, membrane and energy_conversion are required by schema 1.
const auto target = *genome.parameter(Capability::target_size);
const auto built = scaled(target, growth.realized_per_thousand);
phenotype.structural_mass = scaled(built, thousand - growth.damage_per_thousand);
phenotype.extent = static_cast<std::uint32_t>(
integer_cube_root(phenotype.structural_mass / rules->structure_density));
// Version 7: density scales how tightly that mass packs, so a denser body is smaller.
const auto density =
v7 ? std::max<std::uint64_t>(1, rules->structure_density * traits->density / 100)
: rules->structure_density;
phenotype.extent =
static_cast<std::uint32_t>(integer_cube_root(phenotype.structural_mass / density));
std::uint64_t face{};
if (!multiply(face, phenotype.extent, phenotype.extent) ||
!multiply(phenotype.surface, face, 6)) {
@@ -104,6 +118,10 @@ derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState envi
!multiply(phenotype.membrane_mass, shell, rules->membrane_density)) {
return std::unexpected{DevelopmentError::overflow};
}
// Version 7 holds the membrane in nanometres: the same mass at 1,000 nm as at 1 um.
if (v7) {
phenotype.membrane_mass /= thousand;
}
const auto photosynthesis =
genome.development_version() >= 5 && genome.carries(Capability::photosynthesis)
? *genome.parameter(Capability::photosynthesis)
@@ -122,6 +140,15 @@ derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState envi
scaled(phenotype.membrane_mass, rules->membrane_upkeep_per_kilo))) {
return std::unexpected{DevelopmentError::overflow};
}
// Version 7: an essential share no trait reduces, plus the rest over upkeep efficiency.
if (v7) {
const auto essential = scaled(phenotype.maintenance, tuning.essential_upkeep_per_thousand);
std::uint64_t adjustable{};
if (!multiply(adjustable, phenotype.maintenance - essential, 100)) {
return std::unexpected{DevelopmentError::overflow};
}
phenotype.maintenance = essential + adjustable / traits->upkeep_efficiency;
}
phenotype.conversion_per_thousand =
static_cast<std::uint32_t>(*genome.parameter(Capability::energy_conversion));
// A capability the genome does not carry yields nothing, whatever the size.
@@ -137,8 +164,9 @@ derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState envi
if (!speed || *speed > std::numeric_limits<std::uint32_t>::max()) {
return std::unexpected{DevelopmentError::overflow};
}
// Organelles slow the cell: p/2 per thousand off its speed (version 5).
const auto kept = thousand - photosynthesis / photosynthesis_speed_halving;
// Organelles slow the cell: p/2 per thousand off its speed (versions 5 and 6). Version 7
// drops this: organelle mass slows the cell through its handling instead.
const auto kept = v7 ? thousand : thousand - photosynthesis / photosynthesis_speed_halving;
phenotype.movement_speed = static_cast<std::uint32_t>(scaled(*speed, kept));
}
if (genome.carries(Capability::ingestion)) {
@@ -159,9 +187,11 @@ derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState envi
return phenotype;
}
std::expected<DevelopmentPlan, DevelopmentError>
plan_development(const Genome& genome, GrowthState growth, EnvironmentState environment) {
const auto current = derive_phenotype(genome, growth, environment);
std::expected<DevelopmentPlan, DevelopmentError> plan_development(const Genome& genome,
GrowthState growth,
EnvironmentState environment,
const BodyTuning& tuning) {
const auto current = derive_phenotype(genome, growth, environment, tuning);
if (!current) {
return std::unexpected{current.error()};
}
@@ -179,7 +209,7 @@ plan_development(const Genome& genome, GrowthState growth, EnvironmentState envi
for (std::uint32_t attempt = step; attempt > 0; --attempt) {
auto proposed = growth;
proposed.realized_per_thousand += attempt;
const auto grown = derive_phenotype(genome, proposed, environment);
const auto grown = derive_phenotype(genome, proposed, environment, tuning);
if (!grown) {
return std::unexpected{grown.error()};
}