diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ca30c1..a70e820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,8 +84,17 @@ if(BUILD_TESTING) 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) - set_tests_properties(cli-ecosystem-conflict PROPERTIES WILL_FAIL TRUE) + 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) + 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 + PROPERTIES WILL_FAIL TRUE) add_test(NAME cli-file-integration COMMAND "${CMAKE_COMMAND}" "-DEVO_SIM=$" "-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/cli-integration" -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/cli_integration.cmake") diff --git a/apps/evo-sim/main.cpp b/apps/evo-sim/main.cpp index a305e24..1c98352 100644 --- a/apps/evo-sim/main.cpp +++ b/apps/evo-sim/main.cpp @@ -85,6 +85,8 @@ std::expected parse(int argc, char** argv) { Options options; bool initial_state_option = false; bool entities_option = false; + bool ticks_option = false; + bool episode_option = false; for (int index = 1; index < argc; ++index) { const std::string_view key{argv[index]}; if (key == "--help") { @@ -118,10 +120,13 @@ std::expected parse(int argc, char** argv) { entities_option = true; } else if (key == "--episodes") { options.episodes = *parsed; + episode_option = true; } else if (key == "--tick-limit") { options.tick_limit = *parsed; + episode_option = true; } else { options.ticks = *parsed; + ticks_option = true; } } else if (key == "--load") { options.load = value; @@ -138,10 +143,16 @@ std::expected parse(int argc, char** argv) { if (options.entities > evo::max_entities || (!options.load.empty() && initial_state_option)) { return std::unexpected{evo::Error::invalid_arguments}; } - // Episode measurement shares no state, snapshot or particle metric with the proof run. - if (options.ecosystem && (entities_option || options.verify_replay || !options.load.empty() || - !options.save.empty() || !options.metrics.empty() || - options.episodes == 0 || options.tick_limit == 0)) { + // Every option must belong to the selected mode. An option that is accepted and + // then ignored lets a measurement script succeed while running another workload. + const bool proof_only = entities_option || ticks_option || options.verify_replay || + !options.load.empty() || !options.save.empty() || + !options.metrics.empty(); + if (options.ecosystem) { + if (proof_only || options.episodes == 0 || options.tick_limit == 0) { + return std::unexpected{evo::Error::invalid_arguments}; + } + } else if (episode_option) { return std::unexpected{evo::Error::invalid_arguments}; } if (const auto valid = validate_paths(options); !valid) { diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index eea4bdc..ad0f6f2 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -342,6 +342,18 @@ out: the producer always retains captured energy, so its whole inventory never reaches zero. The elapsed time is one uncontrolled wall-clock observation, not a performance threshold. +Review of `eaf58f2` found one defect (2026-09-22): the CLI validated mode options +in one direction only. `--ticks` was accepted and ignored under `--ecosystem`, and +`--episodes`/`--tick-limit` were accepted and ignored without it, so a measurement +script could exit zero while running the other workload. The parser now records +which options were supplied and rejects any that do not belong to the selected +mode, in both directions. Six CLI cases cover this; `cli-ecosystem-rejects-ticks` +and `cli-episodes-require-ecosystem` are the two genuine regressions, while the +entities, save and verify-replay cases were already rejected and add coverage. +The remaining shared options were audited: `--seed` and `--output` are valid in +both modes, and `--load` conflicts were already enforced. CTest is now 16 cases, +all four native configurations were rerun, and `2cd4a15f9fbe9949` is unchanged. + This measures arithmetic conservation and turnover, not ecological plausibility. Strategy constants, lifespans and the targeting rule are chosen inputs. There is no maintenance cost, starvation rule, perception, spatial gate, genome or