Skip to content

ltm: recover_agg_hop_polarities never matches subscripted arrayed-agg endpoints, so arrayed-agg loops always classify Undetermined on the scored/pinned surfaces #745

Closed

Description

@bpowers

Summary

recover_agg_hop_polarities (src/simlin-engine/src/db/ltm/loops.rs, ~lines 1633 and 1644 post-2f2dbbdc) never matches the agg endpoint of a SUBSCRIPTED arrayed-agg hop, so every scored/pinned loop through an arrayed synthetic agg classifies Undetermined (u{n}) even when the hop polarity is statically derivable.

The endpoint matches compare the bare canonical synthetic-agg name against the link's FULL ident:

// `source → agg`: the agg is this link's target.
if let Some((_, agg)) = synthetic.iter().find(|(name, _)| name == &link.to) {
    ...
// `agg → consumer`: the agg is this link's source.
if let Some((agg_ident, agg)) = synthetic.iter().find(|(name, _)| name == &link.from) {

But an arrayed agg's element-graph hops carry a slot subscript -- the link ident is $⁚ltm⁚agg⁚0[a], not $⁚ltm⁚agg⁚0 -- so neither find ever matches, the hop links stay LinkPolarity::Unknown, and the loop-polarity reduction forces LoopPolarity::Undetermined.

The asymmetry is visible in the surrounding code: the non-agg side of the same comparisons already strips subscripts (strip_subscript(link.from.as_str()) / strip_subscript(link.to.as_str())); only the agg-endpoint side forgot to.

Reproduction

growth[r1] = 0.01*pool[r1] + SUM(matrix[r1,*]*scale)
scale = 0.001*SUM(pool[*]) + 0.01

The per-slot feeder loops through the arrayed agg score as u1/u2, although the SUM(matrix[r1,*]*scale) hops are genuinely derivable (Positive w.r.t. the matrix rows -- SUM is monotone in every element it reads).

Why it matters

  • Silent polarity-label degradation: arrayed-agg loops report Undetermined instead of R/B. Loop SCORES are unaffected (this pass only patches polarity labels), so severity is low-medium.
  • Cross-surface POLARITY disagreement: after the GH ltm: loop-score builder's PureScalar fast path never routes a loop through a scalar synthetic agg node (silent zero loop score) #737 fix, the detected surface's spliced agg hops from expand_loops_through_routed_aggs use BARE agg names, so they DO match and get patched -- detected says R/B while scored/pinned says U for the same arrayed-agg loop. (Cross-reference the parallel sibling finding on the arrayed-cycle agg id-namespace overlap between the two surfaces, being filed separately from the same review.)

Fix shape

Symmetric with the existing non-agg side: strip the subscript before the agg-name comparison on both endpoint matches, i.e. compare against strip_subscript(link.to.as_str()) / strip_subscript(link.from.as_str()) (as Ident::new(...) or a str compare). Add a fixture with an arrayed agg (iterated-dim reducer like SUM(matrix[r1,*]*scale)) asserting the recovered loops classify R/B, not U.

Component

src/simlin-engine/src/db/ltm/loops.rs (recover_agg_hop_polarities)

History / context

Part of epic #488.

Activity

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