Skip to content

MDL roundtrip loses per-view font metadata in multi-view models #405

Description

@bpowers

Description

During MDL parsing, when multiple views are merged into a single StockFlow, font metadata is collapsed to a single value by taking only the first non-None font (src/simlin-engine/src/mdl/view/convert.rs:262-264). When the merged view is later split back into multiple views for MDL output, all segments share this single font string.

This means multi-view MDL files where different views specify different $... font lines will roundtrip with the wrong font on later views.

Why it matters

  • Correctness: roundtripping a multi-view MDL file silently loses information, which could affect downstream tools or users who rely on per-view font settings.
  • Maintainability: the current data model (StockFlow has a single font: Option<String>) conflates view-level metadata with model-level metadata, making it harder to reason about what belongs where.

Components affected

  • src/simlin-engine/src/mdl/view/convert.rs (merge logic at lines 262-264)
  • src/simlin-engine/src/mdl/view/ (output/split logic)
  • project_io.proto / data model (StockFlow.font field)

Possible approaches

The fix would require extending the data model so that font metadata is stored per-view rather than per-StockFlow. One approach: attach font metadata to the Group elements that serve as view merge markers, since those already delineate view boundaries within a merged StockFlow. This would require changes to the protobuf schema and both the MDL reader and writer.

Context

Identified during code review of PR #397 (mdl-roundtrip-fidelity branch). The fix requires a data model refactor and was deemed out of scope for that PR.

Activity

  1. added
    engineIssues with the rust-based simulation engine
    compatCompatibility (XMILE, Vensim, etc) problem or enhancement
    on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatCompatibility (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