Skip to content

engine: test_mdl_equivalence fails on main -- native MDL parser emits 3 extra link elements for SIR.mdl #512

@bpowers

Description

@bpowers

Problem

test_mdl_equivalence (gated behind the xmutil feature; not run in CI or pre-commit) is failing on main:

$ cargo test -p simlin-engine --features xmutil test_mdl_equivalence
...
---- test_mdl_equivalence stdout ----
testing: src/libsimlin/testdata/SIR.mdl
  29 elements (alias=5, aux=6, flow=2, link=13, stock=3)
  32 elements (alias=5, aux=6, flow=2, link=16, stock=3)

thread 'test_mdl_equivalence' panicked at src/simlin-engine/tests/mdl_equivalence.rs:817:9:
assertion `left == right` failed: src/libsimlin/testdata/SIR.mdl: view 0 element count differs (29 vs 32)
  xmutil: 29 elements (alias=5, aux=6, flow=2, link=13, stock=3)
  native: 32 elements (alias=5, aux=6, flow=2, link=16, stock=3)
  left: 29
 right: 32

The native Rust MDL parser produces 16 link (causal connector) elements for src/libsimlin/testdata/SIR.mdl, where the C++ xmutil reference parser produces 13. All other element counts match (alias=5, aux=6, flow=2, stock=3). The first failing assertion is the per-view element count at src/simlin-engine/tests/mdl_equivalence.rs:817.

Pre-existing, not caused by recent writer work

This reproduces on a clean working tree on main (verified with git stash -- no working-tree changes needed). It is not caused by recent MDL-writer commits: test_mdl_equivalence only exercises the parser (it parses the same file through both the native and xmutil paths and compares the resulting datamodels), not the writer.

Relationship to the known "26 C-LEARN diffs"

src/simlin-engine/src/mdl/CLAUDE.md and docs/tech-debt.md item 1 mention "26 differences remaining" between the native and xmutil parsers -- but that count comes from the separate test_clearn_equivalence test (#[ignore]d, measures the C-LEARN model). This SIR.mdl link-count divergence is in a different test (test_mdl_equivalence, which is not #[ignore]d, just feature-gated) and is not part of that tracked C-LEARN diff set.

Why it matters

  • Correctness / interoperability: extra causal connectors in the parsed view mean a roundtripped or imported SIR.mdl renders with spurious arrows in Vensim relative to what xmutil produces. One parser is wrong about which connectors the file declares.
  • Test hygiene: test_mdl_equivalence is a real (not #[ignore]d) test that is red on main. It currently only stays green by virtue of not running in CI/pre-commit.

Component(s) affected

  • src/simlin-engine/src/mdl/view/ -- native sketch/connector parsing (elements.rs, convert.rs, processing.rs)
  • Reference: src/simlin-engine/tests/mdl_equivalence.rs (the comparison harness)
  • Fixture: src/libsimlin/testdata/SIR.mdl

Suggested next step

Diff the two parsers' link lists for src/libsimlin/testdata/SIR.mdl to identify the 3 extra native links, then decide whether native or xmutil is correct. Likely candidates for the discrepancy: the native parser is keeping causal connectors that xmutil filters out (e.g. connectors to/from Time or other filtered variables, or duplicate connectors between the same endpoints). If xmutil is dropping legitimate connectors, the test's expectation is wrong; if native is keeping connectors Vensim wouldn't draw, the native parser needs the matching filter.

Discovery context

Identified while working on the MDL writer/parser. The failure is pre-existing on main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompatCompatibility (XMILE, Vensim, etc) problem or enhancementengineIssues with the rust-based simulation engine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions