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
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:
+119
-2
@@ -48,8 +48,13 @@
|
|||||||
// --crash-at <point>:<n> (tests only, M7.7) SIGKILLs this process at the n-th
|
// --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
|
// occurrence of before-upload, before-transaction, after-commit or after-ack (right
|
||||||
// after a step's acknowledgements are written and flushed).
|
// 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/processes/development_opening.hpp"
|
||||||
|
#include "evo/server/lifecycle/primitive_lives.hpp"
|
||||||
#include "evo/server/ops_http.hpp"
|
#include "evo/server/ops_http.hpp"
|
||||||
|
#include "evo/server/primitive_region_host.hpp"
|
||||||
#include "evo/server/region_host.hpp"
|
#include "evo/server/region_host.hpp"
|
||||||
#include "m10_bridge.hpp"
|
#include "m10_bridge.hpp"
|
||||||
#include "session_bridge.hpp"
|
#include "session_bridge.hpp"
|
||||||
@@ -67,6 +72,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <thread>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -143,7 +149,8 @@ std::optional<Options> parse(int argc, char** argv) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
const std::string_view value = argv[++i];
|
const std::string_view value = argv[++i];
|
||||||
const auto n = number(value);
|
const auto n = number(value);
|
||||||
if (flag == "--profile" && (value == "lineage" || value == "environmental"))
|
if (flag == "--profile" &&
|
||||||
|
(value == "lineage" || value == "environmental" || value == "primitive"))
|
||||||
o.profile = value;
|
o.profile = value;
|
||||||
else if (flag == "--world" && n)
|
else if (flag == "--world" && n)
|
||||||
o.host.key.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.
|
// M10 sessions (ADR-0091/0092) need every setting and the QUIC build.
|
||||||
if (o.m10.any() && (!server_app::m10_available || !o.m10.complete()))
|
if (o.m10.any() && (!server_app::m10_available || !o.m10.complete()))
|
||||||
return std::nullopt;
|
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())
|
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);
|
o.host.retained_builds.push_back(o.host.build);
|
||||||
return o;
|
return o;
|
||||||
@@ -591,12 +604,114 @@ template <typename State> int serve(Options& o) {
|
|||||||
return finish(3); // Pending/unknown work is left for the next owner to reconcile.
|
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
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
auto options = parse(argc, argv);
|
auto options = parse(argc, argv);
|
||||||
if (!options) {
|
if (!options) {
|
||||||
std::fputs("usage: evo-server --profile lineage|environmental --world N --region N "
|
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 "
|
"--frame N --pg-host H --pg-port P --pg-database D --pg-user U "
|
||||||
"--objects DIR --build HEX64 [--retained HEX64]... [--pg-hostaddr A "
|
"--objects DIR --build HEX64 [--retained HEX64]... [--pg-hostaddr A "
|
||||||
"--pg-passfile F --pg-ca F] [--flush-ms N] [--drain-ms N] "
|
"--pg-passfile F --pg-ca F] [--flush-ms N] [--drain-ms N] "
|
||||||
@@ -620,6 +735,8 @@ int main(int argc, char** argv) {
|
|||||||
sigaction(SIGTERM, &action, nullptr);
|
sigaction(SIGTERM, &action, nullptr);
|
||||||
sigaction(SIGINT, &action, nullptr);
|
sigaction(SIGINT, &action, nullptr);
|
||||||
std::signal(SIGPIPE, SIG_IGN);
|
std::signal(SIGPIPE, SIG_IGN);
|
||||||
|
if (options->profile == "primitive")
|
||||||
|
return serve_primitive(*options);
|
||||||
return options->profile == "lineage" ? serve<processes::LineageRegion>(*options)
|
return options->profile == "lineage" ? serve<processes::LineageRegion>(*options)
|
||||||
: serve<processes::EnvironmentalCommunity>(*options);
|
: serve<processes::EnvironmentalCommunity>(*options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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`
|
- 11.2d-4 implementation: `evo-world-clone provision --opening primitive-v1`
|
||||||
requires owner-supplied frame/source IDs, all five finite funding channels and
|
requires owner-supplied frame/source IDs, all five finite funding channels and
|
||||||
ordered habitat sites. It writes profile-3 genesis using the primitive payload
|
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
|
PostgreSQL process test covers runtime-role refusal, owner provisioning, exact
|
||||||
retry, profile/frame mismatch and recovered opening values. No deployed world
|
retry, changed frame/opening and recovered values. No deployed world was
|
||||||
was touched. The PostgreSQL CI gate remains to be confirmed.
|
touched. The PostgreSQL CI gate remains to be confirmed.
|
||||||
- Next 11.2d subsection: `evo-server` profile selection and safe provisioning.
|
- 11.2d-5 implementation: `evo-server --profile primitive` selects only the
|
||||||
Authenticated v5 session admission/routing, process-kill qualification and
|
profile-3 creation host, uses its payload bound and becomes ready only after
|
||||||
readiness integration remain after that; the generic host still serves only
|
lease acquisition and full profile-3 recovery. Missing genesis is quarantined;
|
||||||
profiles 1 and 2.
|
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.
|
No deployed world has been provisioned or changed by this work.
|
||||||
|
|||||||
@@ -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
|
was verified directly with the same pinned clang-format version. The primitive
|
||||||
provisioning build and PostgreSQL process test await Linux CI. No deployed world
|
provisioning build and PostgreSQL process test await Linux CI. No deployed world
|
||||||
was provisioned or changed.
|
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.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Real process tests for evo-server (M7.6, ADR-0064): SIGTERM drain and SIGKILL
|
// 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
|
// with recovery by a successor process. Run by tools/ci/postgres-check.sh, which
|
||||||
// sets EVO_SERVER_BIN.
|
// sets EVO_SERVER_BIN.
|
||||||
|
#include "evo/server/lifecycle/primitive_lives.hpp"
|
||||||
#include "fixtures/server_process.hpp"
|
#include "fixtures/server_process.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <source_location>
|
#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>(acked_max),
|
||||||
static_cast<unsigned long long>(committed.tick), static_cast<long long>(to_ready));
|
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
|
} // namespace
|
||||||
|
|
||||||
void run_region_server_process_tests() {
|
void run_region_server_process_tests() {
|
||||||
sigterm_drains_and_releases();
|
sigterm_drains_and_releases();
|
||||||
sigkill_recovers_through_a_successor();
|
sigkill_recovers_through_a_successor();
|
||||||
|
primitive_profile_recovers_before_readiness();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user