Repository navigation
Description
Problem
The if detected.truncated { return None; } fallback branch in try_detect_ltm_loops_incremental (at src/simlin-engine/src/layout/mod.rs:3838) no longer has any dedicated test coverage.
This branch is part of the documented fallback chain: when model_detected_loops returns truncated = true, try_detect_ltm_loops_incremental returns None so the caller (compute_metadata) falls back to persisted loop_metadata instead of silently treating the model as structurally acyclic. This matters in production: WRLD3-scale models routinely exceed the structural-detection cap.
How it was lost
Introduced in PR #461 (branch ltm-perf-enable-always), iteration 16: we split the LTM structural-detection cap from the LTM-synthesis cap by raising MAX_LTM_DETECTED_LOOPS to 100_000 while keeping the synthesis cap MAX_LTM_TOTAL_CIRCUITS at 10_000.
Before the split, an integration test in src/simlin-engine/tests/layout.rs called test_compute_metadata_falls_back_on_truncated_loop_detection built 10_001 disjoint 3-cycles to trip the 10_000 synthesis cap and verify that compute_metadata fell back to persisted loop_metadata on truncated = true.
With the new 100k structural cap, a direct reproduction would need ~100k disjoint cycles (300k+ variables), which pushes CI beyond a reasonable wall time. We tried a complete-bipartite K(N,N) shape to multiply the distinct-cycle count by 2^N - 1, but Johnson's DFS still traverses roughly N!/e raw cycles before the per-SCC sorted-node-set dedup drops them, which is infeasible at N >= 14.
So the integration test was deleted. The sibling fallback branch (on simulation failure) is still covered by test_ltm_fallback_on_sim_error in src/simlin-engine/src/layout/layout_tests.rs:1542, but the truncated branch has no regression guard.
Why it matters
- The fallback is the documented behavior for dense real-world graphs; silent regression would make
compute_metadataemit empty feedback-loop metadata instead of the persistedloop_metadata. - The branch is the only thing distinguishing "empty
loopsbecause there are no cycles" (returnSome(vec![])) from "emptyloopsbecause we gave up enumerating" (returnNone). Conflating them is a real risk during future refactors of either the cap constants or theDetectedLoopsResultshape.
Component(s) affected
src/simlin-engine/src/layout/mod.rs--try_detect_ltm_loops_incrementalsrc/simlin-engine/tests/layout.rs-- integration test surfacesrc/simlin-engine/src/layout/layout_tests.rs-- sibling unit-test surface
Possible approaches
Option (a) -- preferred: Refactor try_detect_ltm_loops_incremental so DetectedLoopsResult is injectable. This enables a direct unit test of the truncated-branch dispatch that is fast, deterministic, and does not require fabricating pathological graph topologies. Likely shape: split the current function into a thin shell that calls model_detected_loops and a pure inner function that takes the result by value, then unit-test the inner function with a hand-crafted DetectedLoopsResult { truncated: true, loops: vec![] }.
Option (b) -- fallback: Wire a dedicated WRLD3-scale integration test (gated behind an expensive-tests feature) that actually trips MAX_LTM_DETECTED_LOOPS during structural enumeration. Slower, non-deterministic across CI hardware, and harder to diagnose when it breaks, but exercises the full salsa pipeline end-to-end.
Context
Identified during PR #461 review while closing out iteration 16. The deletion was load-bearing for keeping CI fast but left a coverage gap we should not silently absorb.
Activity
engine: split structural loop cap from LTM synthesis cap
bpowers commentedon Apr 30, 2026
Closing as moot. The
detected.truncatedfallback branch this issue requested coverage for was eliminated when auto-flip was re-landed in commit 88ca649 ("engine: re-land LTM always-on (auto-flip) + test timeout cap (#469)").Specifically:
DetectedLoopsResult(src/simlin-engine/src/db_analysis.rs:901-903) no longer has atruncated: boolfield; it now contains onlypub loops: Vec<DetectedLoop>.try_detect_ltm_loops_incremental(src/simlin-engine/src/layout/mod.rs) no longer has theif detected.truncated { return None; }branch.The new backstop for dense graphs is auto-flip to discovery mode driven by
MAX_LTM_SCC_NODES, which has its own coverage (e.g.wrld3_ltm_compilation_finishes_in_timeand the discovery-mode tests insrc/simlin-engine/src/db_ltm_unified_tests.rs). If a future change reintroduces a structural-detection truncation path that should fall back to persisted metadata, it will need its own tracking issue.Verified on
mainat HEAD 630fceb (2026-04-29).doc: refresh LTM tech-debt entries after triage of open issues