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>
76 lines
4.6 KiB
C++
76 lines
4.6 KiB
C++
#pragma once
|
|
|
|
#include "evo/biology/metabolism.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <optional>
|
|
|
|
// M11.5 budding (ADR-0098 decision 1, ADR-0125): a funded proposal, detached from any
|
|
// owner. The parent pays its ADR-0032 reproduction investment and a starting provision
|
|
// from its reserve; nothing is drawn from its body.
|
|
namespace evo::biology {
|
|
// Seconds of the bud's full demand (maintenance plus full-speed movement) the parent
|
|
// provides as starting reserve energy: the founder's reserve rule (ADR-0100). Trial.
|
|
inline constexpr std::uint64_t bud_provision_seconds = 30;
|
|
|
|
struct BudTransition {
|
|
GrowthState growth{}; // the bud's, the largest the investment matter builds
|
|
accounting::Inventory body{}; // the bud's developed body
|
|
accounting::Inventory reserve; // the bud's: leftover matter and the provision
|
|
accounting::Inventory parent_reserve; // the parent's reserve after paying
|
|
accounting::Picojoules heat{}; // the investment's construction energy
|
|
auto operator<=>(const BudTransition&) const = default;
|
|
};
|
|
enum class BuddingError : std::uint8_t {
|
|
no_capability, // The genome cannot reproduce.
|
|
not_grown, // The parent is not fully realized, or is damaged.
|
|
insufficient_funding, // Some channel of investment plus provision is missing.
|
|
development, // The genome's rules cannot develop it.
|
|
incompatible_genome // Distinct schema/development laws, or conflicting same-ID contents.
|
|
};
|
|
|
|
// Pure and deterministic. On every channel the parent's reserve before equals its reserve
|
|
// after plus the bud's body and reserve, plus heat in energy. A refusal spends nothing.
|
|
// `share` > 1 (ADR-0137 twins) funds one of that many buds from the same investment: each
|
|
// gets the investment divided by `share`, so twins are smaller, not extra.
|
|
[[nodiscard]] std::expected<BudTransition, BuddingError>
|
|
fund_bud(const Genome& genome, GrowthState parent_growth,
|
|
const accounting::Inventory& parent_reserve, std::uint32_t temperature_millikelvin,
|
|
std::uint32_t share = 1);
|
|
// ADR-0164: the expressed parent pays its own investment; the distinct inherited
|
|
// genome determines the newborn body/growth and its own provision. Both records
|
|
// must use the same schema/development versions. Inputs and parent anatomy are
|
|
// unchanged. This proposal confers no identity, placement, ancestry or control authority.
|
|
[[nodiscard]] std::expected<BudTransition, BuddingError>
|
|
fund_offspring(const Genome& parent, const Genome& offspring, GrowthState parent_growth,
|
|
const accounting::Inventory& parent_reserve, std::uint32_t temperature_millikelvin,
|
|
std::uint32_t share = 1);
|
|
// Exact charge for that pair and share from a full-grown, undamaged parent.
|
|
[[nodiscard]] std::optional<accounting::Inventory>
|
|
offspring_cost(const Genome& parent, const Genome& offspring, std::uint32_t temperature_millikelvin,
|
|
std::uint32_t share = 1);
|
|
// Rules 13 (ADR-0179; Cellular_reproduction_plan.md section 4): a mutation split. The parent's
|
|
// body and reserve divide per channel, the offspring taking `share_per_thousand` (rounded
|
|
// down); each cell then develops the largest growth its own genome builds from its part of the
|
|
// body, and matter beyond that joins its reserve. Nothing is built, burned or lost: on every
|
|
// channel the two bodies and reserves sum to the parent's. Refused, changing nothing, when
|
|
// the parent is below `min_growth` or damaged, or either part builds no cell at all.
|
|
struct SplitTransition {
|
|
GrowthState parent_growth{}, child_growth{};
|
|
accounting::Inventory parent_body{}, parent_reserve{}, child_body{}, child_reserve{};
|
|
auto operator<=>(const SplitTransition&) const = default;
|
|
};
|
|
[[nodiscard]] std::expected<SplitTransition, BuddingError>
|
|
split_cell(const Genome& parent, const Genome& child, GrowthState growth,
|
|
const accounting::Inventory& body, const accounting::Inventory& reserve,
|
|
std::uint32_t temperature_millikelvin, std::uint32_t share_per_thousand,
|
|
std::uint32_t min_growth, const BodyTuning& tuning = default_body_tuning);
|
|
// What one bud takes from a fully grown, undamaged parent of this genome at this temperature
|
|
// (ADR-0129 amendment): investment matter per channel, and construction energy plus the
|
|
// bud's provision; exactly what `fund_bud` charges such a parent. Nullopt when the genome
|
|
// cannot bud or cannot build a cell from its investment.
|
|
[[nodiscard]] std::optional<accounting::Inventory> bud_cost(const Genome& genome,
|
|
std::uint32_t temperature_millikelvin);
|
|
} // namespace evo::biology
|