Skip to content

ltm: reducer read through a variable index scores every row +/-1 #1042

Open

Description

@bpowers

When a reducer's argument reads one array through a variable index (SUM(m[d1, *] * n[d1, idx])), LTM cannot build a link-score equation for the rows feeding it and falls back to the target itself, so every row's link score is dy/dy = +/-1.
No warning is emitted.
Per the LTM epic's rule, an edge it cannot score should be declined with a warning and its loops dropped, never given a made-up number.

Example

d1 = {a, b}, d2 = {c, d}
m[d1, d2]  stock, initial 1, 2, 3, 5,    inflow fm
n[d1, d2]  stock, initial 7, 11, 13, 17, inflow fn
idx        = IF TIME > 2 THEN 1 ELSE 2
y[d1]      = SUM(m[d1, *] * n[d1, idx]) * 0.01
fm[d1, d2] = y[d1] * 0.1
fn[d1, d2] = y[d1] * 0.2

Every m[*,*] -> y[*] and n[*,*] -> y[*] link score is 1, 1, -1, 1 at t = 1..4, and the loops m -> y -> fm and n -> y -> fn score exactly +/-1.
Hand-computed shares for y[a] at t = 1 are 0.39 for each m row, 0.21 for the n row read, and 0 for the n row not read.
At t = 3, when idx switches, every row reads -1, so two reinforcing loops look balancing.
With n[d1, *] in place of n[d1, idx] the scores are exact.

Why it matters

A confident, wrong number with no diagnostic.
Seen only in a constructed model; a switch-selected column inside a reducer is plausible but rare.

Fix

Make the fallback loud: where build_element_reducer_link_score substitutes the target for an equation it could not build, return nothing, and let try_cross_dimensional_link_scores record the edge as unscoreable with one warning naming the index.
That covers every shape reaching this fallback (also a reducer nested in arithmetic on this path, and #744's self-reference case); RANK's documented stand-in is separate.
Small.

Alternative: exact equations, holding idx fixed (PREVIOUS(n[a, PREVIOUS(idx)]), as the direct per-element path does) and pinning m to its row; only if a real model needs it.

Not re-run since #1087 changed how per-element targets are described; the silent fallback is still in the code.

Pointers

  • src/simlin-engine/src/ltm_augment.rs: build_element_reducer_link_score (the target_ref.to_string() fallbacks)
  • src/simlin-engine/src/db/ltm/link_scores.rs: try_cross_dimensional_link_scores, decline_unhoisted_reducer_edge
  • docs/design/ltm--loops-that-matter.md, "Residual array carve-outs" (documents this as "no diagnostic")

Activity

  1. added
    ltm
    bug
    on Oct 12, 2026
  2. changed the title [-]ltm: reducer beside a dynamic-index co-source is un-hoisted and every row's link score is the silent delta-ratio stand-in of +-1 (no diagnostic)[/-] [+]ltm: reducer read through a variable index scores every row +/-1[/+] on Oct 12, 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

    bugltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions