From 22fb904c3ec4a93bdfc88ca782df6716a9699cb8 Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 22 Sep 2026 18:36:46 -0400 Subject: [PATCH] Reject CLI options that do not belong to the selected mode Mode validation ran in one direction only. Under --ecosystem, --ticks was accepted and then ignored; without it, --episodes and --tick-limit were accepted and then ignored. Either way the process exited zero while running the other workload, so a measurement script could report success for a run it never performed. Record which options were actually supplied and reject any that belong to the other mode, in both directions. An option that is accepted and then ignored is now a parse error rather than a silent substitution. Six CLI cases cover this. cli-ecosystem-rejects-ticks and cli-episodes-require-ecosystem are the genuine regressions, reproducing the two reported invocations; 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. Native Release, clang-tidy analysis, ASan and format checks pass 16/16. The ecosystem report is unchanged: 32 episodes still fingerprint 2cd4a15f9fbe9949, and golden d61ad5bf0c928c76 is intact. Co-Authored-By: Claude Opus 5 --- CMakeLists.txt | 11 ++++++++++- apps/evo-sim/main.cpp | 19 +++++++++++++++---- docs/engineering/VALIDATION.md | 12 ++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) 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