Add M8.4 region host deployment, provisioning hook and drill
Deploy evo-region per environment (ADR-0071): one replica with the Recreate strategy (a rolling update would deadlock on the lease), /readyz readiness, /livez liveness, no CPU limit and a drain inside the grace period, with the image digest doubling as the build identity. A new idempotent evo-world-clone provision subcommand creates genesis from development_opening (byte-identical to the qualification fixture) as a Sync hook after the migration. Dev and stage paths include their region; a dev AppProject allows Deployment and Service; region-drill.sh times rollout and forced-deletion recovery; the policy check enforces the host's invariants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
#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
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user