Repository navigation
Description
Problem
A stockless cycle whose only "state" is a PREVIOUS() lag is scored by the LTM enumerator but rejected by pin validation, and the pin rejection's stated rationale is false for this case.
Fixture:
a = PREVIOUS(b, 0)
b = a * k
No stock anywhere. Three facts about this model:
- The LTM causal graph carries the cycle.
dt_depscome fromclassification.all, which INCLUDES lagged refs (src/simlin-engine/src/variable.rs~930-932;src/simlin-engine/src/db/query.rs~336-340). Soa -> b -> ais a cycle in the LTM graph. - The model compiles. The dependency-graph ordering gate prunes PREVIOUS edges, so there is no compile-time circular-dependency error.
- The loop enumerator scores it. There is no stock filter anywhere on the enumeration path, so discovery/exhaustive emit a scored loop for this cycle.
But model_pinned_loops' stock validation (src/simlin-engine/src/db/ltm/pinned.rs ~line 163; post-#673 shape: enriched find_stocks_in_loop + enrich_with_module_stocks both empty => reject) rejects a pin over {a, b} with "contains no stock". The validation's comment claims a purely-instantaneous cycle "would be a compile-time circular dependency" -- false for the PREVIOUS-lagged case, which is exactly the cycle shape that passes the compiler while containing no stock. (The comment falsity itself is being fixed in a doc commit on ltm-core-batch; this issue tracks the behavioral cross-surface disagreement.)
So the cycle is enumerable-but-unpinnable -- the same defect class #673 fixed for module-internal stocks, on a different leg: there the stock existed but the validator could not see it; here the two surfaces genuinely disagree about whether a PREVIOUS-lagged cycle is a feedback loop at all.
Open design question
PREVIOUS(x) is discrete state -- a one-DT memory -- so arguably it IS a feedback loop under the LTM reference's definition (sec. 2.1) and the pin should accept it, matching the enumerator. Alternatively the enumerator is over-permissive and both surfaces should reject stockless lagged cycles. Either resolution is defensible; the requirement is that the two surfaces agree and the validation comment be truthful about why.
Why it matters
- Consistency: a loop the discovery/exhaustive paths report and score cannot be pinned-and-tracked, with a rejection message whose rationale does not apply.
- Severity low: uncommon model shape; silent inconsistency, no wrong simulation numbers.
Components affected
src/simlin-engine/src/db/ltm/pinned.rs(model_pinned_loopsstock validation, ~line 163)src/simlin-engine/src/db/query.rs(~336-340,dt_depsincluding lagged refs) andsrc/simlin-engine/src/variable.rs(~930-932) -- where the enumerator side's inclusion is decided- the loop enumeration path (
src/simlin-engine/src/db/ltm/loops.rs) if the resolution is to filter there instead
Possible approaches
- Accept stockless PREVIOUS-lagged cycles in pin validation (treat PREVIOUS as state), keeping the surfaces consistent with the enumerator. Likely the smaller change: relax the empty-stock rejection when the cycle contains a lagged edge.
- Filter stockless cycles out of enumeration too, so both surfaces reject. Requires distinguishing lagged-only cycles on the enumeration path and is a behavior change for discovery output.
Cross-references
- ltm: pin whose only stock is module-internal is wrongly rejected as 'contains no stock' #673 -- the module-internal-stock instance of the same enumerable-but-unpinnable class (fixed on
ltm-core-batch, commita98d7106) - ltm: loops through SMOOTH, DELAY or TREND calls cannot be pinned #747 -- the builtin-call (synthetic module node) unpinnable instance
- Part of epic epic: Loops that Matter (LTM) -- open work #488 (Core algorithm group)
How discovered
Identified during adversarial review of the #673 fix on branch ltm-core-batch (commit a98d7106), 2026-06-09.
Activity