Skip to content

engine: MDL writer silently drops conveyor/queue compat on export (no ExportWarning) #887

Closed

Description

@bpowers

Problem

The MDL writer (src/simlin-engine/src/mdl/writer.rs) silently drops conveyor and queue stock semantics on export, with no ExportWarning.

Vensim has no conveyor/queue primitive (docs/design/conveyors.md section 9.7 acknowledges this), so lossiness is expected -- but today the loss is completely silent. A conveyor stock exports as a plain INTEG stock, dropping:

  • the conveyor block itself (transit time, capacity, arrest, sample) -- Compat.conveyor
  • leak-marked flows (Compat.leakage, including leak fraction and linear/exponential mode)
  • spreadflow markers (Compat.spreadflow)
  • queue markers (Compat.queue)
  • overflow markers (Compat.overflow)

writer.rs currently contains zero references to any of these fields (verified by grep), so the exported model simulates with materially different dynamics (a first-order INTEG stock instead of a pipeline delay / discrete queue) and the user gets no signal.

Why it matters

Silent semantic loss on export. This is the same class of bug as the fixed #857 (ACTIVE INITIAL / GET DIRECT compat dropped on stocks) -- the export changes simulation behavior with no diagnostic. Since MDL genuinely cannot represent conveyors, the correct behavior is a loud, per-variable warning rather than representation.

Component

  • src/simlin-engine/src/mdl/writer.rs

Suggested fix

The writer already has an ExportWarning side-channel used for exactly this kind of lossy export:

  • warn_dropped_non_negative (writer.rs:1505)
  • warn_unrepresentable_gf_kinds (writer.rs:1530)
  • warn_group_lossiness (writer.rs:1587)

Add a warn_dropped_conveyor_compat-style helper that emits one warning per affected variable:

  • a stock with compat.conveyor or compat.queue set (exported as plain INTEG)
  • a flow with compat.leakage, compat.spreadflow, or compat.overflow set (exported as a plain flow)

Wire it into the stock and flow write paths alongside the existing warn_dropped_non_negative call site (writer.rs:1445). Add tests asserting the warnings fire for a conveyor fixture and that the exported MDL still parses.

Related but distinct

Context

Identified while fixing #872 (XMILE uses_conveyor header emission) during the conveyor-engine PR #869 review follow-up work.

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