Provision empty cellular profile genesis
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 40s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 21s
Foundation / checks (client) (push) Canceled after 2m24s
Foundation / checks (network) (push) Canceled after 1m49s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 40s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 21s
Foundation / checks (client) (push) Canceled after 2m24s
Foundation / checks (network) (push) Canceled after 1m49s
This commit is contained in:
@@ -130,8 +130,10 @@ process fixtures remain separate from organism biology.
|
|||||||
and reporting. `tests` holds contract,
|
and reporting. `tests` holds contract,
|
||||||
fuzz and measurement programs. `src/server/lifecycle` owns funded primitive
|
fuzz and measurement programs. `src/server/lifecycle` owns funded primitive
|
||||||
founder creation and an in-memory cellular tick owner over the finite habitat.
|
founder creation and an in-memory cellular tick owner over the finite habitat.
|
||||||
The cellular owner is not yet wired to durable profile-4 recovery or session
|
The cellular owner now has durable profile-4 recovery/publication and an
|
||||||
intentions, so it is not a playable client path. `evo::simulation` remains
|
adapter for reliable v7 session actions. `evo-server` still lacks the cellular
|
||||||
|
scheduler, player-life entry operation, and cellular view replication, so this
|
||||||
|
is not yet a playable client path. `evo::simulation` remains
|
||||||
graphics-, network- and database-independent.
|
graphics-, network- and database-independent.
|
||||||
|
|
||||||
World0 is persistent state. No normal configure, build, test or CI job may create,
|
World0 is persistent state. No normal configure, build, test or CI job may create,
|
||||||
|
|||||||
+125
-10
@@ -9,10 +9,12 @@
|
|||||||
// [--max-commits N]
|
// [--max-commits N]
|
||||||
// evo-world-clone check-store --world W --region R --pg-* ... --objects DIR
|
// evo-world-clone check-store --world W --region R --pg-* ... --objects DIR
|
||||||
// [--reserve-mib N]
|
// [--reserve-mib N]
|
||||||
// evo-world-clone provision --world W --region R --opening development-v1|primitive-v1
|
// evo-world-clone provision --world W --region R --opening development-v1|primitive-v1|cellular-v1
|
||||||
// --pg-* ... --objects DIR --build HEX [--retain-build]
|
// --pg-* ... --objects DIR --build HEX [--commit HEX32] [--retain-build]
|
||||||
// primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel,
|
// primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel,
|
||||||
// and one or more ordered --site X,Y values.
|
// and one or more ordered --site X,Y values.
|
||||||
|
// 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.
|
||||||
// evo-world-clone compare --world A --region R --other-world B --pg-* ...
|
// evo-world-clone compare --world A --region R --other-world B --pg-* ...
|
||||||
// --objects DIR [--other-objects DIR] --retained HEX... [--max-commits N]
|
// --objects DIR [--other-objects DIR] --retained HEX... [--max-commits N]
|
||||||
//
|
//
|
||||||
@@ -57,6 +59,8 @@
|
|||||||
#include "evo/persistence/region_clone.hpp"
|
#include "evo/persistence/region_clone.hpp"
|
||||||
#include "evo/persistence/sha256.hpp"
|
#include "evo/persistence/sha256.hpp"
|
||||||
#include "evo/processes/development_opening.hpp"
|
#include "evo/processes/development_opening.hpp"
|
||||||
|
#include "evo/biology/cellular_habitat.hpp"
|
||||||
|
#include "evo/server/lifecycle/cellular_lives.hpp"
|
||||||
#include "evo/server/lifecycle/primitive_lives.hpp"
|
#include "evo/server/lifecycle/primitive_lives.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -65,6 +69,7 @@
|
|||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <limits>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
@@ -93,6 +98,9 @@ struct Options {
|
|||||||
std::optional<std::uint64_t> primitive_frame, primitive_source;
|
std::optional<std::uint64_t> primitive_frame, primitive_source;
|
||||||
std::array<std::optional<std::uint64_t>, 5> primitive_funding;
|
std::array<std::optional<std::uint64_t>, 5> primitive_funding;
|
||||||
std::vector<server::SpawnSite> primitive_sites;
|
std::vector<server::SpawnSite> primitive_sites;
|
||||||
|
std::optional<std::uint32_t> cellular_width_um, cellular_height_um,
|
||||||
|
cellular_temperature_mk;
|
||||||
|
std::vector<biology::CellularPatch> cellular_patches;
|
||||||
std::optional<persistence::Sha256Digest> build;
|
std::optional<persistence::Sha256Digest> build;
|
||||||
bool retain_build{};
|
bool retain_build{};
|
||||||
bool crash{};
|
bool crash{};
|
||||||
@@ -118,6 +126,34 @@ std::optional<server::SpawnSite> site(std::string_view text) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
return server::SpawnSite{x, y};
|
return server::SpawnSite{x, y};
|
||||||
}
|
}
|
||||||
|
std::optional<biology::CellularPatch> cellular_patch(std::string_view text) {
|
||||||
|
std::array<std::uint64_t, 8> fields{};
|
||||||
|
for (std::size_t i = 0; i < fields.size(); ++i) {
|
||||||
|
const auto comma = text.find(',');
|
||||||
|
const auto field = i + 1 == fields.size() ? text : text.substr(0, comma);
|
||||||
|
if (field.empty() || (i + 1 != fields.size() && comma == std::string_view::npos))
|
||||||
|
return std::nullopt;
|
||||||
|
const auto [end, error] =
|
||||||
|
std::from_chars(field.data(), field.data() + field.size(), fields[i]);
|
||||||
|
if (error != std::errc{} || end != field.data() + field.size())
|
||||||
|
return std::nullopt;
|
||||||
|
if (i + 1 != fields.size())
|
||||||
|
text.remove_prefix(comma + 1);
|
||||||
|
else if (comma != std::string_view::npos)
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
if (fields[0] > std::numeric_limits<std::uint32_t>::max() ||
|
||||||
|
fields[1] > std::numeric_limits<std::uint32_t>::max())
|
||||||
|
return std::nullopt;
|
||||||
|
biology::CellularPatch result{};
|
||||||
|
result.address = {static_cast<std::uint32_t>(fields[0]),
|
||||||
|
static_cast<std::uint32_t>(fields[1])};
|
||||||
|
result.source = fields[2];
|
||||||
|
result.stock.energy.value = fields[3];
|
||||||
|
for (std::size_t i = 0; i < result.stock.matter.size(); ++i)
|
||||||
|
result.stock.matter[i].value = fields[4 + i];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
template <std::size_t N> std::optional<std::array<std::uint8_t, N>> hex(std::string_view text) {
|
template <std::size_t N> std::optional<std::array<std::uint8_t, N>> hex(std::string_view text) {
|
||||||
if (text.size() != N * 2)
|
if (text.size() != N * 2)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@@ -215,7 +251,7 @@ std::optional<Options> parse(int argc, char** argv) {
|
|||||||
else if ((clone && flag == "--target-objects") ||
|
else if ((clone && flag == "--target-objects") ||
|
||||||
(o.command == "compare" && flag == "--other-objects"))
|
(o.command == "compare" && flag == "--other-objects"))
|
||||||
o.target.objects = value;
|
o.target.objects = value;
|
||||||
else if (clone && flag == "--commit" && hex<16>(value))
|
else if ((clone || o.command == "provision") && flag == "--commit" && hex<16>(value))
|
||||||
o.commit = hex<16>(value);
|
o.commit = hex<16>(value);
|
||||||
else if (clone && flag == "--audit-max" && n && *n > 0)
|
else if (clone && flag == "--audit-max" && n && *n > 0)
|
||||||
o.audit_max = *n;
|
o.audit_max = *n;
|
||||||
@@ -227,7 +263,8 @@ std::optional<Options> parse(int argc, char** argv) {
|
|||||||
else if (o.command == "check-store" && flag == "--reserve-mib" && n && *n <= 1048576)
|
else if (o.command == "check-store" && flag == "--reserve-mib" && n && *n <= 1048576)
|
||||||
o.reserve_mib = *n;
|
o.reserve_mib = *n;
|
||||||
else if (o.command == "provision" && flag == "--opening" &&
|
else if (o.command == "provision" && flag == "--opening" &&
|
||||||
(value == "development-v1" || value == "primitive-v1"))
|
(value == "development-v1" || value == "primitive-v1" ||
|
||||||
|
value == "cellular-v1"))
|
||||||
o.opening = value;
|
o.opening = value;
|
||||||
else if (o.command == "provision" && flag == "--frame" && n)
|
else if (o.command == "provision" && flag == "--frame" && n)
|
||||||
o.primitive_frame = *n;
|
o.primitive_frame = *n;
|
||||||
@@ -248,6 +285,20 @@ std::optional<Options> parse(int argc, char** argv) {
|
|||||||
if (!parsed || o.primitive_sites.size() == server::max_primitive_lives)
|
if (!parsed || o.primitive_sites.size() == server::max_primitive_lives)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
o.primitive_sites.push_back(*parsed);
|
o.primitive_sites.push_back(*parsed);
|
||||||
|
} else if (o.command == "provision" && flag == "--width-um" && n &&
|
||||||
|
*n <= std::numeric_limits<std::uint32_t>::max())
|
||||||
|
o.cellular_width_um = static_cast<std::uint32_t>(*n);
|
||||||
|
else if (o.command == "provision" && flag == "--height-um" && n &&
|
||||||
|
*n <= std::numeric_limits<std::uint32_t>::max())
|
||||||
|
o.cellular_height_um = static_cast<std::uint32_t>(*n);
|
||||||
|
else if (o.command == "provision" && flag == "--ambient-temperature-mk" && n &&
|
||||||
|
*n <= std::numeric_limits<std::uint32_t>::max())
|
||||||
|
o.cellular_temperature_mk = static_cast<std::uint32_t>(*n);
|
||||||
|
else if (o.command == "provision" && flag == "--patch") {
|
||||||
|
const auto parsed = cellular_patch(value);
|
||||||
|
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 == "--build" && hex<32>(value))
|
||||||
o.build = hex<32>(value);
|
o.build = hex<32>(value);
|
||||||
else if (o.command == "provision" && flag == "--retain-build" && value == "true")
|
else if (o.command == "provision" && flag == "--retain-build" && value == "true")
|
||||||
@@ -273,13 +324,30 @@ std::optional<Options> parse(int argc, char** argv) {
|
|||||||
o.primitive_frame || o.primitive_source ||
|
o.primitive_frame || o.primitive_source ||
|
||||||
std::ranges::any_of(o.primitive_funding, [](const auto& v) { return v.has_value(); }) ||
|
std::ranges::any_of(o.primitive_funding, [](const auto& v) { return v.has_value(); }) ||
|
||||||
!o.primitive_sites.empty();
|
!o.primitive_sites.empty();
|
||||||
|
const bool cellular_options = o.cellular_width_um || o.cellular_height_um ||
|
||||||
|
o.cellular_temperature_mk || !o.cellular_patches.empty();
|
||||||
if (o.opening == "primitive-v1") {
|
if (o.opening == "primitive-v1") {
|
||||||
if (!o.primitive_frame || *o.primitive_frame == 0 || !o.primitive_source ||
|
if (!o.primitive_frame || *o.primitive_frame == 0 || !o.primitive_source ||
|
||||||
*o.primitive_source == 0 || o.primitive_sites.empty() ||
|
*o.primitive_source == 0 || o.primitive_sites.empty() ||
|
||||||
!std::ranges::all_of(o.primitive_funding,
|
!std::ranges::all_of(o.primitive_funding,
|
||||||
[](const auto& v) { return v.has_value(); }))
|
[](const auto& v) { return v.has_value(); }))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else if (primitive_options) {
|
if (cellular_options)
|
||||||
|
return std::nullopt;
|
||||||
|
} else if (o.opening == "cellular-v1") {
|
||||||
|
const bool has_stock = std::ranges::any_of(o.cellular_patches, [](const auto& patch) {
|
||||||
|
return patch.stock.energy.value != 0 ||
|
||||||
|
std::ranges::any_of(patch.stock.matter,
|
||||||
|
[](const auto& amount) { return amount.value != 0; });
|
||||||
|
});
|
||||||
|
if (!o.primitive_frame || *o.primitive_frame == 0 || !o.primitive_source ||
|
||||||
|
*o.primitive_source == 0 || o.primitive_sites.empty() ||
|
||||||
|
!std::ranges::all_of(o.primitive_funding,
|
||||||
|
[](const auto& v) { return v.has_value(); }) ||
|
||||||
|
!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;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -375,8 +443,10 @@ std::vector<std::uint8_t> probe_bytes() {
|
|||||||
|
|
||||||
int provision(const Options& o) {
|
int provision(const Options& o) {
|
||||||
const bool primitive = o.opening == "primitive-v1";
|
const bool primitive = o.opening == "primitive-v1";
|
||||||
const auto payload_limit =
|
const bool cellular = o.opening == "cellular-v1";
|
||||||
primitive ? server::max_primitive_lives_bytes : persistence::max_lineage_payload_bytes;
|
const auto payload_limit = cellular ? server::max_cellular_lives_bytes
|
||||||
|
: primitive ? server::max_primitive_lives_bytes
|
||||||
|
: persistence::max_lineage_payload_bytes;
|
||||||
auto store = open_objects(o.source, payload_limit);
|
auto store = open_objects(o.source, payload_limit);
|
||||||
if (!store) {
|
if (!store) {
|
||||||
std::puts("objects refused");
|
std::puts("objects refused");
|
||||||
@@ -400,7 +470,8 @@ int provision(const Options& o) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::unique_ptr<server::PrimitiveLives> primitive_opening;
|
std::unique_ptr<server::PrimitiveLives> primitive_opening;
|
||||||
if (primitive) {
|
std::unique_ptr<server::CellularLives> cellular_opening;
|
||||||
|
if (primitive || cellular) {
|
||||||
server::NurseryConfig config{};
|
server::NurseryConfig config{};
|
||||||
config.world = o.source.key.world;
|
config.world = o.source.key.world;
|
||||||
config.region = o.source.key.region;
|
config.region = o.source.key.region;
|
||||||
@@ -417,6 +488,28 @@ int provision(const Options& o) {
|
|||||||
}
|
}
|
||||||
primitive_opening = std::move(*opening);
|
primitive_opening = std::move(*opening);
|
||||||
}
|
}
|
||||||
|
if (cellular) {
|
||||||
|
biology::CellularHabitatConfig habitat_config{};
|
||||||
|
habitat_config.world = o.source.key.world;
|
||||||
|
habitat_config.region = o.source.key.region;
|
||||||
|
habitat_config.frame = *o.primitive_frame;
|
||||||
|
habitat_config.width_um = *o.cellular_width_um;
|
||||||
|
habitat_config.height_um = *o.cellular_height_um;
|
||||||
|
habitat_config.patches = o.cellular_patches;
|
||||||
|
auto habitat = biology::CellularHabitat::create(std::move(habitat_config));
|
||||||
|
if (!habitat) {
|
||||||
|
std::printf("cellular habitat refused %u\n", static_cast<unsigned>(habitat.error()));
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
auto opening = server::CellularLives::create(
|
||||||
|
**primitive_opening, std::move(*habitat),
|
||||||
|
{{*o.cellular_width_um, *o.cellular_height_um}, 0, *o.cellular_temperature_mk});
|
||||||
|
if (!opening) {
|
||||||
|
std::printf("cellular opening refused %u\n", static_cast<unsigned>(opening.error()));
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
cellular_opening = std::move(*opening);
|
||||||
|
}
|
||||||
const auto report = [&](const char* what, const persistence::RegionHead& head) {
|
const auto report = [&](const char* what, const persistence::RegionHead& head) {
|
||||||
std::printf("%s world=%llu region=%llu sequence=%llu tick=%llu\n", what,
|
std::printf("%s world=%llu region=%llu sequence=%llu tick=%llu\n", what,
|
||||||
static_cast<unsigned long long>(o.source.key.world),
|
static_cast<unsigned long long>(o.source.key.world),
|
||||||
@@ -425,9 +518,25 @@ int provision(const Options& o) {
|
|||||||
static_cast<unsigned long long>(head.end_tick));
|
static_cast<unsigned long long>(head.end_tick));
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
persistence::Uuid commit{};
|
||||||
|
if (o.commit) {
|
||||||
|
commit = *o.commit;
|
||||||
|
} else if (::getrandom(commit.data(), commit.size(), 0) !=
|
||||||
|
static_cast<ssize_t>(commit.size())) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
// Never re-provision or report success for a different profile/frame.
|
// Never re-provision or report success for a different profile/frame.
|
||||||
auto existing = persistence::load_region_checkpoint(*db, o.source.key, timeout);
|
auto existing = persistence::load_region_checkpoint(*db, o.source.key, timeout);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
if (cellular) {
|
||||||
|
auto same_genesis = persistence::provision_cellular_region(
|
||||||
|
*db, *store, o.source.key, *o.primitive_frame, *cellular_opening, commit, 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 manifest = persistence::decode_manifest(existing->manifest);
|
||||||
const auto expected_profile =
|
const auto expected_profile =
|
||||||
primitive ? persistence::CheckpointProfile::primitive_lives_v1
|
primitive ? persistence::CheckpointProfile::primitive_lives_v1
|
||||||
@@ -454,9 +563,15 @@ int provision(const Options& o) {
|
|||||||
std::puts("database refused");
|
std::puts("database refused");
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
persistence::Uuid commit{};
|
if (cellular) {
|
||||||
if (::getrandom(commit.data(), commit.size(), 0) != static_cast<ssize_t>(commit.size()))
|
auto made = persistence::provision_cellular_region(
|
||||||
|
*db, *store, o.source.key, *o.primitive_frame, *cellular_opening, commit, build, timeout);
|
||||||
|
if (!made) {
|
||||||
|
std::printf("cellular provision refused %u\n", static_cast<unsigned>(made.error().kind));
|
||||||
return 4;
|
return 4;
|
||||||
|
}
|
||||||
|
return report("provisioned", made->head);
|
||||||
|
}
|
||||||
if (primitive) {
|
if (primitive) {
|
||||||
auto made =
|
auto made =
|
||||||
persistence::provision_primitive_region(*db, *store, o.source.key, *o.primitive_frame,
|
persistence::provision_primitive_region(*db, *store, o.source.key, *o.primitive_frame,
|
||||||
|
|||||||
@@ -292,6 +292,14 @@ scoped change before starting the next segment.
|
|||||||
same-biological-tick checkpoint publication. This remains a proposal; no
|
same-biological-tick checkpoint publication. This remains a proposal; no
|
||||||
profile-4 entry path or 11.3e playtest is available until the contract is
|
profile-4 entry path or 11.3e playtest is available until the contract is
|
||||||
accepted, implemented and qualified.
|
accepted, implemented and qualified.
|
||||||
|
- 11.3d-7f: the owner persistence API and `evo-world-clone provision
|
||||||
|
--opening cellular-v1` now create only an empty profile-4 genesis. The CLI
|
||||||
|
requires explicit arena dimensions, temperature, nursery funding, ordered
|
||||||
|
spawn sites, finite patch stocks and a stable commit ID; the owner helper
|
||||||
|
verifies the payload, provisions sequence 0/tick 0, resolves an exact genesis
|
||||||
|
retry and refuses nonempty founder/archive state or conflicting reuse. A
|
||||||
|
PostgreSQL integration check covers exact restore and retry behavior. This
|
||||||
|
does not provide a player spawn or make 11.3e playable.
|
||||||
|
|
||||||
## Exit boundary
|
## Exit boundary
|
||||||
|
|
||||||
|
|||||||
@@ -6357,3 +6357,20 @@ GCC 13.2 strict-warning syntax checks pass for the lifecycle, session adapter
|
|||||||
and focused tests in debug and `NDEBUG`; `git diff --check` passes. Runtime test
|
and focused tests in debug and `NDEBUG`; `git diff --check` passes. Runtime test
|
||||||
execution and full CI are pending; local CMake remains blocked by its cached
|
execution and full CI are pending; local CMake remains blocked by its cached
|
||||||
MSVC C++23 feature detection.
|
MSVC C++23 feature detection.
|
||||||
|
|
||||||
|
## 2026-10-10 — M11.3d-7f empty cellular genesis (CI pending)
|
||||||
|
|
||||||
|
Added an owner-only profile-4 genesis API and `evo-world-clone` configuration
|
||||||
|
for an explicitly supplied empty cellular opening. No life, identity or
|
||||||
|
founder is invented by provisioning. PostgreSQL integration coverage verifies
|
||||||
|
sequence-0/tick-0 publication, restored habitat/nursery closure, exact retry
|
||||||
|
and refusal of conflicting genesis.
|
||||||
|
|
||||||
|
GCC 13.2 strict-warning syntax checks pass for
|
||||||
|
`src/persistence/cellular_checkpoint_store.cpp` and
|
||||||
|
`tests/cellular_publication_tests.cpp`; `git diff --check` passes. The
|
||||||
|
Linux-only `evo-world-clone` translation unit cannot compile in this Windows
|
||||||
|
environment because `sys/random.h` is unavailable. The local CMake debug build
|
||||||
|
of `evo-cellular-lives-tests` remains running without output; it is not counted
|
||||||
|
as a pass. No PostgreSQL integration execution, CTest, clang-format or CI result
|
||||||
|
is claimed. The Linux/PostgreSQL qualification remains pending CI.
|
||||||
|
|||||||
@@ -197,6 +197,12 @@ recover_primitive_checkpoint(Postgres& db, const FilesystemObjectStore& objects,
|
|||||||
|
|
||||||
// Profile 4 publication replays the bounded cellular trace from the verified
|
// Profile 4 publication replays the bounded cellular trace from the verified
|
||||||
// predecessor and requires exact candidate bytes and action-to-life agreement.
|
// predecessor and requires exact candidate bytes and action-to-life agreement.
|
||||||
|
// Owner-only genesis provisioning accepts an empty profile-4 state. Player births
|
||||||
|
// are durable runtime operations and cannot be smuggled into genesis.
|
||||||
|
[[nodiscard]] std::expected<CommittedCheckpoint, CellularPublicationFailure>
|
||||||
|
provision_cellular_region(Postgres& owner, const FilesystemObjectStore& objects, RegionKey key,
|
||||||
|
std::uint64_t frame, const server::CellularLives& opening, Uuid commit,
|
||||||
|
const Sha256Digest& build, std::chrono::milliseconds timeout);
|
||||||
[[nodiscard]] std::expected<PublishedCellularBatch, CellularPublicationFailure>
|
[[nodiscard]] std::expected<PublishedCellularBatch, CellularPublicationFailure>
|
||||||
publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects,
|
publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects,
|
||||||
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
|
const LeaseGrant& lease, const CommittedCheckpoint& predecessor,
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ recomputes phenotype and body from archived genomes, verifies positions and
|
|||||||
footprints, verifies exact living-set/archive closure and unique life/account
|
footprints, verifies exact living-set/archive closure and unique life/account
|
||||||
identities, and reconciles every current channel (nursery, heat, habitat, lives,
|
identities, and reconciles every current channel (nursery, heat, habitat, lives,
|
||||||
corpses) to the explicit opening total. It accepts only byte-identical
|
corpses) to the explicit opening total. It accepts only byte-identical
|
||||||
canonical re-encoding. The codec is an in-memory profile contract: manifest
|
canonical re-encoding. Empty profile-4 genesis has zero living and corpse
|
||||||
allowlisting, PostgreSQL publication and process recovery are separate M11.3d
|
records, an empty lineage archive, and an explicit finite habitat/nursery
|
||||||
gates and remain required before this profile is durably playable.
|
opening. Owner provisioning does not add player lives; they require a separate
|
||||||
|
durable birth operation.
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#include "evo/persistence/sha256.hpp"
|
#include "evo/persistence/sha256.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace evo::persistence {
|
namespace evo::persistence {
|
||||||
@@ -67,6 +70,64 @@ bool prepared_is_canonical(const CellularPreparedCommit& prepared,
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
std::expected<CommittedCheckpoint, CellularPublicationFailure>
|
||||||
|
provision_cellular_region(Postgres& owner, const FilesystemObjectStore& objects, RegionKey key,
|
||||||
|
std::uint64_t frame, const server::CellularLives& opening, Uuid commit,
|
||||||
|
const Sha256Digest& build, milliseconds timeout) {
|
||||||
|
const auto payload = opening.snapshot();
|
||||||
|
if (opening.world() != key.world || opening.region() != key.region || opening.frame() != frame ||
|
||||||
|
opening.tick() != 0 || !opening.lives().empty() || !opening.corpses().empty() ||
|
||||||
|
opening.archive().recorded() != 0 || opening.archive().archived() != 0)
|
||||||
|
return std::unexpected{failure(PublicationError::candidate)};
|
||||||
|
const auto digest = sha256(payload);
|
||||||
|
if (!digest)
|
||||||
|
return std::unexpected{failure(PublicationError::digest)};
|
||||||
|
auto manifest = genesis_manifest(key, frame, commit, biology::cellular_motion_tick_microseconds,
|
||||||
|
build, payload.size(), *digest,
|
||||||
|
CheckpointProfile::cellular_lives_v1);
|
||||||
|
auto encoded = manifest ? encode_manifest(*manifest)
|
||||||
|
: std::expected<std::vector<std::uint8_t>, CheckpointError>{
|
||||||
|
std::unexpected{CheckpointError::format}};
|
||||||
|
if (!encoded || !restore_cellular_payload(payload, *manifest))
|
||||||
|
return std::unexpected{failure(PublicationError::candidate)};
|
||||||
|
if (auto stored = put_verified(objects, payload, {*digest, payload.size()}); !stored)
|
||||||
|
return std::unexpected{stored.error()};
|
||||||
|
|
||||||
|
std::string manifest_hex = "\\x";
|
||||||
|
constexpr std::string_view digits = "0123456789abcdef";
|
||||||
|
manifest_hex.reserve(2 + encoded->size() * 2);
|
||||||
|
for (const auto byte : *encoded) {
|
||||||
|
manifest_hex.push_back(digits[byte >> 4U]);
|
||||||
|
manifest_hex.push_back(digits[byte & 0x0fU]);
|
||||||
|
}
|
||||||
|
const std::array<std::string, 1> parameters{std::move(manifest_hex)};
|
||||||
|
auto inserted =
|
||||||
|
owner.query("SELECT evolution.provision_region_checkpoint($1::bytea)", parameters, timeout);
|
||||||
|
if (!inserted) {
|
||||||
|
auto existing = load_region_checkpoint(owner, key, timeout);
|
||||||
|
if (existing && existing->manifest == *encoded)
|
||||||
|
return confirm(existing->head, CellularPreparedCommit{key, commit, *encoded, {}, {}},
|
||||||
|
*manifest);
|
||||||
|
if (existing)
|
||||||
|
return std::unexpected{failure(PublicationError::rejected)};
|
||||||
|
if (existing.error().kind != LeaseStoreError::not_provisioned &&
|
||||||
|
inserted.error().kind == PgError::unknown)
|
||||||
|
return std::unexpected{failure(PublicationError::unknown, {}, existing.error())};
|
||||||
|
const bool unknown = inserted.error().kind == PgError::unknown;
|
||||||
|
return std::unexpected{failure(
|
||||||
|
unknown ? PublicationError::unknown : PublicationError::rejected, {},
|
||||||
|
{unknown ? LeaseStoreError::unknown : LeaseStoreError::store, inserted.error()})};
|
||||||
|
}
|
||||||
|
auto committed = load_region_checkpoint(owner, key, timeout);
|
||||||
|
if (!committed)
|
||||||
|
return std::unexpected{failure(PublicationError::unknown, {}, committed.error())};
|
||||||
|
CellularPreparedCommit prepared{key, commit, *encoded, {}, {}};
|
||||||
|
auto confirmed = confirm(committed->head, prepared, *manifest);
|
||||||
|
if (!confirmed)
|
||||||
|
return std::unexpected{confirmed.error()};
|
||||||
|
return *confirmed;
|
||||||
|
}
|
||||||
|
|
||||||
std::expected<CommittedCheckpoint, CellularPublicationFailure>
|
std::expected<CommittedCheckpoint, CellularPublicationFailure>
|
||||||
retry_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
|
retry_cellular_prepared(Postgres& db, const CellularPreparedCommit& prepared,
|
||||||
milliseconds timeout) {
|
milliseconds timeout) {
|
||||||
|
|||||||
@@ -47,12 +47,47 @@ std::string hex(std::span<const std::uint8_t> bytes) {
|
|||||||
|
|
||||||
void run_cellular_publication_tests() {
|
void run_cellular_publication_tests() {
|
||||||
auto owner = connect_as(env("PGUSER"));
|
auto owner = connect_as(env("PGUSER"));
|
||||||
constexpr RegionKey key{9756, 1};
|
|
||||||
const auto build = filled<32>(0xD9);
|
const auto build = filled<32>(0xD9);
|
||||||
CHECK(owner->query("INSERT INTO evolution.retained_builds(build_identity) VALUES "
|
CHECK(owner->query("INSERT INTO evolution.retained_builds(build_identity) VALUES "
|
||||||
"(decode(repeat('d9',32),'hex')) ON CONFLICT DO NOTHING",
|
"(decode(repeat('d9',32),'hex')) ON CONFLICT DO NOTHING",
|
||||||
{}, 5s));
|
{}, 5s));
|
||||||
|
|
||||||
|
constexpr RegionKey empty_key{9757, 1};
|
||||||
|
auto empty_nursery = PrimitiveLives::create({empty_key.world, empty_key.region, 1, 17, {},
|
||||||
|
{{0, 0}}});
|
||||||
|
CHECK(empty_nursery);
|
||||||
|
auto empty_habitat = evo::biology::CellularHabitat::create(
|
||||||
|
{empty_key.world, empty_key.region, 1, 1'000, 1'000,
|
||||||
|
{{{0, 0}, 19, {{12'000}, {{{10}, {20}, {30}, {40}}}}}}});
|
||||||
|
CHECK(empty_habitat);
|
||||||
|
auto empty_opening = CellularLives::create(**empty_nursery, std::move(*empty_habitat),
|
||||||
|
{{1'000, 1'000}, 0, 293'150});
|
||||||
|
CHECK(empty_opening && (*empty_opening)->lives().empty());
|
||||||
|
auto empty_objects = FilesystemObjectStore::open(env("PGHOST"), empty_key,
|
||||||
|
max_cellular_lives_bytes);
|
||||||
|
CHECK(empty_objects);
|
||||||
|
const auto empty_commit = filled<16>(0x20);
|
||||||
|
auto provisioned = provision_cellular_region(*owner, **empty_objects, empty_key, 1,
|
||||||
|
**empty_opening, empty_commit, build, 5s);
|
||||||
|
CHECK(provisioned && provisioned->head.sequence == 0 && provisioned->head.end_tick == 0);
|
||||||
|
auto empty_manifest = decode_manifest(provisioned->manifest);
|
||||||
|
CHECK(empty_manifest && empty_manifest->profile == CheckpointProfile::cellular_lives_v1 &&
|
||||||
|
empty_manifest->payload_bytes == (*empty_opening)->snapshot().size());
|
||||||
|
auto genesis_payload = (*empty_objects)->get(
|
||||||
|
{empty_manifest->payload_sha256, empty_manifest->payload_bytes});
|
||||||
|
CHECK(genesis_payload);
|
||||||
|
auto restored_genesis = restore_cellular_payload(*genesis_payload, *empty_manifest);
|
||||||
|
CHECK(restored_genesis && (*restored_genesis)->lives().empty() &&
|
||||||
|
(*restored_genesis)->nursery() == (*empty_opening)->nursery() &&
|
||||||
|
(*restored_genesis)->habitat().snapshot() == (*empty_opening)->habitat().snapshot());
|
||||||
|
auto exact_retry = provision_cellular_region(*owner, **empty_objects, empty_key, 1,
|
||||||
|
**empty_opening, empty_commit, build, 5s);
|
||||||
|
CHECK(exact_retry && exact_retry->manifest == provisioned->manifest);
|
||||||
|
CHECK(!provision_cellular_region(*owner, **empty_objects, empty_key, 1, **empty_opening,
|
||||||
|
filled<16>(0x22), build, 5s));
|
||||||
|
|
||||||
|
constexpr RegionKey key{9756, 1};
|
||||||
|
|
||||||
auto endowed = evo::biology::primitive_endowment();
|
auto endowed = evo::biology::primitive_endowment();
|
||||||
CHECK(endowed);
|
CHECK(endowed);
|
||||||
auto funding = endowed->body;
|
auto funding = endowed->body;
|
||||||
|
|||||||
Reference in New Issue
Block a user