From ff121c3ed12f092361d6fa70e68bcc6f9ea722ed Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 26 Oct 2026 11:24:04 -0400 Subject: [PATCH] feat(cellular): seed dev wildlife and tune budding playtests --- apps/evo-client/cellular_controls.hpp | 7 + apps/evo-client/panels.cpp | 32 +++- apps/evo-server/cellular_bridge.hpp | 39 +++-- apps/evo-world-clone/main.cpp | 27 +++- .../region/dev-session-route/listener.yaml | 2 +- .../kubernetes/region/dev/kustomization.yaml | 2 +- .../kubernetes/region/dev/region-values.yaml | 22 +-- .../region/dev/tuning/cellular-revamp.tuning | 22 +-- docs/PROJECT_VISION.md | 4 + docs/STATUS.md | 11 ++ docs/adr/0180-dev-starting-wildlife.md | 41 +++++ docs/adr/README.md | 2 + docs/architecture/CLIENT_ARCHITECTURE.md | 6 + docs/engineering/CELLULAR_PLAYTEST_TUNING.md | 57 +++++++ docs/engineering/VALIDATION.md | 71 ++++++++ .../evo/biology/cellular_revamp_tuning.hpp | 6 +- include/evo/persistence/checkpoint_store.hpp | 4 +- include/evo/persistence/region_checkpoint.hpp | 7 +- .../evo/server/lifecycle/cellular_lives.hpp | 10 +- .../network/session-v14-cellular-revamp.md | 8 + src/biology/cellular_revamp_tuning.cpp | 7 +- src/persistence/cellular_checkpoint_store.cpp | 15 +- src/persistence/population_checkpoint.cpp | 9 +- src/server/lifecycle/cellular_lives.cpp | 152 +++++++++++++++++- src/server/lifecycle/cellular_revamp.cpp | 5 +- tests/cellular_publication_tests.cpp | 86 ++++++++++ tests/cellular_revamp_owner_tests.cpp | 92 ++++++++++- tests/cellular_revamp_tuning_tests.cpp | 23 ++- tests/client_panels.cpp | 19 +++ tests/client_ui_model.cpp | 16 +- tests/postgres_tests.cpp | 5 + tools/ci/postgres-check.sh | 7 + 32 files changed, 738 insertions(+), 78 deletions(-) create mode 100644 docs/adr/0180-dev-starting-wildlife.md create mode 100644 docs/engineering/CELLULAR_PLAYTEST_TUNING.md diff --git a/apps/evo-client/cellular_controls.hpp b/apps/evo-client/cellular_controls.hpp index 20767f8..31bea21 100644 --- a/apps/evo-client/cellular_controls.hpp +++ b/apps/evo-client/cellular_controls.hpp @@ -99,6 +99,13 @@ steer_cellular(const CellularControls& controls, client::Intention intention, short_on[i + 1] = d.bud_cost_matter_fg[i] > d.reserve_matter_fg[i]; return short_on; } +[[nodiscard]] inline bool bud_affordable(const network::CellularLifeDiagnostics& d) { + const bool known = + d.bud_cost_energy_pj != 0 || + std::ranges::any_of(d.bud_cost_matter_fg, [](auto amount) { return amount != 0; }); + const auto short_on = bud_shortfall(d); + return known && std::ranges::none_of(short_on, [](bool missing) { return missing; }); +} [[nodiscard]] inline bool can_fund(const network::CellularOfferedCandidate& candidate, const network::CellularLifeDiagnostics& reserve) { if (candidate.cost_energy_pj > reserve.reserve_energy_pj) diff --git a/apps/evo-client/panels.cpp b/apps/evo-client/panels.cpp index 2acc2d3..0b99cfb 100644 --- a/apps/evo-client/panels.cpp +++ b/apps/evo-client/panels.cpp @@ -1212,8 +1212,13 @@ void hud_vitals(const PanelView& v, FormBuffers& form, bool compact) { const float max_height = compact ? std::max(px(120), io.DisplaySize.y - px(220)) : io.DisplaySize.y * 0.43F; ImGui::SetNextWindowSizeConstraints({width, 0}, {width, max_height}); + // Keep table width stable when the constrained card gains its vertical scrollbar. + ImGui::SetNextWindowContentSize( + {width - 2 * ImGui::GetStyle().WindowPadding.x - ImGui::GetStyle().ScrollbarSize, 0}); ImGui::Begin("Vitals", nullptr, - hud_flags | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize); + hud_flags | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize | + (form.vitals_minimized ? ImGuiWindowFlags_None + : ImGuiWindowFlags_AlwaysVerticalScrollbar)); panel_heading("Your cell", form.vitals_minimized); if (form.vitals_minimized) { if (d) @@ -1349,12 +1354,35 @@ void hud_dock(const PanelView& v, FormBuffers& form, PanelActions& a, bool compa ImGui::BeginDisabled(!play || !play->can_act()); if (action_button("Engulf", {each, px(44)}, {0.38F, 0.68F, 1.0F, 1})) a.cell_action = CellAction::engulf; + ImGui::EndDisabled(); ImGui::SameLine(); - if (action_button("Bud", {each, px(44)}, {0.82F, 0.53F, 0.96F, 1})) { + const bool bud_ready = play && play->can_act() && d && bud_affordable(*d); + ImGui::BeginDisabled(!bud_ready); + if (action_button("Bud", {each, px(44)}, + bud_ready ? ImVec4{0.82F, 0.53F, 0.96F, 1} : ImVec4{0.5F, 0.5F, 0.5F, 1})) { a.cell_action = CellAction::bud; a.cell_become = form.bud_become && d && d->members == 1; } ImGui::EndDisabled(); + if (!bud_ready && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) { + ImGui::BeginTooltip(); + if (d && bud_known(*d)) { + ImGui::TextUnformatted("Resources needed to bud (required / available):"); + ImGui::Text("Energy: %s / %s", energy_text(d->bud_cost_energy_pj).c_str(), + energy_text(d->reserve_energy_pj).c_str()); + for (std::size_t i = 0; i < d->bud_cost_matter_fg.size(); ++i) + ImGui::Text("%s: %s / %s", nutrient_names.at(i + 1), + mass_text(d->bud_cost_matter_fg[i]).c_str(), + mass_text(d->reserve_matter_fg[i]).c_str()); + if (!play || !play->can_act()) + ImGui::TextUnformatted("Waiting for a connection, fresh state or pending action."); + if (d->members > 1) + ImGui::TextUnformatted("Includes the largest possible litter of internal cells."); + } else { + ImGui::TextUnformatted("Budding requirements are unavailable for this cell."); + } + ImGui::EndTooltip(); + } // Rules 13 (v14): continue as the bud, or grow the organism toward Emerge. if (d && d->members != 0 && play && play->life() != 0) { if (d->members == 1) { diff --git a/apps/evo-server/cellular_bridge.hpp b/apps/evo-server/cellular_bridge.hpp index 41bffa2..839916d 100644 --- a/apps/evo-server/cellular_bridge.hpp +++ b/apps/evo-server/cellular_bridge.hpp @@ -219,7 +219,7 @@ class CellularBridge { diagnostics.reserve_energy_pj = life.reserve.energy.value; for (std::size_t i = 0; i < diagnostics.reserve_matter_fg.size(); ++i) diagnostics.reserve_matter_fg[i] = life.reserve.matter[i].value; - if (const auto cost = bud_cost_for(state, life.identity.genome)) { + if (const auto cost = bud_cost_for(state, life)) { diagnostics.bud_cost_energy_pj = cost->energy.value; for (std::size_t i = 0; i < diagnostics.bud_cost_matter_fg.size(); ++i) diagnostics.bud_cost_matter_fg[i] = cost->matter[i].value; @@ -262,8 +262,9 @@ class CellularBridge { } // ADR-0129 (v10): what an engulf or bud intention did this tick. diagnostics.engulf = engulf_result(feedback->engulf); - diagnostics.bud = feedback->bud ? bud_outcome(*feedback->bud) - : network::CellularBudOutcome::not_requested; + const auto bud = feedback->bud; + diagnostics.bud = + bud ? bud_outcome(*bud) : network::CellularBudOutcome::not_requested; // Rules 13 (v14): what held growth back and the tick's flows by channel. diagnostics.growth_limit = feedback->growth_limit; const auto channels = [](const accounting::Inventory& value) { @@ -361,13 +362,11 @@ class CellularBridge { const auto before = deposit_stock_.find(patch.id); deposit.drained = before != deposit_stock_.end() && (patch.available.energy.value < before->second.energy.value || - std::ranges::any_of( - std::array{0, 1, 2, 3}, - [&](int c) { - const auto i = static_cast(c); - return patch.available.matter.at(i).value < - before->second.matter.at(i).value; - })); + std::ranges::any_of(std::array{0, 1, 2, 3}, [&](int c) { + const auto i = static_cast(c); + return patch.available.matter.at(i).value < + before->second.matter.at(i).value; + })); seen_stock_[patch.id] = patch.available; // Rules 12 (v13): a bubble's world velocity, current plus induced drift, so the // client can carry it between perceptions. @@ -589,19 +588,18 @@ class CellularBridge { } private: - // ADR-0129 amendment: a genome's bud cost is pure for this region's temperature, and - // deriving it scans up to a thousand bodies, so it is computed once per genome. + // The parent/plan charge is pure at this region's temperature and fixed rules. + // Internal-cell costs depend on the current body and are recomputed. std::optional bud_cost_for(const server::CellularLives& state, - std::uint64_t genome_id) { - if (const auto known = bud_costs_.find(genome_id); known != bud_costs_.end()) + const server::CellularOwnedLife& life) { + if (life.revamp.members > 1) + return state.budding_cost(life.identity.life); + const auto key = std::pair{life.identity.genome, server::cellular_offspring_genome(life)}; + if (const auto known = bud_costs_.find(key); known != bud_costs_.end()) return known->second; - const auto genome = state.archive().find(genome_id); - if (!genome) - return std::nullopt; if (bud_costs_.size() >= 4096) bud_costs_.clear(); // Bounded: recomputing is only slower. - return bud_costs_[genome_id] = - biology::bud_cost(*genome, state.ambient_temperature_millikelvin()); + return bud_costs_[key] = state.budding_cost(life.identity.life); } static std::uint64_t wall_seconds() { return static_cast(std::chrono::duration_cast( @@ -629,7 +627,8 @@ class CellularBridge { friend bool operator==(const SentOffer&, const SentOffer&) = default; }; std::vector offers_; // Last offer view sent to each owner. - std::map> bud_costs_; // By genome. + std::map, std::optional> + bud_costs_; // ADR-0136: deposit stocks seen at the last replicated tick, and this tick's. std::map deposit_stock_, seen_stock_; std::vector> owned_; // At last replication. diff --git a/apps/evo-world-clone/main.cpp b/apps/evo-world-clone/main.cpp index 144370e..af15e1a 100644 --- a/apps/evo-world-clone/main.cpp +++ b/apps/evo-world-clone/main.cpp @@ -31,6 +31,8 @@ // --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). +// A nonzero playtest.starting_wildlife_cells (ADR-0180) additionally requires +// --playtest-wildlife-first-id N: an audited unused range below --life-allocator-start. // 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. @@ -134,6 +136,7 @@ struct Options { std::optional tuning; // Parsed from tuning_path. std::optional revamp_tuning_path; // cellular-v10 std::optional revamp_tuning; // Parsed from it. + std::optional playtest_wildlife_first_id; // Audited DEV-only reserved range. std::optional life_allocator_start; std::optional build; bool retain_build{}; @@ -365,7 +368,11 @@ std::optional parse(int argc, char** argv) { o.cellular_mixed = cellular_motes(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) + else if (o.command == "provision" && flag == "--playtest-wildlife-first-id") { + o.playtest_wildlife_first_id = number(value); + if (!o.playtest_wildlife_first_id || *o.playtest_wildlife_first_id == 0) + return std::nullopt; + } else if (o.command == "provision" && flag == "--light-pj" && n && *n > 0) o.light_pj = n; else if (o.command == "provision" && flag == "--tuning" && !value.empty()) o.tuning_path = std::string{value}; @@ -480,6 +487,13 @@ std::optional parse(int argc, char** argv) { return std::nullopt; } o.revamp_tuning = *parsed; + const auto count = parsed->playtest_starting_wildlife_cells; + if (count != 0 && (!o.playtest_wildlife_first_id || !o.life_allocator_start || + *o.playtest_wildlife_first_id == 0 || + *o.playtest_wildlife_first_id >= *o.life_allocator_start || + static_cast(count) > + *o.life_allocator_start - *o.playtest_wildlife_first_id)) + return std::nullopt; } if (o.tuning_path) { std::ifstream file(*o.tuning_path, std::ios::binary); @@ -534,6 +548,8 @@ std::optional parse(int argc, char** argv) { return std::nullopt; // The development opening has no lives to allocate. } } + if (o.playtest_wildlife_first_id && o.opening != "cellular-v10") + return std::nullopt; if (!complete(o.source) || (needs_builds && o.retained.empty()) || (clone && !complete(o.target))) return std::nullopt; @@ -657,6 +673,10 @@ int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db, const std::optional& liquid, const std::optional& revamp) { const auto& key = o.source.key; + std::uint32_t wildlife_count{}; + if (o.revamp_tuning) + wildlife_count = + static_cast(o.revamp_tuning->playtest_starting_wildlife_cells); const auto target = revamp ? persistence::cellular_v15_versions : liquid ? persistence::cellular_v14_versions : persistence::cellular_v13_versions; @@ -744,8 +764,9 @@ int finish_photosynthesis_opening(const Options& o, persistence::Postgres& db, 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); + upgraded = persistence::migrate_cellular_revamp_profile( + db, store, *lease, *head, id, build, *revamp, timeout, {}, wildlife_count, + wildlife_count == 0 ? 0 : o.playtest_wildlife_first_id.value_or(0)); else return finish(4); if (!upgraded) { diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index cb02f52..05f9ba0 100644 --- a/deploy/kubernetes/region/dev-session-route/listener.yaml +++ b/deploy/kubernetes/region/dev-session-route/listener.yaml @@ -12,7 +12,7 @@ spec: env: - {name: REGION_SESSION, value: "dev"} - {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"} - - {name: REGION_SESSION_WINDOW, value: "dev-20261026T135918-495ff8ba:1793037558"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261026T160157-7386982f:1793044917"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} ports: # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. diff --git a/deploy/kubernetes/region/dev/kustomization.yaml b/deploy/kubernetes/region/dev/kustomization.yaml index ac82b31..1208b64 100644 --- a/deploy/kubernetes/region/dev/kustomization.yaml +++ b/deploy/kubernetes/region/dev/kustomization.yaml @@ -1,4 +1,4 @@ -# Region host for evolution-dev: world 100, region 13, frame 9 (cellular-v10 opening, rules 13). +# Region host for evolution-dev: world 100, region 14, frame 9 (cellular-v10 opening, rules 13). # The server image digest appears twice on purpose: as the image and as the build # identity the region records in every commit. The policy check requires they match. apiVersion: kustomize.config.k8s.io/v1beta1 diff --git a/deploy/kubernetes/region/dev/region-values.yaml b/deploy/kubernetes/region/dev/region-values.yaml index 2017a16..20237d5 100644 --- a/deploy/kubernetes/region/dev/region-values.yaml +++ b/deploy/kubernetes/region/dev/region-values.yaml @@ -1,10 +1,10 @@ # Region identity and build (the server image digest without "sha256:"). -# Revamp playtests (rules 13, ADR-0179): region 13 holds a cellular-v10 opening, a 60 x 60 mm +# Revamp playtests (rules 13, ADR-0179): region 14 holds a cellular-v10 opening, a 60 x 60 mm # cellular-v7 genesis taken durably to rules 11 with light (trial 40 pJ per square um per # tick), to rules 12 with the currents, handling and moving food of the Git tuning file # (tuning/cellular.tuning), and to rules 13 with the revamp rules of -# tuning/cellular-revamp.tuning. Regions 1-12 stay in the stores untouched; they are simply -# not served while dev runs region 13. A region keeps the tuning it opened with, so a new +# tuning/cellular-revamp.tuning. Regions 1-13 stay in the stores untouched; they are simply +# not served while dev runs region 14. A region keeps the tuning it opened with, so a new # region opens when the tuning changes (until live retuning exists). apiVersion: apps/v1 kind: Deployment @@ -17,11 +17,11 @@ spec: - name: evo-server env: - {name: REGION_WORLD, value: "100"} - - {name: REGION_ID, value: "13"} + - {name: REGION_ID, value: "14"} - {name: REGION_BUILD, value: effea9180d802e50abed76a5da665374f3591eda8aeb99c0fff085ed6df618ae} - {name: REGION_PROFILE, value: cellular} # The whole world's catalog: dev world 100 has only this region. - - {name: REGION_LIFE_ROUTES, value: "13=void.aeternalisgames.com:7400=void.aeternalisgames.com"} + - {name: REGION_LIFE_ROUTES, value: "14=void.aeternalisgames.com:7400=void.aeternalisgames.com"} # Keep the currently promoted build plus prior committed builds recoverable. - {name: REGION_RETAINED, value: "f1183f4476bac87c09504a574112df4663931f67e88cc38dc08f867ce98ff726 815153514ca4a53967932bb46456ff4cb4e1784f9db247bc3b613b7e8365c59f 21507d4369cebef83ee05152daea5ac2f581ea86a9dc85276ef54e3f9f6388c5 5a77cf9e96e7a0e40ea07e9394a3fa458184ce54f8f774a8fb59cbec1db75c54 e17c62bc8dbad089da57e8b30adc391ff8b947cc7182b3160f5e2709103ded78 6c96629eb3c26513d55207b109fe2a9873a58f43510bd067b7d5422572e3fb42 7952185d5ef96504b5793b76fe72e42cbe9c9ac19149bf912adb2c3a735f8dbf f378a43d6146eeed864110b90848df0bec9672fa4c9941a2d04de249068a4a09 ecac8f9f2489c547ce58f12ed01baaa3939c8adbf8aed05c313abbf422cdc855 4af7209941643e0c6a100e2b4e2fef8a959b87fdbfac2173b7867cfc1808bd66 edb39f956df1f481d7ba724cac4ceb3a4fe494efc02f994d31d6c96dfae04a78 0ded41070dd3e0c0daa43e13dadc58c449865eec00530cfceff3c1579c66e916 754446fe4e5f33e9c0d5a1a74a02444a01de1700673442c90827c708aba62cee c597c0bac8b4a796e1e8b70344f9866cb047cc90cfb15af774d38860594ea27a e83c333a87056c678b5e835947647ef42370b43dbfc31997744f28d993f9c4aa db2b0e6a6071502381a768d70fd9bab8c08c64e4717fc23da45dbe8adc5fa3d6 cdc10712ff8bf956f8f5900709500046493523b51dc670d5b2d01eaf604bcd38 028571f257b485acafbe79b704a80f273d899485c4bb264d9c8137bf51e33217 566c29329433934f1436faf94652a7b925df8b4587ab04470322172f47c31c02 1dd640eba3e9dbdd10106698215a0a06df89c5cdf801c53c4c26fb923116552a faeb26fc5db5c4aae9ae9eb4388e807ab4d59499d7639fcab3d878843a740037 5e13e0096eb4010253c270ab98f0e9bbc11571c221eb779d428333e8cd63c955 e891f9427d5ec81b32595d70be9d00bb66c6d8223b4747d12be8c388c2fc0c8e 58aab8aaa538c0c6e5ad7281fd27e50374b489942aa317296dbf9c2ec5ca3434 4a8b0a9dc9f6be491e9eacb464aa7ef7c0d449de3018c4172c01448ce39a5108 3e5b8cef06838821113c8bba064e9415e8c627bca552fb978f830d40027b80f2 67e6bb3d138e7d489850ac99b5915ef8659178a68140b963e282b24020a288e2 f178f7f44251fdc9ae9ccaaecc5ea6f10aa534caa25d506abc3fbde21c69db17 6532f97e9b7d1492f1a17d1228ce7e563016c2187735f44e58ff1e9f786019aa 7c5462391a9bff4f7c25f2761098e7189b7ae204af0a7be61a652e4482f63e6a 9ba005f9216a2211491afd0e335ac5c6f20af1166fbb7518bcc8cec2e536f5ce 7eb84318234e23c223d4279ac01e925ba0b08d6d6950f7ba328f0ce909af8307 0fcdbf1518b677829322dc18e1feebd354a6e39700bd9cdb60ab47dc0465c3a6 801a9ae4fe1049dd27cfd9c356f21f29c6e07238448c201c08d288b5cc8e7e9a f0869be511179866f9a71a63a6a5f65e577e851fd7851184734bb5c56940b1a6 178cd8ffcdfe9fe14f39084d78341a8705ca72e78947bada31ab0356508fc232 0fd4807f67ab317561f115f12c0d8540e04596fdea389d7c2104e97dda5a0351"} --- @@ -36,9 +36,9 @@ spec: - name: provision env: - {name: REGION_WORLD, value: "100"} - - {name: REGION_ID, value: "13"} + - {name: REGION_ID, value: "14"} - {name: REGION_BUILD, value: effea9180d802e50abed76a5da665374f3591eda8aeb99c0fff085ed6df618ae} - # Region 13 (rules 13): cellular-v10, 60 x 60 mm at 20 C, taken through one empty tick, + # Region 14 (rules 13): cellular-v10, 60 x 60 mm at 20 C, taken through one empty tick, # the durable upgrades to rules 11 with light, the liquid upgrade from the mounted # tuning file (whose region size must match) and the revamp upgrade from the mounted # revamp tuning file. 9 pools (500 um radius; a pool feeds at a quarter rate; any in a @@ -50,15 +50,17 @@ spec: # at most 4,096 deposits. The current seed comes from the # commit. The nursery funds 64 primitive founders; rules-12 founders start at random spots # (the 9 sites, 3 mm from pools, are the fallback). - # Genesis is written once: keep --commit stable so every sync resolves it. The world 100 + # Genesis is written once: keep --commit stable so every sync resolves it. + # ADR-0180 reserves IDs 900000003584-900000003615 for the 32 seeded wildlife. Their + # resources come from the nursery, leaving its remainder for players. The # life allocator starts far above the unserved lineage region 1 identities (ADR-0123). - {name: REGION_OPENING, value: cellular-v10} - name: REGION_OPENING_ARGS value: >- - --frame 9 --source-id 1 --commit 5a0d7b3c9e1f2a4b6c8d0e1f2a3b4c5d --light-pj 40 + --frame 9 --source-id 1 --commit a1807b3c9e1f2a4b6c8d0e1f2a3b4c5d --light-pj 40 --tuning /etc/evo/tuning/cellular.tuning --revamp-tuning /etc/evo/tuning/cellular-revamp.tuning - --life-allocator-start 1000000000000 + --life-allocator-start 1000000000000 --playtest-wildlife-first-id 900000003584 --width-um 60000 --height-um 60000 --ambient-temperature-mk 293150 --funding-energy-pj 528588800 --funding-carbon-fg 385024000 --funding-nitrogen-fg 86016000 --funding-phosphorus-fg 44032000 diff --git a/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning b/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning index a71f5ba..63b3eda 100644 --- a/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning +++ b/deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning @@ -1,13 +1,17 @@ # Cellular revamp trial values (rules 13, ADR-0179; Cellular_Revamp_Build_Plan.md). # Same format as cellular.tuning: `key = value`, integers only, `_` may separate digits, -# every key required exactly once. Kept in its own file so images from before rules 13 -# never read keys they do not know. Not yet mounted into the region; see the build plan. +# core keys required exactly once; playtest.* and mutation overrides are optional. +# Mounted for new-region provisioning; an existing region retains its recorded rules. tuning.version = 1 +# DEV opening fixture only (ADR-0180). Zero disables seeding; never replenished on restart. +# Requires an audited --playtest-wildlife-first-id range below --life-allocator-start. +playtest.starting_wildlife_cells = 32 + # Body (body and maintenance plan). body.essential_upkeep_per_mille = 250 # share of upkeep no upkeep-efficiency trait reduces body.reserve_load_per_mille = 1_000 # reserve matter carried as load (slower, costlier thrust) -body.growth_per_tick_centi_mille = 500 # 5 per mille of full size per tick at growth speed 100 +body.growth_per_tick_centi_mille = 625 # 6.25 per mille per tick; 25% faster for playtesting # Energy (feeding and energy plan): what 1,000 fg of reserve matter stands in for when the # reserve's energy runs out. Bubbles carry ~17 pJ of energy per fg of matter, so 2 pJ per fg @@ -50,12 +54,12 @@ mutation.buds_for_adhesion = 5 # on-demand buds before Adhesion is offe # Reproduction (reproduction plan). reproduction.split_share_per_mille = 500 # the offspring's share of a mutation split reproduction.split_min_growth_per_mille = 500 # a cell splits once half grown -reproduction.bud_fee_e_pj = 0 # on-demand bud fee per channel, times the scale; reclaimed -reproduction.bud_fee_c_fg = 0 -reproduction.bud_fee_n_fg = 0 -reproduction.bud_fee_p_fg = 0 -reproduction.bud_fee_o_fg = 0 -reproduction.bud_fee_scale_percent = 0 +reproduction.bud_fee_e_pj = 250_000 # extra fee above the offspring's tissue and provision +reproduction.bud_fee_c_fg = 100_000 +reproduction.bud_fee_n_fg = 30_000 +reproduction.bud_fee_p_fg = 10_000 +reproduction.bud_fee_o_fg = 60_000 +reproduction.bud_fee_scale_percent = 100 # 0 disables the fee; 100 charges the listed amounts reproduction.organism_cap = 256 # births refused at this many lives (an organism counts once) # Multicellular organisms (reproduction plan section 6). diff --git a/docs/PROJECT_VISION.md b/docs/PROJECT_VISION.md index 1c22bcf..31360c2 100644 --- a/docs/PROJECT_VISION.md +++ b/docs/PROJECT_VISION.md @@ -35,6 +35,10 @@ requirements. See [the architecture](architecture/SYSTEM_OVERVIEW.md), ## Recommendations versus experiments +The maintainer's 2026-10-26 test request permits opt-in randomized wildlife roots +only in disposable DEV openings ([ADR-0180](adr/0180-dev-starting-wildlife.md)). +This fixture exception does not change the player-origin requirement for product worlds. + The maintainer clarified structural inheritance, birth-time control choice and NPC-parent continuity on 2026-10-19 in [ADR-0163](adr/0163-structural-inheritance-and-offspring-succession.md). These are diff --git a/docs/STATUS.md b/docs/STATUS.md index 1f98a02..1e3bf2f 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -1,5 +1,16 @@ # Project status and next steps +## DEV startup wildlife and Bud controls - 2026-10-26 + +[ADR-0180](adr/0180-dev-starting-wildlife.md) implements opt-in, nursery-funded +random-genome roots at a fresh rules-13 opening, with deterministic durable +recovery and no replenishment on restart. The DEV trial prepares region 14 with +32 cells, 25% faster funded growth and the existing per-channel budding fee knobs. +Bud disables on resource shortfall and explains all five channels on hover; the +server projection includes the inherited plan and fee. See [tuning and promotion +limits](engineering/CELLULAR_PLAYTEST_TUNING.md) and [validation](engineering/VALIDATION.md). +Source/configuration preparation is distinct from image promotion and deployment. + ## Photosynthesis producers (ADR-0136 step C) - 2026-10-19 [ADR-0175](adr/0175-photosynthesis-producers.md) adds genome schema 5's photosynthesis diff --git a/docs/adr/0180-dev-starting-wildlife.md b/docs/adr/0180-dev-starting-wildlife.md new file mode 100644 index 0000000..4335487 --- /dev/null +++ b/docs/adr/0180-dev-starting-wildlife.md @@ -0,0 +1,41 @@ +# ADR-0180: Opt-in starting wildlife for disposable playtests + +Accepted scoped experiment, 2026-10-26, requested by the maintainer in chat. + +The vision requires player-origin lineages. Random founding wildlife conflicts with +that rule. Resolve this only for explicitly opted-in disposable DEV openings; this +does not change the product rule or authorize a World0 operation. + +The optional revamp tuning key `playtest.starting_wildlife_cells` defaults to zero +and accepts 0–255, below the region's organism cap. Provisioning a nonzero count +also requires `--playtest-wildlife-first-id`, an operator-audited unused identity +range below `--life-allocator-start`. As with ADR-0123, the operator owns the +world-wide identity audit. Never use this range in another region or restored branch +of the same world. The DEV example reserves 900000003584–900000003615 for region 14. + +Seeding is an explicit input to the bundle 14 -> 15 opening upgrade. It requires an +empty region at tick 1, spends nursery resources including construction heat, and +fails atomically on inadequate funding or placement. Roots are unowned test +organisms, with no fabricated player ancestry. Each begins fully grown, undamaged, +with zero spare matter and 30 seconds of full demand as energy, using the same +founder provisioning formula as players. Genome variation uses seeded, bounded +reference indices around the founder, with no acquired modules or free mutations. + +The existing format-11 archive and organism records store the entire result. +Recovery first tries the historical upgrade, then, only for an empty tick-1 source, +reconstructs the fixture from the target's count and first identity and requires +byte equality. No per-tick rule, checkpoint encoding, wire version or golden +changes. Older readers can decode these checkpoints but cannot qualify this new +opening operation; retain the writing build. Existing non-fixture upgrades retain +their exact meaning. Restart and repeated provision never replenish wildlife. + +Alternatives: silently seed product worlds (violates the vision); inject on every +worker start (duplicates stock and breaks history); add a general administrator +spawn protocol (unnecessary scope). Costs: an explicit exception to the no-biology +upgrade convention, extra replay qualification, and finite nursery consumption. +This is fixture coverage, not ecological balance or production qualification. + +The Bud HUD consumes the server's current offspring-plan cost plus the configured +fee. Internal-cell litter displays a conservative maximum because its random draw +occurs at action time. No new simulation or wire version is needed for correcting +this derived presentation. Growth and fee changes remain new-region trial inputs. diff --git a/docs/adr/README.md b/docs/adr/README.md index 44233ba..1e28b36 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -1,5 +1,7 @@ # Architecture decision records +- [ADR-0180: DEV starting wildlife](0180-dev-starting-wildlife.md) - opt-in, nursery-funded random-genome roots for disposable playtest openings, exact recovery and no restart replenishment; a scoped exception to player-origin biology. + - [ADR-0179: Cellular gameplay revamp](0179-cellular-gameplay-revamp.md) - maintainer-accepted direction for rules 13: a 49-mutation catalog with behaviour-weighted offers, mutation splits and stay-or-become reproduction, multicellular organisms and emergence, matter as energy with a region spent pool, per-channel collection, membrane points and heritable body traits; two locked-requirement questions open; implementation pending. - [ADR-0178: Durable liquid regions and session v13](0178-durable-liquid-region.md) - rules 12 on owner format 10 (currents, moving food, liquid motion), raw bundle 14 and schema 58 with a 13 -> 14 upgrade from the Git tuning file, the `cellular-v9` opening and session v13 (motion, currents, brake). diff --git a/docs/architecture/CLIENT_ARCHITECTURE.md b/docs/architecture/CLIENT_ARCHITECTURE.md index 0298e62..d970518 100644 --- a/docs/architecture/CLIENT_ARCHITECTURE.md +++ b/docs/architecture/CLIENT_ARCHITECTURE.md @@ -111,3 +111,9 @@ observations only; optical liquid shading is not a thermal field. Body temperatu ambient temperature and directional heat guidance remain pending authoritative phase-3 state and a negotiated perception contract. Existing public library and wire interfaces are unchanged. + +The [DEV playtest tuning](../engineering/CELLULAR_PLAYTEST_TUNING.md) Bud control +uses the current server-projected charge, including the inherited plan and fee. +Insufficient funding disables it, with a hover tooltip listing required and held +energy, carbon, nitrogen, phosphorus and other matter. Internal-cell litter shows +the maximum possible charge. The server remains authoritative at execution time. diff --git a/docs/engineering/CELLULAR_PLAYTEST_TUNING.md b/docs/engineering/CELLULAR_PLAYTEST_TUNING.md new file mode 100644 index 0000000..337a74d --- /dev/null +++ b/docs/engineering/CELLULAR_PLAYTEST_TUNING.md @@ -0,0 +1,57 @@ +# Cellular playtest opening controls + +These trial settings live in +`deploy/kubernetes/region/dev/tuning/cellular-revamp.tuning`. They are read by +`evo-world-clone provision --opening cellular-v10 --revamp-tuning FILE`; the owner +then retains its recorded rules. Editing the file does not retune an existing +region. Open a fresh disposable region for a changed trial. See [ADR-0180](../adr/0180-dev-starting-wildlife.md). + +| Key | Current DEV value | Meaning | +| --- | --- | --- | +| `playtest.starting_wildlife_cells` | 32 | Initial random-genome cells; 0 disables; max 255 and below the organism cap. Omission defaults to 0 for older files. | +| `body.growth_per_tick_centi_mille` | 625 | 6.25 per thousand per tick at growth speed 100, up from 5: 25% faster when funded. | +| `reproduction.bud_fee_e_pj` | 250000 | Additional energy fee per bud action. | +| `reproduction.bud_fee_c_fg` | 100000 | Additional carbon fee. | +| `reproduction.bud_fee_n_fg` | 30000 | Additional nitrogen fee. | +| `reproduction.bud_fee_p_fg` | 10000 | Additional phosphorus fee. | +| `reproduction.bud_fee_o_fg` | 60000 | Additional other-matter fee. | +| `reproduction.bud_fee_scale_percent` | 100 | Percentage of the listed fee charged; 0 disables it. | + +The fee controls already existed; this change activates and documents them and +corrects the displayed cost to include them. Offspring tissue and starting reserve +remain funded biological costs. Faster growth spends the same resources in less +time; insufficient nutrients can still hold it back. + +The DEV manifest prepares world 100, region 14, with a new stable genesis commit +and `--playtest-wildlife-first-id 900000003584` below +`--life-allocator-start 1000000000000`. This declares a reserved fixture range; +operators must audit its uniqueness across the world's other retained regions. +Regions 1–13 remain stored. Counts other than 32 need a correspondingly audited +range and enough nursery stock. The fixture spends the nursery rather than +minting resources; player founders draw its remainder. + +Each cell uses founder-6 capabilities and full growth, no damage or spare matter, +30 seconds of its own full demand as reserve energy, and a seeded genome with +75–125-point body, collection, burn, engulfment and movement indices. It has no +acquired modules, player account or fabricated ancestry. Randomness is stable +for world, region and identity. Normal autonomous wildlife control takes over. +Recovery and repeated provisioning retain the saved population, including deaths; +they do not top it up. + +Bud uses the current expressed parent and inherited offspring plan, plus the fee; +internal-cell litter conservatively shows its largest possible charge. Hover a +grey Bud button to inspect every required/available channel. A resource-ready +button still submits an intention: growth, placement, regional capacity and +changes before execution can affect the authoritative outcome. + +The region-14 configuration requires an image built from this change before +manual Argo sync. The currently pinned image is not claimed to support the new +opening flag. Build promotion, deployment, live playtesting and identity auditing +against production stores were not performed by these local checks. No World0 +operation is involved. + +Focused durable verification in a new private local PostgreSQL cluster: + +```sh +bash tools/ci/postgres-check.sh --starting-wildlife-only "$PWD/build/playtest-postgres/evo-postgres-tests" +``` diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 0f415c8..e10c667 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -10178,3 +10178,74 @@ Environmental limits and initial failures: The AGENTS.md-required pre-push session-window refresh is desired Git configuration only. No deployment, live reachability, World0 mutation or world reset is claimed. + +## 2026-10-26 - DEV starting wildlife and resource-aware Bud + +Scope: ADR-0180's explicit disposable DEV fixture, cellular opening/recovery, +server-projected budding requirements, native Bud control, and new-region tuning. +Existing unrelated drafts and untracked files were preserved. No golden, per-tick +simulation version, checkpoint encoding or wire layout changed. + +Executed: + +- GCC 14.2 Release with NDEBUG, configured from the release preset with client and + network enabled in build/playtest-release: complete CTest suite 122/122 passed. + Final focused UI-model/owner checks passed 2/2 after a test-only optional-access + cleanup and formatting-only correction in the affected revamp module. +- MSVC 19.44 client preset build succeeded; client CTest 10/10 passed. The final + UI-model cleanup was rebuilt and its test passed again. TMP/TEMP were directed + to ignored build/playtest-windows-tmp for local bindings-file checks. +- Clang 19 ASan+UBSan, existing asan-preset build/client-asan: focused tuning, + owner, UI-model and native panel checks 4/4 passed; final UI-model cleanup 1/1. +- PostgreSQL 18.6, GCC 14 Release with the existing prepared dependency: + tools/ci/postgres-check.sh --starting-wildlife-only against + build/playtest-postgres/evo-postgres-tests passed in a fresh private local + cluster. It published an empty genesis and all prerequisite upgrades, seeded + 32 funded roots, replaced the lease, recovered byte-identical state, published + a real wildlife tick and replayed it identically without adding more cells. +- Parser/owner coverage includes optional count default zero, count bounds, + deterministic genome/placement, ordinary founder endowment rules, exact + conservation, refusal on inadequate nursery stock, invalid identities and + repeated seeding, and restored continuation. Cost checks include the fee; + UI checks cover all five shortfall channels and exact affordability equality. +- Native panels exercise 640x480, 960x640 and 1280x800, including the production + disabled Bud hover tooltip, refusal to click while short, and funded clicking. + A cost-aware fixture exposed Vitals gaining horizontal overflow after restore; + fixed content width and a reserved vertical scrollbar resolved it. +- Repository format-check passed with clang-format 19. A pre-existing formatting + violation in the affected cellular_revamp.cpp was corrected. git diff --check + passed. Rendered deployment policy passed (75 source objects, 140 rendered + objects, 17 overlays); its 50-case fail-closed self-test passed. + +Limits and initial failures: + +- The Windows debug build stopped with MSVC C1902 (program-database manager + mismatch) before compiling the changed code; the Windows Release client build + and Linux Release/sanitizer builds succeeded. No debug pass is claimed. +- Initial compiler and static-analysis failures (a missing draft initializer and + optional-access checks), plus the native layout/hover fixture failures, were + corrected before the successful checks above. An initial sanitizer compile + overlapped a header formatting write; the stable-source rerun passed. +- These are local fixtures, not live gameplay, ecological balance, hardware + performance, or production-store identity-audit evidence. DEV region 14 needs + a compatible image promotion before manual Argo sync. No deployment, live + reachability, World0 change, reset or pruning was performed. The AGENTS.md + pre-push session-window refresh is desired Git configuration only. + +Final static analysis: the analysis preset in build/playtest-analysis built the +changed lifecycle, tuning, persistence, bootstrap and client targets, plus their +regressions, with clang-tidy 19 and warnings as errors. Its focused CTests passed +5/5 and the isolated PostgreSQL opening/recovery check passed again. A pre-existing +unchecked optional access in the touched UI-model test was rewritten through its +existing checked helper. Changed C++ files also passed clang-format 19 dry-run. +The actual QUIC-enabled evo-server also built successfully in build/tidy-postgres. +A separate clang-tidy-19 run on its main translation unit, with an explicit +cellular_bridge.hpp header filter and warnings as errors, passed. It required a +pre-existing optional-feedback access to be made local before checking/reading. +The bridge header passed the Linux clang-format 19 dry-run (minor formatter +versions differ on an existing multiline lambda's wrapping). + +Publication limit: the scoped commit was created locally, but the configured HTTPS +remote rejected git push with an authentication failure. Git Credential Manager +is configured; no stored credential was deleted or changed. A user-authorized retry uses credentials supplied outside the repository. Unrelated drafts and untracked files +remain outside the commit. diff --git a/include/evo/biology/cellular_revamp_tuning.hpp b/include/evo/biology/cellular_revamp_tuning.hpp index dd0e998..e7064d4 100644 --- a/include/evo/biology/cellular_revamp_tuning.hpp +++ b/include/evo/biology/cellular_revamp_tuning.hpp @@ -13,14 +13,16 @@ // Git-managed trial values for the cellular revamp (rules 13, ADR-0179), in their own file // beside the rules-12 tuning file so older images never meet keys they do not know. Same -// format and rules: plain `key = value` integer lines, every key required exactly once and -// range-checked. Later build phases add feeding, mutation and reproduction keys. +// format: plain `key = value` integer lines, range-checked; core keys required once, +// per-mutation overrides and the zero-default DEV opening count optional. namespace evo::biology { inline constexpr std::int64_t cellular_revamp_tuning_version = 1; inline constexpr std::size_t max_cellular_revamp_tuning_bytes = std::size_t{256} * 1'024; struct CellularRevampTuning { std::int64_t version{}; + // Optional DEV opening fixture; zero preserves unseeded, player-origin worlds. + std::int64_t playtest_starting_wildlife_cells{}; // Body: the share of upkeep no upkeep-efficiency trait reduces. std::int64_t body_essential_upkeep_per_mille{}; // Body: share of reserve matter carried as load on handling and thrust costs. diff --git a/include/evo/persistence/checkpoint_store.hpp b/include/evo/persistence/checkpoint_store.hpp index 6b8880b..161f5d4 100644 --- a/include/evo/persistence/checkpoint_store.hpp +++ b/include/evo/persistence/checkpoint_store.hpp @@ -297,7 +297,9 @@ migrate_cellular_liquid_profile(Postgres&, const FilesystemObjectStore&, const L migrate_cellular_revamp_profile(Postgres&, const FilesystemObjectStore&, const LeaseGrant&, const CommittedCheckpoint&, Uuid commit, const Sha256Digest& build, const server::CellularRevampRules& rules, - std::chrono::milliseconds timeout, const PublishHooks& hooks = {}); + std::chrono::milliseconds timeout, const PublishHooks& hooks = {}, + std::uint32_t playtest_wildlife_count = 0, + std::uint64_t playtest_first_identity = 0); // Verify the recorded no-tick operation under current authority, replaying its // entire source/target payload. Version upgrades and profile transitions retain // separate evidence; neither is inferred solely from the target tuple. diff --git a/include/evo/persistence/region_checkpoint.hpp b/include/evo/persistence/region_checkpoint.hpp index 4f97a94..54fa73f 100644 --- a/include/evo/persistence/region_checkpoint.hpp +++ b/include/evo/persistence/region_checkpoint.hpp @@ -310,7 +310,8 @@ cellular_liquid_upgrade_payload(std::span payload, const CheckpointManifest& predecessor, const server::CellularLiquidRules& rules); // Rules 13 (ADR-0179): explicit raw-only bundle 14 -> 15 upgrade declaring the revamp rules -// from the Git tuning file. The rules are the only input; recovery reads them from the target. +// from the Git tuning file. ADR-0180 also admits an explicit empty-opening fixture; +// recovery reads its count/first identity from the target and re-derives every byte. [[nodiscard]] std::expected cellular_revamp_upgrade_manifest(const CheckpointManifest& predecessor, const Sha256Digest& predecessor_digest, Uuid commit, @@ -319,7 +320,9 @@ cellular_revamp_upgrade_manifest(const CheckpointManifest& predecessor, [[nodiscard]] std::expected, CheckpointError> cellular_revamp_upgrade_payload(std::span payload, const CheckpointManifest& predecessor, - const server::CellularRevampRules& rules); + const server::CellularRevampRules& rules, + std::uint32_t playtest_wildlife_count = 0, + std::uint64_t playtest_first_identity = 0); // ADR-0174: explicit one-way, no-tick profile 5 -> 6 transition. The payload wraps the // identical population with its declared environment; bundle and policy are unchanged. [[nodiscard]] std::expected diff --git a/include/evo/server/lifecycle/cellular_lives.hpp b/include/evo/server/lifecycle/cellular_lives.hpp index f87e614..076743b 100644 --- a/include/evo/server/lifecycle/cellular_lives.hpp +++ b/include/evo/server/lifecycle/cellular_lives.hpp @@ -346,9 +346,15 @@ class CellularLives { liquid_upgrade_candidate(const CellularLiquidRules& rules) const; // Rules 13: explicit no-tick format-10/rules-12 -> format-11/rules-13 upgrade declaring the // region's revamp rules. Existing lives keep their genomes; founders born afterwards are - // founder 6. + // founder 6. ADR-0180 optionally seeds nursery-funded DEV roots in an empty tick-1 + // opening. Count zero with first identity zero retains the historical upgrade. [[nodiscard]] std::expected, CellularLivesError> - revamp_upgrade_candidate(const CellularRevampRules& rules) const; + revamp_upgrade_candidate(const CellularRevampRules& rules, + std::uint32_t playtest_wildlife_count = 0, + std::uint64_t playtest_first_identity = 0) const; + // Exact displayed charge, including inherited plan, rules-13 fee and internal tissue. + // Internal litter reports the maximum possible charge (the draw occurs at action time). + [[nodiscard]] std::optional budding_cost(std::uint64_t life_id) const; // Format 11: the declared revamp rules (defaults before). [[nodiscard]] const CellularRevampRules& revamp_rules() const noexcept; // Format 10: the declared liquid rules and the current field they generate (null before). diff --git a/schemas/network/session-v14-cellular-revamp.md b/schemas/network/session-v14-cellular-revamp.md index 3d40811..68297a2 100644 --- a/schemas/network/session-v14-cellular-revamp.md +++ b/schemas/network/session-v14-cellular-revamp.md @@ -23,6 +23,14 @@ energy (matter only; the energy entry is zero). Without an owner life every field is zero. +The inherited prefix's bud-cost fields project the current expressed parent and +offspring-plan investment plus the region's configured fee. For an organism's +internal-cell bud they project tissue construction and fee for the largest +possible litter, since the draw happens at execution time. Zero cost means that +requirements are unavailable or the genome cannot bud. This corrects derived +values without changing the wire layout. Clients may disable Bud when any reserve +channel is below the projected requirement; the server still decides the result. + **Cellular action.** Byte 37 (the v13 flags) adds bit 1 become (only with a bud: the player continues as the bud) and bit 2 emerge (only with no target). Byte 38 is the exclusion mask (0-15). The canonical 24-byte action input stores them as byte 13 bits 1-2 and byte 14 diff --git a/src/biology/cellular_revamp_tuning.cpp b/src/biology/cellular_revamp_tuning.cpp index c4895c0..f3c2552 100644 --- a/src/biology/cellular_revamp_tuning.cpp +++ b/src/biology/cellular_revamp_tuning.cpp @@ -18,6 +18,8 @@ constexpr std::int64_t amount_limit = 1'000'000'000'000'000'000; // pJ or fg per // Schema order is the canonical encoding order. constexpr std::array fields{ Field{"tuning.version", &CellularRevampTuning::version, 1, 1'000}, + Field{"playtest.starting_wildlife_cells", + &CellularRevampTuning::playtest_starting_wildlife_cells, 0, 255}, Field{"body.essential_upkeep_per_mille", &CellularRevampTuning::body_essential_upkeep_per_mille, 0, 1'000}, Field{"body.reserve_load_per_mille", &CellularRevampTuning::body_reserve_load_per_mille, 0, @@ -244,12 +246,15 @@ parse_cellular_revamp_tuning(std::string_view text) { tuning.*field.member = *value; } for (std::size_t index = 0; index < fields.size(); ++index) - if (!seen.at(index)) + if (!seen.at(index) && fields.at(index).key != "playtest.starting_wildlife_cells") return std::unexpected{ error(CellularTuningErrorKind::missing_key, 0, fields.at(index).key)}; if (tuning.version != cellular_revamp_tuning_version) return std::unexpected{ error(CellularTuningErrorKind::unsupported_version, 0, "tuning.version")}; + if (tuning.playtest_starting_wildlife_cells >= tuning.reproduction_organism_cap) + return std::unexpected{ + error(CellularTuningErrorKind::inconsistent, 0, "playtest.starting_wildlife_cells")}; if (tuning.mutation_floor_ppm > tuning.mutation_cap_ppm || tuning.mutation_min_points >= tuning.mutation_max_points) return std::unexpected{ diff --git a/src/persistence/cellular_checkpoint_store.cpp b/src/persistence/cellular_checkpoint_store.cpp index c46c8c6..2a25548 100644 --- a/src/persistence/cellular_checkpoint_store.cpp +++ b/src/persistence/cellular_checkpoint_store.cpp @@ -403,11 +403,13 @@ std::expected migrate_cell std::expected migrate_cellular_revamp_profile( Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease, const CommittedCheckpoint& predecessor, Uuid commit, const Sha256Digest& build, - const server::CellularRevampRules& rules, milliseconds timeout, const PublishHooks& hooks) { + const server::CellularRevampRules& rules, milliseconds timeout, const PublishHooks& hooks, + std::uint32_t count, std::uint64_t first) { return migrate_rules_profile( db, objects, lease, predecessor, commit, build, timeout, hooks, - [rules](std::span payload, const CheckpointManifest& previous) { - return cellular_revamp_upgrade_payload(payload, previous, rules); + [rules, count, first](std::span payload, + const CheckpointManifest& previous) { + return cellular_revamp_upgrade_payload(payload, previous, rules, count, first); }, cellular_revamp_upgrade_manifest); } @@ -722,6 +724,13 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob if (!target) return fail(RecoveryError::payload); auto upgraded = cellular_revamp_upgrade_payload(*bytes, *source, (*target)->revamp_rules()); + if (upgraded && !std::ranges::equal(*upgraded, payload) && !(*target)->lives().empty()) { + // ADR-0180: the only additional opening input is the explicit fixture identity range. + upgraded = cellular_revamp_upgrade_payload( + *bytes, *source, (*target)->revamp_rules(), + static_cast((*target)->lives().size()), + (*target)->lives().front().identity.life); + } if (!upgraded || !std::ranges::equal(*upgraded, payload)) return fail(RecoveryError::history); } else if (liquid) { diff --git a/src/persistence/population_checkpoint.cpp b/src/persistence/population_checkpoint.cpp index e4dc6f7..509b39d 100644 --- a/src/persistence/population_checkpoint.cpp +++ b/src/persistence/population_checkpoint.cpp @@ -261,10 +261,9 @@ cellular_revamp_upgrade_manifest(const CheckpointManifest& previous, return upgrade_manifest(previous, previous_digest, commit, lease, build, bytes, digest, cellular_v14_versions, cellular_v15_versions); } -std::expected, CheckpointError> -cellular_revamp_upgrade_payload(std::span payload, - const CheckpointManifest& previous, - const server::CellularRevampRules& rules) { +std::expected, CheckpointError> cellular_revamp_upgrade_payload( + std::span payload, const CheckpointManifest& previous, + const server::CellularRevampRules& rules, std::uint32_t count, std::uint64_t first) { if (!supported(previous) || previous.profile != CheckpointProfile::cellular_lives_v1 || previous.cellular_versions != cellular_v14_versions) return std::unexpected(CheckpointError::unsupported); @@ -273,7 +272,7 @@ cellular_revamp_upgrade_payload(std::span payload, auto state = restore_cellular_payload(payload, previous); if (!state) return std::unexpected(state.error()); - auto upgraded = (*state)->revamp_upgrade_candidate(rules); + auto upgraded = (*state)->revamp_upgrade_candidate(rules, count, first); if (!upgraded) return std::unexpected(CheckpointError::payload); return (*upgraded)->snapshot(); diff --git a/src/server/lifecycle/cellular_lives.cpp b/src/server/lifecycle/cellular_lives.cpp index 6e893c7..9c8d8a0 100644 --- a/src/server/lifecycle/cellular_lives.cpp +++ b/src/server/lifecycle/cellular_lives.cpp @@ -1281,7 +1281,8 @@ const CellularLiquidRules& CellularLives::liquid_rules() const noexcept { return state_->liquid; } std::expected, CellularLivesError> -CellularLives::revamp_upgrade_candidate(const CellularRevampRules& rules) const { +CellularLives::revamp_upgrade_candidate(const CellularRevampRules& rules, std::uint32_t count, + std::uint64_t first) const { if (state_->format_version != cellular_lives_liquid_format || state_->rules_version != cellular_lives_liquid_rules) return std::unexpected{CellularLivesError::version}; @@ -1294,7 +1295,154 @@ CellularLives::revamp_upgrade_candidate(const CellularRevampRules& rules) const next.format_version = cellular_lives_revamp_format; next.rules_version = cellular_lives_revamp_rules; next.revamp = rules; - return candidate; + if (count == 0) + return first == 0 ? std::move(candidate) : std::unexpected{CellularLivesError::identity}; + // ADR-0180: only an explicit, empty opening may contain fixture roots. + if (tick() != 1 || !next.lives.empty() || !next.corpses.empty() || + next.archive.archived() != 0 || count >= rules.organism_cap || count > 255 || first == 0 || + first > cellular_bud_namespace - count) + return std::unexpected{CellularLivesError::invalid_config}; + for (std::uint32_t index = 0; index < count; ++index) { + const auto id = first + index; + const auto founder = biology::primitive_founder(id, id, biology::primitive_founder_v6); + if (!founder) + return std::unexpected{CellularLivesError::biology}; + biology::GenomeDraft draft{ + .id = id, + .origin_event = id, + .development_version = 7, + .parents = {}, + .capabilities = {founder->capabilities().begin(), founder->capabilities().end()}, + .schema_version = biology::genome_schema_v7, + .movement_arrangement = biology::founder_movement_arrangement, + .cellular_traits = biology::founder_cellular_traits}; + Random random{mutation_seed(world(), region(), id, 0x57494C44U)}; + const auto points = [&] { return static_cast(75 + random.next() % 51); }; + auto& traits = *draft.cellular_traits; + traits.density = points(); + traits.upkeep_efficiency = points(); + traits.growth_speed = points(); + for (auto& channel : traits.collection) + channel = points(); + for (auto& channel : traits.burn) + channel = points(); + traits.engulf_capacity = points(); + traits.kill_absorption = points(); + auto& movement = *draft.movement_arrangement; + movement.output = points(); + movement.efficiency = points(); + movement.steering = points(); + movement.streamlining = points(); + movement.braking = points(); + movement.coasting = points(); + const auto genome = biology::Genome::create(draft); + const auto budget = + genome ? biology::metabolic_budget(*genome, {1000, 0}, + {next.config.ambient_temperature_millikelvin, {}}, + 1000, rules.body) + : std::unexpected{biology::DevelopmentError::overflow}; + if (!budget) + return std::unexpected{CellularLivesError::biology}; + // A normal founder's starting provision, evaluated for its randomized genome. + const accounting::Inventory reserve{ + {budget->demand.value * biology::founder_reserve_seconds}, {}}; + auto empty_body = accounting::Inventory{}; + auto nursery = next.nursery; + auto heat = next.heat; + const auto development = biology::rules_for(genome->development_version()); + if (!development || !subtract_inventory(nursery, reserve) || + !rebody(empty_body, nursery, heat, budget->body, + development->construction_per_kilogram)) + return std::unexpected{CellularLivesError::insufficient_funding}; + const auto extent = budget->phenotype.extent; + if (next.config.area.width_um <= extent + 2000 || + next.config.area.height_um <= extent + 2000) + return std::unexpected{CellularLivesError::no_placement}; + std::optional position; + for (int attempt = 0; attempt < 1024 && !position; ++attempt) { + const biology::CellularPosition spot{ + 1000 + random.next() % (next.config.area.width_um - extent - 2000), + 1000 + random.next() % (next.config.area.height_um - extent - 2000)}; + bool occupied = false; + for (const auto& other : next.lives) { + const auto body = budget_for( + next.archive, other, next.config.ambient_temperature_millikelvin, rules.body); + if (!body) + return std::unexpected{CellularLivesError::biology}; + const auto side = body->phenotype.extent; + occupied = occupied || (spot.x_um < other.position.x_um + side && + other.position.x_um < spot.x_um + extent && + spot.y_um < other.position.y_um + side && + other.position.y_um < spot.y_um + extent); + } + if (!occupied) + position = spot; + } + if (!position) + return std::unexpected{CellularLivesError::no_placement}; + if (!next.archive.admit(*genome) || !next.archive.record_birth(id, id, {tick()})) + return std::unexpected{CellularLivesError::archive}; + CellularOwnedLife life{}; + life.identity = {id, id, id, id, {tick()}}; + life.source = next.nursery_config.source; + life.growth = {1000, 0}; + life.position = *position; + life.body = budget->body; + life.reserve = reserve; + life.offspring_genome = id; + next.lives.push_back(life); + next.nursery = nursery; + next.nursery_config.funding = nursery; + next.heat = heat; + } + // Restore validates bodies, identities, history and channel-by-channel closure. + return restore((*candidate)->snapshot(), world(), region(), frame(), tick()); +} + +std::optional CellularLives::budding_cost(std::uint64_t id) const { + const auto life = + std::ranges::find(state_->lives, id, [](const auto& value) { return value.identity.life; }); + if (life == state_->lives.end()) + return std::nullopt; + const auto parent = state_->archive.find(life->identity.genome); + const auto child = state_->archive.find(cellular_offspring_genome(*life)); + if (!parent || !child) + return std::nullopt; + if (state_->rules_version < cellular_lives_revamp_rules) + return biology::offspring_cost(*parent, *child, ambient_temperature_millikelvin()); + auto cost = + cellular_mutation_cost({.cost = state_->revamp.bud_fee, + .cost_scale_percent = state_->revamp.bud_fee_scale_percent}); + if (life->revamp.members == 1) { + const auto investment = + biology::offspring_cost(*parent, *child, ambient_temperature_millikelvin()); + if (!investment || !add_inventory(cost, *investment)) + return std::nullopt; + } else { + const auto traits = parent->cellular_traits().value_or(biology::founder_cellular_traits); + const auto added = std::min(1 + (traits.litter + 99U) / 100U, + 1 + state_->revamp.bounds.max_litter / 100U); + const auto grown = organism_genome(*parent, life->revamp.members + added); + const auto target = grown + ? biology::metabolic_budget(*grown, life->growth, + {ambient_temperature_millikelvin(), {}}, + 1000, state_->revamp.body) + : std::unexpected{biology::DevelopmentError::overflow}; + const auto development = biology::rules_for(parent->development_version()); + if (!target || !development) + return std::nullopt; + std::uint64_t mass{}; + for (std::size_t c = 0; c < cost.matter.size(); ++c) { + const auto difference = target->body.matter[c].value > life->body.matter[c].value + ? target->body.matter[c].value - life->body.matter[c].value + : 0; + cost.matter[c].value += difference; + mass += difference; + } + const auto price = development->construction_per_kilogram; + cost.energy.value += mass / 1000 * price + mass % 1000 * price / 1000; + } + return cost; } const CellularRevampRules& CellularLives::revamp_rules() const noexcept { return state_->revamp; diff --git a/src/server/lifecycle/cellular_revamp.cpp b/src/server/lifecycle/cellular_revamp.cpp index 6e134df..2311592 100644 --- a/src/server/lifecycle/cellular_revamp.cpp +++ b/src/server/lifecycle/cellular_revamp.cpp @@ -51,9 +51,8 @@ bool cellular_revamp_valid(const CellularRevampRules& rules) noexcept { rules.split_share_per_thousand < 1'000 && rules.split_min_growth != 0 && rules.split_min_growth <= 1'000 && rules.bud_fee_scale_percent <= 100 && rules.bud_fee.energy.value <= most && - std::ranges::all_of( - rules.bud_fee.matter, - [](const accounting::Femtograms& f) { return f.value <= most; }) && + std::ranges::all_of(rules.bud_fee.matter, + [](const accounting::Femtograms& f) { return f.value <= most; }) && rules.organism_cap != 0 && rules.organism_cap <= biology::max_cellular_tick_lives && rules.organism_load_per_thousand <= 10'000 && rules.emerge_members >= 2 && rules.emerge_members <= 10'000 && rules.emerge_mass_fg <= most && diff --git a/tests/cellular_publication_tests.cpp b/tests/cellular_publication_tests.cpp index 591d5cc..df5b98e 100644 --- a/tests/cellular_publication_tests.cpp +++ b/tests/cellular_publication_tests.cpp @@ -4,6 +4,7 @@ #include "evo/persistence/life_reservation_store.hpp" #include "evo/persistence/sha256.hpp" #include "evo/server/cellular_region_host.hpp" +#include "fixtures/cellular_ecology.hpp" #ifdef EVO_POSTGRES_M10 #include "evo/server/cellular_session_batch.hpp" #endif @@ -20,6 +21,7 @@ #include void run_cellular_publication_tests(); +void run_starting_wildlife_publication_tests(); namespace { using namespace evo::persistence; using namespace evo::server; @@ -1221,6 +1223,7 @@ void cellular_death_is_final_and_account_restarts() { } // namespace void run_cellular_publication_tests() { + run_starting_wildlife_publication_tests(); cellular_birth_publication_is_durable(); cellular_profile_migration_is_durable_and_recovers_without_a_tick(); cellular_mutation_publication_binds_results(); @@ -1412,3 +1415,86 @@ void run_cellular_publication_tests() { restarted_committed_value.head.sequence == 2); restarted->drain(); } + +void run_starting_wildlife_publication_tests() { + auto source = evo::fixture::opening(980, true, 64, false, 14); + const RegionKey key{source->world(), source->region()}; + auto owner = connect_as(env("PGUSER")); + auto runtime = connect_as(env("EVO_PG_RUNTIME_USER")); + const auto build = filled<32>(0xD9); + CHECK(owner->query("INSERT INTO evolution.retained_builds(build_identity) VALUES " + "(decode(repeat('d9',32),'hex')) ON CONFLICT DO NOTHING", + {}, 5s)); + const auto identity = [](std::uint8_t index) { + auto id = filled<16>(0x18); + id.back() = index; + return id; + }; + auto objects = FilesystemObjectStore::open(env("PGHOST"), key, max_cellular_lives_bytes); + CHECK(objects); + auto genesis = + provision_cellular_region(*owner, **objects, key, 1, *source, identity(0), build, 5s); + CHECK(genesis); + auto head = *genesis; + auto lease = acquire_region_lease(*runtime, key, build, 60s, 5s); + CHECK(lease); + CellularBatch batch{{key.world, key.region, 1, head.head.commit, head.head.digest, 0, 1}, {{}}}; + CHECK(source->advance_tick({})); + auto first = publish_cellular_batch(*runtime, **objects, *lease, head, batch, *source, + identity(1), build, 5s); + CHECK(first); + head = first->committed; + const auto advance = [&](auto result) { + CHECK(result); + head = *result; + }; + advance(migrate_cellular_boundary_profile(*runtime, **objects, *lease, head, identity(2), build, + 5s)); + advance(migrate_cellular_maturation_profile(*runtime, **objects, *lease, head, identity(3), + build, 5s)); + advance(migrate_cellular_inheritance_profile(*runtime, **objects, *lease, head, identity(4), + build, 5s)); + advance(migrate_cellular_photosynthesis_profile(*runtime, **objects, *lease, head, identity(5), + build, {0, 1, {0}}, 5s)); + CellularLiquidRules liquid{ + .currents = {5, 48'000, 48'000, 250, 2, 4, 3000, 6000, 60, 300}, + .founder = {.thrust_q10 = 20'480, + .reverse_thrust_q10 = 20'480, + .forward_drag_ppm = 95'163, + .lateral_drag_ppm = 95'163, + .turn = 3'276}, + .deposits = {.drift_radius_um = 200, + .max_drift_q10 = 100 * 1024, + .drift_decay_ppm = 95'163, + .merged_cap = 8, + .bubble_radius_um = evo::biology::cellular_mote_radius_um}}; + advance(migrate_cellular_liquid_profile(*runtime, **objects, *lease, head, identity(6), build, + liquid, 5s)); + const std::array builds{build}; + auto before = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s); + CHECK(before && before->state->lives().empty()); + CellularRevampRules rules; + auto expected = before->state->revamp_upgrade_candidate(rules, 32, 900'000); + CHECK(expected); + advance(migrate_cellular_revamp_profile(*runtime, **objects, *lease, head, identity(7), build, + rules, 5s, {}, 32, 900'000)); + const auto opening_bytes = (*expected)->snapshot(); + CHECK(release_region_lease(*runtime, key, *lease, 5s)); + lease = acquire_region_lease(*runtime, key, build, 60s, 5s); + CHECK(lease); + auto recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s); + CHECK(recovered && recovered->state->snapshot() == opening_bytes && + recovered->state->lives().size() == 32 && recovered->state->tick() == 1); + batch = {{key.world, key.region, 1, head.head.commit, head.head.digest, 1, 2}, {{}}}; + batch.ticks.front().lives = checked_value(wildlife_intents(*recovered->state, 2)); + CHECK(recovered->state->advance_tick(batch.ticks.front().lives)); + const auto tick_bytes = recovered->state->snapshot(); + auto tick = publish_cellular_batch(*runtime, **objects, *lease, head, batch, *recovered->state, + identity(8), build, 5s); + CHECK(tick); + recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s); + CHECK(recovered && recovered->state->snapshot() == tick_bytes && + recovered->state->lives().size() == 32); + CHECK(release_region_lease(*runtime, key, *lease, 5s)); + std::puts("starting wildlife publication and replacement-owner replay passed"); +} diff --git a/tests/cellular_revamp_owner_tests.cpp b/tests/cellular_revamp_owner_tests.cpp index adb1cb9..2a30d30 100644 --- a/tests/cellular_revamp_owner_tests.cpp +++ b/tests/cellular_revamp_owner_tests.cpp @@ -1,3 +1,5 @@ +#include "evo/biology/budding.hpp" +#include "evo/biology/founder.hpp" #include "evo/server/lifecycle/cellular_batch.hpp" #include "evo/server/lifecycle/cellular_play_summary.hpp" #include "fixtures/cellular_ecology.hpp" @@ -72,7 +74,10 @@ LifeAccount account(std::uint8_t last) { } // A rules-13 region with a founder 5 born before the upgrade and a founder 6 born after it. -Owner revamp_region(std::uint32_t essential = 250) { +Owner revamp_region(std::uint32_t essential = 250, std::uint64_t fee_pj = 0) { + auto rules = revamp(essential); + rules.bud_fee.energy.value = fee_pj; + rules.bud_fee_scale_percent = fee_pj == 0 ? 0 : 100; auto state = opening(7, true, 2, false); // Funds two founders. checked(state->advance_tick({}), "genesis tick"); state = checked(state->migration_upgrade_candidate(), "boundary upgrade"); @@ -84,10 +89,10 @@ Owner revamp_region(std::uint32_t essential = 250) { state = checked(state->birth_candidate({account(1), 1}, {100, 100, 100, 100, {state->tick()}}), "founder 5 birth"); require(!state->revamp_upgrade_candidate(revamp(1'001)), "an invalid essential share accepted"); - state = checked(state->revamp_upgrade_candidate(revamp(essential)), "revamp upgrade"); + state = checked(state->revamp_upgrade_candidate(rules), "revamp upgrade"); require(state->format_version() == cellular_lives_revamp_format && state->rules_version() == cellular_lives_revamp_rules && - state->revamp_rules() == revamp(essential) && state->liquid_rules() == liquid() && + state->revamp_rules() == rules && state->liquid_rules() == liquid() && state->flow_field() != nullptr && !state->revamp_upgrade_candidate(revamp()), "revamp upgrade repeated, wrong versions or lost rules"); state = checked(state->birth_candidate({account(2), 1}, {101, 101, 101, 101, {state->tick()}}), @@ -125,6 +130,85 @@ void closed(const CellularLives& state) { require(state.current_total() == expected, "revamp region broke closure"); } +void starting_wildlife_is_a_funded_opening() { + auto source = opening(77, true, 64, false); + checked(source->advance_tick({}), "opening tick"); + source = checked(source->migration_upgrade_candidate(), "boundary"); + source = checked(source->maturation_upgrade_candidate(), "maturation"); + source = checked(source->inheritance_upgrade_candidate(), "inheritance"); + source = checked(source->photosynthesis_upgrade_candidate({0, 1, {0}}), "light"); + source = checked(source->liquid_upgrade_candidate(liquid()), "liquid"); + const auto before = source->snapshot(); + auto seeded = checked(source->revamp_upgrade_candidate(revamp(), 32, 900'000), "wildlife"); + require(source->snapshot() == before && seeded->lives().size() == 32, + "seeding changed source or count"); + auto again = checked(source->revamp_upgrade_candidate(revamp(), 32, 900'000), "same seed"); + require(again->snapshot() == seeded->snapshot(), "opening is not deterministic"); + require(!seeded->revamp_upgrade_candidate(revamp(), 32, 900'000), "reseeded a region"); + require(!source->revamp_upgrade_candidate(revamp(), 256, 900'000), "accepted excessive count"); + require(!source->revamp_upgrade_candidate(revamp(), 1, 0), "accepted zero identity"); + require(!source->revamp_upgrade_candidate(revamp(), 1, cellular_bud_namespace), + "accepted bud namespace for a root"); + require(!source->revamp_upgrade_candidate(revamp(), 0, 900'000), "accepted unused identity"); + require(restore(*seeded)->snapshot() == seeded->snapshot(), "fixture restore diverged"); + bool varied = false; + for (const auto& life : seeded->lives()) { + const auto genome = seeded->archive().find(life.identity.genome); + require(genome && life.account == LifeAccount{} && life.parent_life == 0 && + life.growth == biology::GrowthState{1000, 0} && + life.reserve.matter == accounting::Inventory{}.matter, + "fixture changed founder starting rules"); + const auto budget = + checked(biology::metabolic_budget(*genome, life.growth, + {seeded->ambient_temperature_millikelvin(), {}}, 1000, + seeded->revamp_rules().body), + "wildlife budget"); + require(life.reserve.energy.value == + budget.demand.value * biology::founder_reserve_seconds && + life.body == budget.body && life.offspring_genome == genome->id(), + "wildlife endowment or inherited plan wrong"); + varied = varied || genome->cellular_traits() != biology::founder_cellular_traits; + } + require(varied && seeded->nursery() != source->nursery(), "wildlife was free or unvaried"); + closed(*seeded); + for (int tick = 0; tick < 5; ++tick) { + const auto intents = + checked(wildlife_intents(*seeded, seeded->tick() + 1), "wildlife intents"); + checked(seeded->advance_tick(intents), "wildlife tick"); + closed(*seeded); + } + require(restore(*seeded)->snapshot() == seeded->snapshot(), "running fixture restore"); + auto poor = opening(77, true, 1, false); + checked(poor->advance_tick({}), "poor tick"); + poor = checked(poor->migration_upgrade_candidate(), "poor boundary"); + poor = checked(poor->maturation_upgrade_candidate(), "poor maturation"); + poor = checked(poor->inheritance_upgrade_candidate(), "poor inheritance"); + poor = checked(poor->photosynthesis_upgrade_candidate({0, 1, {0}}), "poor light"); + poor = checked(poor->liquid_upgrade_candidate(liquid()), "poor liquid"); + const auto poor_before = poor->snapshot(); + require(!poor->revamp_upgrade_candidate(revamp(), 32, 900'000) && + poor->snapshot() == poor_before, + "insufficient nursery was not atomic"); +} + +void shown_bud_charge_includes_the_fee() { + auto state = revamp_region(); + const auto& life = state->lives().back(); + const auto genome = state->archive().find(life.identity.genome); + require(genome.has_value(), "founder genome"); + require(state->budding_cost(life.identity.life) == + biology::bud_cost(*genome, state->ambient_temperature_millikelvin()), + "zero-fee founder charge changed"); + require(!state->budding_cost(999'999), "cost for missing life"); + auto paid = revamp_region(250, 250'000); + const auto shown = state->budding_cost(life.identity.life); + if (!shown) + throw std::runtime_error("missing shown cost"); + auto expected = shown.value(); + expected.energy.value += 250'000; + require(paid->budding_cost(life.identity.life) == expected, "shown charge omitted the fee"); +} + void upgrade_and_restore() { const auto state = revamp_region(400); const auto copy = restore(*state); @@ -680,6 +764,8 @@ void trace_replays() { } // namespace int main() try { + starting_wildlife_is_a_funded_opening(); + shown_bud_charge_includes_the_fee(); upgrade_and_restore(); mixed_generations_tick_and_continue(); the_spent_pool_drips_back(); diff --git a/tests/cellular_revamp_tuning_tests.cpp b/tests/cellular_revamp_tuning_tests.cpp index 2ed1781..857dd97 100644 --- a/tests/cellular_revamp_tuning_tests.cpp +++ b/tests/cellular_revamp_tuning_tests.cpp @@ -19,9 +19,10 @@ void check(bool condition, std::source_location at = std::source_location::curre CellularRevampTuning trial() { CellularRevampTuning t{.version = 1, + .playtest_starting_wildlife_cells = 32, .body_essential_upkeep_per_mille = 250, .body_reserve_load_per_mille = 1'000, - .body_growth_per_tick_centi_mille = 500, + .body_growth_per_tick_centi_mille = 625, .energy_burn_carbon_pj_per_kfg = 2'000, .energy_burn_nitrogen_pj_per_kfg = 2'000, .energy_burn_phosphorus_pj_per_kfg = 2'000, @@ -49,12 +50,12 @@ CellularRevampTuning trial() { .mutation_buds_for_adhesion = 5, .reproduction_split_share_per_mille = 500, .reproduction_split_min_growth_per_mille = 500, - .reproduction_bud_fee_e_pj = 0, - .reproduction_bud_fee_c_fg = 0, - .reproduction_bud_fee_n_fg = 0, - .reproduction_bud_fee_p_fg = 0, - .reproduction_bud_fee_o_fg = 0, - .reproduction_bud_fee_scale_percent = 0, + .reproduction_bud_fee_e_pj = 250'000, + .reproduction_bud_fee_c_fg = 100'000, + .reproduction_bud_fee_n_fg = 30'000, + .reproduction_bud_fee_p_fg = 10'000, + .reproduction_bud_fee_o_fg = 60'000, + .reproduction_bud_fee_scale_percent = 100, .reproduction_organism_cap = 256, .organism_load_per_mille = 500, .organism_emerge_members = 8, @@ -130,6 +131,14 @@ void canonical_round_trip() { void refusals() { const auto base = encode_cellular_revamp_tuning(trial()); + CHECK(error_of(with(base, "playtest.starting_wildlife_cells", "256")) == + CellularTuningErrorKind::out_of_range); + CHECK(error_of(with(base, "playtest.starting_wildlife_cells", "-1")) == + CellularTuningErrorKind::out_of_range); + auto legacy = base; + const auto start = legacy.find("playtest.starting_wildlife_cells"); + legacy.erase(start, legacy.find('\n', start) - start + 1); + CHECK(parse_cellular_revamp_tuning(legacy)->playtest_starting_wildlife_cells == 0); CHECK(error_of(base + "unknown.key = 1\n") == CellularTuningErrorKind::unknown_key); CHECK(error_of(base + "tuning.version = 1\n") == CellularTuningErrorKind::duplicate_key); CHECK(error_of(base + "no equals sign\n") == CellularTuningErrorKind::syntax); diff --git a/tests/client_panels.cpp b/tests/client_panels.cpp index 2134027..b060861 100644 --- a/tests/client_panels.cpp +++ b/tests/client_panels.cpp @@ -411,6 +411,8 @@ void cellular_panels(const std::filesystem::path& review) { network::CellularLifeDiagnostics diagnostics; diagnostics.reserve_energy_pj = 248000; diagnostics.reserve_matter_fg = {15000, 2400, 800, 6000}; + diagnostics.bud_cost_energy_pj = diagnostics.reserve_energy_pj; + diagnostics.bud_cost_matter_fg = diagnostics.reserve_matter_fg; diagnostics.has_tick_effects = true; diagnostics.maintenance_cost_pj = 80; diagnostics.movement_cost_pj = 20; @@ -680,11 +682,28 @@ void cellular_panels(const std::filesystem::path& review) { draw(); CHECK(!probe(evolution, 0.17F, [&] { return action.mutation.has_value(); })); play.outcome({mutation_id, network::ActionResult::committed, 103, 5}); + form.evolution_open = false; + draw(); + // One missing resource disables Bud; a disabled button still explains its cost. + auto short_reserve = diagnostics; + --short_reserve.reserve_energy_pj; + perception.diagnostics = short_reserve; + draw(); + const float bud_x = dock->Pos.x + dock->Size.x * 0.84F; + const float bud_y = dock->Pos.y + ImGui::GetStyle().WindowPadding.y + 20; + mouse(id, SDL_EVENT_MOUSE_MOTION, bud_x, bud_y); + for (int i = 0; i < 3; ++i) + draw(); + const auto* bud_tooltip = ImGui::FindWindowByName("##Tooltip_00"); + CHECK(bud_tooltip && bud_tooltip->Active); + CHECK(!probe(dock, 0.84F, [&] { return action.cell_action == CellAction::bud; })); + perception.diagnostics = diagnostics; draw(); bool budded = false; for (float fraction = 0.1F; fraction < 1.0F && !budded; fraction += 0.1F) budded = probe(dock, fraction, [&] { return action.cell_action == CellAction::bud; }); CHECK(budded); + form.evolution_open = true; play.observe_end({104, 901, network::CellularDeathReason::engulfed}); perception = {104, 0, {}, {}}; play.observe(perception); diff --git a/tests/client_ui_model.cpp b/tests/client_ui_model.cpp index f286966..1410d14 100644 --- a/tests/client_ui_model.cpp +++ b/tests/client_ui_model.cpp @@ -541,7 +541,7 @@ void cellular_revamp_actions() { CHECK(play.queue(CellAction::emerge, 305)); play.sent(); play.observe_end({305, 800, CellularDeathReason::emerged}); - CHECK(play.life() == 0 && play.ended() && play.ended()->cause == CellularDeathReason::emerged && + CHECK(play.life() == 0 && required(play.ended()).cause == CellularDeathReason::emerged && play.can_restart()); } void cellular_energy_and_birth_wait() { @@ -617,6 +617,20 @@ void cell_headings() { CHECK(!headings.update(1, {6, 6}, *camera)); } int main() try { + network::CellularLifeDiagnostics budding; + CHECK(!evo::client_app::bud_affordable(budding)); + budding.bud_cost_energy_pj = 100; + budding.bud_cost_matter_fg = {10, 20, 30, 40}; + budding.reserve_energy_pj = 100; + budding.reserve_matter_fg = {10, 20, 30, 40}; + CHECK(evo::client_app::bud_affordable(budding)); + for (std::size_t c = 0; c < 4; ++c) { + --budding.reserve_matter_fg[c]; + CHECK(!evo::client_app::bud_affordable(budding)); + ++budding.reserve_matter_fg[c]; + } + --budding.reserve_energy_pj; + CHECK(!evo::client_app::bud_affordable(budding)); labels(); selection(); launcher(); diff --git a/tests/postgres_tests.cpp b/tests/postgres_tests.cpp index 4aac0b3..1760ae9 100644 --- a/tests/postgres_tests.cpp +++ b/tests/postgres_tests.cpp @@ -9,6 +9,7 @@ void run_account_control_store_tests(); void run_life_reservation_store_tests(); void run_primitive_publication_tests(); void run_cellular_publication_tests(); +void run_starting_wildlife_publication_tests(); void run_population_publication_tests(); void run_environment_publication_tests(); void run_probe_handoff_store_tests(); @@ -127,6 +128,10 @@ void run() { } // namespace int main(int argc, char** argv) { try { + if (argc == 2 && std::string_view(argv[1]) == "--starting-wildlife-only") { + run_starting_wildlife_publication_tests(); + return 0; + } if (argc == 2 && std::string_view(argv[1]) == "--population-only") { run_population_publication_tests(); return 0; diff --git a/tools/ci/postgres-check.sh b/tools/ci/postgres-check.sh index 6f50063..7b7c5f3 100644 --- a/tools/ci/postgres-check.sh +++ b/tools/ci/postgres-check.sh @@ -4,6 +4,7 @@ set -euo pipefail # postgres-check.sh --life-reservations-only [] # postgres-check.sh --population-only # postgres-check.sh --environment-only +# postgres-check.sh --starting-wildlife-only # postgres-check.sh --migration-faults (private loopback TLS) # --full (default) is the complete qualification: the C++ suite, the backup, DR and # upgrade process checks, then the SQL-only migration, permission and checksum checks. @@ -14,6 +15,7 @@ set -euo pipefail root="$(cd "$(dirname "$0")/../.." && pwd)" mode=full case "${1:-}" in + --starting-wildlife-only) mode=starting-wildlife; shift ;; --migration-faults) mode=migration-faults; shift ;; --population-only) mode=population; shift ;; --environment-only) mode=environment; shift ;; @@ -89,6 +91,11 @@ if [ "$mode" = environment ]; then "$1" --environment-only exit 0 fi +if [ "$mode" = starting-wildlife ]; then + phase starting-wildlife + "$1" --starting-wildlife-only + exit 0 +fi # M7.9 clone target: a separate database with its own runtime group and login, # so a clone shares neither the source's database nor its runtime credentials. psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_clone_runtime NOLOGIN' -c 'CREATE ROLE evo_clone_login LOGIN IN ROLE evo_clone_runtime'