You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reused pf_strategy_t is not pure for compiled scripts: series/indicator state survives reset_run_state() #219
Found while building pineforge-live's ABI v4 binding (Plan B1 Task 1, 2026-09-08).
Symptom. Calling run_backtest_full twice on the same pf_strategy_t with the same bars yields different trade lists: run 2 has one extra/missing trade near the start. Reproduced on three corpus strategies at engine main 41c9c74 (ABI v4): ta-sma-152-close-cross-01, analyzer-cashflow-cash-costs-01 (34 vs 33 trades), analyzer-parity-choch-bos-isolator-01 (125 vs 126). Two FRESH handles (strategy_create each) agree byte-for-byte, and the per-bar broker-state hashes match on fresh handles.
Cause (hypothesis).reset_run_state() resets the broker/engine state but not the compiled script's own series/indicator state (e.g. var variables, KahanWindowSum buffers in generated.cpp), so the second run starts "warm" and an indicator becomes ready earlier.
Why the existing pin missed it.tests/test_live_flags_off_identity.cpp (PR #218) pins reused == fresh on a synthetic modulo-schedule strategy with no indicator state, so it is vacuous for this class.
Asks.
Either reset compiled-script state at the top of every run() (codegen + engine hook), or document pf_strategy_t as single-use per run in pineforge.h (strategy_create per run).
Add a reused-handle pin over a corpus strategy with indicator state (e.g. run ta-sma-152-close-cross-01 twice on one handle and compare trades + hashes with a fresh handle), so scripts/live_flags_off_identity.py's evidence and the live runtime's assumption are covered.
pineforge-live works around it at the binding level (fresh strategy per run, ordered setter replay) until this lands.
Activity