Repository navigation
Description
Problem
PR #461 (branch ltm-perf-enable-always) adds an auto-flip warning when LTM auto-switches to discovery mode. The warning accumulates through model_all_diagnostics only when SourceProject::ltm_enabled is true. But simlin_sim_new toggles ltm_enabled=false right after compile (to avoid leaking the flag to patch validation), and simlin_project_get_errors compiles with ltm_enabled=false by default.
A user workflow that silently drops the warning:
- Calls
simlin_sim_new(..., enable_ltm=true)on a dense model. - Hits "LTM auto-switched to discovery" silently (auto-flip triggered because the element-level largest SCC exceeded
MAX_LTM_SCC_NODES). - Calls
simlin_project_get_errors/pysimlin'sproject.get_errors()to see what happened.
The get_errors call re-runs diagnostic collection with ltm_enabled=false, so the LTM diagnostic pipeline is skipped entirely and the auto-flip warning is invisible to the caller.
Evidence
-
The gate in
model_all_diagnostics(src/simlin-engine/src/db.rsaround lines 1942-1950):// When LTM is enabled, also trigger LTM variable generation so that // any diagnostics accumulated by `model_ltm_variables` (e.g., the // auto-flip warning from db_ltm.rs) surface through // `collect_all_diagnostics`. Without this call, the warning would // be invisible to `simlin-mcp`/`libsimlin` callers even though // `model_ltm_variables` had already emitted it. if project.ltm_enabled(db) { let _ = model_ltm_variables(db, model, project); }
-
The reset in
simlin_sim_new(src/libsimlin/src/simulation.rsaround lines 94-99):// Always reset ltm_enabled to avoid leaking the flag to // subsequent operations (e.g. patch validation) that share // the same SourceProject. if enable_ltm { engine::db::set_project_ltm_enabled(&mut db, source_project, false); }
-
The test that locks in the gate:
test_ltm_disabled_does_not_surface_auto_flip_warninginsrc/simlin-engine/src/db_ltm_unified_tests.rs:574.
Partial mitigation already in place
simlin_analyze_get_relative_loop_score's error message is self-contained (explains auto-flip threshold inline), so users hitting the score-unavailable path understand what happened. But the separate "ask the project for its errors" workflow silently drops the warning.
Why it matters
Degrades diagnostic UX for the canonical "why does my LTM analysis feel wrong?" workflow. Scores are correctly computed (or correctly unavailable) either way, so this is not a correctness issue, but it makes the auto-flip invisible through the primary error-inspection entry point that AI agents and CLI callers reach for first.
Severity
Medium.
Proposed fix options
One of:
- Capture compile diagnostics in
simlin_sim_new(whileltm_enabled=true) and expose viaSimlinSimstate / a new FFI likesimlin_sim_get_compile_warnings. - Add an
include_ltm_warningsflag tosimlin_project_get_errorsthat re-enables LTM transiently during diagnostic collection. - Remove the
ltm_enabledgate inmodel_all_diagnosticssomodel_ltm_variablesruns always; updatestest_ltm_disabled_does_not_surface_auto_flip_warningto reflect new semantics. Downside: LTM synthesis cost is paid even for callers that never ran a sim. - Track a "latest sim had LTM enabled" flag on
SimlinProjectand use it to decide whetherget_errorsshould include LTM diagnostics. Naturally scopes LTM diagnostics to callers who asked for LTM at least once.
Discovery context
Flagged by Codex in review iterations 7, 9, and 11 of PR #461 (P2 in iter 11). Filed now because the mitigation work needs its own scope decision and is out-of-scope for the cap-lift work.
Files
src/simlin-engine/src/db.rs(around lines 1918-1950,model_all_diagnostics)src/libsimlin/src/simulation.rs(around lines 94-99,simlin_sim_new'sltm_enabledreset)src/simlin-engine/src/db_ltm_unified_tests.rs:574(test_ltm_disabled_does_not_surface_auto_flip_warning)src/simlin-engine/src/db_ltm.rs(model_ltm_variables, source of the auto-flip warning)
Activity
engine: rewrite auto-flip structural-loop test + fix degenerate emit …
engine: remove MAX_LTM_SCC_NODES gate, per-element unit tests
doc: refresh LTM tech-debt entries after triage of open issues
engine: surface LTM synthetic-fragment compile failures
LTM hardening: close out the top tracked gaps from epic #488 (#668)
bpowers commentedon Jun 2, 2026
Fixed in PR #668 (merged as f9f850d). simlin_project_get_errors now surfaces LTM diagnostics (auto-flip advisory, fragment-failure and partial-equation warnings) for projects that requested LTM at least once, via an ltm_requested latch + transient re-enable — with LTM scoped as an analysis overlay: project compilability is still assessed LTM-off, so an LTM-incompatible model that simulates fine is never reported broken. SimlinErrorDetail also gained a severity field threaded through pysimlin and the TS engine so advisories display as warnings, not errors. Pinned by test_get_errors_surfaces_ltm_auto_flip_warning_after_ltm_sim (red-verified), test_get_errors_rk4_ltm_compile_failure_is_not_a_project_error, and pysimlin TestLtmOverlayNotProjectError/TestLtmAdvisorySeverity. The sibling simlin-mcp-core gap is tracked as #662.
mcp-core: collect MCP diagnostics with LTM enabled (GH #662)