Skip to content

ltm: extend multi-source agg hoisting to feeder-sub-slice combinations (co-source-closure loops stay warned-zero) #767

Closed

Description

@bpowers

Summary

Extend multi-source aggregate-node hoisting to feeder-sub-slice combinations so that co-source-closure loops through currently-un-hoisted reducers become genuinely scoreable. combined_read_slice (src/simlin-engine/src/ltm_agg.rs, ~line 892) requires all arrayed sources of a reducer to read identical slices, so the common Vensim shape

D1 = {r1, r2}, D2 = {c1, c2}
matrix[D1, D2]                               -- co-source
frac[D1]                                     -- per-row feeder
growth[D1] = SUM(matrix[D1, *] * frac[D1])   -- matrix reads [Iterated(D1), Reduced]; frac reads [Iterated(D1)]

is declined (the documented multi-source slice-disagreement carve-out) and no synthetic $⁚ltm⁚agg⁚{n} node is minted -- even though frac's slice is a pure projection of the canonical slice onto the shared iterated axis.

Status after the #743 fix (ltm-fix-batch-2, commit 7012d9f0)

The #743 fix made the feeder-side conservative score correct via a changed-last fallback, replacing the old silent ~-250 garbage. But loops closing through the co-source (matrix) remain on the loud degraded path: fragment warnings + zero-stubbed loop scores. This is pinned by the characterization test un_hoisted_iterated_dim_feeder_co_source_closure_stays_loud in src/simlin-engine/tests/integration/ltm_array_agg.rs (~line 3443) -- a fix for this issue must replace that test with positive score assertions.

Principled fix

Accept per-source read slices in combined_read_slice where each source's slice is a projection/sub-slice of the canonical one on the shared axes: the feeder contributes per-row ([Iterated(D1)]), the full co-source per-(row, reduced-cell) ([Iterated(D1), Reduced]). The feeder is per-agg-slot constant, playing exactly the role the scalar feeder plays in the already-hoisted SUM(arrayed[*] * scalar) case (#737/#738's fixture), generalized per row.

Honest effort assessment (from the #743 implementor, who scoped and deferred this)

Multi-day and destabilizing to the settled #752/#534 paths, hence deferred from the batch:

Why it matters

Low-medium severity, capability gap: co-source-closure loops through this common Vensim shape (per-row total = SUM(row * per-row coefficient), e.g. weighted row sums with per-region weights) report warned zeros instead of scores. Visibly degraded (the #738 pattern), not silently wrong -- the silent-garbage half was #743 and is fixed.

Components affected

  • src/simlin-engine/src/ltm_agg.rs -- combined_read_slice, AggNode, emit_agg_routed_edges
  • src/simlin-engine/src/db/ltm/link_scores.rs -- per-(row, slot) link-score enumeration
  • src/simlin-engine/src/ltm_augment.rs -- body pinning for the per-row feeder
  • src/simlin-engine/src/db/ltm/loops.rs -- loop-builder routing

Discovery context

Scoped and deferred during GH #743 work on branch ltm-fix-batch-2 at commit 7012d9f0 ("engine: changed-last fallback for unfreezable ltm partials").

Tracking

Part of LTM tracking epic #488 and the array-support umbrella #273. Related: #743 (the silent-garbage conservative-path bug whose fix left this residual), #744 (body-pinning machinery this fix must coordinate with), #764 (the variable-backed gate's broadcast/permuted residual -- different gate, same "extend the hoist acceptance" family), #765 (Pinned-axes co-reduced-slice value fix), #737/#738 (the scalar-feeder siblings, fixed).

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