You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mdl: a module inside a macro is silently dropped on MDL save #566
If a macro's body contains a module, saving to MDL drops the module without an error or warning, leaving any variables wired to it pointing at nothing.
It should refuse the save with an error naming the module and the macro, as it already does for a module in the main model.
Example
No imported file produces this: the MDL importer does not put modules inside macro bodies.
It takes an edit after import, for example an agent adding a module to a macro model through MCP, then saving as .mdl.
Why it matters
Silent data loss on save, though only reachable through a programmatic edit.
Every other module the MDL format cannot hold is refused with an error.
Fix
Extend the pre-save check in project_to_mdl_with_warnings to look at the variables of every macro model, not only the main model, and return an error for any module there.
Add a test beside the existing project_to_mdl_rejects_* tests with the module placed inside a macro.
Alternative: write a multi-output macro call inside a macro body the way the main model's are written.
Only worth it once the importer can produce one.
Pointers
src/simlin-engine/src/mdl/mod.rs: project_to_mdl_with_warnings, the loop over main_model(project).variables
src/simlin-engine/src/mdl/writer.rs: write_macro_blocks; the Variable::Module(_) => return arm in the variable writer is where the module disappears
changed the title [-]engine: Variable::Module inside a macro-body model is silently dropped by the MDL writer (project_to_mdl reject gate scans only the main model)[/-][+]mdl: a module inside a macro is silently dropped on MDL save[/+]on Oct 12, 2026
Activity
engine: address PR #564 macro review feedback
[-]engine: Variable::Module inside a macro-body model is silently dropped by the MDL writer (project_to_mdl reject gate scans only the main model)[/-][+]mdl: a module inside a macro is silently dropped on MDL save[/+]