Repository navigation
Description
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 r1andscored r1are different loops. - The joins that consume the shared namespace then mis-pair:
reclassify_loops_from_results(db/analysis.rs) and pysimlin'sget_relative_loop_scoreboth 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
r1joins the wrong cycle's series. (On the base commit before the branch's sort-key change, detectedr1happened to join the right series by accident; the branch lost that accidental alignment -- evidence the alignment was never principled.)
Aggravating notes
- Polarity labels also disagree for this class: the detected surface gets
Rbecause its bare-name spliced agg hops are patched byrecover_agg_hop_polarities, while the scored surface staysUbecause its SUBSCRIPTED agg-hop endpoints are not patched. That endpoint gap is its own sibling issue (subscripted agg-hop endpoints missed byrecover_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. - 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 NOWarning-- unlike the scored surface'sagg_recovery_truncatedwarning -- 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_resultssrc/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
bpowers commentedon Jun 10, 2026
The sibling subscripted-agg-endpoint polarity issue referenced above is now filed: #745 (
recover_agg_hop_polaritiesnever matches subscripted arrayed-agg endpoints). It is the polarity half of the cross-surface disagreement described in aggravating note 1 here.ltm: core-algorithm batch of root-caused fixes from epic #488 (#761)