Files
aevolution/include/evo/processes/ensemble.hpp
T
dingoandClaude Opus 5 72ed03f4dd 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>
2026-09-24 05:58:22 -04:00

82 lines
3.8 KiB
C++

#pragma once
#include "evo/biology/lineage.hpp"
#include "evo/biology/mutation.hpp"
#include "evo/processes/genome_strategy.hpp"
namespace evo::processes {
// One point of the gradient. The two axes reach a run by different routes, and
// neither route is the other's. Temperature enters the derivation: it sets the
// phenotype's thermal shortfall, which reaches the ecology through the scheduling
// rule below. Resource level does not enter the derivation at all. Founders are
// derived fully grown, so their construction transition is empty and
// `EnvironmentState::available` cannot move `intake_limit`, assimilation or
// reproduction investment; the resource level reaches a run only as the nutrient
// pool an episode starts with, which bounds producer growth.
struct GradientCell {
std::uint32_t temperature_millikelvin;
std::uint64_t nutrients;
auto operator<=>(const GradientCell&) const = default;
};
struct EnsembleConfig {
std::vector<GradientCell> gradient;
std::uint64_t seeds_per_cell;
std::uint64_t tick_limit;
std::uint32_t base_lifespan;
// Ticks of scheduled life lost per kelvin of thermal shortfall. This extends
// ADR-0029's lifespan rule, which is a harness scheduling device and not
// biology. It is not a mortality model and no contract knows about it.
std::uint32_t lifespan_lost_per_kelvin;
};
// What one strategy did in one half of one cell's seeds. Reported per half so an
// effect that only appears in one of them is visible as the artifact it is.
struct StrategyOutcome {
std::uint64_t genome;
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;
};
struct CellReport {
GradientCell cell;
std::vector<StrategyOutcome> first_half;
std::vector<StrategyOutcome> second_half;
std::uint64_t ticks;
std::uint64_t extinctions;
auto operator<=>(const CellReport&) const = default;
};
struct EnsembleReport {
std::vector<CellReport> cells;
std::uint64_t episodes;
std::uint64_t ticks;
std::uint64_t archived_genomes;
std::uint64_t archived_organisms;
std::uint64_t fingerprint;
auto operator<=>(const EnsembleReport&) const = default;
};
// Produces the founder strategies by diverging one ancestor before any episode
// runs. Nothing mutates during an episode: an organism diverging on its own is
// the NPC-mutation question that remains open.
[[nodiscard]] std::expected<std::vector<biology::Genome>, EcosystemError>
diverge_founders(const biology::Genome& ancestor, std::size_t wanted, std::uint64_t seed);
// Runs the grid, recording every birth and death in the archive as it happens, so
// the diversity a report carries comes from retained records.
[[nodiscard]] std::expected<EnsembleReport, EcosystemError>
run_ensemble(biology::LineageArchive& archive, std::span<const biology::Genome> founders,
const EcosystemConfig& base, const EnsembleConfig& plan, std::uint64_t seed);
} // namespace evo::processes