Repository navigation
ltm: surface MostlyReinforcing/MostlyBalancing in JSON/TS/WASM layers #495
Copy link
Copy link
Closed
Labels
ltmLoops that Matter (LTM) analysis subsystemLoops that Matter (LTM) analysis subsystem
Description
Problem
PR #490 added MostlyReinforcing/MostlyBalancing (Rux/Bux) variants to the Rust LoopPolarity and DetectedLoopPolarity enums, plus a polarity_confidence: f64 field on DetectedLoop. The JSON-emitted to_loop_summary (in src/simlin-engine/src/analysis.rs) surfaces the new variants as mostly_reinforcing / mostly_balancing strings.
However, the TypeScript / WASM / C-FFI layers still see only the three legacy values:
src/libsimlin/src/ffi.rsSimlinLoopPolarityonly hasReinforcing = 0,Balancing = 1,Undetermined = 2.src/libsimlin/src/analysis.rscoalescesMostlyReinforcing->ReinforcingandMostlyBalancing->Balancingbefore returning to FFI consumers, with the polarity confidence dropped on the floor.- The
@simlin/engine/@simlin/diagrampackages downstream of the WASM bindings therefore have no way to distinguish a steady-R loop from a Rux loop, even though the engine knows the difference.
This was an accepted trade-off for #490 to keep the FFI surface stable, but it's tech debt worth tracking separately.
What needs to happen
- Extend the C ABI: either add
Rux = 3,Bux = 4toSimlinLoopPolarityplus apolarity_confidence: f32field onSimlinLoop, or expose confidence through a new accessor. Whichever shape is chosen needs to be additive so existing callers keep compiling. - Update the cbindgen-generated
simlin.hand the WASM@simlin/enginetypes to match. - Plumb the new variants through
src/diagram/so the visual rendering can distinguish Rux / Bux (the LTM literature suggests a "gray" treatment, similar to theconfidence < 0.99rendering in section 13.7 ofdocs/reference/ltm--loops-that-matter.md). - Mirror the FFI extension into pysimlin so its
LoopPolarityenum can survive a round-trip through the FFI without coalescing the way the Python-sidefrom_runtime_scoresalready preserves the variants.
Context
Discovered during PR #490 review (#490). The PR body acknowledged the FFI coalescing as a deliberate scope cut; this issue records the follow-up.
References
src/libsimlin/src/analysis.rs(current coalescing site)src/libsimlin/src/ffi.rs(SimlinLoopPolarity)src/simlin-engine/src/db_analysis.rs(DetectedLoopPolarity,polarity_confidence)src/simlin-engine/src/ltm.rs(POLARITY_CONFIDENCE_THRESHOLD,LoopPolarity)docs/reference/ltm--loops-that-matter.mdsection 13.7 (formula and gray-rendering convention)- LTM tracking epic: epic: Loops that Matter (LTM) -- open work #488
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ltmLoops that Matter (LTM) analysis subsystemLoops that Matter (LTM) analysis subsystem
Activity
ltm: add in-engine runtime loop-polarity reclassification primitive