Select the primitive region host explicitly
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (postgres) (push) Canceled after 0s
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 (network) (push) Canceled after 6m34s
Foundation / checks (client) (push) Canceled after 8m38s
Foundation / checks (checks) (push) Canceled after 8m44s

This commit is contained in:
dingo
2026-10-10 20:37:58 -04:00
parent 9e8de204f0
commit 7da7ef2a6c
4 changed files with 264 additions and 24 deletions
+134 -17
View File
@@ -48,8 +48,13 @@
// --crash-at <point>:<n> (tests only, M7.7) SIGKILLs this process at the n-th
// occurrence of before-upload, before-transaction, after-commit or after-ack (right
// after a step's acknowledgements are written and flushed).
// --profile primitive (M11.2d-5) starts the creation-only profile-3 host. It requires
// an owner-provisioned checkpoint, becomes ready only after recovery, and does not
// accept M9/M10 sessions, synthetic tick input or genesis provisioning.
#include "evo/processes/development_opening.hpp"
#include "evo/server/lifecycle/primitive_lives.hpp"
#include "evo/server/ops_http.hpp"
#include "evo/server/primitive_region_host.hpp"
#include "evo/server/region_host.hpp"
#include "m10_bridge.hpp"
#include "session_bridge.hpp"
@@ -67,6 +72,7 @@
#include <signal.h>
#include <string>
#include <string_view>
#include <thread>
#include <unistd.h>
#include <vector>
@@ -143,7 +149,8 @@ std::optional<Options> parse(int argc, char** argv) {
return std::nullopt;
const std::string_view value = argv[++i];
const auto n = number(value);
if (flag == "--profile" && (value == "lineage" || value == "environmental"))
if (flag == "--profile" &&
(value == "lineage" || value == "environmental" || value == "primitive"))
o.profile = value;
else if (flag == "--world" && n)
o.host.key.world = *n;
@@ -269,6 +276,12 @@ std::optional<Options> parse(int argc, char** argv) {
// M10 sessions (ADR-0091/0092) need every setting and the QUIC build.
if (o.m10.any() && (!server_app::m10_available || !o.m10.complete()))
return std::nullopt;
// Primitive profile serves only the creation-only host in this slice. It
// cannot accept M9/M10 sessions or synthetic biological ticks.
if (o.profile == "primitive" &&
(o.synthetic || !o.crash_point.empty() || o.session.any() || o.m10.any() ||
o.host.flush_interval != 1000ms || o.drain != 10000ms))
return std::nullopt;
if (std::ranges::find(o.host.retained_builds, o.host.build) == o.host.retained_builds.end())
o.host.retained_builds.push_back(o.host.build);
return o;
@@ -591,27 +604,129 @@ template <typename State> int serve(Options& o) {
return finish(3); // Pending/unknown work is left for the next owner to reconcile.
}
}
int serve_primitive(Options& o) {
auto objects = persistence::FilesystemObjectStore::open(
o.objects, o.host.key, server::max_primitive_lives_bytes, nullptr,
o.objects_reserve_mib * 1024 * 1024);
if (!objects) {
std::puts("error objects");
return 2;
}
// The unique_ptr moves into the host, but the store object itself stays put.
const auto* objects_view = objects->get();
const auto pg = o.pg;
auto made = server::PrimitiveRegionHost::create(
{o.host.key, o.host.frame, o.host.lease, o.host.build, o.host.retained_builds},
[pg] { return persistence::Postgres::connect(pg, 2s); }, std::move(*objects));
if (!made) {
std::puts("error config");
return 2;
}
auto& host = **made;
std::unique_ptr<server::OpsServer> ops;
if (!o.ops_listen.empty()) {
auto listening = server::OpsServer::listen(o.ops_listen);
if (!listening) {
std::puts("error ops-listen");
return 2;
}
ops = std::move(*listening);
std::printf("ops listening %u\n", static_cast<unsigned>(ops->port()));
}
server::OpsCounters counters;
counters.objects_reserve_bytes = o.objects_reserve_mib * 1024 * 1024;
bool ready = false;
std::optional<server::HostPhase> phase;
const auto set_ready = [&](bool now) {
if (ready != now) {
ready = now;
std::printf("ready %d\n", ready ? 1 : 0);
}
if (!o.ready_file.empty()) {
std::error_code ignored;
if (ready)
std::ofstream(o.ready_file) << "ready\n";
else
std::filesystem::remove(o.ready_file, ignored);
}
};
const auto finish = [&](int code) {
set_ready(false);
const auto& status = host.status();
std::printf("phase %s epoch=%llu committed=%llu simulated=%llu\n",
server::phase_name(status.phase), static_cast<unsigned long long>(status.epoch),
static_cast<unsigned long long>(status.committed_tick),
static_cast<unsigned long long>(status.simulated_tick));
std::printf("stats commits=%llu store_failures=%llu\n",
static_cast<unsigned long long>(status.commits),
static_cast<unsigned long long>(status.store_failures));
std::printf("exit %d\n", code);
std::fflush(stdout);
return code;
};
for (;;) {
if (stop_requested) {
host.drain();
return finish(0);
}
const auto& status = host.step();
set_ready(status.ready);
if (!phase || *phase != status.phase) {
phase = status.phase;
std::printf("phase %s epoch=%llu committed=%llu simulated=%llu\n",
server::phase_name(status.phase),
static_cast<unsigned long long>(status.epoch),
static_cast<unsigned long long>(status.committed_tick),
static_cast<unsigned long long>(status.simulated_tick));
}
if (ops) {
const auto handler = [&](std::string_view path) -> server::OpsResponse {
const auto& current = host.status();
if (path == "/livez")
return {200, "live\n"};
if (path == "/readyz")
return current.ready ? server::OpsResponse{200, "ready\n"}
: server::OpsResponse{
503, std::string("not ready: ") +
server::phase_name(current.phase) + "\n"};
if (path == "/metrics") {
counters.objects_available_bytes = objects_view->available_bytes().value_or(0);
return {200, server::render_metrics(current, counters),
"text/plain; version=0.0.4; charset=utf-8"};
}
return {404, "not found\n"};
};
ops->serve(handler);
}
std::fflush(stdout);
if (status.phase == server::HostPhase::quarantined)
return finish(4);
std::this_thread::sleep_for(5ms);
}
}
} // namespace
int main(int argc, char** argv) {
auto options = parse(argc, argv);
if (!options) {
std::fputs("usage: evo-server --profile lineage|environmental --world N --region N "
"--frame N --pg-host H --pg-port P --pg-database D --pg-user U "
"--objects DIR --build HEX64 [--retained HEX64]... [--pg-hostaddr A "
"--pg-passfile F --pg-ca F] [--flush-ms N] [--drain-ms N] "
"[--lease-profile default|fast] [--ready-file PATH] "
"[--ops-listen ADDRESS:PORT] [--synthetic-inputs development-v1 "
"[--synthetic-until TICK] [--accelerate N] [--session-listen ADDRESS:PORT "
"--session-cert F --session-key F --session-grant-key F "
"--session-grant-ledger F --session-environment dev]] [--m10-listen "
"ADDRESS:PORT --m10-cert F --m10-key F --m10-issuer F "
"--m10-environment dev|stage|world0 --session-window ACTIVATION:UTC_EXPIRY "
"[--m10-max-grant-lifetime 60..14400] [--m10-area X0,Y0,X1,Y1] "
"[--m10-handoff-key F [--m10-neighbour "
"REGION=X0,Y0,X1,Y1=HOST:PORT=NAME=PUBFILE]...] "
"[--m10-load-governor on|off]]\\n",
stderr);
std::fputs(
"usage: evo-server --profile lineage|environmental|primitive --world N --region N "
"--frame N --pg-host H --pg-port P --pg-database D --pg-user U "
"--objects DIR --build HEX64 [--retained HEX64]... [--pg-hostaddr A "
"--pg-passfile F --pg-ca F] [--flush-ms N] [--drain-ms N] "
"[--lease-profile default|fast] [--ready-file PATH] "
"[--ops-listen ADDRESS:PORT] [--synthetic-inputs development-v1 "
"[--synthetic-until TICK] [--accelerate N] [--session-listen ADDRESS:PORT "
"--session-cert F --session-key F --session-grant-key F "
"--session-grant-ledger F --session-environment dev]] [--m10-listen "
"ADDRESS:PORT --m10-cert F --m10-key F --m10-issuer F "
"--m10-environment dev|stage|world0 --session-window ACTIVATION:UTC_EXPIRY "
"[--m10-max-grant-lifetime 60..14400] [--m10-area X0,Y0,X1,Y1] "
"[--m10-handoff-key F [--m10-neighbour "
"REGION=X0,Y0,X1,Y1=HOST:PORT=NAME=PUBFILE]...] "
"[--m10-load-governor on|off]]\\n",
stderr);
return 2;
}
struct sigaction action{};
@@ -620,6 +735,8 @@ int main(int argc, char** argv) {
sigaction(SIGTERM, &action, nullptr);
sigaction(SIGINT, &action, nullptr);
std::signal(SIGPIPE, SIG_IGN);
if (options->profile == "primitive")
return serve_primitive(*options);
return options->profile == "lineage" ? serve<processes::LineageRegion>(*options)
: serve<processes::EnvironmentalCommunity>(*options);
}
+14 -7
View File
@@ -109,13 +109,20 @@ Local checks do not close ADR-0097's reference-worker qualification.
- 11.2d-4 implementation: `evo-world-clone provision --opening primitive-v1`
requires owner-supplied frame/source IDs, all five finite funding channels and
ordered habitat sites. It writes profile-3 genesis using the primitive payload
bound and refuses an existing region whose profile or frame differs. A real-
bound and refuses an existing region whose profile/frame or full opening differs. A real-
PostgreSQL process test covers runtime-role refusal, owner provisioning, exact
retry, profile/frame mismatch and recovered opening values. No deployed world
was touched. The PostgreSQL CI gate remains to be confirmed.
- Next 11.2d subsection: `evo-server` profile selection and safe provisioning.
Authenticated v5 session admission/routing, process-kill qualification and
readiness integration remain after that; the generic host still serves only
profiles 1 and 2.
retry, changed frame/opening and recovered values. No deployed world was
touched. The PostgreSQL CI gate remains to be confirmed.
- 11.2d-5 implementation: `evo-server --profile primitive` selects only the
profile-3 creation host, uses its payload bound and becomes ready only after
lease acquisition and full profile-3 recovery. Missing genesis is quarantined;
this mode refuses synthetic ticks and the M9/M10 session listeners, and never
provisions or advances biology. The process test checks ready-after-recovery,
missing-genesis refusal, no tick advance and clean lease release. Linux CI
compilation and PostgreSQL process evidence remain pending.
- Next 11.2d subsection: authenticated v5 session admission and routing through
the primitive host, followed by process-kill qualification and readiness
integration. Until that gate passes, the new profile selection is recovery
and operations only; it is not a playable server.
No deployed world has been provisioned or changed by this work.
+17
View File
@@ -5760,3 +5760,20 @@ Windows repository format target stalled in Ninja and was stopped; formatting
was verified directly with the same pinned clang-format version. The primitive
provisioning build and PostgreSQL process test await Linux CI. No deployed world
was provisioned or changed.
## 2026-10-10 — M11.2d-5 primitive evo-server selection (CI pending)
Added explicit `--profile primitive` startup through `PrimitiveRegionHost`, with
profile-3 payload bounds and readiness only after lease acquisition and complete
checkpoint recovery. The primitive mode refuses synthetic ticks and M9/M10
session options; it does not provision genesis or advance biology. The real-
process test checks successful recovery and ready state, unchanged genesis tick,
lease release on SIGTERM, refusal of synthetic tick mode, and quarantine without
genesis.
Executed locally: clang-format 19.1.5 dry-run on the changed C++ files and
`git diff --check`; both passed. The Linux-only server and PostgreSQL process
tests cannot run in this Windows environment: WSL launch was denied with
`E_ACCESSDENIED`, and the configured Linux compiler is not available directly in
PowerShell. CI compilation and runtime qualification are pending. No deployed
world was provisioned or changed.
+99
View File
@@ -1,6 +1,7 @@
// Real process tests for evo-server (M7.6, ADR-0064): SIGTERM drain and SIGKILL
// with recovery by a successor process. Run by tools/ci/postgres-check.sh, which
// sets EVO_SERVER_BIN.
#include "evo/server/lifecycle/primitive_lives.hpp"
#include "fixtures/server_process.hpp"
#include <algorithm>
#include <source_location>
@@ -87,9 +88,107 @@ void sigkill_recovers_through_a_successor() {
static_cast<unsigned long long>(acked_max),
static_cast<unsigned long long>(committed.tick), static_cast<long long>(to_ready));
}
// Profile 3 has an explicit host selection. It becomes ready only after the
// primitive checkpoint is recovered and exits without advancing biology.
void primitive_profile_recovers_before_readiness() {
using namespace evo::persistence;
using namespace evo::server;
const RegionKey key{7, 33};
const fs::path root = fs::path(env("PGHOST")) / "server-primitive-33";
fs::remove_all(root);
fs::create_directory(root);
fs::permissions(root, fs::perms::owner_all, fs::perm_options::replace);
auto db = owner();
CHECK(db->query("INSERT INTO evolution.retained_builds(build_identity) VALUES "
"(decode(repeat('b1',32),'hex')) ON CONFLICT DO NOTHING",
{}, 5s));
const auto endowed = evo::biology::primitive_endowment();
CHECK(endowed);
auto funding = endowed->body;
funding.energy.value += endowed->reserve.energy.value + endowed->construction.value;
auto opening = PrimitiveLives::create({key.world, key.region, 1, 1, funding, {{0, 0}}});
CHECK(opening);
auto objects = FilesystemObjectStore::open(root, key, max_primitive_lives_bytes);
CHECK(objects);
Sha256Digest build{};
build.fill(0xB1);
Uuid commit{};
commit.fill(0x33);
CHECK(provision_primitive_region(*db, **objects, key, 1, **opening, commit, build, 5s));
CHECK(db->query("INSERT INTO evolution.life_allocators VALUES(7,1) ON CONFLICT DO NOTHING", {},
5s));
std::vector<std::string> args{
env("EVO_SERVER_BIN"),
"--profile",
"primitive",
"--world",
"7",
"--region",
"33",
"--frame",
"1",
"--pg-host",
env("PGHOST"),
"--pg-port",
env("PGPORT"),
"--pg-database",
env("PGDATABASE"),
"--pg-user",
env("EVO_PG_RUNTIME_USER"),
"--objects",
root.string(),
"--build",
"b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1",
"--lease-profile",
"fast",
"--ready-file",
(root / "ready").string()};
Child host{args};
CHECK(host.wait_for([](const std::string& line) { return line == "ready 1"; }, 15s));
CHECK(fs::exists(root / "ready"));
CHECK(host.printed("phase running epoch=1 committed=0 simulated=0"));
host.signal(SIGTERM);
CHECK(host.wait_exit(20s) == 0);
CHECK(host.printed("exit 0") && host.printed("ready 0"));
CHECK(!fs::exists(root / "ready"));
const auto head = head_of(key);
CHECK(head.tick == 0 && head.sequence == 0 && head.released);
auto synthetic_args = args;
synthetic_args.emplace_back("--synthetic-inputs");
synthetic_args.emplace_back("development-v1");
Child synthetic{synthetic_args};
CHECK(synthetic.wait_exit(15s) == 2); // Profile 3 never accepts biological tick inputs.
const RegionKey missing_key{7, 34};
const fs::path missing_root = fs::path(env("PGHOST")) / "server-primitive-missing-34";
fs::remove_all(missing_root);
fs::create_directory(missing_root);
fs::permissions(missing_root, fs::perms::owner_all, fs::perm_options::replace);
auto missing_args = args;
const auto region_arg = std::find(missing_args.begin(), missing_args.end(), "--region");
*(region_arg + 1) = "34";
const auto objects_arg = std::find(missing_args.begin(), missing_args.end(), "--objects");
*(objects_arg + 1) = missing_root.string();
const auto ready_arg = std::find(missing_args.begin(), missing_args.end(), "--ready-file");
*(ready_arg + 1) = (missing_root / "ready").string();
Child absent{missing_args};
CHECK(absent.wait_for(
[](const std::string& line) {
return line == "phase quarantined epoch=0 committed=0 simulated=0";
},
15s));
CHECK(absent.wait_exit(15s) == 4 && !absent.printed("ready 1"));
const auto missing_head = load_region_head(*db, missing_key, 5s);
CHECK(!missing_head && missing_head.error().kind == LeaseStoreError::not_provisioned);
}
} // namespace
void run_region_server_process_tests() {
sigterm_drains_and_releases();
sigkill_recovers_through_a_successor();
primitive_profile_recovers_before_readiness();
}