Skip to content

engine: TypeScript API cannot read post-run loop polarity #760

Closed as not planned

Description

@bpowers

The TypeScript engine (@simlin/engine) can only read a model's loops before simulation, so every loop it returns has its structural polarity and a confidence of 1.0 or 0.0.
libsimlin already has a post-run entry point, simlin_analyze_get_loops_runtime, that relabels loops from their simulated loop scores (including "mostly reinforcing" and "mostly balancing") with a real polarity confidence.
pysimlin uses it (Sim.get_loops_runtime, Run.loops); TypeScript does not bind it.

Why it matters

Nothing in the web app reads loops today, so no user sees this yet.
It is the first step for any web display of loop polarity (#731).
The LoopPolarity enum and Loop.polarityConfidence already exist in the TS types, so callers can be misled into thinking the values are runtime values.

Fix

Bind simlin_analyze_get_loops_runtime and expose it on the run or sim handle (for example Sim.loops()), next to the existing model-level Model.loops().
Both entry points return the same SimlinLoops struct, so the existing readLoops reader works for both.
It needs to go through the EngineBackend interface so the worker backend gets it too.

While there, update the "Simlin implementation note" in docs/reference/ltm--loops-that-matter.md (after the Rux/Bux table, around line 695).
It still says the TS surface folds Rux/Bux to R/B and points at #495, which is closed.

Pointers

  • src/engine/src/direct-backend.ts (modelGetLoops), src/engine/src/internal/analysis.ts
  • src/engine/src/worker-server.ts, src/engine/src/worker-backend.ts
  • src/libsimlin/src/analysis.rs (simlin_analyze_get_loops_runtime)
  • pysimlin reference: src/pysimlin/simlin/sim.py (get_loops_runtime)
  • Blocks diagram: show feedback loops and their polarity in the editor #731.

Activity

  1. added
    ltm
    on Jun 10, 2026
  2. added
    enhancement
    on Oct 12, 2026
  3. changed the title [-]engine: @simlin/engine never binds simlin_analyze_get_loops_runtime (runtime Rux/Bux polarity and real confidence unreachable from TS)[/-] [+]engine: TypeScript API cannot read post-run loop polarity[/+] on Oct 12, 2026
  4. added
    duplicate
    on Oct 12, 2026
  5. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing as a duplicate of #731.

    Still real (direct-backend.ts binds only simlin_analyze_get_loops), but nothing in the web app reads loops, so this binding only matters as step 1 of #731's feature.

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

    duplicateenhancementltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions