Files
aevolution/src/processes/development_opening.cpp
T
dingoandClaude Opus 5.5 17fe23e5f0
Foundation / checks (deploy) (push) Successful in 3m32s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m56s
Foundation / checks (network) (push) Successful in 13m46s
Foundation / checks (tsan) (push) Successful in 7m59s
Foundation / checks (checks) (push) Successful in 33m36s
Foundation / checks (postgres) (push) Successful in 45m30s
Foundation / postgres-tools (push) Successful in 20s
Foundation / server-image (push) Successful in 25s
Foundation / image (push) Successful in 2m36s
M11.1: genome schema 2 with per-second rates (ADR-0099, segment 2)
Movement and ingestion are stored per second in schema 2 (ranges x20). Schema 1 records
stay valid, are never rewritten, and read as exactly x20 via Genome::per_second; drafts
default to schema 1 so existing literals keep their meaning. Development version 1
converts genome rates at its own 50 ms quantum (round down), so phenotypes are
unchanged. Mutation keeps the parent's schema and step; the lineage archive header names
exactly the highest schema held (all-schema-1 archives keep their bytes); the
development-v1 opening names schema 1. No golden changed; two tests that used 2 as an
unknown schema now use the next one. Refresh the dev session window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:16:55 -04:00

109 lines
4.2 KiB
C++

#include "evo/processes/development_opening.hpp"
#include <array>
#include <limits>
#include <optional>
namespace evo::processes {
namespace {
// Mirrors tests/fixtures/environmental_region.hpp exactly; the lineage-region
// contracts test proves byte equality with the fixture for world 7.
EnvironmentalConfig config(world::WorldIdentity id) {
EnvironmentalConfig c;
c.rules = 2;
c.world = id.world;
c.frame = id.frame;
c.producer = 1;
c.consumer = 2;
c.source = 3;
c.tick_microseconds = 50000;
c.area_um2 = 1;
c.irradiance_numerator = 11;
c.irradiance_denominator = 3;
c.efficiency = 600;
c.growth_numerator = 3;
c.growth_denominator = 2;
c.growth_cost = 1;
c.recipe = {1, 2, 1, 1, 1};
c.intake.fill(100);
c.assimilation = 1000;
c.producer_min_mK = c.consumer_min_mK = 270000;
c.producer_max_mK = c.consumer_max_mK = 310000;
c.decay.fill(1);
return c;
}
std::unique_ptr<EnvironmentalCommunity> community(world::WorldIdentity id) {
using namespace world;
constexpr auto maximum = std::numeric_limits<std::uint64_t>::max();
std::array<std::uint64_t, 10> environment{200, 6, 6, 400, 0, 0, 200, 0, 2000, 0};
const FieldSite site{{0, 0, -16000}, {{0}, {0}, {0}, {10}, {20}, {3}}, {1}};
std::array<FieldOpening, 10> opening{};
for (std::size_t k = 0; k < 10; ++k)
opening[k] = {static_cast<Field>(k), {&environment[k], 1}};
const FieldDefaults defaults{
{accounting::Femtograms{0}, accounting::Femtograms{maximum}, accounting::Femtograms{0}}};
auto f = FieldStore::create(id, 1, defaults, {&site, 1}, opening, 2000000);
auto t = ChunkStore::create({}, 1, 2000000, {{VolumeUnits{100}, VolumeUnits{100}}});
if (!f || !t || !(*t)->load({0, 0, -1000}))
return nullptr;
std::array<OrganismResources, 2> accounts{};
accounts[0].id = {1};
accounts[1].id = {2};
accounts[0].capacities.fill(100000000);
accounts[1].capacities.fill(100000000);
auto r = EnvironmentalTransfers::create(id, std::move(*f), std::move(*t), accounts, 4000000);
if (!r)
return nullptr;
auto o = EnvironmentalCommunity::create(config(id), std::move(*r), 8000000);
return o ? std::move(*o) : nullptr;
}
std::optional<biology::Genome> genome(std::uint64_t id, std::uint64_t parent) {
biology::GenomeDraft draft;
draft.schema_version = biology::genome_schema_v1; // development-v1 is fixed (ADR-0099).
draft.id = id;
draft.origin_event = id;
draft.development_version = 1;
if (parent != 0)
draft.parents = {parent};
draft.capabilities = {{biology::Capability::energy_conversion, 400, 0},
{biology::Capability::membrane, 120, 0},
{biology::Capability::target_size, 8'000'000, 0}};
auto made = biology::Genome::create(draft);
if (!made)
return std::nullopt;
return *made;
}
} // namespace
EnvironmentalInput development_input(std::uint64_t tick) noexcept {
EnvironmentalInput in;
in.temperature_mK = 290000;
in.source_enabled = tick % 7 == 0 ? 0 : 1;
if (tick == 16)
in.bite = {2, 2, 2, 2, 1};
if (tick == 20)
in.terminal[1] = 1;
return in;
}
std::expected<std::unique_ptr<LineageRegion>, DevelopmentOpeningError>
development_opening(std::uint64_t world) {
if (world == 0)
return std::unexpected{DevelopmentOpeningError::identity};
const world::WorldIdentity id{world, development_opening_frame};
auto founder = genome(1, 0);
auto descendant = genome(2, 1);
auto opening = community(id);
if (!founder || !descendant || !opening)
return std::unexpected{DevelopmentOpeningError::build};
biology::LineageArchive archive;
if (!archive.admit(*founder) || !archive.admit(*descendant) ||
!archive.record_birth(5, 1, Tick{0}) || !archive.record_death(5, Tick{0}) ||
!archive.record_birth(10, 1, Tick{0}) || !archive.record_birth(11, 2, Tick{0}))
return std::unexpected{DevelopmentOpeningError::build};
auto region = LineageRegion::create(std::move(opening), archive, {10, 11, 12, 3});
if (!region)
return std::unexpected{DevelopmentOpeningError::build};
return std::move(*region);
}
} // namespace evo::processes