Repository navigation
Description
Summary
Simlin classifies user-defined modules with internal stocks as DynamicModule, but composite/pathway LTM instrumentation is only generated for implicit (stdlib) models. As a result, user-defined dynamic modules do not get composite link scores and are analyzed with the black-box fallback.
Why this is a problem
The LTM integration papers treat hidden internal structure (macros/modules) via composite path scores so loop attribution remains faithful to the expanded causal structure. Restricting composites to stdlib modules breaks that equivalence for user-defined modules that are structurally identical to stdlib dynamics (stocks, flows, multiple internal paths).
Concretely, links into user-defined dynamic modules can be scored with the black-box formula instead of per-path composite scores, which can change discovered loop importance and relative loop scores.
Literature / algorithm alignment
- Reference doc: Section 6 (Handling Macros), especially 6.3 and 6.7.
- Design doc states the macro handling approach should generalize to modules.
Expected algorithmic behavior: for any dynamic module boundary, compute internal pathway scores and use max-abs composite score at each timestep for boundary link scoring.
Current implementation behavior
- Dynamic classification includes user modules with stocks:
src/simlin-engine/src/ltm.rs(classify_module_for_ltm)
- Composite port precomputation is limited to
model.implicit == true:src/simlin-engine/src/ltm_augment.rs(compute_composite_ports)
- Internal ilink/path/composite variable generation is also limited to
model.implicit == true:src/simlin-engine/src/ltm_augment.rs(generate_ltm_variables_inner)
Impact
- User-defined dynamic modules can be systematically under-instrumented compared to stdlib modules.
- Loop dominance results can depend on whether structure is packaged as stdlib macro vs user module.
Success criteria
- Composite port detection runs for all
DynamicModulemodels that are instantiated in analyzed models, not only implicit stdlib models. - Internal ilink/path/composite synthetic variables are generated for those dynamic modules as well.
- Parent boundary links to those modules use composite references when a valid input-port→output pathway exists.
- Add tests showing equivalent LTM loop/link scoring for:
- a stdlib dynamic module case
- an isomorphic user-defined dynamic module case
- Document any intentional exceptions (if some module classes cannot be instrumented safely).
Notes
This issue is separate from the known flow-to-stock timing shift behavior.
Activity
bpowers commentedon Apr 30, 2026
Fixed in commit 01970ba ("engine: unified LTM module composite scoring (#416)").
The
model.implicit == truegate that previously limited composite/pathway generation to stdlib macros has been removed.compute_composite_portsno longer exists; pathway/composite generation now runs for any model (stdlib or user-defined) with detected input ports.find_model_output_ports_for_module(src/simlin-engine/src/db.rs), which scans parent models formodule.internal_varreferences to detect output ports for any user-defined dynamic module.model_ltm_variables(src/simlin-engine/src/db_ltm.rs:2902-2963); the gate is nowhas_input_ports = !pathways.is_empty()(db_ltm.rs:2417), independent of stdlib provenance.test_ltm_module_with_non_standard_output_nameindb_ltm_module_tests.rs:206, which exercises composite scoring on a user-defined module with a non-standard output name.Verified on
mainat HEAD 630fceb (2026-04-29).doc: refresh LTM tech-debt entries after triage of open issues