Skip to content

datamodel::StockFlow lacks a name/title field #326

Closed

Description

@bpowers

Problem

datamodel::StockFlow does not carry a view title/name field. As a result, write_stock_flow_view() in the MDL writer (src/simlin-engine/src/mdl/writer.rs) hardcodes "View 1" as the sketch view title. This means the original view name from a parsed MDL file is lost on roundtrip -- reading a model with a view named e.g. "Overview" and writing it back out will produce "View 1" instead.

Why it matters

  • Correctness: View names carry semantic meaning in Vensim models. Losing them on roundtrip is a fidelity regression.
  • Roundtrip fidelity: MDL read-write-read cycles should preserve all metadata that the engine understands. This is one of the remaining gaps.

Components affected

  • src/simlin-engine/src/datamodel.rs -- StockFlow struct needs a name: Option<String> (or similar) field
  • src/simlin-engine/src/mdl/writer.rs -- write_stock_flow_view() should use the field instead of hardcoding "View 1"
  • src/simlin-engine/src/mdl/parser.rs (or convert layer) -- needs to populate the new field when parsing view headers
  • XMILE reader/writer may also need updates for consistency

Possible approach

  1. Add pub name: Option<String> to datamodel::StockFlow.
  2. Populate it during MDL parsing from the view header line (e.g. *View 1).
  3. Use it in the MDL writer, falling back to "View 1" when None.
  4. Update XMILE serde if <views><view name="..."> is not already handled.
  5. Add a roundtrip test that verifies view name preservation.

Context

Identified during review of PR #324 (MDL writer implementation). The hardcoded value was an intentional pragmatic choice to keep the PR scope manageable.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions