Files
aevolution/src/processes/development_opening.cpp
T
dingoandClaude Opus 5.5 3f08a1d221 Add M8.6 synthetic load driver and fault drill
A drill-only evo-server --synthetic-inputs development-v1 driver feeds
deterministic inputs from the committed head after every recovery, with
request IDs that match acknowledgements across owners (ADR-0073); it is
off in Git and the policy check keeps it off. fault-drill.sh loads dev
or stage and runs repeated forced kills (RTO, zero lost
acknowledgements), a full object volume (nothing acknowledged), an
empty volume (quarantine, never a fresh world) and an operator-driven
database outage (stale epoch never resumes), restoring the Git
configuration on exit. Process tests prove contiguous acknowledgement
across a SIGKILL and exact resumption after the committed head.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 10:52:01 -04:00

108 lines
4.1 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.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