Repository navigation
ltm: batch of root-caused fixes from epic #488 - #740
Merged
Merged
Conversation
LoopPolarity::from_runtime_scores nested a positive-vs-negative magnitude test inside the confidence-threshold gate, so the inner else served two roles: the strictly-dominant balancing case and the exact-tie case. The tie case is unreachable for any threshold > 0 (an exact magnitude tie makes the confidence ratio 0, which fails the threshold check), but the shared syntactic form read as if balancing silently won ties -- a rule the LTM literature does not justify. Restructure the (true, true) arm into explicit confidence-below-threshold / reinforcing-dominant / balancing-dominant / tie-fallback cases. The tie fallback returns Undetermined and carries a compile-time const-block assertion documenting why it is unreachable with the production threshold; because the threshold is a const the assertion is const-evaluable, so setting it to 0 fails the build instead of silently classifying a tie as Balancing. No observable behavior change with the current 0.99 threshold. Adds a unit test pinning the strictly-dominant balancing case. Addresses GH #506.
multiply_score_series and max_abs_score_series compose two per-timestep link-score series with let n = a.len().min(b.len()), silently truncating to the shorter operand. Today both operands always span step_count so the mismatch path is unreachable, but the silent min means a future change that produced mismatched lengths would corrupt downstream timestep alignment quietly rather than crashing -- the kind of latent bug LTM correctness work has repeatedly had to hunt down after the fact. Add a debug_assert_eq! naming each helper so a length mismatch fails loudly in debug and test builds, while release keeps the defensive min so production degrades to a short composite instead of panicking. A brief comment records the both-operands-span-step_count invariant and why release retains the min. Addresses GH #678.
find_model_output_ports already sorts its output-port set before returning (landed in PR #684), replacing an unordered HashSet drain whose process- random iteration order leaked into pathway enumeration, magnitude-tie winner selection, and the $⁚ltm⁚path⁚{port}⁚{idx} synthetic-var indices -- making salsa cache values byte-unstable across processes for multi-output modules with tied pathway scores. That fix shipped without the regression test the issue called for. Add a test that pins the sorted contract through the sub_model_output_ports wrapper (which delegates straight to find_model_output_ports for a non- stdlib model): a main model reads three internal ports of a multi-output sub-model in reverse-alphabetical order, and the returned set must be canonical-name-sorted regardless of read, declaration, or hash order. The function is pub(super) within the ltm module, so the test exercises it via the crate-visible wrapper rather than constructing a tied-pathway-score fixture (which would be disproportionate for pinning the sort itself). Addresses GH #680.
analyze_graphical_function_polarity classified a lookup table's monotonicity by comparing the raw y-delta dy = y[i] - y[i-1] against a y-range-relative epsilon (#492). For non-uniform x-spacing that is wrong: a small dy over a small dx is a large slope (a real, fast change) yet reads as a plateau, and a small dy over a wide dx is a negligible slope yet reads as a real change -- so the Positive/Negative/Unknown verdict can silently flip, propagating a wrong static link polarity into loop classification. Compare each segment's slope dy/dx against a slope-appropriate tolerance that scales with the table's average-magnitude slope (y_max-y_min)/ (x_max-x_min) and a small absolute floor, mirroring #492's noise tolerance on the slope axis. On uniformly-spaced tables every dx equals the average x-spacing, so this reduces to exactly the old behavior and the existing uniform-spacing tests stay green. A degenerate vertical segment (x[i] == x[i-1]) is skipped when it is a redundant duplicate point and bails to Unknown when it is a genuine two-outputs-for-one-input step, since the slope is then undefined and the polarity genuinely undeterminable. parse_table always fills an absent x column with a uniform ramp, so x and y are equal length; the loop iterates the common length defensively regardless. Adds a non-uniform-x test where the y-delta and slope heuristics disagree (a steep narrow local dip the y-delta epsilon smooths over but the slope catches), plus degenerate-x coverage. Updates the #492 comment and the tech-debt note that scoped this out. Addresses GH #536.
The prior 3-port fixture had a ~1/6 chance of passing vacuously when the production sort were reverted, since a 3-element HashSet drains in sorted order with non-trivial frequency. Raising to 6 ports reduces the false-green probability to 1/720. Ports are declared in the sub-model in (a, c, e, b, d, f) order and read by main in (f, d, b, e, c, a) order. Neither matches the expected canonical sort, so the sort must actively reorder them rather than accidentally inherit declaration or read order.
The original #536 commit set slope_epsilon = 1e-6 * (y_max - y_min) / x_span, equal to 1e-6 times the average slope magnitude. For a uniformly-spaced n-point table the effective per-segment dy threshold becomes slope_epsilon * dx = 1e-6 * (y_max - y_min) / (n - 1), which is (n - 1) times tighter than the #492 threshold 1e-6 * (y_max - y_min). A 50-point monotone table with a single -5e-8 import-noise dip (safely within the old #492 tolerance) was classified Unknown instead of Positive, re-introducing the false-Unknown bug #492 fixed. Fix: set slope_epsilon = 1e-6 * (y_max - y_min) / avg_dx where avg_dx = x_span / (n - 1) is the average x-spacing over the iterated segment count. The per-segment dy threshold is then slope_epsilon * dx = 1e-6 * (y_max - y_min) * dx / avg_dx. On uniformly-spaced tables dx == avg_dx so the threshold reduces EXACTLY to 1e-6 * (y_max - y_min) -- the same value #492 used. For non-uniform tables the threshold still scales proportionally with segment width, so the narrow-steep-segment case (#536 motivation) is preserved: a segment whose dx is much smaller than avg_dx still sees a proportionally tighter dy threshold. The degenerate cases (x_span == 0 or n < 2) fall back to the absolute 1e-12 floor as before. Add a 50-point regression test (test_graphical_function_polarity_ uniform_50pt_import_noise) that was RED against the original #536 formula and is GREEN with the fix. All four existing non-uniform tests (narrow_dip / narrow_bump / vertical_segment / duplicate_point) remain green: narrow_dip's -10 slope still exceeds the ~3e-7 slope_epsilon for that fixture's avg_dx. Also tighten the const-assert comment in types.rs: the assert pins the threshold > 0 invariant that makes the tie arm unreachable, not merely prevents "silently classifying a tie as Balancing" (the tie arm now returns Undetermined anyway). Add a comment in polarity.rs that ascending x is the VM binary-search lookup precondition so dx > 0 on any runtime-valid table and slope sign equals dy sign. Updates CLAUDE.md polarity note and docs/tech-debt.md item #21 to accurately state that uniform-spacing behavior NOW reduces exactly to the old threshold (the original note was aspirational, not yet true).
The loop-score equation-bytes / RSS instrumentation in
generate_loop_score_variables was activated by a runtime
std::env::var("LTM_BENCH_TRACE") check on every compile, and the whole
apparatus -- read_rss_mib (which reads /proc/self/status), should_trace,
the byte-counter arithmetic, equation_text_len, and the eprintln!
branches -- compiled into every production build even though it is
strictly a benchmarking aid. Production WASM builds carried the
/proc/self/status read path, and an env-var feature gate invites
accidental activation in deployed environments.
The tracing now lives in a loop_score_trace module gated entirely behind
a dedicated ltm_bench cargo feature: the default build's LoopScoreTrace
is a zero-sized no-op whose start/record/done methods are empty and
inline away, so the env lookup, the /proc read, and the eprintln! dead
code are #[cfg]-ed out of compilation rather than merely dead-code
eliminated. A default-features rlib no longer contains the
LTM_BENCH_TRACE or ltm-trace strings at all. The ltm_full_bench example
and the cap-lift diagnosis doc note that reproducing the trace now needs
--features ltm_bench instead of the env var.
Addresses GH #464.
substitute_reducers_in_equation replaces a recognized inline reducer
subexpression with its $⁚ltm⁚agg⁚{n} aggregate-node name to build the
agg→target partial. If the parse of its input failed before
substitution, it returned the input unchanged, so the inline reducer
silently survived into the partial -- a partial that references the live
reducer instead of the hoisted aggregate node, a wrong-but-clean-
compiling link score. This is the agg-substitution-omission sibling of
the GH #311 PREVIOUS-omission hazard.
The function now returns Result<String, PartialEquationError> like the
sibling partial-equation builders, and the sole db-bearing caller
(emit_agg_to_target_link_scores) converts the error into a Warning via
the existing emit_ltm_partial_equation_warning path and skips the
variable, rather than emitting a misleading score. The three target-shape
arms each handle it: the scalar and ApplyToAll arms warn once and return
(an ApplyToAll body is shared across every element, so one edge-level
warning is correct), and the Arrayed arm threads the substitution error
through the same Result the per-element equation builder returns so the
existing per-element match converts it. The empty-reducers early return
stays a pure pass-through that never parses, so it keeps returning Ok.
The failure is effectively unreachable in production -- the input is a
print_eqn re-print of an already-parsed AST -- so this is defense-in-depth
mirroring the GH #311 treatment. Addresses GH #661.
analyze_model's pipeline did compile_project_incremental(..).ok()?, so any compile failure -- most notably the GH #486 LTM+non-Euler hard-fail -- was silently collapsed into an empty ModelAnalysis indistinguishable from a model that genuinely has no loops. A caller asking "what loops does this RK4 model have?" got an empty result and no hint that the real fix is switching to Euler or disabling LTM. run_ltm_pipeline now returns Result<Option<PipelineResult>, String>: Err carries the actionable compile-error message, Ok(None) is a non-compile structural degradation (model absent from the causal graph, post-simulation discovery bail), and Ok(Some) is success. analyze_model threads the Err into a new ModelAnalysis::analysis_error field (None on a healthy or gracefully-degraded model). The MCP read_model/edit_model surfaces re-expose it as the camelCase analysisError field (elided when absent), so an agent sees the Euler guidance instead of silence. The misleading "Returns gracefully on simulation failure" rustdoc is updated to describe the new contract.
read_model and edit_model collected their diagnostics on a freshly-synced db with ltm_enabled=false, so the LTM-only advisories (the auto-flip-to-discovery warning, the synthetic-fragment compile-failure warnings) never reached MCP callers -- even though both tools always run LTM loop analysis via analyze_model. This bypassed the GH #466 latch fix entirely, which only covered the libsimlin FFI path. Both tools always run LTM, so there is no per-call gate to thread: the diagnostic-collection passes now transiently enable ltm_enabled for the harvest and surface the resulting Warning-severity diagnostics in a new model-scoped `warnings` field on the output (previously the surfaces only ever carried Error-severity diagnostics, so warnings were dropped outright). edit_model enables LTM on both its pre- and post-edit passes so the new-error gate compares like-with-like. The transient enable reuses LtmEnabledGuard, moved out of libsimlin into simlin_engine::db so both the libsimlin FFI (GH #466) and mcp-core (GH #662) share one RAII guard that restores ltm_enabled unconditionally on drop -- even on an early return or panic -- rather than each consumer re-implementing the toggle. libsimlin keeps a pub(crate) re-export so its existing crate::analysis::LtmEnabledGuard call sites resolve unchanged.
`model_element_causal_edges` took a both-scalar fast path that emitted a
direct `from -> to` element edge and skipped the classified-site IR
entirely. For a scalar feeder of a hoisted reducer whose target is also
scalar (`total = base + SUM(pop[*] * scale)`, with `total`/`scale`
scalar), the `(scale, total)` site is classified `ThroughAgg`, but the
fast path emitted a direct `scale -> total` edge instead of routing
`scale -> $⁚ltm⁚agg⁚{n}`. The `pop[d] -> agg` and `agg -> total` hops
always existed (those edges are not both-scalar), so only the
scalar-feeder->agg hop was silently lost, making a feedback loop that
routes through that hop invisible at the element-graph level (GH #533).
The fix guards the fast path on the absence of any `ThroughAgg` site for
the pair: when one is present we fall through to the normal per-site
dispatch, whose `emit_agg_routed_edges` empty-`from_dims` arm already
emits the agg hop correctly. A mixed pair (`total = scale + SUM(pop[*] *
scale)`, one `Direct` and one `ThroughAgg` site) now gets both the direct
`scale -> total` edge and the agg hop, matching the non-fast-path
dispatch. The common reducer-free scalar->scalar case keeps the fast
path. The reference-site IR is already built unconditionally before the
per-edge loop, so consulting it for a scalar->scalar edge is one extra
HashMap lookup on an already-computed map, not a new salsa query.
The GH #486 guard rejected an RK2/RK4 + LTM compile whenever any instantiated model had a stock. But the Euler-only flow-to-stock link-score formula is only meaningless to RK2/RK4 when LTM actually emits a flow-to-stock score; a loop-free model (an open-loop accumulation whose constant inflow never reads the stock back) emits none in exhaustive mode, so rejecting it is a false positive (GH #663). The refined precondition gates on the EXACT thing #486 protects against: "an instantiated model emits at least one flow-to-stock link score". A new pub(super) helper model_emits_flow_to_stock_score reads the already-salsa-cached model_ltm_variables var set and asks whether any link-score var's target endpoint is a stock -- which, since the only causal edge into a stock is flow -> stock, is exactly a flow-to-stock score. It is a cache hit on the assembly path plus a linear scan. Reading the emitted var set rather than a loop-presence proxy is what keeps the refinement sound across modes. In exhaustive mode LTM scores only the edges of detected loops, so an open-loop stock is silent. But in discovery mode (user-forced or auto-flipped) and in any model with input ports, model_ltm_variables scores ALL causal edges and so emits a flow-to-stock score for an open-loop stock's flow -> stock edge even though no loop contains it -- a 'has any loop' proxy would under-reject those and let RK4 produce silently-wrong scores. The check iterates the same instantiated set the old guard did, so a flow-to-stock score produced entirely inside a submodel instance is still caught. Tests cover: root open-loop stock under RK4/RK2 now compiles (Euler control unchanged); the same open-loop stock under forced discovery is still rejected (all-edge scoring); an input-port submodel whose stock is in no loop is still rejected (all-edge scoring); a looped submodel under a stock-free RK4 main stays rejected; existing #486 probes stay green.
PR #461 moved rel_loop_score normalization to post-simulation in ltm_post.rs, where the helpers re-sorted loop ids lexicographically (b1, b10, b2, ...) to pin determinism over the prior HashMap's hash-randomized iteration. That order is bit-level different from the removed compile-time emitter, which accumulated the partition-sum denominator in the loops' emission order; because IEEE-754 addition is non-associative the lex sort perturbs every dense-partition denominator at the ULP, so any consumer diffing timeseries across engine versions sees spurious diffs. Switch LtmVariablesResult.loop_partitions from HashMap to IndexMap (the issue's preferred approach) so its iteration order is the loops' emission order, and have the post-sim consumers walk map order instead of sorting. indexmap (already in the tree via salsa, which also supplies its salsa::Update impl) is added as a direct simlin-engine dependency and re-exported as engine::indexmap so libsimlin and the integration tests thread the IndexMap through without their own dependency. Emission order is the content-derived order assign_loop_ids produces (it sorts on the canonical edge-sequence rotation, not on HashMap enumeration -- ltm::graph::loop_id_sort_key), so it is deterministic across salsa cache invalidations and across processes; IndexMap's order-insensitive PartialEq (used for salsa cache equality) therefore never causes spurious invalidation while the iteration order stays fixed. A sibling change (#487) had already made loop_partitions per-slot (Vec<Option<usize>>); only the map container changes here. reclassify_loops_from_results and the FFI debug-assert only do per-id lookups, so they are order-agnostic; the libsimlin streaming-denominator path (ensure_denom_for_element) iterated the map directly, so it now sums in emission order too, matching the engine's full-sweep helper. GH #468.
The flow-to-stock link score numerator uses the causal-interval-aligned rendering `i(t-dt) - i(t-2dt)` (`PREVIOUS(flow) - PREVIOUS(PREVIOUS(flow))`) rather than Stella's `i(t) - i(t-dt)`. Both are mathematically valid and have identical continuous-time limits, but they differ by a one-DT phase shift in discrete output. Until now this was explained only in the design doc's divergence #6, so a user comparing Simlin LTM output against Stella had no way to know the shift was intentional rather than a bug. Add a Simlin implementation note to the user-facing reference doc's Section 3.2 covering the two renderings, the causal-interval rationale, the user-visible one-DT shift, and the cross-tool timestamp-shift workaround. Cross-reference it from design-doc divergence #6 and back. Note the convention is documented per-link to avoid conflating it with the distinct intra-loop window consistency issue. GH #505
A batch of small, pre-vetted cleanups and two regression tests from adversarial reviews of the preceding LTM commits on this branch: - ltm/types.rs: correct the zero-threshold parenthetical on the loop-polarity tie arm. A zero threshold does not route near-ties to Undetermined here; strict near-ties still dominate to MostlyReinforcing/MostlyBalancing, and only EXACT ties reach this arm. What changes is the FIRST arm (confidence < 0 is never true), so low-confidence mixed cases would stop returning Undetermined. - analysis.rs: broaden the analysis_error field and analyze_model rustdoc from "could not be compiled" to "could not be compiled or simulated" (Vm::new / run_to_end failures land in analysis_error too), and format those failures the same way as the compile path (prefer e.details, fall back to the code's Display) instead of e.to_string(). - db/ltm/mod.rs: fix the model_emits_flow_to_stock_score docstring. The guard runs BEFORE assemble_module on the rejection path, so it computes the query rather than hitting a salsa cache; reword to "the same bounded query the Euler assembly path runs unconditionally, paid at most once per stock-bearing model, with later assembly getting the cache hit". - ltm_unified_tests.rs: add an arrayed #663 regression test pinning that a decorated flow-to-stock `to` endpoint (a scalar flow broadcasting into an arrayed stock under RK4 + forced discovery emits per-element `…→tank[a]`/`[b]`/`[c]` scores) is still recognised and rejected -- exercises strip_subscript on the `to` side, which no existing test covered. Also note in loop_partitions_iterate_in_emission_order that its model_detected_loops oracle shares assign_loop_ids with the code under test (the dedicated assign_loop_ids_is_order_independent tests cover that path). - ltm_post.rs: add a consumer-side emission-order regression test for compute_rel_loop_scores: 12 same-prefix loops in one partition with scores (eleven 1.0s + one 1e16) chosen so the emission-order abs-sum denominator differs bit-for-bit from a lex-order one, asserting the output matches the emission-order accumulation and that the two orders genuinely differ. - CLAUDE.md / design-plan doc: split the over-long ltm_post.rs bullet for readability, and update the cap-lift bench run command (drop the dead LTM_BENCH_TRACE env var, add --features ltm_bench). GH #663 GH #468
The read_model and edit_model E2E suites each carried their own copy of the ~40-line chain_scc_project_json fixture (the 51-node single-SCC model that trips the LTM auto-flip-to-discovery gate). The two copies had drifted: edit_model's simSpecs included saveStep/timeUnits and read_model's did not. Hoist one canonical copy into test_support.rs (the shared integration helper module for this crate's single-harness convention) and import it from both suites. Keep the fuller simSpecs (saveStep/timeUnits) as the canonical shape; both suites only assert on the auto-flip warning, so the extra fields are inert.
Round-2 review nits on the GH #505 documentation: the reference-doc note's '(Eq. 6)' read as if the reference doc numbered its own equations -- it is the external Schoenberg/Hayward/Eberlein 2023 citation, now stated explicitly with the full continuous ratio. The design doc also carried two remaining references to the pre- consolidation tests/simulate_ltm.rs path; both now point at tests/integration/simulate_ltm.rs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
==========================================
+ Coverage 90.61% 90.65% +0.04%
==========================================
Files 224 224
Lines 136278 136448 +170
==========================================
+ Hits 123484 123698 +214
+ Misses 12794 12750 -44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code ReviewI reviewed the PR end-to-end. The batch is well-structured: each issue has a clear root cause, a minimal fix, and tests (including soundness-corner probes for #663 / #468 / #533 / #536). I did not find any blocking correctness issues. A few observations I considered but rejected as findings:
Overall verdict: correct. 🤖 Generated with Claude Code |
This was referenced Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch of root-caused fixes for 12 open issues from the LTM tracking epic #488, selected for being clear and unambiguous enough to fully own. Each issue (or cluster of related issues) was implemented by a dedicated agent, then adversarially reviewed by a separate agent, iterating until no material findings remained; all findings and their resolutions are reflected in the commits.
Fixes #506
Fixes #678
Fixes #680
Fixes #536
Fixes #464
Fixes #661
Fixes #660
Fixes #662
Fixes #533
Fixes #663
Fixes #468
Fixes #505
What changed, by issue
#506 — unreachable MostlyBalancing tie-break. Restructured
LoopPolarity::from_runtime_scoresinto explicit dominant-reinforcing / dominant-balancing / tie cases (the issue's Option 1); the tie arm returnsUndetermined. Decision: used aconst { assert!(POLARITY_CONFIDENCE_THRESHOLD > 0.0) }instead of the suggesteddebug_assert!— clippy rejects assertions on constants, and the const block is strictly stronger (zeroing the threshold now fails the build instead of silently changing tie semantics). No behavior change at the production threshold.#678 — silent series truncation.
multiply_score_series/max_abs_score_seriesnowdebug_assert_eq!operand lengths; release keeps the defensivemin. Decision: no debug-onlyshould_panictest (debug/release-fragile); the invariant is documented inline.#680 — nondeterministic multi-output-port ordering. The production sort had already landed in PR #684; this branch contributes the missing regression test. Review iteration: the initial 3-port fixture had a ~1/6 false-green rate (a 3-element
HashSetdrains sorted by luck); strengthened to 6 ports — the reviewer's revert experiment then caught the removed sort 40/40 runs. Downstream determinism (DFS neighbor order, BTreeSet-backed port query) was verified end-to-end.#536 — GF monotonicity used y-delta, not slope.
analyze_graphical_function_polaritynow compares per-segment slopedy/dxagainst a tolerance scaled by the table's average-magnitude slope. Decisions: duplicate points (dx==0, dy==0) are skipped as non-determining; genuine vertical steps (dx==0, dy!=0) bail toUnknown. Review iteration: the first tolerance (/x_span) was effectively(n-1)xtighter on uniformly-spaced tables, silently re-regressing the #492 import-noise fix for finely-sampled tables — rescaled by average segment width (/avg_dx) so uniform tables reproduce the pre-existing #492 threshold bit-exactly (verified), pinned by a 50-point regression test.#464 — LTM_BENCH_TRACE build hygiene. The tracing apparatus (RSS reads, byte counters, eprintlns) moved behind a dedicated
ltm_benchcargo feature with a zero-sized no-op shim for default builds; the runtime env check is gone (the feature flag is now the gate). Decision: a feature rather thancfg(test)— the tracing serves theltm_full_benchexample, not tests. Verified 0 occurrences of the tracing strings/symbols in a default-features rlib; clippy clean in both configurations; no dependent crate enables it.#661 — silent reducer-substitution fallback.
substitute_reducers_in_equationreturnsResult<_, PartialEquationError>; the sole production caller converts failures to a Warning via the establishedemit_ltm_partial_equation_warningpath and skips the variable (mirroring the #311 loud-failure treatment) across all three target-shape arms. Defense-in-depth: the path is unreachable today (input is a re-print of a parsed AST).#660 — analyze_model swallowed compile errors.
run_ltm_pipelinenow distinguishes "compiled, genuinely no loops" (Ok(None)) from "could not compile/simulate for LTM" (Err), surfaced as a newModelAnalysis.analysis_error: Option<String>and exposed by the MCP read_model/edit_model tools asanalysisError. The #486 RK4+LTM Euler guidance now reaches MCP callers instead of an inexplicable empty loop list.#662 — MCP diagnostics ran with ltm_enabled=false.
LtmEnabledGuardmoved from libsimlin intosimlin_engine::db(libsimlin re-exports it; #466 path unchanged) and mcp-core's read_model/edit_model collect diagnostics with LTM transiently enabled. Decisions: both tools unconditionally runanalyze_model, so there is no per-call gate to thread — diagnostics are always collected LTM-enabled (cost is shared with the analysis via salsa); and since the MCP outputs previously carried only Error-severity diagnostics, both tools gained awarningsoutput field so the auto-flip advisory and fragment-failure warnings are actually visible. Verified: the transient flag cannot leak into saved project files, and LTM emits only Warning-severity diagnostics so the edit_model new-error gate stays symmetric.#533 — both-scalar fast path bypassed ThroughAgg routing.
model_element_causal_edgesnow consults the classified-site IR before taking the scalar→scalar fast path; aThroughAggsite falls through to the normal dispatch, which emits thescale → $⁚ltm⁚agg⁚nhop (and the mixed Direct+ThroughAgg case emits both edges). The fast path is byte-equivalent for plain scalar edges. Out-of-scope discoveries filed and tracked on the epic: #737 (PureScalar loop-score path ignores agg routing), #738 (scalar-target synthetic agg fails fragment compile), #739 (projection proptest never generates inlined reducers); a characterization test documents the current end-to-end behavior.#663 — non-Euler guard over-rejected loop-free models. The #486 guard now rejects RK2/RK4+LTM only when an instantiated model actually emits a flow-to-stock link score (
model_emits_flow_to_stock_score: any emitted link-score var whosetoendpoint is a stock — exact, because the only causal edges into stocks are flow→stock edges). Decision: the issue's "has any feedback loop" proxy is unsound — discovery mode and input-port models score ALL edges, so an open-loop stock still emits a flow-to-stock score there and must still be rejected; tests pin both soundness corners plus an arrayed decorated-name case. Open-loop RK4 accumulations with LTM now compile.#468 — emission-order denominator summation.
LtmVariablesResult.loop_partitionsis now anIndexMap(direct dep; already in-tree via salsa) populated in emission order, and the post-sim rel-score helpers iterate map order instead of lex-sorting — restoring the pre-#461 accumulation-order semantics. Verified emission order is a pure function of model content (assign_loop_ids' canonical sort), so the order-insensitive IndexMap equality cannot expose stale orders through salsa. Bonus: the libsimlin streaming-denominator path previously iterated hash-randomized; it now gets the same deterministic order. A bit-exactness test proves the consumer accumulates in emission order, not lex.#505 — flow-to-stock 1-DT shift documented. The user-facing reference doc now explains the two valid numerator timing conventions, why Simlin aligns the numerator with the causal interval (
PREVIOUS(flow) - PREVIOUS(PREVIOUS(flow))), the one-DT shift vs Stella, and the cross-tool reconciliation; cross-referenced both ways with the design doc's divergence #6. Every claim was verified against the implementation and the integration-test timestamp compensation.Process notes