From a3939bda4e39fefd8cd52dd10f0273d1dc00e20e Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 13 Oct 2026 11:30:16 -0400 Subject: [PATCH] Provision a world's life allocator from the owner provisioner The DEV cellular region reported every first-life request as unknown: world 100 had no life_allocators row, and life-reservations-v1 leaves that row to the owner with no runtime initializer. evo-world-clone provision now accepts --life-allocator-start N with the primitive-v1 and cellular-v1 openings. It creates the allocator once before the genesis check, leaves it untouched on reruns, and refuses a start above the existing counter. ADR-0123 records the DEV cellular region bring-up: region 100/2, schema v33, the trial opening, the allocator start and the 300 s grant ceiling. Also refresh the dev session window (3 h). Co-Authored-By: Claude Opus 5.5 --- apps/evo-world-clone/main.cpp | 43 +++++++++- .../region/dev-session-route/listener.yaml | 2 +- ...-region-and-life-allocator-provisioning.md | 78 ++++++++++++++++++ docs/adr/README.md | 1 + docs/engineering/VALIDATION.md | 17 ++++ schemas/life-reservations-v1.md | 4 +- tests/region_store_tests.cpp | 81 +++++++++++++++++++ 7 files changed, 221 insertions(+), 5 deletions(-) create mode 100644 docs/adr/0123-dev-cellular-region-and-life-allocator-provisioning.md diff --git a/apps/evo-world-clone/main.cpp b/apps/evo-world-clone/main.cpp index 6983d2e..05407c8 100644 --- a/apps/evo-world-clone/main.cpp +++ b/apps/evo-world-clone/main.cpp @@ -17,6 +17,9 @@ // cellular-v1 also requires --width-um N --height-um N --ambient-temperature-mk N // and one or more ordered --patch X,Y,SOURCE,ENERGY,C,N,P,O values plus a stable --commit // HEX32. +// primitive-v1 and cellular-v1 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. // evo-world-clone compare --world A --region R --other-world B --pg-* ... // --objects DIR [--other-objects DIR] --retained HEX... [--max-commits N] // @@ -103,6 +106,7 @@ struct Options { std::vector primitive_sites; std::optional cellular_width_um, cellular_height_um, cellular_temperature_mk; std::vector cellular_patches; + std::optional life_allocator_start; std::optional build; bool retain_build{}; bool crash{}; @@ -302,7 +306,10 @@ std::optional parse(int argc, char** argv) { if (!parsed || o.cellular_patches.size() == biology::max_cellular_patches) return std::nullopt; o.cellular_patches.push_back(*parsed); - } else if (o.command == "provision" && flag == "--build" && hex<32>(value)) + } else if (o.command == "provision" && flag == "--life-allocator-start" && n && *n > 0 && + *n < std::numeric_limits::max()) + o.life_allocator_start = n; + else if (o.command == "provision" && flag == "--build" && hex<32>(value)) o.build = hex<32>(value); else if (o.command == "provision" && flag == "--retain-build" && value == "true") o.retain_build = true; @@ -350,8 +357,8 @@ std::optional parse(int argc, char** argv) { !o.cellular_width_um || !o.cellular_height_um || !o.cellular_temperature_mk || o.cellular_patches.empty() || !has_stock || !o.commit) return std::nullopt; - } else if (primitive_options || cellular_options) { - return std::nullopt; + } else if (primitive_options || cellular_options || o.life_allocator_start) { + return std::nullopt; // The development opening has no lives to allocate. } } if (!complete(o.source) || (needs_builds && o.retained.empty()) || @@ -475,6 +482,36 @@ int provision(const Options& o) { return 3; } } + // ADR-0123: the world's life-identity allocator is owner state, created once at the + // operator-audited start before any genesis check, so an already provisioned region + // still gets it. It only ever advances, so one below the start is a conflict. + if (o.life_allocator_start) { + const std::array p{std::to_string(o.source.key.world), + std::to_string(*o.life_allocator_start)}; + const std::array world{p[0]}; + auto rows = db->query("INSERT INTO evolution.life_allocators(world_id, next_identity) " + "VALUES ($1::evolution.u64, $2::evolution.u64) " + "ON CONFLICT (world_id) DO NOTHING", + p, timeout); + if (rows) + rows = db->query("SELECT next_identity FROM evolution.life_allocators " + "WHERE world_id = $1::evolution.u64", + world, timeout); + const auto next = rows && rows->size() == 1 && (*rows)[0].size() == 1 && (*rows)[0][0] + ? number(*(*rows)[0][0]) + : std::nullopt; + if (!next) { + std::puts("life-allocator refused"); + return 3; + } + if (*next < *o.life_allocator_start) { + std::puts("life-allocator refused existing below start"); + return 4; + } + std::printf("life-allocator world=%llu next=%llu\n", + static_cast(o.source.key.world), + static_cast(*next)); + } std::unique_ptr primitive_opening; std::unique_ptr cellular_opening; if (primitive || cellular) { diff --git a/deploy/kubernetes/region/dev-session-route/listener.yaml b/deploy/kubernetes/region/dev-session-route/listener.yaml index b395373..9304121 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-20261013T150331-42833:1791914611"} + - {name: REGION_SESSION_WINDOW, value: "dev-20261013T153015-33322:1791916215"} - {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 new file mode 100644 index 0000000..313c049 --- /dev/null +++ b/docs/adr/0123-dev-cellular-region-and-life-allocator-provisioning.md @@ -0,0 +1,78 @@ +# ADR-0123: Dev cellular region and life-allocator provisioning + +## Status + +Accepted 2026-10-13 for the M11.3 cellular probe in evolution-dev, at the +maintainer's direction. It changes DEV deployment and the owner provisioning +tool only; no gameplay rule, protocol or runtime authority changes. + +## Context + +The M11.3 probe (`docs/playtests/M11_3_CELLULAR_PROBE.md`) needs a cellular +region in DEV. Bringing one up exposed four gaps: + +1. **Region 100/1 cannot host the cellular profile.** It holds profile-3 + lineage history; `evo-server --profile cellular` needs a cellular-v1 + (profile-4) genesis. Resetting or rewriting region history is forbidden, and + unnecessary, because regions are independent. +2. **The DEV schema was v11.** The store Jobs still pinned the 2026-10-05 + postgres-tools image, so PostgreSQL refused the profile-4 genesis manifest + (`cellular provision refused 5`, `PublicationError::rejected`). +3. **No life allocator existed for world 100.** `reserve_primitive_life` + raises `life allocator not provisioned` (EVL04) without a + `life_allocators` row. `schemas/life-reservations-v1.md` assigns that row + to the owner after an audit, and nothing in Git created it. The server + reported every first-life request as `unknown` and never ticked. +4. **Cellular grants are scoped and short.** Grants name their region, so + region-1 bundles are refused with `wrong_scope`. The cellular bridge keeps the + default 300-second grant ceiling and refuses `--m10-max-grant-lifetime`. + +## Decision + +- **DEV serves region 100/2 with the cellular profile.** The single + `evo-region` Deployment switches to region 2. Region 1's database rows and + objects stay untouched and are no longer served. The base Deployment and + provision Job take `REGION_PROFILE`, `REGION_LIFE_ROUTES`, `REGION_OPENING` + and `REGION_OPENING_ARGS`. Their defaults keep stage on lineage with the + development opening. For a single-region world, the life-route catalog is + the region's own endpoint: + `2=void.aeternalisgames.com:7400=void.aeternalisgames.com`. +- **Trial opening (tunable, not a world rule).** The opening is: + - a 10 x 10 mm arena at 293.15 K; + - nursery funding for eight founders (8 x `primitive_endowment()`); + - eight spawn sites; + - four rich, three lean and one empty 1,000 µm patch; + - a stable genesis commit `18ff2e1ab8cef4c9cd73d4cc6e322496`. + + It is written once, so changing it means a new region. +- **DEV schema v33.** The store Jobs pin postgres-tools from Gitea run 350 + (source `ae3b2b4`), the run that built the promoted DEV server image. +- **The provisioner creates the life allocator.** The owner provisioning tool + takes `evo-world-clone provision --life-allocator-start N`, accepted only with + the primitive-v1 and cellular-v1 openings: + - The run inserts `life_allocators(world, N)` once, before the genesis check, + so an already provisioned region still gets the row. + - A later run leaves the counter untouched and reports it; the counter only + advances. + - A run whose start is above an existing counter refuses with exit 4. + + There is still no runtime initializer or reset. +- **DEV world 100 starts at 1,000,000,000,000.** The audited range required by + life-reservations-v1 is satisfied by choosing a start far above every + 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. +- **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. + +## Consequences + +- Any new primitive or cellular world must choose and record its allocator + start in its provision Job. Stage and World0 do not use this flag until + their own audited starts are decided. +- DEV world 100 now mixes an unserved lineage region 1 and a cellular region 2. + Returning DEV to lineage means reverting the overlay values. Region 1's + history remains recoverable. +- The 300-second grant ceiling caps each probe session at about five minutes, + and a bundle expires five minutes after it is minted. diff --git a/docs/adr/README.md b/docs/adr/README.md index 0346e44..4ec5eac 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -23,6 +23,7 @@ - [ADR-0120: Cellular mutation eligibility trial](0120-cellular-mutation-eligibility-trial.md) - starts with 60 seconds of retained fed energy per unranked offer requesting up to three candidates; the threshold remains open to playtest review. - [ADR-0121: Durable cellular mutation selection](0121-durable-cellular-mutation-selection.md) - specifies a distinct reliable action, allocator identity, tick-bound replay and atomic publication for M11.4c. - [ADR-0122: Append-only cellular genome revisions](0122-append-only-cellular-genome-revisions.md) - preserves immutable birth-genome links while adding a versioned revision chain and no-tick cellular-v3 migration. +- [ADR-0123: Dev cellular region and life-allocator provisioning](0123-dev-cellular-region-and-life-allocator-provisioning.md) - moves DEV to cellular region 100/2 at schema v33 and has the owner provisioner create a world's life allocator once at an audited start. - [ADR-0058: Region durability contract](0058-region-durability-contract.md) - accepted M7.1 full checkpoint batches and explicit state closure; storage implementation follows. diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 1b7cba9..062e1ab 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -7152,3 +7152,20 @@ the publisher with the corrected offset while retaining migration 20's recorded checksum. The migration runner's accepted latest history and upgrade fixtures now extend through version 33. Local PostgreSQL is unavailable on this Windows environment; migration, publication, and server-image checks are awaiting CI. + +## 2026-10-13 — DEV cellular region and life-allocator provisioning (CI pending) + +ADR-0123. Bringing up the M11.3 probe moved DEV to cellular region 100/2, +migrated the DEV schema from v11 to v33 (postgres-tools from run 350), and +showed that world 100 had no `life_allocators` row, so every first-life request +resolved `unknown`. `evo-world-clone provision` now accepts +`--life-allocator-start N` with the primitive-v1 and cellular-v1 openings. It +creates the allocator once, leaves it untouched on reruns, and refuses a start +above the existing counter. `region_store_tests` adds a PostgreSQL process case +for first create, idempotent rerun, lower and higher starts, and refusal with +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 diff --git a/schemas/life-reservations-v1.md b/schemas/life-reservations-v1.md index 38fa5fb..6ba7298 100644 --- a/schemas/life-reservations-v1.md +++ b/schemas/life-reservations-v1.md @@ -6,7 +6,9 @@ It is not a successful spawn and must never be acknowledged as one. The owner provisions `life_allocators(world_id, next_identity)` only after auditing an unused range above every retained identity in the life, organism, genome and origin-event namespaces for that world. There is no runtime initializer, -reset or automatic provisioning. This subsection does not provision a dev world. +reset or automatic provisioning. This subsection does not provision a dev world; +ADR-0123 adds the owner-only `evo-world-clone provision --life-allocator-start N`, +which creates the row once at the audited start N in a world's provision Job. Every allocation uses one value in each of those distinct namespaces. The counter is shared across the world's regions, never wraps, and retains gaps from rejected requests. Future birth/mutation allocators must share this allocation authority; diff --git a/tests/region_store_tests.cpp b/tests/region_store_tests.cpp index 05a8496..bc02ec3 100644 --- a/tests/region_store_tests.cpp +++ b/tests/region_store_tests.cpp @@ -345,11 +345,92 @@ void primitive_provisioning_is_explicit_and_profile_safe() { recovered->state->config().funding == funding && recovered->state->config().sites == std::vector{{0, 0}, {10000000, 0}}); } + +// ADR-0123: provisioning creates the world's life allocator once at the audited +// start; reruns leave it untouched, and a start above the existing counter refuses. +void provisioning_creates_the_life_allocator_once() { + using evo::biology::primitive_endowment; + const ServerRegion r{{9760, 1}, fresh("allocator-9760")}; + 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& opening, std::uint64_t start, int& code) { + std::vector args{ + env("EVO_WORLD_CLONE_BIN"), + "provision", + "--world", + "9760", + "--region", + "1", + "--opening", + opening, + "--pg-host", + env("PGHOST"), + "--pg-port", + env("PGPORT"), + "--pg-database", + env("PGDATABASE"), + "--pg-user", + env("PGUSER"), + "--objects", + r.root.string(), + "--build", + "c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3", + "--retain-build", + "true", + "--life-allocator-start", + std::to_string(start)}; + if (opening == "primitive-v1") { + const std::vector primitive{"--frame", + "3", + "--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", + "0,0"}; + args.insert(args.end(), primitive.begin(), primitive.end()); + } + Child tool{args}; + code = tool.wait_exit(30s); + return tool.lines(); + }; + const auto next_identity = [] { + auto db = owner(); + auto rows = db->query( + "SELECT next_identity FROM evolution.life_allocators WHERE world_id = 9760", {}, 5s); + return rows && rows->size() == 1 && (*rows)[0][0] ? *(*rows)[0][0] : std::string{}; + }; + int code = -1; + const auto development = run("development-v1", 5000, code); + CHECK(code == 2 && next_identity().empty()); // No lives, so no allocator. + const auto first = run("primitive-v1", 5000, code); + CHECK(code == 0 && has(first, "life-allocator world=9760 next=5000") && + has(first, "provisioned world=9760 region=1 sequence=0 tick=0")); + const auto retry = run("primitive-v1", 5000, code); + CHECK(code == 0 && has(retry, "life-allocator world=9760 next=5000") && + has(retry, "already-provisioned world=9760 region=1 sequence=0 tick=0")); + const auto lower = run("primitive-v1", 10, code); + CHECK(code == 0 && has(lower, "life-allocator world=9760 next=5000")); + const auto higher = run("primitive-v1", 6000, code); + CHECK(code == 4 && has(higher, "life-allocator refused existing below start")); + CHECK(next_identity() == "5000"); +} } // namespace void run_region_store_tests() { provisioning_is_idempotent(); primitive_provisioning_is_explicit_and_profile_safe(); + provisioning_creates_the_life_allocator_once(); full_volumes_publish_nothing(); failing_writes_leave_nothing(); check_store_qualifies_the_stores();