Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (deploy) (push) Successful in 5m15s
Foundation / checks (network) (push) Successful in 21m56s
Foundation / checks (client) (push) Successful in 22m54s
Foundation / checks (tsan) (push) Successful in 47m4s
Foundation / checks (postgres) (push) Successful in 1h15m49s
Foundation / checks (checks) (push) Failing after 1h30m4s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
ADR-0175 implements ADR-0136 step C with trial costs to be balanced after playtesting. Genome schema 5 adds a photosynthesis efficiency (empty in schemas 1-4, so earlier offers and draws are unchanged; mutation operators 29-32 are appended). Development version 5 builds the organelles as internal membrane (p/4 of structure, upkept twice) and slows movement by p/2 per thousand. Founder 4 and cellular rules 11 let lineages earn the capability as an offspring plan that children express. Owner format 9 declares the region's light. Inside each tick's detached candidate, active unfrozen producers capture cross-section x irradiance x efficiency (a quarter while moving), credited to the reserve and boundary inflow together and replayed from recorded intentions. Well-lit wildlife producers hold still. The joint owner keeps infall, water and radiation and nests a rules-11 owner unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
4.8 KiB
C++
101 lines
4.8 KiB
C++
#pragma once
|
|
|
|
#include "evo/biology/metabolism.hpp"
|
|
|
|
namespace evo::biology {
|
|
enum class MutationEffect : std::uint8_t { adjust_up, adjust_down, acquire, shed };
|
|
// One entry of the static catalog. The ID is stable: it orders candidates and
|
|
// names them across calls, and it carries no ranking.
|
|
struct MutationOperator {
|
|
std::uint16_t id;
|
|
Capability target;
|
|
MutationEffect effect;
|
|
auto operator<=>(const MutationOperator&) const = default;
|
|
};
|
|
// What the recorded context is. The draw reads this and the parent genome and
|
|
// nothing else, so events elsewhere in a world cannot move a candidate set.
|
|
struct MutationContext {
|
|
std::uint64_t seed;
|
|
std::uint32_t stream; // explicit stream identity, never a shared global
|
|
std::uint64_t event_index; // a new event earns a new draw; a retry does not
|
|
std::uint16_t candidate_count;
|
|
GrowthState growth;
|
|
EnvironmentState environment;
|
|
auto operator<=>(const MutationContext&) const = default;
|
|
};
|
|
// A proposal. It reserves nothing. Maintenance and mass are what ADR-0032 would
|
|
// charge for the successor, not a price invented here and not a score.
|
|
struct MutationCandidate {
|
|
std::uint16_t operator_id;
|
|
Capability target;
|
|
MutationEffect effect;
|
|
std::uint32_t parameter; // the successor's value; zero when shed
|
|
std::uint64_t maintenance;
|
|
std::uint64_t total_mass;
|
|
auto operator<=>(const MutationCandidate&) const = default;
|
|
};
|
|
// What was offered, and what it was drawn from. The record carries its own
|
|
// context and parent because a candidate list cannot stand in for them: a small
|
|
// catalog yields few distinct lists, so different contexts draw the same one
|
|
// often, and comparing lists would accept a stale offer.
|
|
struct MutationOffer {
|
|
std::uint64_t parent;
|
|
std::uint64_t parent_digest;
|
|
MutationContext context;
|
|
std::vector<MutationCandidate> candidates;
|
|
auto operator<=>(const MutationOffer&) const = default;
|
|
};
|
|
// A fully funded genome change, detached from the organism until its owner
|
|
// commits it. Body matter is recomputed from the successor; reserve includes
|
|
// channel-specific material releases and pays all deficits plus construction
|
|
// energy. A refusal never spends anything.
|
|
struct MutationTransition {
|
|
Genome successor;
|
|
accounting::Inventory body;
|
|
accounting::Inventory reserve;
|
|
accounting::Inventory intake;
|
|
accounting::Inventory release;
|
|
auto operator<=>(const MutationTransition&) const = default;
|
|
};
|
|
enum class MutationError : std::uint8_t {
|
|
invalid_context,
|
|
no_candidates,
|
|
unknown_candidate,
|
|
context_changed,
|
|
altered_offer,
|
|
invalid_successor,
|
|
insufficient_funding,
|
|
development
|
|
};
|
|
inline constexpr std::size_t max_candidates = 8;
|
|
// ADR-0175 trial value: an acquired photosynthesis starts at 10 % efficiency.
|
|
inline constexpr std::uint32_t photosynthesis_acquired_start = 100;
|
|
|
|
[[nodiscard]] std::span<const MutationOperator> mutation_catalog() noexcept;
|
|
// Identical inputs always yield identical candidates, sorted by operator ID.
|
|
// The order is canonical and means nothing: nothing here is ranked.
|
|
[[nodiscard]] std::expected<MutationOffer, MutationError>
|
|
mutation_candidates(const Genome& genome, const MutationContext& context);
|
|
// Compares the offer's recorded context and parent against the current ones
|
|
// before anything else, so a changed context is rejected rather than answered
|
|
// with a different mutation.
|
|
[[nodiscard]] std::expected<Genome, MutationError>
|
|
select_mutation(const Genome& genome, const MutationContext& context, const MutationOffer& offered,
|
|
std::uint16_t chosen, std::uint64_t successor_id, std::uint64_t origin_event);
|
|
// Revalidates the offer, derives both bodies at the offer's recorded growth and
|
|
// environment, and funds the exact channel transition from retained reserve.
|
|
// Added matter in each channel incurs construction energy at that genome's
|
|
// versioned construction rate. No state is changed by this proposal.
|
|
[[nodiscard]] std::expected<MutationTransition, MutationError>
|
|
fund_mutation(const Genome& genome, const MutationContext& context, const MutationOffer& offered,
|
|
std::uint16_t chosen, std::uint64_t successor_id, std::uint64_t origin_event,
|
|
const accounting::Inventory& reserve);
|
|
// ADR-0157: preserve and validate the original draw, but fund its selected genome
|
|
// at the organism's current growth. No redraw or reset to the offer's old body.
|
|
[[nodiscard]] std::expected<MutationTransition, MutationError>
|
|
fund_mutation_at_growth(const Genome& genome, const MutationContext& context,
|
|
const MutationOffer& offered, std::uint16_t chosen,
|
|
std::uint64_t successor_id, std::uint64_t origin_event,
|
|
const accounting::Inventory& reserve, GrowthState current_growth);
|
|
} // namespace evo::biology
|