Skip to content

ltm: compute_read_slice maps a StarRange over a proper subdimension to Reduced over the full parent extent #766

Closed

Description

@bpowers

Summary

compute_read_slice (src/simlin-engine/src/ltm_agg.rs, the StarRange bullet in its rustdoc at ~lines 852-857 at 3ba78eb4) maps IndexExpr2::StarRange(_, _) to AxisRead::Reduced unconditionally -- including when the named subdimension is a proper subset of the source axis's own dimension. For SUM(arr[*:SubDim]) where SubDim is a proper subdimension of arr's axis, the read slice claims the reducer reads the FULL parent extent of that axis, when in fact it reads only the subrange's elements.

The rustdoc bullet acknowledges the coarseness but says "tightening this is tracked as GH #765" -- which is incorrect (see "Distinct from #765/#764" below). This issue is the correct tracking entry; the breadcrumb at ltm_agg.rs:852-857 should be repointed here when this is picked up.

Consequences

Everything downstream of the read slice treats rows OUTSIDE the subrange as read by the reducer:

  1. Extra spurious element edges -- emit_agg_routed_edges (src/simlin-engine/src/db/analysis.rs) routes every element of the full parent extent into the agg node, a conservative SUPERSET of the true edges. Loop enumeration may discover loops through source elements the reducer never reads.
  2. Wrong MEAN-style divisors -- per-row link scores via read_slice_rows (src/simlin-engine/src/db/ltm/loops.rs) enumerate the co-reduced slice over the full extent, so a divisor-bearing reducer (MEAN, STDDEV) over a subrange divides by the parent dimension's size instead of the subdimension's size. Same value-imprecision flavor as ltm: cross-dimensional partial-reduce link scores ignore Pinned axes in the co-reduced slice (inflated divisor + garbage unread-row scores) #765's pinned-axis divisor bug, but with a different root cause (see below).

Distinct from #765 and #764

Root cause

AxisRead has no way to express "reduced over a subset of the axis": Reduced means the whole extent. compute_read_slice's StarRange arm deliberately matches classify_subscript_shape's AC1.4 treatment of an all-StarRange subscript as Wildcard, so the coarseness is consistent across the classifier and the agg machinery -- consistently coarse.

Possible approach

A subrange-aware AxisRead variant (or Reduced carrying an Option<Vec<element>> subset, resolved from the subdimension's elements via DimensionsContext/SubdimensionRelation):

Why it matters

Low severity. The element edges are a conservative superset (never a missed edge), and the value imprecision requires a divisor-bearing reducer (MEAN/STDDEV) over a proper subdimension inside a feedback loop -- an uncommon shape. Pre-existing since the #514-era read-slice work.

Components affected

  • src/simlin-engine/src/ltm_agg.rs -- compute_read_slice StarRange arm, AxisRead
  • src/simlin-engine/src/db/analysis.rs -- emit_agg_routed_edges
  • src/simlin-engine/src/db/ltm/loops.rs -- read_slice_rows
  • src/simlin-engine/src/db/ltm_ir.rs -- classify_subscript_shape AC1.4 (consistency)

Related

Discovery context

Flagged by a reviewer during GH #752 review rounds on branch ltm-fix-batch-2 (commit 3ba78eb4): the existing rustdoc breadcrumb describes this defect but mis-attributes its tracking to #765.

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