← Changelog

State-Store Lifecycle Hygiene Sweep

Patch7 June 2026· library-wide

Audit / Issue Found

The lead-dev checklist for a strategy's state-store integrity has four prongs: every property the strategy reads from state has a guaranteed initialisation path, the wipe-stats handler resets the right things and leaves live position state alone, no property is dual-purposed across code paths, and ephemeral runtime values do not leak across hot-reloads. The codebase was audited against all four prongs.

Before the patch

Five strategies had a hidden brittleness around two property classes that were being read without an explicit initialisation at the top of the file. Four of them, ADX trend, Ichimoku cloud, Parabolic SAR, and SuperTrend, used a trailing-stop peak-price property that was protected at the read site by a defensive check, but was not actually initialised in the init block. The fifth, Glosten-Milgrom, used two realized-profit properties that were similarly protected at the read site, but not initialised. None of these were active bugs today because the defensive checks at the read sites masked the missing init. But every defensive check is also a future-refactor hazard: the day someone simplifies one of those checks away thinking the property is initialised, the next fresh-pair run would let undefined propagate into the trail-stop math or the realized-profit accumulator and corrupt downstream values silently.

After the patch

All five strategies now explicitly initialise the missing properties in their top-of-file init block. The defensive checks at the read sites are left in place as belt-and-braces, but the strategy no longer depends on them. A future refactor that drops one of the defensive checks will still find a clean zero in state instead of undefined.

Two other categories were checked across the library and came back clean. The wipe-stats handlers correctly reset only the performance counters and leave live position state alone, so wiping stats while in a trade does not make the strategy think the position is gone. No property is dual-purposed across code paths, so no read of S-anything returns a value that means different things depending on which branch wrote it last.

Bottom line

The state-store initialisation is now explicit everywhere, so a future cleanup that simplifies a defensive check at a read site cannot accidentally re-open a path for undefined to leak into numeric math. The rest of the state-store discipline was already correct.