Skip to content

ltm: square-source aggs (repeated dim in result_dims) pin by dim name across co-source and agg-to-target halves; only the feeder half is defended #785

Closed

Description

@bpowers

Summary

A degenerate square-source reducer -- x[D1] = 1 + SUM(cube[D1,D1,*] * frac[D1,D1]) with cube[D1,D1,D2] and frac[D1,D1] -- mints a synthetic agg whose result_dims == ["D1","D1"]: both axes classify Iterated with the same target dim. The LTM machinery enumerates agg slots over the full square while the executed A2A simulation reads only the diagonal, and several emission paths resolve subscript indices by FIRST-MATCH dim name -- which is ambiguous when a dim repeats in result_dims.

Commit 1461b6dc (branch ltm-shape-phase1, follow-up to merged PR #784) defended the FEEDER half: pin_iterated_dim_indices now bails on duplicate dim names, converting the score to the #743-style UnfreezablePartial loud skip (fixture: square_source_duplicate_dim_feeder_scores_are_loudly_skipped in src/simlin-engine/src/db/ltm_unified_tests.rs).

The other two halves still pin by dim name and likely share the first-match hazard on this shape:

Why it matters

If the co-source half resolves a repeated dim by first match and emits a numerically wrong but confident link score, that violates the no-silent-wrong-numbers invariant (the loud-skip discipline from #743/#762). Even if all halves turn out merely inconsistent rather than silently wrong, the asymmetry (one half loudly skipped, the others not) makes the surface incoherent on this shape.

Components affected

  • src/simlin-engine/src/db/ltm/link_scores.rs -- pin_body_to_row (co-source row partials), positions_in_to_dims / qualified_pin_for_target (agg-to-target projection), pin_iterated_dim_indices (feeder; already defended)
  • enumerate_agg_nodes -- mints the square result_dims agg in the first place

Fix direction

Either:

  1. Decline the hoist for repeated-dim result_dims at enumerate_agg_nodes (conservative, simplest). The executed simulation reads only the diagonal of cube[D1,D1,*], so the square slot enumeration is structurally questionable anyway; declining routes the shape to existing fallback handling.
  2. Generalize positional resolution (the resolve_mismatched_index_position pattern) across all three halves so a repeated dim name resolves by position, not first match.

Cross-reference the engine-side question of what cube[D1,D1,*] execution actually reads (the diagonal) vs LTM's square slot enumeration -- a diagonalizing canonicalization (per #778's option 1) would make all halves agree by construction.

Related

Discovery context

Identified while fixing PR #784's automated-review P3 findings on branch ltm-shape-phase1 (commit 1461b6dc), 2026-06-11.

Activity

  1. added
    ltm
    on Jun 11, 2026
  2. bpowers commented on Jun 11, 2026

    @bpowers
    OwnerAuthor

    Severity refinement from the adversarial review of commit 1461b6d (the feeder-half defense), as this issue anticipated:

    Empirically, with the co-source made endogenous (cube[D1,D1,D2] = 0.0001*pop[D1]), the co-source half post-1461b6dc emits 8 confident per-(row, slot) scores. pin_body_to_row bails on the ambiguous frac[d1,d1] index via the pre-existing resolve_mismatched_index_position uniqueness defense and falls back to the delta-ratio form (magnitude +/-1) -- including on the 4 phantom off-diagonal cube[r1,r2,c] -> agg[r1,r2] edges the executed simulation never reads.

    Containment is loop-level only: all 17 loops traversing a phantom edge or the skipped feeder link fail fragment compile loudly (warned constant-0 stubs, the #780 pattern), and only the 4 diagonal cube loops compile. But the phantom +/-1 LINK scores enter the results slab and the link-level surfaces -- analyze_links synthetic collapse, rel-link denominators, discovery mode -- with no warning attached.

    So this remains a real silent-wrong-number on the LINK surface for the square shape (pre-existing; 1461b6d neither introduced nor touched it). The phantom-edge fan-out itself is #778; this issue covers the first-match pin ambiguity across the co-source and agg-to-target halves.

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