Repository navigation
Description
Summary
The LTM partition map keys on element-level stock names (e.g., population[nyc]) because it is built from model_element_cycle_partitions. For pure-dimension A2A loops, however, build_element_level_loops calls var_graph.find_stocks_in_loop(&var_level_nodes) and stores variable-level stock names (e.g., population) in Loop::stocks. partition_for_loop then does find_map(|s| stock_partition.get(s)) and the lookup misses, so every A2A loop returns partition = None.
The behaviour is now formalised in ltm.rs:114-118 as a deliberate design invariant and tests/layout.rs:779-798 documents it, but the underlying normalisation gap remains: compute_rel_loop_scores* normalises against partition denominators, so multiple independent A2A loops all land in the same fictitious "no parent" bucket and their relative scores cross-normalise against unrelated partitions.
Why this matters
- Models with multiple disconnected A2A feedback subsystems get incorrect rel-scores (cross-normalised together instead of partition-local).
- Mixed (A2A + scalar) partitions never arise in practice because the engine always assigns A2A loops to
None. A latent bug in the layout aggregation for mixed-stride partitions exists but can only be triggered through hand-crafted helper inputs (see codex review on PR ltm: per-element relative loop scores via subscripted IDs #472).
Locations
src/simlin-engine/src/ltm.rs::CyclePartitions::partition_for_loop-- the lookup that misses for A2A loopssrc/simlin-engine/src/db_ltm.rs:2098-2099--build_element_level_loopspopulates variable-level names for A2A loopssrc/simlin-engine/src/db_ltm.rs:2171-2202-- cross-element branch correctly uses element-level namessrc/simlin-engine/src/ltm_post.rs:73-131, 178-179--compute_rel_loop_scoresandcompute_rel_loop_scores_per_elementuse the broken partition keyssrc/simlin-engine/tests/layout.rs:779-798, 801--test_compute_metadata_importance_series_length_matches_step_countdocuments the quirk
Suggested fix
Two options trade off:
- (a) element-level stocks for A2A loops: change
Loop::stocksfor A2A loops to carry one element-level name per element of the A2A dim (all in the same SCC by construction). Local fix, but changes theLoopstruct's semantic; downstream consumers (enumerate_module_pathwaysand others) may need updates. - (b) expansion in
partition_for_loop: keepLoop::stocksas variable-level names but extendpartition_for_loopto expand each variable-level stock to its element-level instances and look those up. Type-stable, but adds lookup complexity.
Either fix needs to confirm that enumerate_module_pathways and other Loop::stocks consumers still get the names they expect.
Severity
medium (silent correctness for multi-A2A-loop models)
References
docs/tech-debt.mditem unit checking #35- Codex review of PR ltm: per-element relative loop scores via subscripted IDs #472 (originally surfaced this)
Activity
doc: link LTM tech-debt and engine CLAUDE.md to GitHub tracking epic
doc: add LTM arrays hardening design plan
bpowers commentedon May 13, 2026
Resolved by 11eb1af, 40bf7d5, f26330f, c3318a2 — Phase 2 of the LTM arrays hardening plan (docs/design-plans/2026-05-11-ltm-arrays-hardening.md). A2A
Loop::stocksnow carries element-level stock names;loop_partitionsis keyed per slot (HashMap<String, Vec<Option<usize>>>); relative loop scores normalise per-(partition, slot), so an independent A2A loop no longer cross-pollutes a sibling.engine: preserve loop emission order for rel_loop_score denominator