Skip to content

Add protobuf support for EXCEPT equations, element-level dimension mappings, and DataSource metadata #341

Closed

Description

@bpowers

Background

Phase 2 of the MDL full compatibility work introduced three new datamodel constructs:

  1. Equation::Arrayed with default_equation -- Represents Vensim's :EXCEPT: syntax, where a default equation applies to all dimension elements not explicitly overridden. The Equation::Arrayed variant now has an Option<String> third field for this default equation.

  2. DimensionMapping with element_map -- Replaces the previous Dimension.maps_to: Option<String> with mappings: Vec<DimensionMapping>, supporting element-level correspondence between subscript families (e.g., mapping individual elements of one dimension to elements of another).

  3. DataSource metadata -- A new struct on Compat that stores parsed arguments from Vensim's GET DIRECT DATA/CONSTANTS/LOOKUPS/SUBSCRIPT functions, preserving the file path, tab/delimiter, and lookup coordinates so the MDL writer can reconstruct the original function call.

Current behavior

Protobuf serialization (serde.rs) returns an explicit error when encountering any of these constructs, preventing silent data loss. The error messages direct users to the sd.json format for full fidelity.

What needs to change

To support these constructs in protobuf:

  • EXCEPT equations: Add a default_equation field to the protobuf Variable message (or the arrayed equation representation) so that Equation::Arrayed with a default can roundtrip through protobuf.

  • Element-level dimension mappings: Extend the protobuf Dimension message to include a repeated DimensionMapping message with target name and element-level map entries, replacing or supplementing the current maps_to string field.

  • DataSource metadata: Add a DataSource message to the protobuf schema with fields for kind (enum: Data, Constants, Lookups, Subscript), file, tab_or_delimiter, row_or_col, and cell. Include this as an optional field on the Compat message.

Proto schema changes will require regenerating TypeScript and Rust bindings (pnpm build:gen-protobufs).

Acceptance criteria

  • Protobuf serialization roundtrips all three constructs without error
  • Existing protobuf-serialized data (with None/empty values for new fields) continues to deserialize correctly
  • The explicit error paths in serde.rs are replaced with proper serialization logic

Activity

  1. added
    enhancement
    engine
    on Feb 27, 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

    engineenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions