Repository navigation
Description
Summary
Document Simlin's flow-to-stock numerator timing convention in the user-facing reference doc (docs/reference/ltm--loops-that-matter.md). The convention is currently described only in the design doc, leaving users no way to reconcile Simlin LTM output with reference SD software (Stella, iThink) without spelunking source code.
Problem
Simlin's flow-to-stock link score numerator uses PREVIOUS(flow) - PREVIOUS(PREVIOUS(flow)) rather than flow - PREVIOUS(flow). The rationale: in Euler integration, the flow value at t-1 is what drove the stock change from t-1 to t, so PREVIOUS(flow) aligns the numerator's causal interval with the denominator's second-order Δstock.
This is a defensible interpretation of the corrected 2023 formula (Schoenberg, Hayward, Eberlein 2023, Eq. 3), but it produces results that are shifted by one DT relative to reference SD software. The integration test (src/simlin-engine/tests/simulate_ltm.rs) compensates by shifting reference timestamps forward by DT when loading golden data.
Current documentation state
| Doc | Status |
|---|---|
docs/design/ltm--loops-that-matter.md (divergence #6, lines 740-746) |
Documented |
docs/reference/ltm--loops-that-matter.md Section 3.2 (Flow-to-Stock Link Score) |
Missing |
A user comparing Simlin LTM output against Stella output would see numerically identical values shifted by one timestep and have no way to know whether (a) Simlin is buggy, (b) Stella is buggy, or (c) the difference is intentional and what the rationale is.
Why it matters
- User trust / cross-tool comparison: Without documentation, users will reasonably suspect a bug. The choice is mathematically defensible but interpretive; both renderings produce identical continuous-time limits.
- Discoverability: Implementation detail buried in
ltm_augment.rsand design-doc divergence note isn't reachable from the user reference doc. - Reproducibility: Anyone trying to reproduce a Stella LTM analysis in Simlin (or vice versa) needs to know about the DT-shift compensation up front.
Proposal
- Add a subsection to
docs/reference/ltm--loops-that-matter.mdSection 3.2 (Flow-to-Stock Link Score) explaining:- The two valid timing conventions for the numerator:
flow - PREVIOUS(flow)-- current rate's change (Stella convention)PREVIOUS(flow) - PREVIOUS(PREVIOUS(flow))-- causal-interval-aligned (Simlin convention)
- The rationale: in Euler, the flow at t-1 drove the stock change measured at t, so the Simlin convention aligns numerator and denominator on the same causal interval.
- The user-visible consequence: Simlin LTM output is shifted by one DT relative to Stella for the same model and inputs. Both are mathematically valid; the choice is interpretive.
- The workaround for cross-tool comparison: shift one set of timestamps by ±DT.
- The two valid timing conventions for the numerator:
- Cross-reference from
docs/design/ltm--loops-that-matter.mddivergence enlarge clouds #6 to the new reference-doc section.
Optional follow-up (out of scope here, worth tracking separately if pursued)
Consider adding a feature flag for the alternate convention (flow - PREVIOUS(flow)) to make Stella comparison easier without manual timestamp shifting.
Paper context
The 2023 paper presents Eq. 3 in continuous-time form (Eq. 6: LS(i→S) = |di/dt / d²S/dt²|), which is timing-convention-agnostic. The discrete-time approximation has two valid renderings; both produce identical continuous-time limits. The Simlin convention is a defensible choice but should be documented as such, not silently divergent.
File references
- Implementation:
src/simlin-engine/src/ltm_augment.rs--generate_flow_to_stock_equation(~lines 1782-1839; numerator/denominator at ~1824-1828) - Design doc divergence note:
docs/design/ltm--loops-that-matter.md(divergence enlarge clouds #6, "Flow-to-stock numerator timing") - Reference doc target section:
docs/reference/ltm--loops-that-matter.mdSection 3.2 - Integration test compensation:
src/simlin-engine/tests/simulate_ltm.rs(search for "shift" or "DT")
Tracking
Part of LTM epic #488.
How discovered
Identified during a documentation review of LTM divergence notes -- the design doc lists this as divergence #6 with a clear rationale, but the user-facing reference doc gives no hint that Simlin's discrete formula renders differently than Stella's.
Activity
doc: document flow-to-stock 1-DT-shift convention
doc: tighten eq. 6 citation and fix stale ltm test paths