Skip to content

ltm: bare arrayed reducer arg consumed per-slot by execution is hoisted as a whole-array scalar agg (silent wrong link and loop scores) #788

Closed

Description

@bpowers

Summary

A BARE arrayed argument to a whole-RHS reducer -- SUM(other) with other[D1] arrayed, inside an A2A equation over D1 -- is consumed PER-SLOT by execution but hoisted by LTM into a SCALAR synthetic aggregate whose value is the WHOLE-ARRAY sum. Every score touching the reducer is silently wrong (unwarned, sustained): phantom cross-element edges, a wrong changed-first freeze, and wildly inflated loop scores.

This is the bare-ARRAYED-arg sibling of #779 (bare SCALAR feeder of an un-hoisted reducer). Same root cause -- the read-slice vocabulary cannot express a bare iterated read -- but #779's loud-decline fix (commit ef91194d, branch ltm-phase1-residuals) covers only the changed-LAST live-feeder leg. The synthetic-agg halves and the changed-FIRST whole-reducer freeze still score silently wrong.

Fixture (reproduced at ef91194d with a TestProject fixture)

D1 = {a, b}
pop[D1]    -- stock
other[D1]  = pop * 0.01
frac[D1]   = pop * 0.005
growth[D1] = SUM(other) * frac   -- flow into pop

Execution resolves the bare other in the A2A-over-D1 context to the ACTIVE slot: SUM(other) = other[r] (a sum over one scalar), so growth[a] at t0 = 1.0 * 0.5 = 0.5 -- NOT the whole-array sum 2.0 * 0.5.

What LTM does instead (all unwarned)

  1. enumerate_agg_nodes hoists SUM(other) into a scalar synthetic agg $:ltm:agg:0 = SUM(other) whose VALUE is the whole-array sum (2.0): the hoisted fragment evaluates outside the A2A context, so the bare ref reads the full extent.
  2. The element graph models cross-element edges other[a/b] -> $:ltm:agg:0 -> growth[a/b] that do not exist in execution (execution has only the diagonal other[r] -> growth[r]).
  3. The changed-first partial for the frac -> growth edge freezes PREVIOUS(SUM(other)) -- again the whole-array sum -- into the partial.

Measured result (ZERO warnings):

  • $:ltm:link_score:frac->growth = ~100.7 sustained
  • $:ltm:link_score:$:ltm:agg:0->growth[a] = ~100.7
  • loop u1 = ~2512; loops u2/u3 = ~50

This violates epic #488's standing "no silent wrong numbers" invariant.

Components affected

  • src/simlin-engine/src/ltm_agg.rs -- enumerate_agg_nodes hoists the bare-arg SUM(other) as an all-Reduced slice; no vocabulary for a bare iterated read (the per-slot consumption execution actually performs)
  • src/simlin-engine/src/ltm_augment.rs -- wrap_non_matching_in_previous whole-reducer changed-first freeze captures the whole-array sum
  • src/simlin-engine/src/db/ltm/link_scores.rs -- the emitted agg-routed and feeder link scores

Possible approaches

Note the interaction with engine semantics: execution's per-slot resolution of a bare arrayed name inside a reducer is the XMILE A2A reading (a bare arrayed name in an A2A equation denotes the active element). Whatever the engine-side resolution of the related execution issue (see the co-filed engine issue on the bare-ref-with-sliced-co-source x|D1| bug), LTM must model what execution actually computes.

Discovery context

Empirically confirmed during the adversarial review of commit ef91194d ("engine: decline bare-spelled feeder of un-hoisted reducer loudly", the GH #779 fix, branch ltm-phase1-residuals), reproduced at that commit with TestProject fixtures. Pre-existing, not a regression from that commit; out of scope for #779's fix.

Tracking

Part of LTM tracking epic #488 (cluster A). Related: #779 (bare scalar feeder sibling; its fix covers only the changed-last live-feeder leg), #743/#767 (the subscripted-spelling lineage), #738 (closed scalar-target agg compile sibling).

Activity

  1. added
    ltm
    on Jun 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

    ltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions