Decide affordability where composition is known
A construction transition could require more of an element than was available, because the check compared net mass. A step growing a body from 13 to 14 femtograms nets one femtogram but acquires a carbon and a nitrogen while freeing one of other, and released other pays for neither. Matching totals let one element silently fund another. Net mass was never the right question, and the layer asking it could not ask a better one: plan_development has no composition. A single scalar pool could not carry the answer either, since it cannot say that carbon is plentiful while nitrogen is not. The environment now states what is available per ledger channel. plan_development keeps a total-mass bound, which is sound because net never exceeds gross, but it is a proposal rather than an authority. metabolic_budget narrows it to the largest step whose own intake fits channel by channel, and reports the growth that step actually funds. That revises ADR-0031 on this point, recorded in both ADRs. The tests place a single femtogram in each channel in turn and require that no step needing a different element is funded, that nothing is acquired beyond what is present, and that the mass-only plan would have admitted the step; a carbon and a nitrogen together then fund it exactly. Across six target sizes by seven growth fractions by four stock levels, every reported intake fits the availability channel by channel and never exceeds the proposed step. Confirmed to fail with the check removed. The releasing case moved to a target of 20 femtograms, where the step occurs at the full rule step rather than depending on a scarce supply that the corrected plan no longer bounds the same way. Native Release, clang-tidy analysis, ASan and format checks pass 19/19. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "evo/accounting/ledger.hpp"
|
||||
#include "evo/biology/genome.hpp"
|
||||
|
||||
namespace evo::biology {
|
||||
@@ -12,8 +13,10 @@ struct GrowthState {
|
||||
};
|
||||
struct EnvironmentState {
|
||||
std::uint32_t temperature_millikelvin{};
|
||||
// Bounds what a plan can fund. Nothing here is spent or reserved.
|
||||
std::uint64_t available_material{};
|
||||
// What is there to build from, per ledger channel. A single pool could not
|
||||
// say that carbon is plentiful while nitrogen is not, which is the whole
|
||||
// question once a body has a composition. Nothing here is spent or reserved.
|
||||
accounting::Inventory available{};
|
||||
auto operator<=>(const EnvironmentState&) const = default;
|
||||
};
|
||||
// Chosen constants, reviewable as a unit and selected by the genome's
|
||||
@@ -61,7 +64,10 @@ rules_for(std::uint32_t development_version);
|
||||
[[nodiscard]] std::expected<Phenotype, DevelopmentError>
|
||||
derive_phenotype(const Genome& genome, GrowthState growth, EnvironmentState environment);
|
||||
// Advances realized growth toward the target by at most the rule step, reduced to
|
||||
// the largest step the available material funds exactly. Never repairs damage.
|
||||
// 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);
|
||||
} // namespace evo::biology
|
||||
|
||||
@@ -23,6 +23,7 @@ struct MetabolicRules {
|
||||
// the derived body on every channel. Release is a rounding artifact of the
|
||||
// declared composition, bounded by a few femtograms; it is not excretion.
|
||||
struct ConstructionTransition {
|
||||
GrowthState after; // the growth this transition actually funds
|
||||
accounting::Inventory intake; // energy and matter that must be acquired
|
||||
accounting::Inventory release; // matter freed as the composition rebalances
|
||||
auto operator<=>(const ConstructionTransition&) const = default;
|
||||
|
||||
Reference in New Issue
Block a user