Stop calling the end of watching a death

Three defects from review of 89ad95b.

An organism still alive when an episode stopped was recorded dead. A one-tick
run reported no extinctions while writing terminal records for founders that had
not died, and their watched time was added to the same total as completed
lifetimes. Observation ending is a fact about the run, not about the organism,
and ADR-0034 makes a recorded death terminal, so there was nothing to be
terminal about. Survivors stay living now and are counted apart, with their
watched time as the lower bound it is; lived_ticks and observed_ticks answer
different questions and are never summed together.

A genome without the reproduction capability derives a zero investment, which
the driver refused outright, so seeds 10, 12 and 15 failed the whole run.
Filtering those variants out before sampling would have been the worse repair:
the measured set would then be the fertile subset a guard approved of, and being
unable to reproduce is a result rather than grounds for exclusion. The driver
runs such a strategy and proposes no birth for it. ADR-0029 is amended rather
than quietly contradicted.

A half's thermal shortfall was assigned where it was documented as a total, so
two episodes at 15,000 reported 15,000.

Only configurations the driver already rejected behave differently, so the M2.6
pin 2cd4a15f9fbe9949 was checked rather than assumed and still holds. The
ensemble pin moved because the reported facts changed, not to pass a test; the
reason sits beside it. Each fix was confirmed load-bearing by reverting it alone.

