Skip to content

engine: @simlin/engine never binds simlin_analyze_get_loops_runtime (runtime Rux/Bux polarity and real confidence unreachable from TS) #760

@bpowers

Description

@bpowers

Problem

@simlin/engine (the TypeScript WASM surface) never binds simlin_analyze_get_loops_runtime, so TS consumers can never observe runtime-reclassified loop polarity (MostlyReinforcing/MostlyBalancing, "Rux"/"Bux") or a real polarity_confidence -- even though the enum variants and the Loop.polarityConfidence field already exist in src/engine/src/types.ts (the #495 type plumbing).

Concretely, src/engine/src/direct-backend.ts (~line 424) binds only the structural entry point:

The runtime entry point that does the honest post-simulation reclassification exists in libsimlin:

pysimlin binds it (Sim.get_loops_runtime, and Run.loops consumes the same reclassification), so Python sees honest post-sim labels. TS does not, so the diagram/web UI cannot render them.

Why it matters

Capability/parity gap (severity low-medium): Python consumers get honest Rux/Bux labels with real confidence values; TS/web consumers are stuck with pre-simulation structural labels and a degenerate 1.0/0.0 confidence. This is the same #495-follow-on plumbing class as #701 (runtime/discovery signals that exist in the engine and FFI but never reach TS).

It is also a prerequisite for #731 (diagram: render Rux/Bux with confidence-gray treatment): #731's body states "the data is now available to the diagram via the @simlin/engine Loop type", but that is only true of the types -- no binding actually delivers Rux/Bux or a non-trivial polarityConfidence to TS at runtime. #731 cannot render honest post-simulation polarity until this lands.

Components affected

  • src/engine/src/direct-backend.ts (bind the runtime entry point; expose e.g. Sim.getLoops() / a runtime-loops method on the sim handle)
  • src/engine/src/types.ts (types already present; surface API addition)
  • the worker backend / EngineBackend interface (worker-server.ts / worker-backend.ts) so the binding works on both Direct and Worker paths

Possible approach

Mirror pysimlin's split: keep the structural Model-level loops accessor and add a Sim-level (post-run) loops accessor that calls simlin_analyze_get_loops_runtime on the completed sim handle. The existing readLoops/LOOP_SIZE readers should be reusable since both entry points return the same SimlinLoop array shape.

Context

Identified during GH #679 work on branch ltm-core-batch (commit fca4cfec). The gap exists on main today: src/libsimlin/src/analysis.rs exports both entry points, pysimlin binds both, src/engine/src references only the structural one.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    ltmLoops that Matter (LTM) analysis subsystem

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions