M4.5 closes M4 by measuring what aggregation costs, and adds no library code except one defect fix the measurement found. One rule is written once and applied at both resolutions. The control is what makes the rest mean anything: with one member per class a class average is that member, so the two runs must agree exactly, and they do, tick by tick, in every channel. A deliberate one-unit drift in the aggregate rule is caught by it, so the instrument is verified rather than assumed. Without it a measured gap would be indistinguishable from a transcription mistake in one of the two runs. The result is reported, not smoothed into a tolerance. At class widths ten and fifty the aggregate population survives ten thousand ticks within 375 parts per thousand on population and 43 on energy. At twenty-five, one hundred and two hundred it dies out entirely while the individual run sustains seventy-five members: a false extinction caused by resolution alone, because a whole class starves the moment its average cannot pay upkeep, where individuals starve a few at a time and the survivors keep the shared per-capita share up. The collapse is not monotone in class width. Twenty-five destroys the population and fifty sustains it. An earlier version of the test asserted that coarser is never better; the measurement refuted it, so the assertion went rather than the widths being chosen to make it hold. The non-monotonicity is asserted now, because it is surprising and because the warning written around it could otherwise become wrong without failing. A tier policy cannot assume degradation worsens smoothly as classes widen, and M4.6 inherits that. Conservation was exact at every tick on both sides of all five runs, including the three that died out. That is the clearest available demonstration of the thing ECOLOGY_MODEL keeps saying: conservation is not ecological evidence. Two flaws in my own experiment were found before any number was believed. The aggregate model had been producing overlapping classes, so the model measured was not one a cohort could represent; newborns now extend the youngest class while it is narrower than the width, and every step is checked to construct a valid Cohort. The first figures were discarded. The comparison also found a real M4.3 defect, which is what a validation milestone is for. plan_advance checked affordability with arrivals added before losses were taken, but emitted the ledger legs outflows-first, so an interval affordable as a whole underflowed leg by leg and was refused at commit. A fifty-tick interval shedding 10,480 against 6,950 held while drawing 13,080 in reproduced it. Arrivals are the first leg now, matching the order the arithmetic was checked in, with a regression and a corrected escrow expectation in an existing test. Release 38/38, analysis, ASan 38/38 and clang-format all ran and passed here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
244 lines
14 KiB
CMake
244 lines
14 KiB
CMake
cmake_minimum_required(VERSION 3.28)
|
|
project(AeternalisEvolution VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
|
message(FATAL_ERROR "Use an out-of-source build, e.g. cmake --preset debug")
|
|
endif()
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
include(CheckCXXSourceCompiles)
|
|
check_cxx_source_compiles("#include <expected>
|
|
#if !defined(__cpp_lib_expected) || __cpp_lib_expected < 202202L
|
|
#error std::expected is required
|
|
#endif
|
|
int main() { std::expected<int, int> result{42}; return *result == 42 ? 0 : 1; }"
|
|
EVO_HAS_EXPECTED)
|
|
if(NOT EVO_HAS_EXPECTED)
|
|
message(FATAL_ERROR "This compiler/standard-library pair lacks the required C++23 std::expected")
|
|
endif()
|
|
|
|
option(EVO_WARNINGS_AS_ERRORS "Treat owned-code warnings as errors" ON)
|
|
option(EVO_ENABLE_TIDY "Run clang-tidy during compilation" OFF)
|
|
option(EVO_BUILD_FUZZER "Build the Clang libFuzzer snapshot target" OFF)
|
|
option(EVO_BUILD_ECS_EXPERIMENT "Build the isolated EnTT comparison (explicit preparation required)" OFF)
|
|
set(EVO_SANITIZER "none" CACHE STRING "none, address (ASan/UBSan), or thread")
|
|
set_property(CACHE EVO_SANITIZER PROPERTY STRINGS none address thread)
|
|
include(cmake/ProjectOptions.cmake)
|
|
|
|
set(evo_simulation_sources src/simulation/world.cpp src/simulation/snapshot.cpp src/simulation/scheduler.cpp src/simulation/spatial.cpp)
|
|
add_library(evo_simulation STATIC ${evo_simulation_sources})
|
|
add_library(evo::simulation ALIAS evo_simulation)
|
|
target_include_directories(evo_simulation PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
target_compile_features(evo_simulation PUBLIC cxx_std_23)
|
|
evo_owned_target(evo_simulation)
|
|
|
|
add_library(evo_accounting STATIC src/accounting/ledger.cpp)
|
|
add_library(evo::accounting ALIAS evo_accounting)
|
|
target_include_directories(evo_accounting PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
target_compile_features(evo_accounting PUBLIC cxx_std_23)
|
|
evo_owned_target(evo_accounting)
|
|
|
|
add_library(evo_biology STATIC src/biology/genome.cpp src/biology/development.cpp src/biology/metabolism.cpp src/biology/mutation.cpp src/biology/lineage.cpp)
|
|
add_library(evo::biology ALIAS evo_biology)
|
|
target_include_directories(evo_biology PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
target_link_libraries(evo_biology PUBLIC evo::accounting)
|
|
target_compile_features(evo_biology PUBLIC cxx_std_23)
|
|
evo_owned_target(evo_biology)
|
|
|
|
add_library(evo_ecology STATIC src/ecology/cohort.cpp src/ecology/collapse.cpp src/ecology/population.cpp src/ecology/materialize.cpp)
|
|
add_library(evo::ecology ALIAS evo_ecology)
|
|
target_include_directories(evo_ecology PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
target_link_libraries(evo_ecology PUBLIC evo::accounting evo::biology)
|
|
target_compile_features(evo_ecology PUBLIC cxx_std_23)
|
|
evo_owned_target(evo_ecology)
|
|
|
|
add_library(evo_processes STATIC src/processes/producer.cpp src/processes/feeding.cpp src/processes/ecosystem.cpp src/processes/genome_strategy.cpp src/processes/ensemble.cpp)
|
|
add_library(evo::processes ALIAS evo_processes)
|
|
target_link_libraries(evo_processes PUBLIC evo::accounting evo::biology)
|
|
evo_owned_target(evo_processes)
|
|
|
|
add_executable(evo-sim apps/evo-sim/main.cpp)
|
|
target_link_libraries(evo-sim PRIVATE evo::simulation evo::processes)
|
|
evo_owned_target(evo-sim)
|
|
|
|
include(CTest)
|
|
if(BUILD_TESTING)
|
|
add_executable(evo-feeding-tests tests/feeding_tests.cpp)
|
|
target_link_libraries(evo-feeding-tests PRIVATE evo::processes)
|
|
evo_owned_target(evo-feeding-tests)
|
|
add_test(NAME feeding-contracts COMMAND evo-feeding-tests)
|
|
set_tests_properties(feeding-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-ecosystem-tests tests/ecosystem_tests.cpp)
|
|
target_link_libraries(evo-ecosystem-tests PRIVATE evo::processes)
|
|
evo_owned_target(evo-ecosystem-tests)
|
|
add_test(NAME ecosystem-contracts COMMAND evo-ecosystem-tests)
|
|
set_tests_properties(ecosystem-contracts PROPERTIES TIMEOUT 300)
|
|
add_executable(evo-genome-tests tests/genome_tests.cpp)
|
|
target_link_libraries(evo-genome-tests PRIVATE evo::biology)
|
|
evo_owned_target(evo-genome-tests)
|
|
add_test(NAME genome-contracts COMMAND evo-genome-tests)
|
|
set_tests_properties(genome-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-development-tests tests/development_tests.cpp)
|
|
target_link_libraries(evo-development-tests PRIVATE evo::biology)
|
|
evo_owned_target(evo-development-tests)
|
|
add_test(NAME development-contracts COMMAND evo-development-tests)
|
|
set_tests_properties(development-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-metabolism-tests tests/metabolism_tests.cpp)
|
|
target_link_libraries(evo-metabolism-tests PRIVATE evo::processes)
|
|
evo_owned_target(evo-metabolism-tests)
|
|
add_test(NAME metabolism-contracts COMMAND evo-metabolism-tests)
|
|
set_tests_properties(metabolism-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-mutation-tests tests/mutation_tests.cpp)
|
|
target_link_libraries(evo-mutation-tests PRIVATE evo::biology)
|
|
evo_owned_target(evo-mutation-tests)
|
|
add_test(NAME mutation-contracts COMMAND evo-mutation-tests)
|
|
set_tests_properties(mutation-contracts PROPERTIES TIMEOUT 120)
|
|
add_executable(evo-lineage-tests tests/lineage_tests.cpp)
|
|
target_link_libraries(evo-lineage-tests PRIVATE evo::biology)
|
|
evo_owned_target(evo-lineage-tests)
|
|
add_test(NAME lineage-contracts COMMAND evo-lineage-tests)
|
|
set_tests_properties(lineage-contracts PROPERTIES TIMEOUT 120)
|
|
add_executable(evo-ensemble-tests tests/ensemble_tests.cpp)
|
|
target_link_libraries(evo-ensemble-tests PRIVATE evo::processes)
|
|
evo_owned_target(evo-ensemble-tests)
|
|
add_test(NAME ensemble-contracts COMMAND evo-ensemble-tests)
|
|
set_tests_properties(ensemble-contracts PROPERTIES TIMEOUT 300)
|
|
add_executable(evo-producer-tests tests/producer_tests.cpp)
|
|
target_link_libraries(evo-producer-tests PRIVATE evo::processes)
|
|
evo_owned_target(evo-producer-tests)
|
|
add_test(NAME producer-contracts COMMAND evo-producer-tests)
|
|
set_tests_properties(producer-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-cohort-tests tests/cohort_tests.cpp)
|
|
target_link_libraries(evo-cohort-tests PRIVATE evo::ecology)
|
|
evo_owned_target(evo-cohort-tests)
|
|
add_test(NAME cohort-contracts COMMAND evo-cohort-tests)
|
|
set_tests_properties(cohort-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-collapse-tests tests/collapse_tests.cpp)
|
|
target_link_libraries(evo-collapse-tests PRIVATE evo::ecology)
|
|
evo_owned_target(evo-collapse-tests)
|
|
add_test(NAME collapse-contracts COMMAND evo-collapse-tests)
|
|
set_tests_properties(collapse-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-population-tests tests/population_tests.cpp)
|
|
target_link_libraries(evo-population-tests PRIVATE evo::ecology)
|
|
evo_owned_target(evo-population-tests)
|
|
add_test(NAME population-contracts COMMAND evo-population-tests)
|
|
set_tests_properties(population-contracts PROPERTIES TIMEOUT 120)
|
|
add_executable(evo-materialize-tests tests/materialize_tests.cpp)
|
|
target_link_libraries(evo-materialize-tests PRIVATE evo::ecology)
|
|
evo_owned_target(evo-materialize-tests)
|
|
add_test(NAME materialize-contracts COMMAND evo-materialize-tests)
|
|
set_tests_properties(materialize-contracts PROPERTIES TIMEOUT 120)
|
|
add_executable(evo-equivalence-tests tests/equivalence_tests.cpp)
|
|
target_link_libraries(evo-equivalence-tests PRIVATE evo::ecology)
|
|
evo_owned_target(evo-equivalence-tests)
|
|
add_test(NAME resolution-equivalence COMMAND evo-equivalence-tests)
|
|
set_tests_properties(resolution-equivalence PROPERTIES TIMEOUT 600)
|
|
add_executable(evo-ledger-tests tests/ledger_tests.cpp)
|
|
target_link_libraries(evo-ledger-tests PRIVATE evo::accounting)
|
|
evo_owned_target(evo-ledger-tests)
|
|
add_test(NAME ledger-contracts COMMAND evo-ledger-tests)
|
|
set_tests_properties(ledger-contracts PROPERTIES TIMEOUT 60)
|
|
add_executable(evo-tests tests/simulation_tests.cpp)
|
|
target_link_libraries(evo-tests PRIVATE evo::simulation)
|
|
evo_owned_target(evo-tests)
|
|
add_test(NAME simulation-contracts COMMAND evo-tests)
|
|
add_test(NAME test-harness-failure COMMAND evo-tests --self-test-failure)
|
|
set_tests_properties(test-harness-failure PROPERTIES WILL_FAIL TRUE)
|
|
add_test(NAME cli-replay COMMAND evo-sim --seed 123456 --ticks 1000 --entities 8 --verify-replay)
|
|
set_tests_properties(cli-replay PROPERTIES PASS_REGULAR_EXPRESSION "d61ad5bf0c928c76")
|
|
add_test(NAME cli-invalid-number COMMAND evo-sim --ticks -1)
|
|
set_tests_properties(cli-invalid-number PROPERTIES WILL_FAIL TRUE)
|
|
add_test(NAME cli-ecosystem COMMAND evo-sim --ecosystem --seed 0 --episodes 32)
|
|
set_tests_properties(cli-ecosystem PROPERTIES TIMEOUT 120
|
|
PASS_REGULAR_EXPRESSION "2cd4a15f9fbe9949")
|
|
# An option belonging to the other mode must be rejected, never accepted and ignored.
|
|
add_test(NAME cli-ecosystem-conflict COMMAND evo-sim --ecosystem --verify-replay)
|
|
add_test(NAME cli-ecosystem-rejects-ticks COMMAND evo-sim --ecosystem --seed 0 --ticks 1)
|
|
add_test(NAME cli-ecosystem-rejects-entities COMMAND evo-sim --ecosystem --entities 4)
|
|
add_test(NAME cli-ecosystem-rejects-save COMMAND evo-sim --ecosystem --save episodes.evo)
|
|
add_test(NAME cli-episodes-require-ecosystem COMMAND evo-sim --episodes 2 --tick-limit 1)
|
|
add_test(NAME cli-tick-limit-requires-ecosystem COMMAND evo-sim --ticks 10 --tick-limit 1)
|
|
add_test(NAME cli-ecosystem-rejects-seeds-per-cell COMMAND evo-sim --ecosystem --seeds-per-cell 4)
|
|
set_tests_properties(cli-ecosystem-conflict cli-ecosystem-rejects-ticks
|
|
cli-ecosystem-rejects-entities cli-ecosystem-rejects-save
|
|
cli-episodes-require-ecosystem cli-tick-limit-requires-ecosystem
|
|
cli-ecosystem-rejects-seeds-per-cell
|
|
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 "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)
|
|
add_test(NAME cli-ensemble-excludes-ecosystem COMMAND evo-sim --ensemble --ecosystem)
|
|
add_test(NAME cli-ensemble-rejects-episodes COMMAND evo-sim --ensemble --episodes 2)
|
|
add_test(NAME cli-ensemble-rejects-ticks COMMAND evo-sim --ensemble --ticks 1)
|
|
add_test(NAME cli-ensemble-rejects-entities COMMAND evo-sim --ensemble --entities 4)
|
|
# Halves need at least one seed each, and the driver caps strategies at four.
|
|
add_test(NAME cli-ensemble-rejects-single-seed COMMAND evo-sim --ensemble --seeds-per-cell 1)
|
|
add_test(NAME cli-ensemble-rejects-excess-strategies COMMAND evo-sim --ensemble --strategies 5)
|
|
add_test(NAME cli-seeds-per-cell-requires-ensemble COMMAND evo-sim --seeds-per-cell 4)
|
|
add_test(NAME cli-strategies-requires-ensemble COMMAND evo-sim --strategies 3)
|
|
set_tests_properties(cli-ensemble-conflict cli-ensemble-excludes-ecosystem
|
|
cli-ensemble-rejects-episodes cli-ensemble-rejects-ticks cli-ensemble-rejects-entities
|
|
cli-ensemble-rejects-single-seed cli-ensemble-rejects-excess-strategies
|
|
cli-seeds-per-cell-requires-ensemble cli-strategies-requires-ensemble
|
|
PROPERTIES WILL_FAIL TRUE)
|
|
add_test(NAME cli-file-integration COMMAND "${CMAKE_COMMAND}"
|
|
"-DEVO_SIM=$<TARGET_FILE:evo-sim>" "-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/cli-integration"
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/tests/cli_integration.cmake")
|
|
set_tests_properties(simulation-contracts cli-replay cli-file-integration PROPERTIES TIMEOUT 60)
|
|
endif()
|
|
|
|
add_executable(evo-benchmark tests/benchmarks/simulation_benchmark.cpp)
|
|
target_link_libraries(evo-benchmark PRIVATE evo::simulation)
|
|
evo_owned_target(evo-benchmark)
|
|
|
|
add_executable(evo-spatial-benchmark tests/benchmarks/spatial_benchmark.cpp)
|
|
target_link_libraries(evo-spatial-benchmark PRIVATE evo::simulation)
|
|
evo_owned_target(evo-spatial-benchmark)
|
|
|
|
if(EVO_BUILD_FUZZER)
|
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR MSVC OR EVO_SANITIZER STREQUAL "thread")
|
|
message(FATAL_ERROR "Fuzzing requires Linux Clang and is incompatible with TSan")
|
|
endif()
|
|
# Compile the kernel itself with coverage and sanitizer instrumentation.
|
|
add_executable(evo-snapshot-fuzz tests/fuzz/snapshot_fuzz.cpp ${evo_simulation_sources})
|
|
target_include_directories(evo-snapshot-fuzz PRIVATE include)
|
|
evo_owned_target(evo-snapshot-fuzz)
|
|
target_compile_options(evo-snapshot-fuzz PRIVATE -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer)
|
|
target_link_options(evo-snapshot-fuzz PRIVATE -fsanitize=fuzzer,address,undefined)
|
|
endif()
|
|
|
|
if(EVO_BUILD_ECS_EXPERIMENT)
|
|
include(tools/entt-pin.cmake)
|
|
set(entt_root "${CMAKE_SOURCE_DIR}/build/external/entt")
|
|
if(NOT EXISTS "${entt_root}/include/entt/entt.hpp" OR NOT EXISTS "${entt_root}/LICENSE")
|
|
message(FATAL_ERROR "Run cmake -P tools/prepare-entt.cmake explicitly before configuring the experiment")
|
|
endif()
|
|
file(SHA256 "${entt_root}/include/entt/entt.hpp" entt_header_hash)
|
|
file(SHA256 "${entt_root}/LICENSE" entt_license_hash)
|
|
if(NOT entt_header_hash STREQUAL EVO_ENTT_HEADER_SHA256 OR NOT entt_license_hash STREQUAL EVO_ENTT_LICENSE_SHA256)
|
|
message(FATAL_ERROR "Experimental EnTT dependency failed integrity validation")
|
|
endif()
|
|
add_executable(evo-ecs-experiment experiments/ecs/comparison.cpp)
|
|
target_include_directories(evo-ecs-experiment PRIVATE include)
|
|
target_include_directories(evo-ecs-experiment SYSTEM PRIVATE "${entt_root}/include")
|
|
evo_owned_target(evo-ecs-experiment)
|
|
if(BUILD_TESTING)
|
|
add_test(NAME ecs-experiment-contracts COMMAND evo-ecs-experiment --verify)
|
|
set_tests_properties(ecs-experiment-contracts PROPERTIES TIMEOUT 120)
|
|
endif()
|
|
endif()
|
|
|
|
find_program(EVO_CLANG_FORMAT NAMES clang-format-19 clang-format)
|
|
add_custom_target(format-check COMMAND "${CMAKE_COMMAND}"
|
|
"-DFORMATTER=${EVO_CLANG_FORMAT}" "-DSOURCE_ROOT=${CMAKE_CURRENT_SOURCE_DIR}"
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/tools/check-format.cmake" VERBATIM)
|