diff --git a/apps/evo-world-clone/main.cpp b/apps/evo-world-clone/main.cpp index 2f88843..819eca1 100644 --- a/apps/evo-world-clone/main.cpp +++ b/apps/evo-world-clone/main.cpp @@ -580,17 +580,29 @@ int provision(const Options& o) { // Never re-provision or report success for a different profile/frame. auto existing = persistence::load_region_checkpoint(*db, o.source.key, timeout); if (existing) { + const auto manifest = persistence::decode_manifest(existing->manifest); if (cellular) { - auto same_genesis = - persistence::provision_cellular_region(*db, *store, o.source.key, primitive_frame, - *cellular_opening, commit, build, timeout); + // The genesis records the build that wrote it, and image promotions change + // --build, so an unadvanced genesis is matched exactly under its own build + // (ADR-0123). Past genesis the head is no longer the genesis manifest; as for + // the other openings, the profile and frame identify the region. + if (!manifest || + manifest->profile != persistence::CheckpointProfile::cellular_lives_v1 || + manifest->frame != primitive_frame) { + std::puts("provision refused existing profile/frame mismatch"); + return 4; + } + if (manifest->sequence > 0) + return report("already-provisioned", existing->head); + auto same_genesis = persistence::provision_cellular_region( + *db, *store, o.source.key, primitive_frame, *cellular_opening, commit, + manifest->build, timeout); if (same_genesis) return report("already-provisioned", same_genesis->head); std::puts("provision refused existing cellular region; use its original --commit to " "resolve genesis"); return 4; } - const auto manifest = persistence::decode_manifest(existing->manifest); const auto expected_profile = primitive ? persistence::CheckpointProfile::primitive_lives_v1 : persistence::CheckpointProfile::environmental_lineage_v1; diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index 2682f33..7a6e597 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-20261013T165600-97691:1791921360"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261013T171415-75125:1791922455"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} ports: # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. diff --git a/docs/adr/0123-dev-cellular-region-and-life-allocator-provisioning.md b/docs/adr/0123-dev-cellular-region-and-life-allocator-provisioning.md index 313c049..ec1728d 100644 --- a/docs/adr/0123-dev-cellular-region-and-life-allocator-provisioning.md +++ b/docs/adr/0123-dev-cellular-region-and-life-allocator-provisioning.md @@ -62,6 +62,16 @@ region in DEV. Bringing one up exposed four gaps: identity the DEV lineage run could have issued. That run was about 43,000 ticks, with lineage identities held in region-1 checkpoints rather than in SQL. Identities are 64-bit, so the gap is free. +- **Cellular reprovisioning survives image promotions.** The genesis manifest + records the build that wrote it, and every promotion changes `--build`, so + the provision hook refused region 2 after the first promotion + (`provision refused existing cellular region`, although the commit was + unchanged). The check also could never have passed once the head moved past + genesis. + - At sequence 0, an existing cellular region is now matched exactly under + its own recorded build, so a different commit or opening is still refused. + - Past genesis, as for the lineage and primitive openings, a matching profile + and frame identify it. - **Grants for region 2 must be minted with `--region 2 --lifetime 300` or less.** Longer probe sessions require a separate, reviewed change to the cellular grant ceiling; this ADR does not make it. diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 062e1ab..8016253 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -7168,4 +7168,13 @@ the development opening. Executed locally: g++-14 `-std=c++23 -fsyntax-only -Wall -Wextra -Wconversion -Werror` on both changed files, and clang-format 19.1.5. The PostgreSQL process test runs only in CI. The DEV overlay adopts the flag only after CI publishes -the server image that contains it. \ No newline at end of file +the server image that contains it. +The first sync with the promoted image showed the allocator created +(`life-allocator world=100 next=1000000000000`). It then refused region 2, +because the cellular genesis check re-encoded the manifest with the new +`--build`. Provisioning now matches an unadvanced cellular genesis under its +recorded build, and accepts profile and frame once the head is past genesis. +`region_store_tests` adds a cellular case: a rerun under a new build is +already-provisioned, while another commit or opening is refused. Checked +locally with g++-14 `-Werror`, clang-tidy-19 `--warnings-as-errors=*` and +clang-format 19.1.5; the PostgreSQL process tests run in CI. \ No newline at end of file diff --git a/tests/region_store_tests.cpp b/tests/region_store_tests.cpp index cdc5ff5..c63c1db 100644 --- a/tests/region_store_tests.cpp +++ b/tests/region_store_tests.cpp @@ -427,12 +427,94 @@ void provisioning_creates_the_life_allocator_once() { CHECK(code == 4 && has(higher, "life-allocator refused existing below start")); CHECK(next_identity() == "5000"); } + +// ADR-0123: an image promotion changes --build, but a cellular genesis records the +// build that wrote it. A rerun under a new build still resolves the same genesis, +// while a different commit or opening is refused. +void cellular_provisioning_survives_a_build_promotion() { + using evo::biology::primitive_endowment; + const ServerRegion r{{9761, 1}, fresh("cellular-provision-9761")}; + const auto endowed = primitive_endowment(); + CHECK(endowed); + evo::accounting::Inventory funding = endowed->body; + funding.energy.value += endowed->reserve.energy.value + endowed->construction.value; + const auto run = [&](const std::string& build, const std::string& commit, + const std::string& patch, int& code) { + Child tool{{env("EVO_WORLD_CLONE_BIN"), + "provision", + "--world", + "9761", + "--region", + "1", + "--opening", + "cellular-v1", + "--pg-host", + env("PGHOST"), + "--pg-port", + env("PGPORT"), + "--pg-database", + env("PGDATABASE"), + "--pg-user", + env("PGUSER"), + "--objects", + r.root.string(), + "--build", + build, + "--retain-build", + "true", + "--commit", + commit, + "--frame", + "9", + "--source-id", + "1", + "--funding-energy-pj", + std::to_string(funding.energy.value), + "--funding-carbon-fg", + std::to_string(funding.matter[0].value), + "--funding-nitrogen-fg", + std::to_string(funding.matter[1].value), + "--funding-phosphorus-fg", + std::to_string(funding.matter[2].value), + "--funding-other-fg", + std::to_string(funding.matter[3].value), + "--site", + "2500,2500", + "--width-um", + "10000", + "--height-um", + "10000", + "--ambient-temperature-mk", + "293150", + "--patch", + patch}}; + code = tool.wait_exit(30s); + return tool.lines(); + }; + const std::string first_build(64, 'c'); + const std::string second_build = std::string(63, 'c') + "d"; + const std::string commit(32, 'a'); + const std::string patch = "3000,3000,2,1000,1000,1000,1000,1000"; + int code = -1; + const auto first = run(first_build, commit, patch, code); + CHECK(code == 0 && has(first, "provisioned world=9761 region=1 sequence=0 tick=0")); + const auto promoted = run(second_build, commit, patch, code); + CHECK(code == 0 && has(promoted, "already-provisioned world=9761 region=1 sequence=0 tick=0")); + const auto other_commit = run(second_build, std::string(32, 'b'), patch, code); + CHECK(code == 4 && has(other_commit, "provision refused existing cellular region; use its " + "original --commit to resolve genesis")); + const auto other_opening = + run(second_build, commit, "4000,4000,2,1000,1000,1000,1000,1000", code); + CHECK(code == 4 && has(other_opening, "provision refused existing cellular region; use its " + "original --commit to resolve genesis")); +} } // namespace void run_region_store_tests() { provisioning_is_idempotent(); primitive_provisioning_is_explicit_and_profile_safe(); provisioning_creates_the_life_allocator_once(); + cellular_provisioning_survives_a_build_promotion(); full_volumes_publish_nothing(); failing_writes_leave_nothing(); check_store_qualifies_the_stores();