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
+15 -4
View File
@@ -32,10 +32,18 @@ inline constexpr std::uint64_t development_v2_rate_microseconds = 1'000'000;
[[nodiscard]] constexpr std::uint64_t
development_rate_microseconds(std::uint32_t development_version) noexcept {
return development_version == 1 ? development_v1_tick_microseconds
: development_version >= 2 && development_version <= 6
? development_v2_rate_microseconds // Versions 3-6 keep version 2's rates.
: development_version >= 2 && development_version <= 7
? development_v2_rate_microseconds // Versions 3-7 keep version 2's rates.
: 0;
}
// Development version 7 (ADR-0179): region-declared body tuning. Upkeep is an essential
// share of the mass-based upkeep that no trait reduces, plus the rest divided by the
// genome's upkeep efficiency. Earlier versions ignore it.
struct BodyTuning {
std::uint32_t essential_upkeep_per_thousand{250}; // Trial (ADR-0179).
auto operator<=>(const BodyTuning&) const = default;
};
inline constexpr BodyTuning default_body_tuning{};
// Chosen constants, reviewable as a unit and selected by the genome's
// development version. Declared model parameters, not balance.
struct DevelopmentRules {
@@ -68,6 +76,7 @@ struct Phenotype {
// built inside the cell. At efficiency p per thousand they add p/4 of the structural mass
// as membrane mass (so they are upkept twice, like membrane) and slow movement by p/2 per
// thousand. Light itself is captured by the region's environment owner, never here.
// Version 7 keeps the organelle mass but drops the speed penalty: mass slows the cell.
inline constexpr std::uint32_t photosynthesis_organelle_quarter = 4;
inline constexpr std::uint32_t photosynthesis_speed_halving = 2;
// A proposal. It reserves nothing, pays for nothing and commits nothing; the
@@ -85,12 +94,14 @@ rules_for(std::uint32_t development_version);
// Pure: a phenotype is recomputed from retained inputs rather than cached, so a
// cached copy can always be checked against a recomputation.
[[nodiscard]] std::expected<Phenotype, DevelopmentError>
derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState environment);
derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState environment,
const BodyTuning& tuning = default_body_tuning);
// Advances realized growth toward the target by at most the rule step, reduced to
// the largest step the available mass and energy admit. This bounds by total mass
// only: it cannot see which elements a step consumes, so it is a proposal and not
// an affordability authority. `metabolic_budget` decides that, per channel, and
// can only narrow this further. Never repairs damage.
[[nodiscard]] std::expected<DevelopmentPlan, DevelopmentError>
plan_development(const Genome& genome, GrowthState growth, EnvironmentState environment);
plan_development(const Genome& genome, GrowthState growth, EnvironmentState environment,
const BodyTuning& tuning = default_body_tuning);
} // namespace evo::biology
+4
View File
@@ -40,6 +40,10 @@ inline constexpr FounderVersion primitive_founder_v4{genome_schema_v5, 5};
// Founder 5 serves rules 12 (Cellular_Region_Movement_Plan.md): founder 4 with the founder
// movement arrangement (every index at the 100-point reference).
inline constexpr FounderVersion primitive_founder_v5{genome_schema_v6, 6};
// Founder 6 serves rules 13 (ADR-0179): founder 5 on genome schema 7 and development 7, with
// the membrane in nanometres (1,000 nm, the same 1 um) and the founder's cellular traits.
inline constexpr FounderVersion primitive_founder_v6{genome_schema_v7, 7};
inline constexpr std::uint32_t founder_membrane_nanometres = 1'000;
inline constexpr std::uint32_t primitive_founder_development_version =
primitive_founder_v1.development_version;
// The founder genome under a world-scoped identity and its origin event. Fails only on
+48 -3
View File
@@ -32,7 +32,8 @@ enum class Unit : std::uint8_t {
femtograms_per_tick, // Schema 1: per 50 ms tick.
millikelvin,
micrometres_per_second, // Schema 2 (ADR-0099).
femtograms_per_second // Schema 2 (ADR-0099).
femtograms_per_second, // Schema 2 (ADR-0099).
nanometres // Schema 7 membrane (ADR-0179).
};
struct CapabilitySpec {
Unit unit;
@@ -88,6 +89,21 @@ inline constexpr std::array<CapabilitySpec, capability_count> capability_schema_
CapabilitySpec{Unit::femtograms, 1, 1'000'000'000, true, 0},
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0},
CapabilitySpec{Unit::per_thousand, 1, 1000, false, capability_bit(Capability::membrane)}};
// Schema 7 (ADR-0179): schema 5 with the membrane in nanometres, so it can change in 5%
// steps of the founder's 1 um (1,000 nm). Other units are unchanged; energy conversion is
// read as the share of bubble energy kept, reproduction as the bud's share of the body.
inline constexpr std::array<CapabilitySpec, capability_count> capability_schema_v7{
CapabilitySpec{Unit::per_thousand, 1, 1000, true, 0},
CapabilitySpec{Unit::nanometres, 1, 10'000'000, true, 0},
CapabilitySpec{Unit::micrometres_per_second, 0, 2'000'000, false,
capability_bit(Capability::membrane)},
CapabilitySpec{Unit::femtograms_per_second, 0, 20'000'000, false,
capability_bit(Capability::membrane)},
CapabilitySpec{Unit::per_thousand, 1, 1000, false,
capability_bit(Capability::energy_conversion)},
CapabilitySpec{Unit::femtograms, 1, 1'000'000'000, true, 0},
CapabilitySpec{Unit::millikelvin, 1, 100'000, false, 0},
CapabilitySpec{Unit::per_thousand, 1, 1000, false, capability_bit(Capability::membrane)}};
// The current schema's table.
inline constexpr const auto& capability_schema = capability_schema_v2;
// Schema 1 rates are per tick of this quantum.
@@ -113,6 +129,24 @@ inline constexpr std::uint16_t movement_reference_points = 100;
inline constexpr std::uint16_t max_movement_points = 1'000;
inline constexpr MovementArrangement founder_movement_arrangement{100, 100, 0, 100, 100,
100, 0, 100, 0};
// Schema 7 (ADR-0179): heritable cellular traits beyond the capability records. Indices are
// reference points where 100 is the founder; the recipe is per thousand of the body's
// structure in C, N, P and other matter (summing to 1000); litter is extra offspring per
// bud in hundredths (150 = one extra plus a 50% chance of a second); adhesion is 0 or 1.
struct CellularTraits {
std::uint16_t density{}, upkeep_efficiency{}, growth_speed{};
std::array<std::uint16_t, 5> collection{}; // E, C, N, P, O.
std::array<std::uint16_t, 4> burn{}; // C, N, P, O.
std::uint16_t engulf_capacity{}, kill_absorption{}, litter{};
std::array<std::uint16_t, 4> recipe{}; // C, N, P, O per thousand.
std::uint16_t adhesion{};
auto operator<=>(const CellularTraits&) const = default;
};
inline constexpr std::uint16_t max_trait_points = 1'000;
inline constexpr std::uint16_t max_litter = 9'900; // At most 100 offspring per bud.
inline constexpr CellularTraits founder_cellular_traits{
100, 100, 100, {100, 100, 100, 100, 100}, {100, 100, 100, 100},
100, 100, 0, {500, 150, 50, 300}, 0};
// Unvalidated input. Only Genome::create turns one into a record.
struct GenomeDraft {
std::uint64_t id{};
@@ -126,6 +160,8 @@ struct GenomeDraft {
std::uint32_t schema_version{1};
// Required from schema 6 and refused before it.
std::optional<MovementArrangement> movement_arrangement{};
// Required from schema 7 and refused before it.
std::optional<CellularTraits> cellular_traits{};
};
enum class GenomeError : std::uint8_t {
unsupported_version,
@@ -153,15 +189,19 @@ inline constexpr std::uint32_t genome_schema_v5 = 5;
// Schema 6 (rules 12, Cellular_Region_Movement_Plan.md): schema 5's capabilities and steps
// plus the movement arrangement.
inline constexpr std::uint32_t genome_schema_v6 = 6;
// Schema 7 (rules 13, ADR-0179): schema 6 with the membrane in nanometres and the cellular
// traits. Its mutations are the named catalog, not the generic operators.
inline constexpr std::uint32_t genome_schema_v7 = 7;
// The newest schema. Older records stay valid and are never rewritten (ADR-0099).
inline constexpr std::uint32_t genome_schema_version = genome_schema_v6;
// The capability table of a supported schema (1 to 6); nullptr otherwise.
inline constexpr std::uint32_t genome_schema_version = genome_schema_v7;
// The capability table of a supported schema (1 to 7); nullptr otherwise.
[[nodiscard]] constexpr const std::array<CapabilitySpec, capability_count>*
capability_schema_for(std::uint32_t schema) noexcept {
return schema == genome_schema_v1 ? &capability_schema_v1
: schema == genome_schema_v2 || schema == genome_schema_v3 || schema == genome_schema_v4
? &capability_schema_v2
: schema == genome_schema_v5 || schema == genome_schema_v6 ? &capability_schema_v5
: schema == genome_schema_v7 ? &capability_schema_v7
: nullptr;
}
inline constexpr std::size_t max_parents = 2;
@@ -205,6 +245,10 @@ class Genome {
[[nodiscard]] const std::optional<MovementArrangement>& movement_arrangement() const noexcept {
return movement_arrangement_;
}
// Present exactly from schema 7.
[[nodiscard]] const std::optional<CellularTraits>& cellular_traits() const noexcept {
return cellular_traits_;
}
[[nodiscard]] bool carries(Capability kind) const noexcept;
[[nodiscard]] std::expected<std::uint32_t, GenomeError>
parameter(Capability kind) const noexcept;
@@ -230,6 +274,7 @@ class Genome {
std::vector<std::uint64_t> parents_;
std::vector<CapabilityRecord> capabilities_;
std::optional<MovementArrangement> movement_arrangement_;
std::optional<CellularTraits> cellular_traits_;
std::uint64_t digest_{};
};
} // namespace evo::biology
+5 -1
View File
@@ -8,6 +8,9 @@
namespace evo::biology {
// Development version 4 (rules 7, ADR-0137): a bud is always this share of the parent's body.
inline constexpr std::uint32_t bud_body_per_thousand_v4 = 500;
// Development version 7 (ADR-0179): the reproduction value is the bud's share of the body again,
// and the construction discount stays at the founder's level (500 per thousand: a quarter off).
inline constexpr std::uint32_t primitive_bud_skill_v7 = 500;
// Shares in thousandths over the ledger's C/N/P/other channels, summing to 1000.
// The last channel absorbs the rounding remainder, so a split conserves mass.
using Composition = std::array<std::uint16_t, 4>;
@@ -59,7 +62,8 @@ metabolic_rules_for(std::uint32_t development_version);
// its versioned cadence. The default preserves earlier budget results exactly.
[[nodiscard]] std::expected<MetabolicBudget, DevelopmentError>
metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState environment,
std::uint32_t max_growth_per_thousand = 1000);
std::uint32_t max_growth_per_thousand = 1000,
const BodyTuning& tuning = default_body_tuning);
// An analysis, not a rule (ADR-0098 decision 7): whole seconds until feeding funds the
// budget's reproduction investment, channel by channel and in energy, when the organism
// takes in its full intake limit for `feeding_per_thousand` of the time and pays its