Skip to content

ltm: arrayed-cycle detected/scored loop-id namespace overlap lets the runtime id join read another loop's series #746

Closed

Description

@bpowers

Summary

For any feedback cycle containing an arrayed variable, the detected and scored LTM surfaces enumerate different loop sets but assign ids independently from the same r{n}/b{n}/u{n} namespace -- so the runtime id join can silently read another loop's score series.

  • model_detected_loops (src/simlin-engine/src/db/analysis.rs) emits one variable-level loop per cycle.
  • The scored surface (model_ltm_variables) enumerates per-element loops for arrayed cycles.
  • Both number their loops r1, r2, ... / b1, ... / u1, ... over their own loop sequence. When the sequences differ (which they do whenever an arrayed cycle expands per-element, or polarity labels diverge), detected r1 and scored r1 are different loops.
  • The joins that consume the shared namespace then mis-pair: reclassify_loops_from_results (db/analysis.rs) and pysimlin's get_relative_loop_score both look up $⁚ltm⁚loop_score⁚{id} by detected id, reading whichever scored loop happened to get that id.

The scalar-cycle instance of this divergence was fixed on branch ltm-core-batch for #737 (commits a14a6bee, 2f2dbbdc, whose messages characterize this remaining boundary honestly). This issue tracks the documented remaining class: cycles through arrayed variables.

Demonstrated fixture

growth[r1] = 0.01*pool[r1] + SUM(matrix[r1,*]*scale)
scale = 0.001*SUM(pool[*]) + 0.01
  • detected = {r1: feeder cycle, r2: pool/growth cycle}
  • scored = {r1: pool/growth A2A loop, u1, u2: per-slot feeder loops}
  • detected r1 joins the wrong cycle's series. (On the base commit before the branch's sort-key change, detected r1 happened to join the right series by accident; the branch lost that accidental alignment -- evidence the alignment was never principled.)

Aggravating notes

  1. Polarity labels also disagree for this class: the detected surface gets R because its bare-name spliced agg hops are patched by recover_agg_hop_polarities, while the scored surface stays U because its SUBSCRIPTED agg-hop endpoints are not patched. That endpoint gap is its own sibling issue (subscripted agg-hop endpoints missed by recover_agg_hop_polarities -- being filed in parallel; cross-link when it exists). The polarity disagreement compounds the id divergence because ids are assigned per polarity-class prefix.
  2. Silent cap with no observability: the new expand_loops_through_routed_aggs (src/simlin-engine/src/db/ltm/loops.rs, ~line 1710; MAX_DETECTED_AGG_VARIANTS_PER_LOOP = 64, ~line 1853) defensively caps per-loop variant expansion. When tripped (pathological: one edge routing through 65+ distinct reducers), the loop is silently left unexpanded with NO Warning -- unlike the scored surface's agg_recovery_truncated warning -- re-creating id divergence with zero observability.

Why it matters

Medium severity: wrong-series joins on the production FFI/pysimlin surface (get_relative_loop_score reading $⁚ltm⁚loop_score⁚{id}) and wrong runtime reclassification (reclassify_loops_from_results) for arrayed models with agg-traversing cycles -- a common shape (any model with a reducer in a feedback loop over an array). The result is not an error or a zero; it is a plausible-looking series belonging to a different loop.

Root cause

Latent since the #516-era split of detected vs scored loop enumeration: the two surfaces were allowed to enumerate different loop sets while continuing to share an id namespace that is positional, not content-derived. The durable cross-surface identity is the loop's content (e.g., its stock set), not its sequence-assigned id.

Components affected

  • src/simlin-engine/src/db/analysis.rs -- model_detected_loops, reclassify_loops_from_results
  • src/simlin-engine/src/db/ltm/loops.rs -- expand_loops_through_routed_aggs (variant cap, no warning)
  • src/pysimlin -- get_relative_loop_score ($⁚ltm⁚loop_score⁚{id} join)

Possible approaches (from review)

  • Per-element expansion parity on the detected surface (make detected enumerate the same per-element loops the scored surface does), or
  • A content-stable join key (e.g., the loop's stock set) instead of positional ids, or
  • Per-loop series names keyed on content rather than sequence-assigned ids.

Independently of the chosen direction: emit a Warning when MAX_DETECTED_AGG_VARIANTS_PER_LOOP trips, matching the scored surface's agg_recovery_truncated behavior.

Discovery context

Identified during adversarial review on branch ltm-core-batch (HEAD ~db9136e5), while fixing the scalar-cycle instance for #737.

Tracking

Part of LTM tracking epic #488. Related: #737 (the fixed scalar-cycle instance of this divergence), #516 (closed; the era when the detected/scored split was introduced), #685 (partition-metadata parity -- related cross-surface identity concern, but explicitly about result-scoped partition indices, NOT this id-join defect), #679 (exhaustive-mode loops never reach runtime reclassification at all), #273 (LTM array-support umbrella). Sibling (filed in parallel): subscripted agg-hop endpoints missed by recover_agg_hop_polarities.

Activity

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

    @bpowers
    OwnerAuthor

    The sibling subscripted-agg-endpoint polarity issue referenced above is now filed: #745 (recover_agg_hop_polarities never matches subscripted arrayed-agg endpoints). It is the polarity half of the cross-surface disagreement described in aggravating note 1 here.

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