-
Notifications
You must be signed in to change notification settings - Fork 19
Systems format translator: duplicate source/dest flow pairs produce colliding identifiers #399
Copy link
Copy link
Open
Description
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:
A > B @ 3
A > B @ 5
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_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-format branch.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels