Skip to content

ltm-finding: discovery zero-edge-exclusion 'loses no loop' claim is overstated; baton-passing loops are invisible #699

Closed

Description

@bpowers

Summary

SearchGraph in src/simlin-engine/src/ltm_finding.rs excludes zero-score (and NaN) edges from each per-timestep search graph, justified by an in-code completeness claim that is too strong. Three comments assert variants of "any loop that ever matters has all-nonzero links at the step where it does, and remains discoverable there":

  • src/simlin-engine/src/ltm_finding.rs ~L204-208 (SearchGraph::from_edges): "Any loop that ever matters has all-nonzero links at the timestep where it does, and remains discoverable there."
  • src/simlin-engine/src/ltm_finding.rs ~L1277-1281 (step_adj): "any loop that ever matters has all-nonzero links at the step where it does -- where it remains discoverable (GH ltm-finding: strongest-path discovery infeasible on large arrayed models (element-level blowup) #647)."
  • src/simlin-engine/src/ltm_finding.rs ~L3071-3074 (test_inactive_loop_found_at_active_step doc): "Discovery runs at every timestep, so per-step exclusion of inactive edges loses no loop that ever matters."

The claim is false for a "baton-passing" loop whose links are each active at different times but are never all simultaneously nonzero at any single (sampled) timestep. The exclusion is correct per-step (a loop with a zero-score link genuinely has loop score 0 there), but the completeness conclusion does not follow: there is no requirement that all of a real loop's links be simultaneously nonzero at some timestep.

Why this matters

  • Correctness of attribution / overstated guarantee. The comments imply discovery is complete with respect to "loops that ever matter," which is not what the algorithm delivers. A class of dynamically-real loops is silently invisible to discovery while exhaustive mode reports them.
  • A test enshrines the gap with a misattributed cause. discovery_decoupled_stocks in src/simlin-engine/tests/simulate_ltm.rs asserts found.len() == 2 (the two self-loops) and its comment blames the removed best_score pruning ("the strong self-loop paths set high best_scores on shared nodes ... pruning the weaker cross-stock path"). The real cause is the zero-edge exclusion plus non-overlapping link activity, not best-score pruning. The comment is stale/wrong.

Empirical demonstrations

  1. test/decoupled_stocks/decoupled.stmx -- exhaustive structural analysis finds 3 loops (two self-loops plus the cross loop stock_1 -> flow_2 -> stock_2 -> flow_1); discovery finds only 2. The cross loop is missed because stock_1 -> flow_2 is nonzero only at step 4 while stock_2 -> flow_1 is nonzero only at steps 6-10 -- the two links never overlap at any saved step, so the cross loop has no single timestep where all its links are nonzero.

  2. Sub-save_step gating -- a model with dt = 0.25, save_step = 1.0, and a cross loop gated by PULSE(0.5, 0) firing at an unsaved sub-step: the gated link's score reads 0.0 at every saved step, so discovery misses the loop entirely while exhaustive reports it. This second aspect (sampling at save_step rather than dt) is the part ltm: discovery misses loops active only between saved steps #309 already covers; demonstration (1) is independent of save_step and would persist even at full dt resolution.

Component(s) affected

  • src/simlin-engine/src/ltm_finding.rs (the three comments, SearchGraph::from_edges, step_adj/discover_step)
  • src/simlin-engine/tests/simulate_ltm.rs (discovery_decoupled_stocks expectation + misattributing comment)

Scope note (not a regression vs the published method)

This is not a regression relative to the Eberlein & Schoenberg per-step discovery method -- per-step discovery inherently shares this property (a loop is only ever surfaced at a step where it is fully active). The ask here is to soften the in-code "loses nothing" claims and document the limitation, not to change the algorithm.

Suggested resolution

  1. Reword the three comments to the accurate guarantee, e.g.: "loses no loop that is ever simultaneously active at a sampled timestep" -- and explicitly note that a baton-passing loop whose links are active at disjoint times can be missed (exhaustive mode still finds it).
  2. Fix the discovery_decoupled_stocks comment to attribute the missed cross loop to the zero-edge-exclusion / non-overlapping-link-activity cause, not the removed best-score pruning. Keep found.len() == 2 as the documented expected behavior, now correctly explained.
  3. Optionally document the limitation in the user-facing LTM reference alongside the per-step / save_step caveats.

Relationship to existing issues

Context

Identified during a deep LTM review while cross-validating discovery against exhaustive results on test/decoupled_stocks/decoupled.stmx.

Activity

  1. added
    ltm
    on Jun 3, 2026
  2. bpowers commented on Jun 8, 2026

    @bpowers
    OwnerAuthor

    Fixed by PR #705 (merged, commit 26a641e), verified present on main:

    Closing as resolved. (FFI surfacing of the #696 truncation flag remains tracked as #701.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions