From 51cf23dbc96093dd5812fc34751c21001c06251e Mon Sep 17 00:00:00 2001 From: dingo Date: Fri, 9 Oct 2026 15:36:02 -0400 Subject: [PATCH] M11.1: development version 2 and the primitive founder (first bud in 5-15 min) Development version 2 is defined per second; phenotype/budget rates carry their period (rate_microseconds: 50 ms for v1, 1 s for v2) and the M2 fixture adapters accept only v1. Tunable v2 constants (maintenance 10, membrane upkeep 15, movement 50 pJ/s per 1000 fg) and the primitive founder (schema 2: 1 um membrane, 8e6 fg, 200 um/s, 574,000 fg/s ingestion, 500 per-thousand bud) give a first bud in 300/600/901 s when feeding 100/50/33 % of the time at full-speed movement (bud_funding_seconds; never at 10 %), the maintainer's 5-15 minute target. Tests pin the range; v1 is unchanged. 11.1 complete. Refresh the dev session window. Co-Authored-By: Claude Opus 5.5 --- CMakeLists.txt | 2 +- .../region/dev-session-route/listener.yaml | 2 +- docs/STATUS.md | 8 ++- docs/adr/0099-time-based-biological-rates.md | 25 +++++++++ docs/engineering/VALIDATION.md | 21 ++++++++ include/evo/biology/development.hpp | 16 ++++-- include/evo/biology/founder.hpp | 31 +++++++++++ include/evo/biology/metabolism.hpp | 20 ++++++-- src/biology/development.cpp | 24 ++++++--- src/biology/founder.cpp | 19 +++++++ src/biology/metabolism.cpp | 51 +++++++++++++++++-- src/processes/genome_strategy.cpp | 8 +++ tests/development_tests.cpp | 6 +-- tests/metabolism_tests.cpp | 44 +++++++++++++++- 14 files changed, 249 insertions(+), 28 deletions(-) create mode 100644 include/evo/biology/founder.hpp create mode 100644 src/biology/founder.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 52e6373..6f106c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ target_include_directories(evo_accounting PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/in target_compile_features(evo_accounting PUBLIC cxx_std_23) evo_owned_target(evo_accounting) -add_library(evo_biology STATIC src/biology/genome.cpp src/biology/development.cpp src/biology/metabolism.cpp src/biology/mutation.cpp src/biology/lineage.cpp) +add_library(evo_biology STATIC src/biology/genome.cpp src/biology/development.cpp src/biology/metabolism.cpp src/biology/mutation.cpp src/biology/lineage.cpp src/biology/founder.cpp) add_library(evo::biology ALIAS evo_biology) target_include_directories(evo_biology PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(evo_biology PUBLIC evo::accounting) diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index 1d8c018..ef0074c 100644 --- a/deploy/kubernetes/region/dev-session-route/listener.yaml +++ b/deploy/kubernetes/region/dev-session-route/listener.yaml @@ -12,7 +12,7 @@ spec: env: - {name: REGION_SESSION, value: "dev"} - {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"} - - {name: REGION_SESSION_WINDOW, value: "dev-20261009T184926-c2b9:1791585566"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261009T192945-09ad:1791587985"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} ports: # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. diff --git a/docs/STATUS.md b/docs/STATUS.md index 598bd89..d1f1465 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -29,8 +29,12 @@ the maintainer chose directional rounding): dev world's rules 2 opening is unchanged. Development version 1 outputs stay tied to their declared 50 ms quantum. The tick-abstract M2 fixtures are not migrated. ADR-0089's rate migration is complete. -- **Next in 11.1:** development version 2, a first bud fundable within a session - (ADR-0098 decision 7). +- **Development version 2 and the primitive founder (done; tunable):** rates are per + second. A full-grown founder that pays full-speed movement throughout funds its first + bud in 5, 10 and 15 minutes when feeding 100%, 50% and 33% of the time (ADR-0099). + 11.1 is complete. +- **Next:** 11.2, primitive lives and persistent control. Server side only; client UI + parts of 11.x are deferred to the maintainer. Open from M10 (BACKLOG): - the maintainer's native-client observation, moved to the later 2k drill; diff --git a/docs/adr/0099-time-based-biological-rates.md b/docs/adr/0099-time-based-biological-rates.md index f7183d7..3310037 100644 --- a/docs/adr/0099-time-based-biological-rates.md +++ b/docs/adr/0099-time-based-biological-rates.md @@ -123,6 +123,31 @@ contract and a versioned migration that preserves 50 ms behaviour. - **Result:** every rate that a live world can run on is now either per second (genome schema 2, rules 3) or tied to a declared quantum it converts from. +## Development version 2 and the first bud (2026-10-09) +The maintainer chose to set the birth-cost target now and tune it in playtests +(ADR-0098 decision 7). +- **Development version 2** is defined per second. Phenotype and budget rates carry + their period (`rate_microseconds`: 50 ms for version 1, 1 s for version 2), and the + M2 fixture adapters accept only version 1. +- **Its constants are tunable values, not locked rules:** + - maintenance 10 and membrane upkeep 15 pJ/s per 1000 fg, a quarter of version 1's + per-second equivalent; + - movement 50 pJ/s per 1000 fg at 1 mm/s; + - construction 40 pJ per 1000 fg and intake energy 50 pJ per fg, unchanged; + - the same compositions and geometry as version 1. +- **The primitive founder** (`biology/founder.hpp`; schema 2, development 2; tunable): + energy conversion 400‰, 1 um membrane, 8e6 fg target, movement 200 um/s, ingestion + 574,000 fg/s at the reference surface, and a bud of 500‰ of the body. +- **The result** (`bud_funding_seconds`, an analysis): a full-grown founder pays its + whole demand, including full-speed movement, all of the time. Feeding at its intake + limit for 100%, 50% and 33% of the time funds its first bud in 300, 600 and 901 s + (5, 10 and 15 minutes). At 10% of the time it never does. + - Phosphorus binds first: the bud keeps the body's composition, and the membrane is + P-rich, while intake comes in the structure's composition. + - The test pins the decision's range, not exact values. +- **Assumed:** the founder starts fully grown. How a new life's body is funded is + 11.2's contract, and may change the first-bud time. + ## Consequences - Segment 1: `accounting/rates.hpp` (`per_tick`, `exact_per_tick`, `per_second_from_per_tick`) and the `rate-contracts` test. diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 5064767..1d08638 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -5423,3 +5423,24 @@ Executed: - clang-tidy 19 on the changed sources and tests: clean. - The 18 Postgres suites: passed. - Windows `debug`: 61/61. + +## 2026-10-09 — M11.1 development version 2 and the primitive founder (ADR-0099) + +Development version 2 is defined per second. Phenotype and budget rates carry +`rate_microseconds`, and the M2 fixture adapters refuse anything but version 1. +`bud_funding_seconds` and `primitive_founder` were added. +`development_v2_and_the_first_bud` checks: +- the hand-calculated per-second phenotype and budget; +- first bud at 300, 600 and 901 s for feeding 100%, 50% and 33% of the time, against + the bounds of the decision's 5–15 minute range; +- never at 10%; +- version 1 rates stay per 50 ms; +- the fixtures refuse version 2. + +Development and metabolism tests that used version 2 as unknown now use 3. + +Executed: +- WSL `linux-debug` and `linux-asan`: 61/61 each. +- clang-tidy 19: clean, after a zero-surplus guard and value reads in the test. +- The 18 Postgres suites: passed. +- Windows `debug`: 61/61. diff --git a/include/evo/biology/development.hpp b/include/evo/biology/development.hpp index 1f84371..c000683 100644 --- a/include/evo/biology/development.hpp +++ b/include/evo/biology/development.hpp @@ -22,13 +22,16 @@ struct EnvironmentState { // Development version 1 is defined in ticks of this quantum: its per-tick constants and // outputs, and the genome rates it reads (converted from per second, ADR-0099). inline constexpr std::uint64_t development_v1_tick_microseconds = 50'000; +// Development version 2 (ADR-0099, M11.1) is defined per second: its rate constants and +// its rate outputs (maintenance, movement, ingestion) are per second. +inline constexpr std::uint64_t development_v2_rate_microseconds = 1'000'000; // Chosen constants, reviewable as a unit and selected by the genome's // development version. Declared model parameters, not balance. struct DevelopmentRules { std::uint64_t structure_density; // femtograms per cubic micrometre std::uint64_t membrane_density; // femtograms per cubic micrometre - std::uint64_t maintenance_per_kilogram; // picojoules per tick per 1000 fg - std::uint64_t membrane_upkeep_per_kilo; // picojoules per tick per 1000 fg + std::uint64_t maintenance_per_kilogram; // picojoules per rate period per 1000 fg + std::uint64_t membrane_upkeep_per_kilo; // picojoules per rate period per 1000 fg std::uint64_t construction_per_kilogram; // picojoules per 1000 fg built std::uint64_t reference_surface; // square micrometres std::uint32_t reference_temperature; // millikelvin @@ -42,12 +45,15 @@ struct Phenotype { std::uint64_t total_mass{}; // femtograms std::uint32_t extent{}; // micrometres, the cube-model side length std::uint64_t surface{}; // square micrometres - std::uint64_t maintenance{}; // picojoules per tick - std::uint32_t movement_speed{}; // micrometres per tick; zero without the capability - std::uint64_t ingestion_rate{}; // femtograms per tick; zero without the capability + std::uint64_t maintenance{}; // picojoules per rate period + std::uint32_t movement_speed{}; // micrometres per rate period; zero without the capability + std::uint64_t ingestion_rate{}; // femtograms per rate period; zero without the capability std::uint32_t conversion_per_thousand{}; // Millikelvin beyond the genome's tolerance. A reported quantity, not a rule. std::uint32_t thermal_shortfall{}; + // The period the rates above are per: the development version's (50 ms for version + // 1, one second for version 2). A process converts with accounting::per_tick. + std::uint64_t rate_microseconds{}; auto operator<=>(const Phenotype&) const = default; }; // A proposal. It reserves nothing, pays for nothing and commits nothing; the diff --git a/include/evo/biology/founder.hpp b/include/evo/biology/founder.hpp new file mode 100644 index 0000000..a9512c6 --- /dev/null +++ b/include/evo/biology/founder.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "evo/biology/genome.hpp" + +#include +#include + +// The primitive founder (ADR-0098): every new life starts from this same genome, so no +// account carries a biological advantage into a new life. Genome schema 2 and development +// version 2 (rates per second, ADR-0099). Its parameters are tunable playtest values, not +// locked rules: with development version 2 a full-grown founder funds its first bud in +// about 5 minutes feeding all of the time, 10 minutes feeding half of it and 15 minutes +// feeding a third of it, while moving at full speed throughout (ADR-0098 decision 7). +namespace evo::biology { +// Per-second rates and sizes of the founder, reviewable as a unit. +struct FounderParameters { + std::uint32_t energy_conversion; // per thousand + std::uint32_t membrane; // micrometres + std::uint32_t target_size; // femtograms + std::uint32_t movement; // micrometres per second + std::uint32_t ingestion; // femtograms per second at the reference surface + std::uint32_t reproduction; // per thousand of the body invested in a bud +}; +inline constexpr FounderParameters primitive_founder_parameters{400, 1, 8'000'000, + 200, 574'000, 500}; +inline constexpr std::uint32_t primitive_founder_development_version = 2; +// The founder genome under a world-scoped identity and its origin event. Fails only on +// an invalid identity (zero). +[[nodiscard]] std::expected primitive_founder(std::uint64_t id, + std::uint64_t origin_event); +} // namespace evo::biology diff --git a/include/evo/biology/metabolism.hpp b/include/evo/biology/metabolism.hpp index fb8571e..a90c935 100644 --- a/include/evo/biology/metabolism.hpp +++ b/include/evo/biology/metabolism.hpp @@ -3,6 +3,8 @@ #include "evo/accounting/ledger.hpp" #include "evo/biology/development.hpp" +#include + namespace evo::biology { // 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. @@ -12,7 +14,7 @@ using Composition = std::array; struct MetabolicRules { Composition structure; Composition membrane; - // Picojoules per tick per 1000 femtograms at 1000 micrometres per tick. + // Picojoules per rate period per 1000 femtograms at 1000 micrometres per rate period. std::uint64_t movement_per_kilogram; // Picojoules of intake capacity per 1000 femtograms of it. std::uint64_t intake_energy_per_kilogram; @@ -33,12 +35,13 @@ struct ConstructionTransition { // multiplier applied to a total. struct MetabolicBudget { Phenotype phenotype; - accounting::Inventory body; // matter only; a body is not energy - accounting::Picojoules maintenance; // per tick - accounting::Picojoules movement; // per tick at full speed, a capacity + accounting::Inventory body; // matter only; a body is not energy + // Rates are per phenotype.rate_microseconds (the development version's period). + accounting::Picojoules maintenance; // per rate period + accounting::Picojoules movement; // per rate period at full speed, a capacity accounting::Picojoules demand; // maintenance plus movement ConstructionTransition construction; // what the next growth step would move - accounting::Inventory intake_limit; // per tick + accounting::Inventory intake_limit; // per rate period // Zero without the reproduction capability, rather than a default. accounting::Inventory reproduction_investment; std::uint16_t assimilation_per_thousand{}; @@ -50,4 +53,11 @@ metabolic_rules_for(std::uint32_t development_version); // quantities. The genome record itself stays free of accounting types. [[nodiscard]] std::expected metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState environment); +// 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 +// whole demand (maintenance and full-speed movement) all of the time. Nothing when it +// never would: no investment, a channel it never takes in, or no energy surplus. +[[nodiscard]] std::optional +bud_funding_seconds(const MetabolicBudget& budget, std::uint32_t feeding_per_thousand) noexcept; } // namespace evo::biology diff --git a/src/biology/development.cpp b/src/biology/development.cpp index 92ebdc3..471c001 100644 --- a/src/biology/development.cpp +++ b/src/biology/development.cpp @@ -55,10 +55,16 @@ std::uint64_t matter_total(const accounting::Inventory& inventory) noexcept { } // namespace std::expected rules_for(std::uint32_t development_version) { - if (development_version != 1) { - return std::unexpected{DevelopmentError::unsupported_rules}; + if (development_version == 1) { + return DevelopmentRules{1000, 1200, 2, 3, 40, 60'000, 293'150, 50}; } - return DevelopmentRules{1000, 1200, 2, 3, 40, 60'000, 293'150, 50}; + // Version 2 (ADR-0099; tunable, ADR-0098 decision 7): rates per second. Maintenance + // and membrane upkeep are a quarter of version 1's per-second equivalent (40, 60), so + // a primitive cell can fund its first bud within a session of feeding. + if (development_version == 2) { + return DevelopmentRules{1000, 1200, 10, 15, 40, 60'000, 293'150, 50}; + } + return std::unexpected{DevelopmentError::unsupported_rules}; } std::expected @@ -98,10 +104,14 @@ derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState envi phenotype.conversion_per_thousand = static_cast(*genome.parameter(Capability::energy_conversion)); // A capability the genome does not carry yields nothing, whatever the size. - // Development version 1 is defined in 50 ms ticks: genome rates (per second) enter it - // at that quantum, rounded down as capacities (ADR-0099; exact for schema 1 records). - const auto rate_per_tick = [](std::uint64_t per_second) { - return accounting::per_tick(per_second, development_v1_tick_microseconds, + // Version 1 is defined in 50 ms ticks: genome rates (per second) enter it at that + // quantum, rounded down as capacities (ADR-0099; exact for schema 1 records). + // Version 2 is defined per second and reads them as they are. + const bool v1 = genome.development_version() == 1; + phenotype.rate_microseconds = + v1 ? development_v1_tick_microseconds : development_v2_rate_microseconds; + const auto rate_per_tick = [&](std::uint64_t per_second) { + return accounting::per_tick(per_second, phenotype.rate_microseconds, accounting::Rounding::down); }; if (genome.carries(Capability::movement)) { diff --git a/src/biology/founder.cpp b/src/biology/founder.cpp new file mode 100644 index 0000000..72d3fe3 --- /dev/null +++ b/src/biology/founder.cpp @@ -0,0 +1,19 @@ +#include "evo/biology/founder.hpp" + +namespace evo::biology { +std::expected primitive_founder(std::uint64_t id, std::uint64_t origin_event) { + const auto& p = primitive_founder_parameters; + GenomeDraft draft; + draft.schema_version = genome_schema_version; + draft.id = id; + draft.origin_event = origin_event; + draft.development_version = primitive_founder_development_version; + draft.capabilities = {{Capability::energy_conversion, p.energy_conversion, 0}, + {Capability::membrane, p.membrane, 0}, + {Capability::movement, p.movement, 0}, + {Capability::ingestion, p.ingestion, 0}, + {Capability::reproduction, p.reproduction, 0}, + {Capability::target_size, p.target_size, 0}}; + return Genome::create(draft); +} +} // namespace evo::biology diff --git a/src/biology/metabolism.cpp b/src/biology/metabolism.cpp index f48d7e3..7e3141c 100644 --- a/src/biology/metabolism.cpp +++ b/src/biology/metabolism.cpp @@ -1,5 +1,7 @@ #include "evo/biology/metabolism.hpp" +#include "evo/accounting/rates.hpp" + #include namespace evo::biology { @@ -102,10 +104,14 @@ accounting::Inventory fraction_of(const accounting::Inventory& source, std::expected metabolic_rules_for(std::uint32_t development_version) { - if (development_version != 1) { - return std::unexpected{DevelopmentError::unsupported_rules}; + if (development_version == 1) { + return MetabolicRules{structure_shares, membrane_shares, 20, 50'000}; } - return MetabolicRules{structure_shares, membrane_shares, 20, 50'000}; + // Version 2: per second; movement at 1000 um/s costs 50 pJ/s per 1000 fg (tunable). + if (development_version == 2) { + return MetabolicRules{structure_shares, membrane_shares, 50, 50'000}; + } + return std::unexpected{DevelopmentError::unsupported_rules}; } std::expected @@ -203,4 +209,43 @@ metabolic_budget(const Genome& genome, GrowthState growth, EnvironmentState envi } return budget; } + +std::optional bud_funding_seconds(const MetabolicBudget& budget, + std::uint32_t feeding_per_thousand) noexcept { + const auto period = budget.phenotype.rate_microseconds; + if (period == 0 || accounting::microseconds_per_second % period != 0 || + feeding_per_thousand == 0 || feeding_per_thousand > thousand || + matter_total(budget.reproduction_investment) == 0) + return std::nullopt; + const auto periods_per_second = accounting::microseconds_per_second / period; + // Per-second amounts; ceil(need / rate) seconds for each. + const auto seconds = [&](std::uint64_t need, + std::uint64_t per_period) -> std::optional { + if (need == 0) + return std::uint64_t{0}; + std::uint64_t per_second{}; + if (!multiply(per_second, scaled(per_period, feeding_per_thousand), periods_per_second) || + per_second == 0) + return std::nullopt; + return need / per_second + (need % per_second != 0 ? 1 : 0); + }; + std::uint64_t longest = 0; + for (std::size_t c = 0; c < budget.reproduction_investment.matter.size(); ++c) { + const auto t = seconds(budget.reproduction_investment.matter[c].value, + budget.intake_limit.matter[c].value); + if (!t) + return std::nullopt; + longest = std::max(longest, *t); + } + // Energy: the fed share of intake, less the whole demand, all per period. + const auto fed = scaled(budget.intake_limit.energy.value, feeding_per_thousand); + if (fed <= budget.demand.value) + return std::nullopt; + std::uint64_t surplus{}; + if (!multiply(surplus, fed - budget.demand.value, periods_per_second) || surplus == 0) + return std::nullopt; + const auto need = budget.reproduction_investment.energy.value; + longest = std::max(longest, need / surplus + (need % surplus != 0 ? 1 : 0)); + return longest; +} } // namespace evo::biology diff --git a/src/processes/genome_strategy.cpp b/src/processes/genome_strategy.cpp index 571a4a1..03b7266 100644 --- a/src/processes/genome_strategy.cpp +++ b/src/processes/genome_strategy.cpp @@ -8,6 +8,11 @@ consumer_for(const biology::Genome& genome, biology::GrowthState growth, if (!budget) { return std::unexpected{budget.error()}; } + // The M2 fixtures step in tick-abstract units that match development version 1's + // 50 ms rates; a per-second version would be read twenty times too fast (ADR-0099). + if (budget->phenotype.rate_microseconds != biology::development_v1_tick_microseconds) { + return std::unexpected{biology::DevelopmentError::unsupported_rules}; + } return ConsumerConfig{opening, budget->intake_limit, budget->assimilation_per_thousand}; } @@ -19,6 +24,9 @@ strategy_for(const biology::Genome& genome, biology::GrowthState growth, if (!budget) { return std::unexpected{budget.error()}; } + if (budget->phenotype.rate_microseconds != biology::development_v1_tick_microseconds) { + return std::unexpected{biology::DevelopmentError::unsupported_rules}; + } return StrategyConfig{opening, budget->intake_limit, budget->assimilation_per_thousand, diff --git a/tests/development_tests.cpp b/tests/development_tests.cpp index f36b46e..af2af0e 100644 --- a/tests/development_tests.cpp +++ b/tests/development_tests.cpp @@ -166,13 +166,13 @@ void thermal_shortfall_is_reported_not_enforced() { } void rule_versions_and_invalid_growth() { - CHECK(rules_for(1)); - for (const auto version : {0U, 2U, 99U}) { + CHECK(rules_for(1) && rules_for(2)); // Version 2: per second (ADR-0099). + for (const auto version : {0U, 3U, 99U}) { const auto missing = rules_for(version); CHECK(!missing && missing.error() == DevelopmentError::unsupported_rules); } auto source = draft(); - source.development_version = 2; + source.development_version = 3; const auto future = build(source); const auto derived = derive_phenotype(future, {1000, 0}, temperate); CHECK(!derived && derived.error() == DevelopmentError::unsupported_rules); diff --git a/tests/metabolism_tests.cpp b/tests/metabolism_tests.cpp index bb0c025..968bf63 100644 --- a/tests/metabolism_tests.cpp +++ b/tests/metabolism_tests.cpp @@ -1,3 +1,4 @@ +#include "evo/biology/founder.hpp" #include "evo/processes/genome_strategy.hpp" #include @@ -379,7 +380,7 @@ void absent_capabilities_cost_nothing() { void rules_fail_closed() { CHECK(metabolic_rules_for(1)); - for (const auto version : {0U, 2U, 99U}) { + for (const auto version : {0U, 3U, 99U}) { const auto missing = metabolic_rules_for(version); CHECK(!missing && missing.error() == DevelopmentError::unsupported_rules); } @@ -467,6 +468,46 @@ void a_genome_drives_a_feeding_tick() { CHECK(!denied && denied.error() == FeedingError::intake_limit); } } // namespace +// Development version 2 (ADR-0099) and the primitive founder (ADR-0098 decision 7): rates +// per second, and a first bud fundable in about 5, 10 and 15 minutes feeding all, half +// and a third of the time while moving at full speed throughout. Tunable targets, so +// the bounds are the decision's range, not exact values. +void development_v2_and_the_first_bud() { + const auto founder = primitive_founder(1, 1); + CHECK(founder && founder->schema_version() == 2 && founder->development_version() == 2); + CHECK(!primitive_founder(0, 1)); + const auto budget = metabolic_budget(*founder, {1000, 0}, temperate); + CHECK(budget); + const auto& p = budget->phenotype; + CHECK(p.rate_microseconds == 1'000'000 && p.extent == 20 && p.surface == 2400); + CHECK(p.membrane_mass == 2'880'000 && p.total_mass == 10'880'000); + CHECK(p.maintenance == 108'800 + 43'200); // 10 and 15 pJ/s per 1000 fg. + CHECK(p.movement_speed == 200 && p.ingestion_rate == 22'960); // 574000 * 2400 / 60000. + CHECK(budget->movement.value == 108'800); // 10880 * 50 * 200 / 1000. + const auto at = [&](std::uint32_t share) { return bud_funding_seconds(*budget, share); }; + const auto funded_all = at(1000), funded_half = at(500), funded_third = at(333); + CHECK(funded_all && funded_half && funded_third); + const auto all = funded_all.value_or(0), half = funded_half.value_or(0), + third = funded_third.value_or(0); + std::cout << "first bud seconds: all=" << all << " half=" << half << " third=" << third << "\n"; + CHECK(all >= 270 && all <= 330); + CHECK(half >= 540 && half <= 660); + CHECK(third >= 810 && third <= 990); + CHECK(all < half && half < third); + CHECK(!at(100)); // Feeding a tenth of the time while always moving never funds a bud. + CHECK(!at(0) && !at(1001)); + // Version 1 rates stay per 50 ms tick, and the M2 fixtures accept only version 1. + const auto v1 = metabolic_budget(build(capable()), {1000, 0}, temperate); + CHECK(v1 && v1->phenotype.rate_microseconds == 50'000); + CHECK(!evo::processes::consumer_for(*founder, {1000, 0}, temperate, {})); + CHECK(evo::processes::consumer_for(build(capable()), {1000, 0}, temperate, {})); + // Without the reproduction capability there is nothing to fund. + auto plain = draft(); + plain.schema_version = 2; + plain.development_version = 2; + CHECK(!bud_funding_seconds(*metabolic_budget(build(plain), {1000, 0}, temperate), 1000)); +} + int main() try { hand_calculated_budget(); construction_composes_each_compartment(); @@ -482,6 +523,7 @@ int main() try { rules_fail_closed(); splits_conserve_at_awkward_masses(); a_genome_drives_a_feeding_tick(); + development_v2_and_the_first_bud(); std::cout << "PASS metabolic budgets, composition splits and genome-driven feeding\n"; return 0; } catch (...) {