Repository navigation
Closed
Description
The MDL round-trip tests could pass while the writer was wrong.
They compared too little of the model after a save and re-read, covered few of the corpus files, and never simulated the result, so several writer bugs shipped unnoticed (a | in documentation corrupting the next equations; 29 of 240 corpus files whose saved MDL would not re-open).
Gaps
- (a) The equivalence check ignored variable type, units, documentation, graphical functions, and every per-element equation (all compared as the string
"<arrayed>"), so a wrong dimension recovered forSUM(a[*])would pass. - (b) Only 60 of 262
.mdlfixtures were in the corpus, with stale exclusions (xidz_zidz.mdl,test_lookups.mdl,test_lookups_inline.mdlround-trip fine). - (c) No test that every corpus file's saved MDL re-opens.
- (d) No property test generating models and saving them.
- (e) No check that the re-read model simulates the same.
- (f) Checking the writer's output in Vensim itself is a manual, ignored test; that stays manual without a Vensim license.
Where each stands
- (a)
save_roundtrip_tests.rs: every corpus file, read, saved and read again, must equal the original model (views and equation spelling aside); its allowlist is empty. - (b), (c)
mdl_roundtrip.rs: the three files are in the corpus, andcorpus_reparse_ratchetcovers every file. - (d)
writer_proptest.rs:first_save_is_a_fixed_pointover generated models with arrays, subranges, stocks, flows and lookups. - (e)
tests/integration/save_meaning.rs: every corpus model saved in each format, simulated, and compared with the original.
Pointers
src/simlin-engine/src/mdl/save_roundtrip_tests.rssrc/simlin-engine/tests/integration/mdl_roundtrip.rssrc/simlin-engine/tests/integration/save_meaning.rs
Activity
bpowers commentedon Jul 7, 2026
Concrete motivation for gap (a) from the just-landed wildcard/bang subscript recovery (branch
mdl-writer-hardening):The writer now recovers
SUM(a[*])->SUM(a[Dim!])by looking up variablea's declared dimension at the wildcard's position (WriterContext::dim_at,src/simlin-engine/src/mdl/writer.rs:252, used atwriter.rs:737forIndexExpr0::Wildcard). All three roundtrip gates are blind to a MIS-recovery of that dimension:tests/integration/mdl_roundtrip.rs) only check re-parse success and text idempotence;Equation::Arrayed(_, _, _, _)opaquely (the<arrayed>collapse noted in gap (a)), and ApplyToAll reductions are not semantically compared either.So a future change that recovers the WRONG declared dimension for a wildcard position would pass every gate. This makes gap (a) concretely load-bearing for the freshly-landed recovery path: at least one array fixture whose ApplyToAll/reduction equation TEXT is semantically compared across MDL->MDL roundtrip (not
<arrayed>) is needed to guarddim_at.Discovered while hardening the MDL writer, 2026-07-06.
[-]engine: MDL roundtrip harness coverage gaps let confirmed writer bugs ship undetected[/-][+]mdl: round-trip tests miss writer bugs[/+]bpowers commentedon Oct 12, 2026
Closing: already fixed on main.
All five gaps are covered after PR #1076 (f629e96): (a) mdl/save_roundtrip_tests.rs compares the full datamodel after read-save-read over every corpus .mdl with an empty EXPECTED list (:184); (b)/(c) tests/integration/mdl_roundtrip.rs lists xidz_zidz/lookups/lookups_inline (:36-39) and corpus_reparse_ratchet (:1896) has an empty allowlist; (d) mdl/writer_proptest.rs first_save_is_a_fixed_point (:813); (e) tests/integration/save_meaning.rs simulates every corpus save in every format pair against a ratcheted table.