Release 33/33, analysis, ASan 33/33 and clang-format all ran and passed here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-24 05:58:22 -04:00
co-authored by Claude Opus 5
parent 89ad95bf12
commit 72ed03f4dd
12 changed files with 316 additions and 34 deletions
+4 -1
View File
@@ -136,8 +136,11 @@ if(BUILD_TESTING)
PROPERTIES WILL_FAIL TRUE)
add_test(NAME cli-ensemble COMMAND evo-sim --ensemble --seed 0 --seeds-per-cell 4
--strategies 3 --tick-limit 400)
# Repinned when survivors stopped being recorded as deaths and the report gained
# deaths/survivors/observed_ticks with a summed shortfall. The reported facts
# changed, so the old value describes a report this build no longer produces.
set_tests_properties(cli-ensemble PROPERTIES TIMEOUT 120
PASS_REGULAR_EXPRESSION "c2b96c86101be628")
PASS_REGULAR_EXPRESSION "5ec59d390909b526")
# The two measurement modes are separate workloads, and neither may borrow the
# other's options: --episodes counts episodes, --seeds-per-cell counts seeds.
add_test(NAME cli-ensemble-conflict COMMAND evo-sim --ensemble --verify-replay)
+3 -1
View File
@@ -70,7 +70,9 @@ so a difference that appears in one half only is visible as the seed artifact it
is. Options belong to exactly one mode: `--episodes` counts episodes and is
rejected here, `--seeds-per-cell` counts seeds and is rejected in ecosystem mode.
A cell's numbers are not fitness, adaptation or balance, and the resource axis is
deliberately not monotonic. See
deliberately not monotonic. Lifetimes are censored: an organism still alive when
an episode stops is reported as a survivor with the time it was watched, never as
a death, so `lived_ticks` and `observed_ticks` answer different questions. See
[ADR-0035](docs/adr/0035-genome-ecology-ensembles.md) for scope and for why.
The second command continues saved PRNG/component state. `--verify-replay`
+3 -1
View File
@@ -381,8 +381,10 @@ std::expected<void, evo::Error> run_ensemble_mode(const Options& options) {
const auto& outcome = (*halves[half])[which];
report << (which == 0 ? "" : ",") << "{\"genome\":" << outcome.genome
<< ",\"episodes\":" << outcome.episodes << ",\"births\":" << outcome.births
<< ",\"organisms\":" << outcome.organisms
<< ",\"organisms\":" << outcome.organisms << ",\"deaths\":" << outcome.deaths
<< ",\"lived_ticks\":" << outcome.lived_ticks
<< ",\"survivors\":" << outcome.survivors
<< ",\"observed_ticks\":" << outcome.observed_ticks
<< ",\"thermal_shortfall\":" << outcome.thermal_shortfall
<< ",\"scheduled_lifespan\":" << outcome.scheduled_lifespan << "}";
}
+18 -2
View File
@@ -267,8 +267,24 @@ and abundance spreads the same income too thin to fund a birth. Separately, the
fixture's reproduction investment is pinned to the genome schema's floor because
intake scales with surface while investment scales with mass; at any larger
fraction nothing can earn a birth within a lifespan and both axes measure nothing.
That is a finding about the ADR-0031/0032 cost model, not a fixture detail. Native
Release, analysis, ASan and formatting passed 33/33; Linux CI has not run yet.
That is a finding about the ADR-0031/0032 cost model, not a fixture detail.
Review of `89ad95b` found three defects, all now fixed with regressions confirmed
to fail without their fix. The harness recorded a death for every organism still
alive when an episode stopped, so a one-tick run reported no extinctions while
writing terminal records for founders that had not died; ending observation is not
death, survivors now stay living in the archive and their watched time is summed
apart from completed lifetimes. A draw that produced a genome without the
reproduction capability derived a zero investment, which ADR-0029's driver refused
outright, so seeds 10, 12 and 15 failed the whole run; the driver now runs such a
strategy and proposes no birth for it, because filtering those variants out would
have made the measured set the fertile subset chosen by a guard. And a half's
thermal shortfall was assigned rather than accumulated, so a field documented as a
total reported one episode's reading. The M2.6 fingerprint `2cd4a15f9fbe9949` is
unchanged, since only configurations the driver previously rejected behave
differently; the ensemble CLI pin was repinned because the reported facts changed.
Native Release, analysis, ASan and formatting passed 33/33; Linux CI has not run
yet.
Before biology, resolve the relevant heredity and energetic contracts rather
than treating proof particles as organisms. Exact game tick rate, NPC mutation,
+12 -2
View File
@@ -2,7 +2,9 @@
## Status
Adopted for the M2.6 headless measurement harness. No gameplay AI, perception,
Adopted for the M2.6 headless measurement harness, and amended in M3.6 so a
strategy that does not reproduce is run rather than refused (see the founder
strategy paragraph below). No other part of the driver changed. No gameplay AI, perception,
behavior model, senescence biology, metabolic rate or population abstraction is
selected. The simulation contracts of ADR-0024 through ADR-0028 are unchanged.
@@ -41,7 +43,15 @@ Lifespan is a host scheduling rule that bounds the episode, not senescence, agin
biology or a death cause. No maintenance, starvation or metabolic cost is added.
A founder strategy fixes opening inventory, intake cap, assimilation, an investment
bundle, a reproduction threshold and a lifespan. ADR-0028 makes a child duplicate
bundle, a reproduction threshold and a lifespan. A strategy with nothing to invest
does not reproduce, and the driver runs it rather than refusing it: the empty
bundle would otherwise clear both reproduction bounds trivially and request a birth
transferring nothing, so the driver proposes no birth for it at all. Amended for
M3.6, which derives strategies from genomes: a mutation may legitimately drop the
reproduction capability, and refusing such a strategy here would have made the
strategies a run can measure a subset chosen by this guard rather than by the draw.
Only configurations this ADR previously rejected outright behave differently, so
the M2.6 fingerprint `2cd4a15f9fbe9949` is unchanged. ADR-0028 makes a child duplicate
its parent, so a founder strategy identifies one lineage for the whole episode and
competing strategies are the only source of variation. Lineage membership is
recovered by walking retained parent references to a founder.
+36 -6
View File
@@ -27,9 +27,18 @@ same organism. A parent reproduces once it holds what it would invest, which
avoids inventing a separate margin.
Run those strategies over a grid of resource levels and temperatures, many seeds
per cell, on ADR-0029's existing episode driver. The driver does not change, so
the M2.6 fingerprint still holds and the ecology under test is the one already
validated.
per cell, on ADR-0029's existing episode driver, whose behaviour for every
configuration it already accepted is unchanged, so the M2.6 fingerprint still
holds and the ecology under test is the one already validated.
One guard in that driver had to be amended rather than worked around. It refused a
strategy with nothing to invest, which is exactly what a genome without the
reproduction capability derives, so a draw that happened to produce one failed the
whole run. Filtering such variants out before sampling would have been worse than
the failure: the measured set would then be the fertile subset, chosen by a guard,
and a strategy's inability to reproduce is a result rather than a reason to exclude
it. The driver now runs such a strategy and proposes no birth for it. ADR-0029 is
amended accordingly.
The two axes reach a run by different routes, and implementation showed the
routes are not symmetric. Founders are derived fully grown, so their construction
@@ -56,6 +65,15 @@ the diversity a run reports comes from retained records rather than from counter
the harness kept for itself. Nothing mutates mid-episode, because an organism
diverging on its own is exactly the NPC-mutation question that remains open.
An organism alive when an episode stops was not observed to die. Observation
ended, which is a fact about the run and not about the organism, so no death is
recorded for it: ADR-0034 makes a recorded death terminal, and there is nothing
here to be terminal about. Such an organism stays living in the archive and is
reported as a survivor whose watched time is a lower bound on a lifetime this run
never saw the end of. Completed lifetimes and censored observations are summed
separately and never added together, because a mean over both would understate
every survivor.
The report is distributional. Per strategy and per cell it carries episodes,
births, survivals, lifetime and mean thermal shortfall, so a reader sees a spread
rather than an outcome. To make overfitting visible rather than merely warned
@@ -71,7 +89,11 @@ about genomes would change a tested fixture and break a pinned fingerprint for n
gain, since a derived `StrategyConfig` is the same shape the driver already takes.
Letting thermal shortfall reduce a budget would put a mortality rule inside a
contract that says it is not one. Reporting one number per cell would hide exactly
the variance the named risk is about. Deriving lifespan from body size would be an
the variance the named risk is about. Treating the end of an episode as a death
would have made every reported lifetime a mixture of two different facts and would
have written terminal records the archive cannot retract. Excluding non-reproducing
variants before sampling would have kept the driver untouched at the cost of
measuring only the strategies that a guard already approved of. Deriving lifespan from body size would be an
allometric claim this project has no basis for; it stays a harness constant
applied to every strategy alike.
@@ -87,7 +109,11 @@ of surviving in a report, and the archive gives the diversity figures a provenan
The grid is small and the seed count modest, so the report describes this fixture
and nothing wider. The thermal penalty, the lifespan base and the grid bounds are
chosen constants. Recording every birth and death costs a scan of the slots each
tick. Founders diverge once, before the run, so the ensemble compares a fixed set
tick. Lifetimes are censored: an episode that ends with survivors reports a lower
bound for each of them, so `lived_ticks` and `observed_ticks` answer different
questions and a reader has to choose which one it is asking. Across a run the
archive therefore ends holding living carriers, which is accurate about what was
observed and is not a claim that anything persists. Founders diverge once, before the run, so the ensemble compares a fixed set
of strategies rather than an evolving population.
## Risks
@@ -125,7 +151,11 @@ modelled, and nothing here is persistent.
Test that a derived strategy matches the genome's own budget, that conservation
holds at every tick of every cell, that the archive ends holding exactly the
founders and every organism that lived, that lineage status reflects the carriers,
that the two seed halves agree within a stated band for every strategy and cell,
that ending an episode records no death and leaves survivors living in the
archive, that a strategy which cannot reproduce is measured rather than refused,
that a half's thermal shortfall is a total across its episodes rather than one
reading, that the two seed halves agree within a stated band for every strategy
and cell,
that each axis alone changes outcomes rather than leaving cells identical, that a
thermally tolerant strategy keeps more of its life at the extremes than an
intolerant one, and that a repeated run reproduces the report exactly. The gradient
+64
View File
@@ -796,3 +796,67 @@ names, so a rejection arriving from a different branch would still pass. Golden
frozen genome fixture are unchanged, and ADR-0029's episode driver was not
touched. No deployment manifest or image pin changed. Linux validation is pending;
no Gitea result is claimed since `b01a824`.
Review of `89ad95b` found three defects (2026-09-24), each now fixed with a
regression confirmed to fail against the unfixed code.
The harness recorded a death for every organism still alive when an episode
stopped. A one-tick run therefore reported zero extinctions while writing terminal
death records for founders that had not died, and every such organism's watched
time was added to the same total as a completed lifetime. Ending observation is
not death, and ADR-0034 makes a recorded death terminal, so there was nothing for
the archive to be terminal about. Survivors now stay living, are counted in
`survivors`, and their watched time accumulates in `observed_ticks`, which is a
lower bound on a lifetime the run never saw end. `deaths` and `lived_ticks` cover
only organisms observed to die, and the two are never added together. The run and
archive test now checks that deaths plus survivors equals every organism recorded
and that a lineage is absent exactly when all its carriers were seen to die.
A draw that produced a genome without the reproduction capability derived a zero
reproduction investment, which ADR-0029's driver refused outright, so
`--ensemble --seed 10` exited with invalid_arguments; seeds 12 and 15 were
confirmed to fail the same way and seed 11 to succeed. Filtering such variants out
before sampling was rejected as the worse repair: the measured set would then have
been the fertile subset chosen by a guard, and an inability to reproduce is a
result rather than a reason for exclusion. The driver now accepts the strategy and
proposes no birth for it, since an empty investment would otherwise clear both
reproduction bounds trivially and request a birth transferring nothing. ADR-0029
is amended rather than silently contradicted, and ADR-0035's claim that the driver
does not change was corrected to say what did.
Only configurations the driver previously rejected outright behave differently, so
the M2.6 pin was expected to hold and was checked rather than assumed:
`--ecosystem --seed 0 --episodes 32` still reports `2cd4a15f9fbe9949`, and the
ecosystem, feeding and producer suites pass unchanged. The ecosystem test that
asserted a zero investment is rejected now asserts the opposite fact, that such an
episode runs and reports no births.
A half's thermal shortfall was assigned rather than accumulated, so a field
documented as a total across the half's episodes carried one episode's reading.
Two episodes at 15,000 millikelvin reported 15,000 rather than 30,000. It now
accumulates per episode. The tolerance test's expectations were per-episode
readings and are now stated against the episode count, with an assertion that the
count exceeds one so a sum and a single reading cannot look alike.
`cli-ensemble` was repinned from `c2b96c86101be628` to `5ec59d390909b526`,
confirmed stable across three runs and distinct from seed 7's `090b83efb85ae477`.
This is a change in reported facts, not a test accommodation: survivors are no
longer counted as deaths, the outcome record gained `deaths`, `survivors` and
`observed_ticks`, and the shortfall is now a sum, so the previous value describes
a report this build does not produce. The rationale is recorded beside the pin.
Each fix was confirmed to be load-bearing by reverting it alone and rebuilding.
Restoring the survivor-as-death behaviour failed the archive test at the survivor
count and, when that test was run second, the dedicated regression at `deaths ==
0`. Restoring the zero-investment rejection failed the sterile-strategy regression
at `EcosystemEpisode::create`. Restoring the assignment of thermal shortfall
failed the summation regression. One of my own expectations was wrong rather than
the code: a one-tick episode's survivors include organisms born during that tick,
watched for none of it, so observed time equals one tick per founder rather than
one per survivor. The test now says that.
Coverage limits unchanged from the increment above, with two additions. Censored
lifetimes mean a run's mean lifetime is not computable from `lived_ticks` alone
and no test asserts one. Across a run the archive now ends holding living
carriers, which is accurate about what was observed and is not a claim that
anything persists; nothing is serialized.
+10
View File
@@ -35,7 +35,17 @@ struct StrategyOutcome {
std::uint64_t episodes;
std::uint64_t births;
std::uint64_t organisms;
// An organism observed to die and one whose episode simply stopped are not the
// same fact, and the two are never added together. `deaths` counts organisms
// seen to die and `lived_ticks` sums their complete lifetimes. `survivors`
// counts organisms still alive when observation ended and `observed_ticks`
// sums how long each was watched, which is a lower bound on a life whose
// length is not known. A mean lifetime computed over both would understate
// every survivor, so a reader has to choose which question it is asking.
std::uint64_t deaths;
std::uint64_t lived_ticks;
std::uint64_t survivors;
std::uint64_t observed_ticks;
std::uint64_t thermal_shortfall; // summed over the episodes of this half
std::uint32_t scheduled_lifespan;
auto operator<=>(const StrategyOutcome&) const = default;
+12 -4
View File
@@ -52,10 +52,12 @@ EcosystemEpisode::create(EcosystemConfig config, std::span<const StrategyConfig>
return std::unexpected{EcosystemError::invalid_config};
}
for (const auto& founder : founders) {
// A zero lifespan would retire a founder before it ever acted; a zero
// investment would request a birth the community rejects outright.
if (founder.lifespan == 0 || founder.investment == accounting::Inventory{} ||
founder.assimilation_per_thousand > 1000) {
// A zero lifespan would retire a founder before it ever acted. A zero
// investment is a strategy that does not reproduce, which is a genome a
// mutation can legitimately produce, so the driver runs it and simply
// never proposes a birth for it. Refusing it here would have made the
// measurable strategies a subset chosen by this guard.
if (founder.lifespan == 0 || founder.assimilation_per_thousand > 1000) {
return std::unexpected{EcosystemError::invalid_config};
}
}
@@ -205,6 +207,12 @@ std::expected<bool, EcosystemError> EcosystemEpisode::step() {
}
const auto& plan = strategy(parent);
const auto& balance = probe.balances()[balance_index(parent)];
// A strategy with nothing to invest does not reproduce. Without this the
// empty investment would clear both bounds trivially and request a birth
// that transfers nothing, which the community rejects outright.
if (plan.investment == accounting::Inventory{}) {
continue;
}
// Feeding only adds to an unbitten parent, so this bound stays valid.
if (!covers(plan.reproduction_threshold, balance) || !covers(plan.investment, balance)) {
continue;
+18 -9
View File
@@ -76,6 +76,9 @@ run_ensemble(biology::LineageArchive& archive, std::span<const Genome> founders,
CellReport measured{};
measured.cell = cell;
std::vector<StrategyConfig> strategies;
// The per-episode shortfall each strategy carries in this cell, kept aside
// so the reported total is a sum over episodes rather than one reading.
std::vector<std::uint64_t> shortfall;
for (const auto& genome : founders) {
const auto phenotype = biology::derive_phenotype(genome, {1000, 0}, environment);
if (!phenotype) {
@@ -102,9 +105,9 @@ run_ensemble(biology::LineageArchive& archive, std::span<const Genome> founders,
StrategyOutcome blank{};
blank.genome = genome.id();
blank.scheduled_lifespan = lifespan;
blank.thermal_shortfall = phenotype->thermal_shortfall;
measured.first_half.push_back(blank);
measured.second_half.push_back(blank);
shortfall.push_back(phenotype->thermal_shortfall);
}
for (std::uint64_t index = 0; index < plan.seeds_per_cell; ++index) {
auto config = base;
@@ -134,8 +137,9 @@ run_ensemble(biology::LineageArchive& archive, std::span<const Genome> founders,
}
++half[strategy].organisms;
}
for (auto& outcome : half) {
++outcome.episodes;
for (std::size_t which = 0; which < half.size(); ++which) {
++half[which].episodes;
half[which].thermal_shortfall += shortfall[which];
}
while (true) {
const auto stepped = episode->step();
@@ -166,6 +170,7 @@ run_ensemble(biology::LineageArchive& archive, std::span<const Genome> founders,
if (!archive.record_death(identity[slot], tick)) {
return std::unexpected{EcosystemError::invalid_config};
}
++half[strategy].deaths;
half[strategy].lived_ticks += tick.value - born_at[slot];
}
}
@@ -174,14 +179,17 @@ run_ensemble(biology::LineageArchive& archive, std::span<const Genome> founders,
}
}
const auto summary = episode->report();
// Anything still alive lived to the end of the episode.
// An organism still alive when the episode stops was not observed to
// die: observation ended, which is not a terminal fact about it. The
// archive keeps it living, because ADR-0034 makes a recorded death
// terminal and there is nothing here to be terminal about. Its watched
// time is a lower bound on a lifetime this run never saw the end of,
// so it is summed apart from the lifetimes that did complete.
for (std::uint32_t slot = 2; slot <= slots; ++slot) {
if (living[slot]) {
const auto strategy = static_cast<std::size_t>(episode->lineage(slot) - 2);
half[strategy].lived_ticks += summary.ticks - born_at[slot];
if (!archive.record_death(identity[slot], Tick{summary.ticks})) {
return std::unexpected{EcosystemError::invalid_config};
}
++half[strategy].survivors;
half[strategy].observed_ticks += summary.ticks - born_at[slot];
}
}
measured.ticks += summary.ticks;
@@ -202,7 +210,8 @@ run_ensemble(biology::LineageArchive& archive, std::span<const Genome> founders,
for (const auto& outcome : *half) {
for (const auto value :
{outcome.genome, outcome.episodes, outcome.births, outcome.organisms,
outcome.lived_ticks, outcome.thermal_shortfall,
outcome.deaths, outcome.lived_ticks, outcome.survivors,
outcome.observed_ticks, outcome.thermal_shortfall,
static_cast<std::uint64_t>(outcome.scheduled_lifespan)}) {
hash = mix(hash, value);
}
+10 -3
View File
@@ -214,18 +214,25 @@ void invalid_configuration_is_rejected() {
auto oversized = config;
oversized.capacity = static_cast<std::uint32_t>(max_consumers);
CHECK(!EcosystemEpisode::create(oversized, founders, 1));
for (auto broken : {0U, 1U, 2U}) {
for (auto broken : {0U, 1U}) {
auto invalid = founders[0];
if (broken == 0) {
invalid.lifespan = 0;
} else if (broken == 1) {
invalid.investment = {};
} else {
invalid.assimilation_per_thousand = 1001;
}
const std::array rejected{invalid};
CHECK(!EcosystemEpisode::create(config, rejected, 1));
}
// A strategy with nothing to invest does not reproduce, which is a genome a
// mutation can produce. It is run rather than refused, and it leaves nothing.
auto barren = founders[0];
barren.investment = {};
const std::array sterile{barren};
auto episode = EcosystemEpisode::create(config, sterile, 1);
CHECK(episode);
const auto summary = episode->run();
CHECK(summary && summary->births == 0);
}
} // namespace
int main() try {
+126 -5
View File
@@ -115,12 +115,29 @@ void the_run_is_reproducible_and_archived() {
// Every founder is archived, and so is every organism that ever lived.
CHECK(report->archived_genomes == set.size());
CHECK(report->archived_organisms > report->episodes * set.size());
// A death is recorded only where one was observed. An organism whose episode
// stopped while it was alive stays living in the archive, so a lineage is
// reported absent exactly when every one of its carriers was seen to die.
std::uint64_t survivors = 0, deaths = 0;
for (const auto& cell : report->cells) {
for (const auto* which : {&cell.first_half, &cell.second_half}) {
for (const auto& outcome : *which) {
survivors += outcome.survivors;
deaths += outcome.deaths;
}
}
}
CHECK(deaths > 0 && survivors > 0); // Both paths occur in this fixture.
CHECK(deaths + survivors == report->archived_organisms);
std::uint64_t carried = 0;
for (const auto& genome : set) {
CHECK(archive.find(genome.id()));
// Every episode ended, so nothing is still carrying anything.
CHECK(*archive.status(genome.id()) == LineageStatus::absent);
CHECK(*archive.living_carriers(genome.id()) == 0);
carried += *archive.living_carriers(genome.id());
CHECK(*archive.status(genome.id()) == (*archive.living_carriers(genome.id()) == 0
? LineageStatus::absent
: LineageStatus::living));
}
CHECK(carried == survivors);
// A repeated run reproduces the whole report.
LineageArchive again;
const auto repeated = run_ensemble(again, set, base_world(), plan(), 11);
@@ -246,8 +263,12 @@ void tolerance_keeps_more_life_at_the_extremes() {
CHECK(at_reference.first_half[0].scheduled_lifespan ==
at_reference.first_half[1].scheduled_lifespan);
// At the extreme the intolerant one is stressed more and scheduled shorter.
CHECK(at_extreme.first_half[0].thermal_shortfall == 30'000);
CHECK(at_extreme.first_half[1].thermal_shortfall == 10'000);
// Shortfall is a total across the half's episodes, so it scales with them.
const auto episodes = at_extreme.first_half[0].episodes;
CHECK(episodes > 1); // Otherwise a sum and a single reading look alike.
CHECK(at_extreme.first_half[1].episodes == episodes);
CHECK(at_extreme.first_half[0].thermal_shortfall == 30'000 * episodes);
CHECK(at_extreme.first_half[1].thermal_shortfall == 10'000 * episodes);
CHECK(at_extreme.first_half[0].scheduled_lifespan == 1); // The loss floors it.
CHECK(at_extreme.first_half[1].scheduled_lifespan == 300U - 10U * 20U);
CHECK(at_extreme.first_half[1].scheduled_lifespan >
@@ -256,6 +277,103 @@ void tolerance_keeps_more_life_at_the_extremes() {
CHECK(at_reference.first_half[0].scheduled_lifespan == 300);
}
void ending_observation_is_not_death() {
// A single tick stops every episode with its founders alive. None of them
// died, so none may be recorded dead, and the run must say so.
LineageArchive archive;
const auto set = founders();
auto brief = plan();
brief.tick_limit = 1;
brief.seeds_per_cell = 2;
const auto report = run_ensemble(archive, set, base_world(), brief, 11);
CHECK(report);
std::uint64_t survivors = 0, deaths = 0, observed = 0, lived = 0;
for (const auto& cell : report->cells) {
CHECK(cell.extinctions == 0); // Nothing died out in one tick.
for (const auto* which : {&cell.first_half, &cell.second_half}) {
for (const auto& outcome : *which) {
survivors += outcome.survivors;
deaths += outcome.deaths;
observed += outcome.observed_ticks;
lived += outcome.lived_ticks;
}
}
}
CHECK(deaths == 0); // The defect recorded a death for every founder.
CHECK(lived == 0); // And charged each one a completed lifetime.
CHECK(survivors > 0); // They are survivors, counted as such.
// Each founder was watched for exactly its one tick. Anything born during
// that tick is also a survivor, watched for none of it, so observed time is
// a lower bound and not a lifetime.
CHECK(observed == report->episodes * set.size());
CHECK(survivors >= report->episodes * set.size());
// The archive agrees: nothing was observed to die, so every lineage lives.
for (const auto& genome : set) {
CHECK(*archive.status(genome.id()) == LineageStatus::living);
CHECK(*archive.living_carriers(genome.id()) > 0);
}
}
void a_strategy_that_cannot_reproduce_is_still_measured() {
// A mutation may legitimately drop reproduction. Such a genome yields a zero
// investment, which the driver once refused outright, so the whole ensemble
// failed on the seeds that happened to draw one. It now runs and simply never
// reproduces; excluding it would have made the measured set a subset chosen
// by a guard rather than by the draw.
auto source = ancestor_draft();
source.capabilities.erase(
std::remove_if(source.capabilities.begin(), source.capabilities.end(),
[](const auto& record) { return record.kind == Capability::reproduction; }),
source.capabilities.end());
const auto barren = Genome::create(source);
CHECK(barren);
CHECK(!barren->carries(Capability::reproduction));
const EnvironmentState where{reference_temperature, pooled(1'000)};
const auto budget = metabolic_budget(*barren, {1000, 0}, where);
CHECK(budget && budget->reproduction_investment == Inventory{});
const auto strategy = strategy_for(*barren, {1000, 0}, where, Inventory{}, 60);
CHECK(strategy && strategy->investment == Inventory{});
// The driver accepts it rather than rejecting the configuration.
auto config = base_world();
config.tick_limit = 120;
const std::array only{*strategy};
auto episode = EcosystemEpisode::create(config, only, 3);
CHECK(episode);
const auto summary = episode->run();
CHECK(summary && summary->births == 0); // It lives, and it leaves nothing.
// And the seeds that previously failed now produce a whole run.
for (const std::uint64_t seed : {10U, 12U, 15U}) {
LineageArchive archive;
const auto set = diverge_founders(ancestor(), 3, seed);
CHECK(set);
auto brief = plan();
brief.seeds_per_cell = 2;
brief.tick_limit = 60;
CHECK(run_ensemble(archive, *set, base_world(), brief, seed));
}
}
void thermal_shortfall_is_summed_over_episodes() {
// The field is a total across a half's episodes, not one episode's reading.
LineageArchive archive;
const auto set = founders();
auto stressed = plan();
stressed.gradient = {{reference_temperature + 15'000U, 1'000}};
stressed.seeds_per_cell = 4;
stressed.tick_limit = 40;
const auto report = run_ensemble(archive, set, base_world(), stressed, 11);
CHECK(report && report->cells.size() == 1);
const auto& cell = report->cells[0];
for (const auto* which : {&cell.first_half, &cell.second_half}) {
for (const auto& outcome : *which) {
CHECK(outcome.episodes == 2);
// Two episodes at 15,000 millikelvin of shortfall total 30,000; the
// defect reported 15,000, the value of a single episode.
CHECK(outcome.thermal_shortfall == 30'000);
}
}
}
void invalid_plans_are_refused() {
LineageArchive archive;
const auto set = founders();
@@ -291,6 +409,9 @@ int main() try {
the_two_seed_halves_agree();
the_gradient_changes_the_outcome();
tolerance_keeps_more_life_at_the_extremes();
ending_observation_is_not_death();
a_strategy_that_cannot_reproduce_is_still_measured();
thermal_shortfall_is_summed_over_episodes();
invalid_plans_are_refused();
std::cout << "PASS genome-derived strategies, gradient ensembles and split-half agreement\n";
return 0;