feat(cellular): session v14, bundle 15 and rules-13 wildlife
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Session v14 carries the rules-13 revamp: a body block in the owner's view (members, emergence threshold, exclusions, Emerge open, payable energy, mass and the 20 traits), become, emerge and channel exclusions on actions, become on mutation choices, catalog offers (id, chance, cost) and the emerged ending. Older sessions never see a v14 field. The client shows Stay / Become offspring offers named from the shared catalog, continuing as a bud, the organism and its Emerge button, kept channels, the body and the emerged end screen. Bundle 15 (rules 13 on owner format 11) is durable: schema 60 admits it raw-only, stores become as bit 15 of the choice's operator, widens the action input and mutation results, and publishes the 14 -> 15 revamp profile migration. evo-world-clone opens cellular-v10 (cellular-v9 plus the revamp upgrade from --revamp-tuning), resumable and recoverable. Wildlife counts reserve matter as energy, waits for the bud fee, grows organisms one short of emerging, and hunts by the region step's rules-13 engulf test. The play summary adds organisms, offers and the spent pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// evo-world-clone check-store --world W --region R --pg-* ... --objects DIR
|
||||
// [--reserve-mib N]
|
||||
// evo-world-clone provision --world W --region R --opening
|
||||
// development-v1|primitive-v1|cellular-v1 to cellular-v9
|
||||
// development-v1|primitive-v1|cellular-v1 to cellular-v10
|
||||
// --pg-* ... --objects DIR --build HEX [--commit HEX32] [--retain-build]
|
||||
// primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel,
|
||||
// and one or more ordered --site X,Y values.
|
||||
@@ -28,7 +28,9 @@
|
||||
// cellular-v8 (ADR-0176) also requires --light-pj N. cellular-v9 (rules 12, ADR-0177)
|
||||
// is cellular-v8 followed by the liquid upgrade: it also requires --tuning FILE (the Git
|
||||
// tuning file, whose region size must match --width-um/--height-um) and accepts
|
||||
// --current-seed N (default: derived from the --commit bytes).
|
||||
// --current-seed N (default: derived from the --commit bytes). cellular-v10 (rules 13,
|
||||
// ADR-0179) is cellular-v9 followed by the revamp upgrade: it also requires
|
||||
// --revamp-tuning FILE (the Git revamp tuning file).
|
||||
// primitive-v1 and cellular-v1/v2/v3 accept --life-allocator-start N
|
||||
// (ADR-0123): the world's life-identity allocator is created once at the operator-audited
|
||||
// start N; a later run leaves it untouched and refuses one that is below N.
|
||||
@@ -74,6 +76,7 @@
|
||||
// Exit: 0 done, 2 usage, 3 source/history/database failure, 4 target/objects refused,
|
||||
// 5 target unknown, 6 compared histories differ.
|
||||
#include "evo/biology/cellular_habitat.hpp"
|
||||
#include "evo/biology/cellular_revamp_tuning.hpp"
|
||||
#include "evo/persistence/checkpoint_store.hpp"
|
||||
#include "evo/persistence/region_clone.hpp"
|
||||
#include "evo/persistence/sha256.hpp"
|
||||
@@ -127,16 +130,22 @@ struct Options {
|
||||
std::optional<std::uint64_t> light_pj; // cellular-v8/v9: pJ per square um per tick
|
||||
std::optional<std::string> tuning_path; // cellular-v9: the Git tuning file
|
||||
std::optional<std::uint64_t> current_seed;
|
||||
std::optional<biology::CellularTuning> tuning; // Parsed from tuning_path.
|
||||
std::optional<biology::CellularTuning> tuning; // Parsed from tuning_path.
|
||||
std::optional<std::string> revamp_tuning_path; // cellular-v10
|
||||
std::optional<biology::CellularRevampTuning> revamp_tuning; // Parsed from it.
|
||||
std::optional<std::uint64_t> life_allocator_start;
|
||||
std::optional<persistence::Sha256Digest> build;
|
||||
bool retain_build{};
|
||||
bool crash{};
|
||||
};
|
||||
|
||||
// The openings that declare light: cellular-v8, and cellular-v9 which adds the liquid upgrade.
|
||||
// The openings that declare light: cellular-v8, cellular-v9 which adds the liquid upgrade, and
|
||||
// cellular-v10 which adds the revamp upgrade after it.
|
||||
bool lit_opening(std::string_view opening) {
|
||||
return opening == "cellular-v8" || opening == "cellular-v9";
|
||||
return opening == "cellular-v8" || opening == "cellular-v9" || opening == "cellular-v10";
|
||||
}
|
||||
bool liquid_opening(std::string_view opening) {
|
||||
return opening == "cellular-v9" || opening == "cellular-v10";
|
||||
}
|
||||
std::optional<std::uint64_t> number(std::string_view text) {
|
||||
std::uint64_t value{};
|
||||
@@ -349,8 +358,10 @@ std::optional<Options> parse(int argc, char** argv) {
|
||||
(value == "development-v1" || value == "primitive-v1" || value == "cellular-v1" ||
|
||||
value == "cellular-v2" || value == "cellular-v3" || value == "cellular-v4" ||
|
||||
value == "cellular-v5" || value == "cellular-v6" || value == "cellular-v7" ||
|
||||
value == "cellular-v8" || value == "cellular-v9"))
|
||||
value == "cellular-v8" || value == "cellular-v9" || value == "cellular-v10"))
|
||||
o.opening = value;
|
||||
else if (o.command == "provision" && flag == "--revamp-tuning" && !value.empty())
|
||||
o.revamp_tuning_path = std::string{value};
|
||||
else if (o.command == "provision" && flag == "--light-pj" && n && *n > 0)
|
||||
o.light_pj = n;
|
||||
else if (o.command == "provision" && flag == "--tuning" && !value.empty())
|
||||
@@ -442,11 +453,31 @@ std::optional<Options> parse(int argc, char** argv) {
|
||||
return std::nullopt;
|
||||
} else if (o.opening == "cellular-v7" || lit_opening(o.opening)) {
|
||||
// Pools and bubbles only: square patches belong to the earlier openings. Only
|
||||
// cellular-v8 and v9 (ADR-0176) declare light; only v9 takes a tuning file.
|
||||
// cellular-v8 to v10 (ADR-0176) declare light; v9 and v10 take a tuning file, and
|
||||
// v10 the revamp tuning file.
|
||||
if (lit_opening(o.opening) != o.light_pj.has_value() ||
|
||||
(o.opening == "cellular-v9") != o.tuning_path.has_value() ||
|
||||
(o.current_seed && o.opening != "cellular-v9"))
|
||||
liquid_opening(o.opening) != o.tuning_path.has_value() ||
|
||||
(o.opening == "cellular-v10") != o.revamp_tuning_path.has_value() ||
|
||||
(o.current_seed && !liquid_opening(o.opening)))
|
||||
return std::nullopt;
|
||||
if (o.revamp_tuning_path) {
|
||||
std::ifstream file(*o.revamp_tuning_path, std::ios::binary);
|
||||
const std::string text{std::istreambuf_iterator<char>(file),
|
||||
std::istreambuf_iterator<char>()};
|
||||
if (!file.good() && !file.eof()) {
|
||||
std::printf("revamp tuning file unreadable: %s\n",
|
||||
o.revamp_tuning_path->c_str());
|
||||
return std::nullopt;
|
||||
}
|
||||
auto parsed = biology::parse_cellular_revamp_tuning(text);
|
||||
if (!parsed) {
|
||||
std::printf("revamp tuning file refused at line %zu (%s): %s\n",
|
||||
parsed.error().line, parsed.error().key.c_str(),
|
||||
std::string{biology::describe(parsed.error().kind)}.c_str());
|
||||
return std::nullopt;
|
||||
}
|
||||
o.revamp_tuning = *parsed;
|
||||
}
|
||||
if (o.tuning_path) {
|
||||
std::ifstream file(*o.tuning_path, std::ios::binary);
|
||||
const std::string text{std::istreambuf_iterator<char>(file),
|
||||
@@ -593,7 +624,7 @@ std::vector<std::uint8_t> probe_bytes() {
|
||||
// cellular-v9 (rules 12): the liquid rules from the tuning file, for the opening's area and
|
||||
// a current seed (given, or derived from the genesis commit's bytes 8-15).
|
||||
std::optional<server::CellularLiquidRules> liquid_rules(const Options& o) {
|
||||
if (o.opening != "cellular-v9" || !o.tuning || !o.cellular_width_um || !o.cellular_height_um)
|
||||
if (!liquid_opening(o.opening) || !o.tuning || !o.cellular_width_um || !o.cellular_height_um)
|
||||
return std::nullopt;
|
||||
std::uint64_t seed = o.current_seed.value_or(0);
|
||||
if (!o.current_seed) {
|
||||
@@ -605,18 +636,27 @@ std::optional<server::CellularLiquidRules> liquid_rules(const Options& o) {
|
||||
seed);
|
||||
}
|
||||
|
||||
// cellular-v10 (rules 13): the revamp rules from the revamp tuning file.
|
||||
std::optional<server::CellularRevampRules> revamp_rules(const Options& o) {
|
||||
if (o.opening != "cellular-v10" || !o.revamp_tuning)
|
||||
return std::nullopt;
|
||||
return server::cellular_revamp_rules(*o.revamp_tuning);
|
||||
}
|
||||
|
||||
// ADR-0176 cellular-v8: a cellular-v7 genesis taken through one empty tick and the durable
|
||||
// bundle 9 -> 10 -> 11 -> 12 -> 13 upgrades, declaring the region's light. cellular-v9 adds the
|
||||
// 13 -> 14 liquid upgrade. Resumable: it continues from whichever bundle the head has reached,
|
||||
// and does nothing at its target bundle.
|
||||
// 13 -> 14 liquid upgrade and cellular-v10 the 14 -> 15 revamp upgrade. Resumable: it continues
|
||||
// from whichever bundle the head has reached, and does nothing at its target bundle.
|
||||
int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db,
|
||||
const persistence::FilesystemObjectStore& store,
|
||||
std::uint64_t frame, const persistence::Sha256Digest& build,
|
||||
std::uint64_t light_pj,
|
||||
const std::optional<server::CellularLiquidRules>& liquid) {
|
||||
const std::optional<server::CellularLiquidRules>& liquid,
|
||||
const std::optional<server::CellularRevampRules>& revamp) {
|
||||
const auto& key = o.source.key;
|
||||
const auto target =
|
||||
liquid ? persistence::cellular_v14_versions : persistence::cellular_v13_versions;
|
||||
const auto target = revamp ? persistence::cellular_v15_versions
|
||||
: liquid ? persistence::cellular_v14_versions
|
||||
: persistence::cellular_v13_versions;
|
||||
// A finished opening needs no lease: a rerun (every Argo sync's provision hook) runs
|
||||
// while the region server holds it, and must report the region rather than fail.
|
||||
if (const auto current = persistence::load_region_checkpoint(db, key, timeout); current) {
|
||||
@@ -640,7 +680,7 @@ int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db,
|
||||
auto head = persistence::load_region_checkpoint(db, key, timeout);
|
||||
if (!head)
|
||||
return finish(3);
|
||||
for (unsigned step = 0; step < 7; ++step) {
|
||||
for (unsigned step = 0; step < 8; ++step) {
|
||||
const auto manifest = persistence::decode_manifest(head->manifest);
|
||||
if (!manifest || manifest->profile != persistence::CheckpointProfile::cellular_lives_v1 ||
|
||||
manifest->frame != frame)
|
||||
@@ -700,6 +740,9 @@ int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db,
|
||||
else if (versions == persistence::cellular_v13_versions && liquid)
|
||||
upgraded = persistence::migrate_cellular_liquid_profile(db, store, *lease, *head, id,
|
||||
build, *liquid, timeout);
|
||||
else if (versions == persistence::cellular_v14_versions && liquid && revamp)
|
||||
upgraded = persistence::migrate_cellular_revamp_profile(db, store, *lease, *head, id,
|
||||
build, *revamp, timeout);
|
||||
else
|
||||
return finish(4);
|
||||
if (!upgraded) {
|
||||
@@ -887,9 +930,9 @@ int provision(const Options& o) {
|
||||
"--commit to resolve genesis");
|
||||
return 4;
|
||||
}
|
||||
if (const auto finished =
|
||||
finish_photosynthesis_opening(o, *db, *store, primitive_frame, build,
|
||||
o.light_pj.value_or(0), liquid_rules(o));
|
||||
if (const auto finished = finish_photosynthesis_opening(
|
||||
o, *db, *store, primitive_frame, build, o.light_pj.value_or(0),
|
||||
liquid_rules(o), revamp_rules(o));
|
||||
finished != 0)
|
||||
return finished;
|
||||
auto head = persistence::load_region_checkpoint(*db, o.source.key, timeout);
|
||||
@@ -942,9 +985,9 @@ int provision(const Options& o) {
|
||||
return 4;
|
||||
}
|
||||
if (lit_opening(o.opening)) {
|
||||
if (const auto finished =
|
||||
finish_photosynthesis_opening(o, *db, *store, primitive_frame, build,
|
||||
o.light_pj.value_or(0), liquid_rules(o));
|
||||
if (const auto finished = finish_photosynthesis_opening(
|
||||
o, *db, *store, primitive_frame, build, o.light_pj.value_or(0), liquid_rules(o),
|
||||
revamp_rules(o));
|
||||
finished != 0)
|
||||
return finished;
|
||||
auto head = persistence::load_region_checkpoint(*db, o.source.key, timeout);
|
||||
@@ -1091,6 +1134,15 @@ int summary(const Options& o) {
|
||||
static_cast<unsigned long long>(play->unrecorded),
|
||||
static_cast<unsigned long long>(play->owned_deaths),
|
||||
static_cast<unsigned long long>(play->wildlife_deaths));
|
||||
std::printf("revamp merged=%llu emerged=%llu organisms=%llu largest=%llu offers_pending=%llu "
|
||||
"offers_earned=%llu spent_fg=%llu\n",
|
||||
static_cast<unsigned long long>(play->merged),
|
||||
static_cast<unsigned long long>(play->emerged),
|
||||
static_cast<unsigned long long>(play->organisms),
|
||||
static_cast<unsigned long long>(play->largest_organism),
|
||||
static_cast<unsigned long long>(play->offers_pending),
|
||||
static_cast<unsigned long long>(play->offers_earned),
|
||||
static_cast<unsigned long long>(play->spent_matter_fg));
|
||||
std::printf("lifespan_ticks min=%llu median=%llu max=%llu\n",
|
||||
static_cast<unsigned long long>(play->lifespan_min),
|
||||
static_cast<unsigned long long>(play->lifespan_median),
|
||||
|
||||
Reference in New Issue
Block a user