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 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-09-22 18:36:46 -04:00
co-authored by Claude Opus 5
parent eaf58f2b85
commit 22fb904c3e
3 changed files with 37 additions and 5 deletions
+15 -4
View File
@@ -85,6 +85,8 @@ std::expected<Options, evo::Error> 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<Options, evo::Error> 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<Options, evo::Error> 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) {