Repository navigation
Description
Summary
The per-element link-score pinning machinery in src/simlin-engine/src/ltm_augment.rs has two sibling bare-Var arms that pin an unsubscripted arrayed reference without consulting the variable's DECLARED dimensions. Both should be fixed together by threading declared dims (and the mapped-dim correspondence) into every per-element bare-Var pin.
1. Reachable: bare subset-dims dep in a per-element / arrayed-agg target body (silent-zero scores)
subscript_idents_at_element's bare-Var arm (ltm_augment.rs ~2179 at f057ef38; the Expr0::Var match in subscript_idents_in_expr0) pins EVERY listed bare dep with the target's FULL element tuple, regardless of the dep's own arity:
growth[Region,Age] = pop[Region, young] * w # w declared [Age]
The per-element pinning pass rewrites the bare w to w[region·r, age·y] -- arity 2 over a 1-D variable. Every per-element link-score fragment for the pop -> growth edge fails to compile, the fragments are dropped, and the pop -> growth scores silently read constant 0 for the whole run. The only signal is per-fragment "failed to compile" Assembly warnings (the #546/#548/#587 hazard class: degraded score masquerades as an inactive link).
2. Latent analogue: bare live-source ref in a positionally-MAPPED per-element target
rewrite_per_element_source_refs' own bare-Var arm (ltm_augment.rs ~2555 at f057ef38) -- which pins a genuinely-bare reference to the LIVE SOURCE -- projects by the source's OWN dims (AxisRead::Iterated { dim, source_dim } with dim == source_dim for every axis) and has no mapped-correspondence arm. A bare source reference in a positionally-mapped per-element target (growth[State,Age] = pop[State,young] * pop with a positional State -> Region mapping) would fail to row-resolve (per_element_row_for_target returns None) the same way. This shape is contrived and untested (both endpoints must type-check as a bare mapped broadcast), but it is the exact analogue of arm 1 and the same fix covers it.
Fix direction
Pin a bare arrayed dep only over the dimensions it DECLARES (a subset of the target's element tuple), which requires threading the dep's declared dims into the per-element pinning pass; for the live-source arm, additionally consult DimensionsContext::mapped_element_correspondence so a positionally-mapped axis resolves to the corresponding source element (the same correspondence the Subscript arm already carries via per_element_row_for_target's Iterated { dim, source_dim }).
Components affected
src/simlin-engine/src/ltm_augment.rs--subscript_idents_at_element/subscript_idents_in_expr0(bare-Vararm),rewrite_per_element_source_refs(bare-Vararm)
Discovery context
Found during adversarial review of the LTM transform-first restructuring on branch roundtrips-track-a (part of the #965 typed-IR arc). Verified byte-identical between HEAD f057ef38 and the restructured tree -- pre-existing, NOT a regression of that work. Empirically confirmed: the bare-w model above emits four "failed to compile" Assembly warnings on both trees.
Tracking
Part of LTM epic #488 (Augmentation group). Related but distinct:
- ltm-augment: partial builders PREVIOUS-wrap dimension-name subscript indices (Wildcard and Bare shapes), silently stubbing scores #759 -- the other pin-machinery silent-stub defect (dimension NAMES inside subscript indices get PREVIOUS-wrapped); different root cause (dep-set leakage + wrapper guards), but a fix here should stay consistent with its guard work.
- engine: bare arrayed name inside nested PREVIOUS() in an apply-to-all equation fails to compile #541 (closed) -- the engine-side bare-arrayed-name-inside-nested-PREVIOUS limitation; that was a compiler shape bug, this is LTM-generator-side over-subscription.
- ltm: no test checks that LTM equations compile across real models #782 -- the every-emitted-fragment-compiles harness that would catch class 1 generically.
- ltm: replace string-backed synthetic equations with typed IR #965 -- the typed-IR restructuring under which a declared-dims-aware pin becomes natural to express.
Activity