Problem
The systems format translator (src/simlin-engine/src/systems/translate.rs) does not validate or handle duplicate source/destination pairs in flows. If a model contains two flow declarations with the same source and destination, such as:
The translator generates colliding variable identifiers for both (e.g., both produce a_outflows_b and a_to_b), which would cause compilation failures or silent overwrites downstream.
Why it matters
- Correctness: Silent overwrites mean one flow equation would replace the other, producing wrong simulation results with no error message.
- Developer experience: If compilation does fail, the error would be a confusing duplicate-identifier error from the compiler rather than a clear message pointing at the duplicate flow declaration.
- Robustness: As the systems format is intended for AI agents and humans to author models quickly, unclear failure modes undermine trust.
Component(s) affected
src/simlin-engine/src/systems/translate.rs (identifier generation in flow translation)
Possible approaches
- Reject duplicates with a clear error: During translation, track
(source, dest) pairs and emit a diagnostic if the same pair appears twice. This is the simplest and probably correct behavior -- duplicate flows with the same source/dest are likely a modeling error.
- Disambiguate with suffixes: Generate identifiers like
a_to_b_1, a_to_b_2 for duplicate pairs. This is more permissive but adds complexity and may mask authoring mistakes.
Option 1 is recommended.
Context
Identified during review of the systems format translation logic on the systems-format branch.
Problem
The systems format translator (
src/simlin-engine/src/systems/translate.rs) does not validate or handle duplicate source/destination pairs in flows. If a model contains two flow declarations with the same source and destination, such as:The translator generates colliding variable identifiers for both (e.g., both produce
a_outflows_banda_to_b), which would cause compilation failures or silent overwrites downstream.Why it matters
Component(s) affected
src/simlin-engine/src/systems/translate.rs(identifier generation in flow translation)Possible approaches
(source, dest)pairs and emit a diagnostic if the same pair appears twice. This is the simplest and probably correct behavior -- duplicate flows with the same source/dest are likely a modeling error.a_to_b_1,a_to_b_2for duplicate pairs. This is more permissive but adds complexity and may mask authoring mistakes.Option 1 is recommended.
Context
Identified during review of the systems format translation logic on the
systems-formatbranch.