Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / postgres-tools (push) Successful in 31s
Foundation / server-image (push) Successful in 4m29s
Foundation / image (push) Successful in 5m43s
ADR-0182 section 17. The plan's 2,000-organism cap became the rules-12 key region.organism_cap, which was parsed but never enforced; the real bound was max_cellular_tick_lives = 256 (ADR-0106), which rules 13's organism cap could not exceed. The bound is now 4,096, for testing limits only; the DEV tuning file keeps 256. - max_cellular_tick_lives (4,096) bounds the raw region path: step, owner state, batch trace (cellular_batch_bytes_for) and current checkpoint traces. max_cellular_frozen_lives (256) keeps cohort populations, population batches, migration traces and pre-v3 cellular traces, whose database checks are fixed. - Tuning: reproduction.organism_cap and wildlife_cap accept up to 4,096. - Schema 68: the trace checker under the current publishers (cellular_births_v45) accepts 4,096 intents, births and mutations per tick; spawn_wildlife takes up to 256 cells a command. - Region view and portal: the lineage archive's fill (births of 65,536, genomes of 4,096), at which a region stops ticking. - PostgreSQL suite: 256 wildlife spawned in one command, then a 289-life tick published and recovered exactly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
163 lines
8.9 KiB
C++
163 lines
8.9 KiB
C++
// ADR-0139: paired qualification of exact retained-member cohorts, not compression.
|
|
#include "../../tests/fixtures/cellular_ecology.hpp"
|
|
#include "evo/server/lifecycle/cellular_population.hpp"
|
|
|
|
#include <chrono>
|
|
|
|
namespace {
|
|
using namespace evo;
|
|
using namespace evo::server;
|
|
using namespace evo::fixture;
|
|
using Clock = std::chrono::steady_clock;
|
|
|
|
std::uint64_t paired(std::uint64_t seed, bool rich, std::uint64_t ticks, std::uint64_t width) {
|
|
auto reference = opening(seed, rich);
|
|
auto population = checked(CellularPopulation::create(restore(*reference)), "cohort owner");
|
|
std::set<std::uint64_t> mutated;
|
|
std::uint64_t collapsed = 0, materialized = 0, cohort_ticks = 0, max_members = 0;
|
|
std::uint64_t reference_ns = 0, population_ns = 0, conversions_ns = 0;
|
|
const auto initial = reference->snapshot();
|
|
require(!population->collapse(100), "controlled founder collapsed");
|
|
require(!population->materialize(100), "missing cohort materialized");
|
|
require(population->state().snapshot() == initial, "refused conversion mutated state");
|
|
require(!population->advance_tick({}), "missing controlled intentions admitted");
|
|
require(population->state().snapshot() == initial, "refused tick mutated state");
|
|
for (std::uint64_t step = 0; step < ticks; ++step) {
|
|
if (step % width == 0) {
|
|
const auto start = Clock::now();
|
|
std::set<std::uint64_t> genomes;
|
|
for (const auto& life : population->state().lives())
|
|
if (life.account == LifeAccount{})
|
|
genomes.insert(life.identity.genome);
|
|
for (const auto genome : genomes) {
|
|
// Whole-genome oscillation is deliberate: an adversarial conversion may
|
|
// not select a better member, heal one, refresh its age or duplicate stock.
|
|
if ((step / width) % 2 == 0) {
|
|
collapsed += checked(population->collapse(genome), "collapse");
|
|
require(checked(population->collapse(genome), "repeat collapse") == 0,
|
|
"collapse duplicated membership");
|
|
} else if (std::ranges::any_of(population->members(), [genome](const auto& m) {
|
|
return m.genome == genome;
|
|
})) {
|
|
materialized += checked(population->materialize(genome), "materialize");
|
|
require(!population->materialize(genome), "materialized twice");
|
|
}
|
|
}
|
|
conversions_ns += static_cast<std::uint64_t>(
|
|
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count());
|
|
require(population->state().snapshot() == reference->snapshot(),
|
|
"conversion changed retained biology");
|
|
}
|
|
const auto input = inputs(*reference, seed, mutated);
|
|
std::vector<CellularLifeIntent> controlled;
|
|
for (const auto& life : reference->lives())
|
|
if (life.account != LifeAccount{}) {
|
|
const auto found = std::ranges::find(input.lives, life.identity.life,
|
|
&CellularLifeIntent::life_id);
|
|
require(found != input.lives.end(), "missing fixture player");
|
|
controlled.push_back(*found);
|
|
require(!population->in_cohort(life.identity.life), "controlled cohort member");
|
|
}
|
|
auto start = Clock::now();
|
|
const auto executed = checked(
|
|
reference->advance_tick_with_mutations(input.lives, input.mutations), "reference tick");
|
|
reference_ns += static_cast<std::uint64_t>(
|
|
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count());
|
|
start = Clock::now();
|
|
const auto candidate =
|
|
checked(population->advance_tick(controlled, input.mutations), "population tick");
|
|
population_ns += static_cast<std::uint64_t>(
|
|
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count());
|
|
require(candidate.buds == executed.buds && candidate.mutations == executed.mutations,
|
|
"population events diverged");
|
|
for (const auto& mutation : executed.mutations)
|
|
if (mutation.result == CellularMutationResult::applied)
|
|
mutated.insert(mutation.life_id);
|
|
require(population->state().snapshot() == reference->snapshot(),
|
|
"population demographic/biomass/diversity/history divergence");
|
|
require(population->state().current_total() == population->state().opening_total(),
|
|
"population inventory divergence");
|
|
for (const auto& member : population->members()) {
|
|
const auto life =
|
|
std::ranges::find(population->state().lives(), member.life,
|
|
[](const auto& cell) { return cell.identity.life; });
|
|
require(life != population->state().lives().end() && life->account == LifeAccount{} &&
|
|
life->presence == CellularPresence::active &&
|
|
life->identity.genome == member.genome,
|
|
"invalid ownership tag");
|
|
}
|
|
cohort_ticks += population->members().size();
|
|
max_members =
|
|
std::max(max_members, static_cast<std::uint64_t>(population->members().size()));
|
|
}
|
|
const auto summary = checked(summarize_cellular_play(*reference), "population census");
|
|
std::cout << "{\"kind\":\"paired\",\"seed\":" << seed
|
|
<< ",\"holdout\":" << (seed >= 2 ? "true" : "false")
|
|
<< ",\"rich\":" << (rich ? "true" : "false") << ",\"ticks\":" << ticks
|
|
<< ",\"conversion_width\":" << width << ",\"collapsed\":" << collapsed
|
|
<< ",\"materialized\":" << materialized << ",\"cohort_member_ticks\":" << cohort_ticks
|
|
<< ",\"peak_members\":" << max_members << ",\"deaths\":" << summary.deaths
|
|
<< ",\"buds\":" << summary.buds << ",\"mutations\":" << summary.mutations
|
|
<< ",\"reference_ns\":" << reference_ns << ",\"population_ns\":" << population_ns
|
|
<< ",\"conversion_ns\":" << conversions_ns << ",\"max_state_error\":0}\n";
|
|
if (rich && seed == 1 && ticks >= 8192)
|
|
require(collapsed > 0 && materialized > 0 && cohort_ticks > 0,
|
|
"long qualification missed cohort conversion");
|
|
return cohort_ticks;
|
|
}
|
|
|
|
void capacity(std::uint32_t count) {
|
|
auto population =
|
|
checked(CellularPopulation::create(opening(7, true, count)), "capacity owner");
|
|
std::vector<std::uint64_t> samples;
|
|
for (unsigned tick = 0; tick < 32; ++tick) {
|
|
std::vector<CellularLifeIntent> players;
|
|
for (const auto& life : population->state().lives())
|
|
players.push_back({life.identity.life, {}});
|
|
const auto start = Clock::now();
|
|
checked(population->advance_tick(players), "capacity tick");
|
|
samples.push_back(static_cast<std::uint64_t>(
|
|
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count()));
|
|
require(population->state().lives().size() == count, "capacity silently culled a life");
|
|
}
|
|
if (count == biology::max_cellular_frozen_lives) {
|
|
const auto before = population->state().snapshot();
|
|
LifeRequest request{};
|
|
request.account.front() = 1;
|
|
request.action = 1;
|
|
const auto refused = population->state().birth_candidate(
|
|
request, {1000, 1000, 1000, 1000, {population->state().tick()}});
|
|
require(!refused && refused.error() == CellularLivesError::no_placement,
|
|
"capacity failed to backpressure");
|
|
require(before == population->state().snapshot(), "capacity refusal changed state");
|
|
}
|
|
std::ranges::sort(samples);
|
|
std::cout << "{\"kind\":\"capacity\",\"lives\":" << count
|
|
<< ",\"samples\":32,\"p50_step_ns\":" << samples[16]
|
|
<< ",\"p95_step_ns\":" << samples[30] << ",\"max_step_ns\":" << samples.back()
|
|
<< ",\"snapshot_bytes\":" << population->state().snapshot().size() << "}\n";
|
|
}
|
|
} // namespace
|
|
|
|
int main(int argc, char** argv) try {
|
|
if (argc > 2 || (argc == 2 && std::string_view{argv[1]} != "--verify"))
|
|
return 2;
|
|
std::cout << "{\"kind\":\"metadata\",\"model\":\"exact-cellular-cohorts-1\","
|
|
"\"rules\":8,\"quantum_us\":50000,\"regional_approximation\":false,"
|
|
"\"compression_claimed\":false,\"runtime_enabled\":false}\n";
|
|
std::uint64_t member_ticks = 0;
|
|
for (std::uint64_t seed = 0; seed < 4; ++seed)
|
|
for (const bool rich : {true, false})
|
|
for (const auto width : {1ULL, 16ULL, 64ULL})
|
|
member_ticks += paired(seed, rich, argc == 1 ? 8192 : 512, width);
|
|
if (argc == 2)
|
|
member_ticks += paired(1, true, 8192, 16);
|
|
require(member_ticks > 0, "qualification missed all cohort members");
|
|
for (const auto count : {16U, 64U, 128U, 256U})
|
|
capacity(count);
|
|
return 0;
|
|
} catch (const std::exception& error) {
|
|
std::fprintf(stderr, "%s\n", error.what());
|
|
return 1;
|
|
}
|