Repository navigation
Description
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.conveyororcompat.queueset (exported as plain INTEG) - a flow with
compat.leakage,compat.spreadflow, orcompat.overflowset (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
- engine: a conveyor leak fraction given as a graphical function is ignored #865 covers deferred engine edge cases (GF leak fraction, PREVIOUS, JSON serialization) -- not the MDL export surface.
- pysimlin JSON converter silently drops Compat fields (data_source today; conveyor/queue/leakage/spreadflow/overflow) + ArrayedEquation.has_except_default #882 covers the pysimlin JSON converter dropping Compat fields -- Python mirror, not the MDL writer.
- core datamodel.ts Compat conversion is lossy (carries only activeInitial); confirm whether conveyor/queue markers must reach core + web editor #883 covers the core datamodel.ts Compat conversion -- TypeScript mirror, not the MDL writer.
- engine: MDL writer ignores compat on stocks and arrayed vars, silently dropping ACTIVE INITIAL / GET DIRECT #857 (closed) fixed ACTIVE INITIAL / GET DIRECT compat on stocks; it did not touch conveyor/queue fields.
Context
Identified while fixing #872 (XMILE uses_conveyor header emission) during the conveyor-engine PR #869 review follow-up work.
Activity