Skip to content

ltm: per-element bare-Var pinning ignores the dep's declared dims (subset-dims dep silently zeroes scores; mapped live-source analogue) #974

Closed

Description

@bpowers

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-Var arm), rewrite_per_element_source_refs (bare-Var arm)

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:

Activity

  1. added
    ltm
    on Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions