Repository navigation
Description
Summary
A lead worth ~30 minutes that could shrink #995 substantially, possibly to nothing. Check this before starting that work.
The completeness guard added in #994 declines an edge when an unresolvable dimension-name index survives into a finished per-element partial. On C-LEARN it declines 226 edges, of which 135 carry an array-valued operand and are currently attributed to #995 (the array-operand contract).
But the surviving index on those 135 looks like something the LTM pin machinery should already have caught. Representative:
$⁚ltm⁚link_score⁚one_year→rs_ff_co2_ff_aggregated[developed_countries]
... vector_elm_map(PREVIOUS(target_is_active[cop, target·t1]), target_order) ...
target·t1 is pinned; cop is left as a bare dimension name. But target_is_active is declared over [cop, target] and the target equation iterates cop — that is the identity shape, which resolve_axis_index_name returns IteratedDim for and which the row derivation resolves with no mapping and no correspondence involved. It is exactly the shape #994 fixed for LOOKUP table holders.
Why it matters
If the pin should be firing there and is not, those 135 are a pin gap, not a compiler gap:
- fixing the pin would make them compile correctly rather than being declined;
- engine: an array-valued operand must be a view over storage, so PREVIOUS() of an array fails to compile (affects ordinary A2A models, not just LTM) #995's real target shrinks from 109 by however many of the 135 turn out to be reachable this way;
- and the guard would stop firing on them automatically, since it keys on the surviving index — the very thing a correct pin removes. (This is why shipping the guard forecloses nothing.)
What to check
- Does the pin candidate list for the emitter behind these edges include
target_is_active? If it does, why is thecopaxis not projected? - Is this the same missing-candidate shape engine: root-cause and fix the silent LTM fragment-compile failures #994 fixed for table holders (
referenced_tablesabsent from the dependency set), or a different omission? - How many of the 135 are the identity shape versus genuinely needing the mapped correspondence — the latter fall into ltm: mapped_element_correspondence cannot see the reference spelling, so it declines element maps it should honour #997's blocked territory.
Reproduce
cargo run --release -p simlin-engine --example ltm_fragment_failures (added in #994) buckets failures by compiler error and cross-tabulates against endpoint shape and construct. The 135 are the vector-op column of the declined set.
Untested — this is an observation from measuring the overlap between the guard and #995, not a diagnosis. It is recorded rather than acted on because it is a new thread, and because it was noticed after the piece that surfaced it was finished.
CORRECTION (investigated): real, but NOT a lever on #995
Measured. Two things in the text above are wrong; the item is still worth doing, on different grounds.
1. The "shrinks #995" claim is wrong. Of the 125 vector-builtin link scores that survive the guard, only 5 carry a bare dimension-name index; the other 120 are clean of one and are genuine #995-only defects (84 ELM MAP, 22 SORT ORDER, 14 SELECT). A pin fix removes at most 5. The reasoning error: the 135 are the shape described, but they were already removed from #995's territory when the completeness guard shipped, so they cannot be removed from it twice. Against a no-guard baseline the claim held; against main it does not. #995's target stays ~109, and this is not a prerequisite for it.
2. The representative example above is unrepresentative. vector_elm_map(PREVIOUS(target_is_active[cop, target·t1]), target_order) is not one of the 135 — it is one of only five surviving edges carrying an unpinned index. All 135 declined edges are VECTOR SELECT, with arg 1 of exactly two shapes:
PREVIOUS(aggregated_definition[*, aggregated_regions])
PREVIOUS(semi_agg_definition[*, semi_agg])
What is real, and why it is still worth doing
The pin should fire, and pinning is semantically correct here. Source shape:
RS FF CO2 FF Aggregated[Aggregated Regions] =
VECTOR SELECT(Aggregated Definition[COP!, Aggregated Regions], ..., VSSUM, VSERRATLEASTONE)
Target iterates Aggregated Regions, the dep is declared [COP, Aggregated Regions], the index spells that same dimension — pure identity, no mapping involved. 135 of 135 are identity; zero need the mapped correspondence, so #997's blocked territory is untouched.
The argument-vs-result trap does not apply. It only bites when pinning the axis the builtin reduces over. Here the reduced axis is spelled * explicitly and stays, so pinning the other axis leaves arg 1 an array over * — exactly what VECTOR SELECT wants. (For VECTOR ELM MAP a single pinned element is required, not merely tolerated: vm_vector_elm_map.rs documents result[i] = source[base_i + round(offset[i])] where the base is the flat position arg 1's element reference establishes, cited to Ventana's reference and to real-Vensim ground truth in test/sdeverywhere/models/vector/vector.dat. The genuine trap is VECTOR SORT ORDER, whose arg 1 is the row being ranked — and 0 of the 22 surviving sort-order edges carry a bare dimension index, so the trap shape does not arise in this corpus.)
Value: 135 currently-declined edges become correct scores. Standalone, no semantic hazard, no dependence on #997.
ROOT CAUSE FOUND (measured): the axis allocator is order-greedy
Not a pin bug. allocate_implicit_axes_partial (src/simlin-engine/src/compiler/dimensions.rs:45-101) resolves each dep dimension in declaration order, running its name / mapping / size passes per dimension. So an earlier dep axis can claim an active slot by MAPPING that a later dep axis matches by NAME — and a name match is strictly stronger.
Instrumented on C-LEARN, rs_ff_co2_ff_aggregated[developed_countries]:
pinnable = [("aggregated_definition", ["cop","aggregated_regions"]), ("rs_co2_ff", ["cop"])]
dep=aggregated_definition dep_dims=["cop","aggregated_regions"]
target_dims=["aggregated_regions"] target_elems=["developed_countries"]
elems=[None, None] axes=[] complete=false
- dep dim 0
cop: name pass misses; the mapping pass' reverse branch askshas_mapping_to(aggregated_regions, cop), andAggregated_Regionsdeclares a 7-entry element map ontocop— hit, claiming active slot 0. - dep dim 1
aggregated_regions: the slot it matches BY NAME is already taken →None.
Then dep_axis_elements finds axis 0 has target_pos = Some(0) but cop != aggregated_regions, asks mapped_element_correspondence, which declines explicit element maps → None. Both axes None, axes empty, dep_element_pins drops the entry, and the index is never pinned.
The function's own first pass documents this exact hazard and fixes it for the size fallback — "Try to find an exact name match anywhere in unused active dims. This prevents size-based fallback from grabbing the wrong dimension when the correct name match exists later in the list." The mapping pass was added afterwards and reintroduced the bug it was written to prevent, for mappings instead of sizes.
Fix direction: hoist name matching across ALL dep dims before any mapping or size matching, mirroring what the first pass already does for size.
This is a compiler function, and the LTM pin is only one caller
allocate_implicit_axes_partial has two callers: the LTM pin (ltm_augment_post_transform.rs:195) and allocate_implicit_axes (:149), whose sole caller is compiler/context.rs:274 — ordinary subscript lowering. The same greedy order therefore runs during real compilation.
In the LTM path a mis-assignment drops a pin. In the compiler path it would select a wrong slot — a silently wrong number in an ordinary simulation, with no diagnostic. This is NOT claimed to happen; context.rs may constrain arity or names so the shape cannot arise. It is unmeasured, and it is the first thing to establish, because it decides whether this is an LTM attribution bug or a live correctness bug in the simulator.
Sequence
- Determine whether the
context.rspath can reach the same mis-assignment, and if so whether it produces a wrong result rather than a wrong-but-coincidentally-right slot. - Fix the allocator (name-first across all dims). Same fix either way — but the test and the risk assessment differ completely.
- Re-measure the 135.
Do not start 2 before 1.
Test requirement — this is the part that will bite
If the diagnosis is right, a fixture using a lowercase single-word dimension name will pass vacuously, because such a name is already canonical and the comparison succeeds. That is exactly why this survived the existing test suite. Any fix must use a dimension whose declared name is NOT canonical — capitals or spaces — or it proves nothing.
Activity
[-]ltm: 135 declined edges may be a pin gap, not a compiler gap (check before starting #995)[/-][+]ltm: identity-shape dimension indexes are left unpinned, declining 135 correct-and-pinnable edges[/+][-]ltm: identity-shape dimension indexes are left unpinned, declining 135 correct-and-pinnable edges[/-][+]engine: allocate_implicit_axes_partial is order-greedy -- a mapping match on an earlier dep dim steals the slot a later dim matches by name[/+]bpowers commentedon Jul 30, 2026
Compiler-path exposure: measured, NOT demonstrated — and deliberately not escalated.
The open question was whether
compiler/context.rs:274(ordinary subscript lowering) can reach the same mis-assignment, since that would mean a wrong slot rather than a dropped pin. Measured by instrumentingallocate_implicit_axesand running the whole lib suite:["region"] ["region"] -> Some([0])through 3 axes), with exactly two exceptions:["dimb"] active=["suba"] -> Some([0])(single-axis mapping/subdimension) and["region"] active=["region","age"] -> Some([0])(name match, fewer dims than active).The bug requires two or more dep axes where an earlier one claims by mapping a slot a later one matches by name. No shape in the corpus has it — the only mapping-driven allocation is single-axis, where no ordering hazard exists.
What this supports: the defect is demonstrated in the LTM path and not demonstrated in the compiler path; on the tested corpus the required shape does not occur.
What it does not support: that it cannot occur. Three deliberately-contrived fixtures failed to reach the function at all — including a trivial
echo[Region] = simple * 2control — so bare arrayed references in those shapes take some other lowering path. Failing to construct the shape bounds the author's grasp of that path as much as the path itself.So this is not being escalated to a correctness issue. A high-severity filing would rest on structural reasoning the measurement does not support, which is the same error as an earlier estimate in this thread that had to be retracted.
If someone wants the compiler question settled rather than bounded, that is its own piece, and the way in is finding what actually reaches
get_implicit_subscripts— the 43 shapes above are the map, and one of the tests producing them is the entry point. Best handed to someone who knows the array-lowering paths.Tooling note for anyone reproducing this:
cargo testcaptures stderr without--nocapture, and an initial run reported 0 calls, nearly supporting the conclusion that the function was dead. It is 824.engine: pin executed mapped-reference semantics, close out the GH #996 …
engine: close the LTM mapped-dimension and array-operand gaps (#995, #…