Guard config contracts at startup#11
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PARAMETERS.src/config_validation.rs, called once beforeSimulation::new.[report]line.Why
Silent fallback values and malformed config values are scientifically risky: a missing or invalid parameter can change model behavior without the operator realizing it. This PR makes the currently used literal defaults auditable and adds a startup boundary that stops unambiguous invalid config before timestep 0.
Runtime Behavior
[config-validation] PASSED: 0 error(s), 0 warning(s), mode=strict.Simulation::new, write failed run metadata where possible, print a[report] status=config_validation_failed ..., and exit with code 2.AMR_CONFIG_VALIDATION=warnallows explicit non-production continuation while preserving the failed validation status in logs/metadata/report output.Hard errors currently cover:
get_global_paramkeys missing fromPARAMETERS;get_requiredkeys missing fromPARAMETERS;get_or_default(map, "...")keys missing fromPARAMETERS;Warnings currently cover:
0.0or1.0, because runtime treats>0.5as true.Scope
Validation
cargo check --all-targetscargo test --test config_validation -- --nocapturecargo test --test config_invariants -- --nocapturecargo test --test probability_invariants -- --nocapturecargo test --test determinism -- --nocapturecargo test --test csv_invariants -- --nocapturecargo test --test dimension_invariants -- --nocapturerustfmt --check src/main.rs src/observability.rs src/config_validation.rs tests/config_invariants.rs tests/config_validation.rs tests/csv_invariants.rs tests/determinism.rs tests/dimension_invariants.rs tests/probability_invariants.rsgit diff --checkRunner Smoke
20260612T001542-58395population_size=1000,time_steps=200,CalibrationMode::Partial, seed123456789[config-validation] PASSED: 0 error(s), 0 warning(s), mode=strict870119f5a194b21e63bfcc58d95ba91c7b35649c3158667752dc48f9a40bebb7263299