Repository navigation
engine: a validation battery a modeler can trust - #1077
Conversation
run_tests runs the model tests of system dynamics practice (units, extreme conditions, integration error, sensitivity, loop knockouts and disturbances), and an agent repeats what it flags to the modeler. On the corpus most of that was noise: divisors tried at zero, dates scaled as durations, rounding read as a stock going negative, families flipped by wiggles, one measurement reported twice, while a model draining its cash to -6.5 million in its own run passed. Each check now says what happened, not why. Under an extreme, a stock's element or a series the model marks non-negative is flagged when it goes below zero and the model's own run keeps it at or above zero. The model's own run is a check of its own, listed first. Nothing checked is reported as passed: a model that does not simulate says why once, and a test that would compare nothing is skipped saying so. Extremes are conditions of the system: a tenth of a divisor, four DTs a stage in a time constant's own unit, a date's start and past-stop, a rate no faster than Euler can follow. Integration error is one Richardson measurement at the model's own row times: it passes at or under 1% of a stock's scale, is flagged up to 5% and fails above, naming the time constant DT is too large for. Sensitivity flags a change of behavior family that moves the series materially, reads each run at its own scale with magnitudes shared (series::compared_scales, which run_experiment uses too), shows an oscillation's damping, and lists checks that make the same change of the same series once. Rules a labeled corpus showed buy nothing are left out. Value-only runs hold at most 64 MiB of results at once, so memory does not grow with the host's cores. tools/battery_corpus.json labels every check the battery lists over 29 corpus models, and an ignored gate holds it to those labels' counts.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1077 +/- ##
==========================================
+ Coverage 92.66% 92.69% +0.03%
==========================================
Files 308 308
Lines 188506 189518 +1012
==========================================
+ Hits 174672 175672 +1000
- Misses 13834 13846 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 839a364b32
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if worst <= INTEGRATION_TOLERANCE { | ||
| return Ok(vec![check]); |
There was a problem hiding this comment.
Flag nonconvergence before applying the error tolerance
When the half-to-quarter-DT difference does not converge but the model-to-half-DT difference is at or below 1%, this early return leaves the check's default outcome as Passed and skips the branches that report nonconvergence. A discrete, chaotic, or DT-reading model can therefore pass solely because its first refinement happens to move less than the tolerance; handle !converges before allowing this return.
AGENTS.md reference: src/simlin-engine/AGENTS.md:L234-L234
Useful? React with 👍 / 👎.
| check | ||
| .result | ||
| .responses | ||
| .iter() | ||
| .find(|r| material(r)) | ||
| .map(|r| (r.variable.clone(), r.family)) |
There was a problem hiding this comment.
Compare every material response before folding checks
When a sensitivity check has multiple material responses, this key considers only the first one. If two parameters produce the same leading change but only one also changes another recorded stock, the weaker check is folded away wholesale and that distinct response disappears from the battery output; compare the complete set of material responses, or merge unique responses before discarding a check.
AGENTS.md reference: src/simlin-engine/AGENTS.md:L234-L234
Useful? React with 👍 / 👎.
| .filter(|(key, _)| { | ||
| super::series::column_of(model, key.as_str()).map(|(owner, _)| owner) | ||
| == Some(ident.as_str()) |
There was a problem hiding this comment.
Reject module instances as numeric series
When a citation names a module instance, column_of assigns every module·child result column to that module, so series_of now treats the module as a collection of numeric series. Consequently goes_negative can verify a claim about the module when any child is negative, and single-series citations such as ends_near can verify the module itself when it happens to contain only one result column, even though a module has no value of its own; reject Variable::Module here or require the caller to name a qualified child variable.
AGENTS.md reference: src/simlin-engine/AGENTS.md:L236-L236
Useful? React with 👍 / 👎.
| (TestName::Units, _) if !declares_units(model) => Err( | ||
| "the model declares no units, so there is nothing to check: units are checked \ | ||
| once variables declare them" | ||
| .to_string(), |
There was a problem hiding this comment.
Run the units check for invalid project unit definitions
When the project contains a malformed or conflicting unit declaration but the selected model's variables have no unit strings, this guard skips units_check entirely. units_check explicitly includes UnitDefinition diagnostics, which are project-level and exist independently of whether a model variable references a unit, so the battery reports that there is nothing to check while hiding a real unit-definition error; consult the project diagnostics before taking this skip path.
AGENTS.md reference: src/simlin-engine/AGENTS.md:L95-L95
Useful? React with 👍 / 👎.
Code review findingsReviewed the new validation battery ( [P2]
|
The integration check passed a model whose first refinement moved it under the tolerance before asking whether the second refinement moved it less: a model that reads DT can move 0.5% at half the DT and 5% at a quarter, and its error is not bounded by the first. Convergence is decided first. The units test was skipped when no variable declares units, though a project's unit definitions can be malformed on their own. The check runs, and is skipped only when it finds nothing and no variable declares units.
|
Follow-up commit 2ad8658 for the Codex review:
|
|
Reviewed the diff against
Verified not bugs: memory accounting units in Overall correctness: correct. The patch is a substantive, carefully-structured refactor that keeps the public types additive, pins its claims with corpus data, and does not introduce correctness regressions I can confirm. |
Why
run_testsis how an agent asks whether a model is well behaved, and what it flags, an agent repeats to the modeler. A fresh-eyes review ran it over the corpus and found its findings were mostly noise:Meanwhile a real flaw passed: an AI-generated model whose cash falls to -6.5 million in its own run.
What
runFails); a test that would compare nothing (stocks only inside modules, nothing recorded) is skipped saying so.extremes.series::compared_scales, the one owner, whichrun_experimentuses too). A response shows an oscillation's damping in both runs.runs::concurrent_runs).Decisions worth a reviewer's eye
Evidence
Labeled corpus (ignored gate, release), 29 models. Before this change the battery listed 96 non-passing checks, of which 71 would be accepted by a modeler and 25 not; now 68 listed, 52 accepted, 16 not. Every listed check carries a one-line reason a reader can disagree with.
Integration against exact solutions (adversarial reviewer's measurements): reported against true error 0.0616 / 0.0636 for exponential decay at DT 0.6 with a save step of 0.7 under Euler; 0.336 / 0.340 for an oscillator under RK2. Read at the model's nominal save step instead of its row times, the first case would report 0.252.
Memory: C-LEARN peaks at 446 MB with the bound and 736 MB without, measured by the reviewer.
Each rule is pinned from both sides: the integration thresholds at 0.997% / 1.0001% and 4.990% / 5.021%; material movement exactly at 5%; the own run first with more failures than the list holds; the batch bound with a test budget and a peak-concurrency count; a non-simulating model's answer at 690 bytes.
Mutation testing: 31 of 32 mutations of the changed rules are killed; the survivor is a test written against the constant it checks.
The pre-commit hook passed in full.
What this does not establish
sameChange.==or the author's declared input range, neither carried yet).DELAY FIXEDmodels do not simulate on main, so the corpus says nothing about them.🤖 Generated with Claude Code
https://claude.ai/code/session_01LYR7N9WZwQuFnZFW8JDUgx