Skip to content

ltm: black-box module link scoring collapses magnitude to 1 #307

Closed

Description

@bpowers

Summary

The black-box module link score equation collapses magnitude to ~1 whenever active, because it computes ABS((Δto)/(Δto)) * sign(...).

Why this is a problem

LTM link-score magnitude is supposed to represent fractional contribution (|Δ_x(z)/Δ(z)|). For black-box module links, the current equation loses that information entirely and encodes mostly sign + activity. This can distort loop-score magnitudes and ranking when any loop includes black-box-scored module edges.

Literature / algorithm alignment

  • Reference doc Section 3.1 defines instantaneous link magnitude as |Δ_x(z)/Δ(z)| with ceteris-paribus partial change.
  • For hidden structure (macros/modules), the integration approach uses pathway/composite scores (Section 6), not a unit-magnitude substitute.

Expected algorithmic behavior: even when internal structure is abstracted, link magnitude should remain contribution-sensitive, not constant-one when active.

Current implementation behavior

generate_module_link_score_equation emits:

  • zero guards for Δto == 0 / Δfrom == 0
  • ABS((Δto)/(Δto)) * sign((Δto)/(Δfrom))

Location:

  • src/simlin-engine/src/ltm_augment.rs (generate_module_link_score_equation)

Impact

  • Loops containing black-box module edges can be over- or under-weighted relative to loops with full ceteris-paribus/composite scoring.
  • Results can depend on whether a dependency crosses a module boundary that uses this fallback.

Success criteria

  1. Replace or constrain the black-box fallback so magnitude is not identically 1 when active.
  2. Preferred: compute a contribution-consistent magnitude using available structure (composite/pathway where possible, ceteris-paribus equivalent where available).
  3. If a truly equivalent magnitude cannot be computed for some module class, surface that explicitly in output/metadata and avoid treating it as fully comparable to regular link scores.
  4. Add regression tests asserting that black-box module links can take nontrivial magnitudes (not just {0, ±1}) in at least one realistic scenario.
  5. Update LTM design docs to describe the exact fallback semantics and limitations.

Notes

This issue is independent of the known intentional flow-to-stock timing shift.

Activity

  1. bpowers commented on Apr 30, 2026

    @bpowers
    OwnerAuthor

    Fixed in commit c16d9a9 ("engine: fix LTM var sort ordering and extract black-box formula helper").

    The old ABS((delta_to)/(delta_to)) * sign(...) formula that collapsed magnitude to ~1 has been replaced. The current black-box module-link-score formula is a true delta-ratio, preserving magnitude information:

    // src/simlin-engine/src/db.rs:1994-2005
    pub(super) fn black_box_delta_ratio_equation(from_ident: &str, to_ident: &str) -> String {
        // ...
        "if (TIME = INITIAL_TIME) then 0 \
         else if ((to - PREVIOUS(to)) = 0) OR ((from - PREVIOUS(from)) = 0) \
              then 0 \
         else ((to - PREVIOUS(to)) / (from - PREVIOUS(from)))"
    }

    The new formula computes delta_to / delta_from: magnitude reflects how much the target changes per unit change in the source, with proper zero-guards for both numerator and denominator. Used at all module-boundary fallback call sites in db.rs (lines ~2075-2112) and db_ltm.rs (lines ~343-373).

    The success criteria from the issue (non-trivial magnitudes, not just {0, +/-1}) are met by construction.

    Verified on main at HEAD 630fceb (2026-04-29).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions