Repository navigation
Description
Summary
Loop deduplication is currently done by sorted node set, which merges distinct directed loops that traverse the same variables in different orders/directions.
Why this is a problem
In feedback analysis, loop identity is defined by directed causal structure (ordered links), not just the set of participating variables. Collapsing by node set can remove structurally distinct loops and alter loop counts, reported polarity composition, and score attribution.
Literature / algorithm alignment
The LTM literature discusses distinct loops in directed graphs and evaluates discovery completeness against exhaustive directed-loop enumeration. Treating two different directed cycles as one because they share nodes is not equivalent to elementary circuit identity.
Current implementation behavior
- Exhaustive path dedup (
ltm.rs) key = sortedfromnode names. - Discovery dedup (
ltm_finding.rs) key = sorted node names from DFS stack. - Integration test notes this explicitly in arms-race expectations (7 instead of 8 due reverse three-way loop collapse).
Locations:
src/simlin-engine/src/ltm.rs(deduplicate_loops)src/simlin-engine/src/ltm_finding.rs(add_loop_if_unique)src/simlin-engine/tests/simulate_ltm.rs(discovery_arms_race_3partycomments)
Impact
- Distinct loops can be lost, especially in symmetric systems where opposite-direction cycles exist over same node set.
- Discovery-vs-exhaustive comparisons may look better/worse for the wrong reason (identity mismatch).
Success criteria
- Define loop identity using directed edges (canonicalized by rotation, but preserving orientation/order), not node-set membership.
- Apply the same identity rule in both exhaustive and discovery paths.
- Update tests to validate that opposite-direction cycles on the same node set are represented as distinct loops when structurally distinct.
- Revisit affected expected loop counts (e.g., arms race fixtures) under the corrected identity.
- Ensure deterministic IDs still remain stable across runs with the new identity rule.
Notes
This issue does not request any change to the known flow-to-stock time alignment decision.
Activity
doc: refresh LTM tech-debt entries after triage of open issues
engine: pin exact wrld3 element circuit count post canonical dedup
engine: dedup ltm cycles by canonical edge sequence
engine: update arms_race_3party expected loop count to 8
engine: re-pin wrld3 element-level enumeration count post canonical d…
doc: design note for canonical cycle dedup
engine: dedup ltm cycles by canonical edge sequence (#308) (#494)