Repository navigation
Production-readiness probes + engine state-reset / finite-fill fixes - #28
Merged
Merged
Conversation
Design spec (gap analysis -> ranked plan), source-verified findings doc (fixed F1/F3/F5 + open O2/O4/O5/O6/O7 + validation-methodology disclosures), and a TV-parity probe handoff spec (Families A-E with clean-room .pine sketches + capture recipes). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…l sizing Two source-verified latent bugs (no corpus impact — both paths are unreachable on the clean, fresh-handle corpus; re-verified 233 excellent + 1 anomaly, 0 regressions): 1. Handle reuse leaked state. run() only reserved trades_; it never cleared trades_/net_profit_sum_/gross sums/counters, open position, pending orders, risk latches, intraday/day counters, or source-series history. The C ABI advertises reuse-then-rerun (sweeps), so run 2 on a reused handle accumulated — could even start already in a position or risk-halted. New reset_run_state() resets the full per-run surface (configuration preserved) at the top of every run loop. 2. Silent wrong-qty fallback. calc_qty/calc_qty_for_type returned the raw percent/cash number as a contract count when fill_price<=0 or NaN (a $0/NaN print sized '10% of equity' as 10 contracts). Now reject (qty 0). execute_market_entry drops a fill at a non-finite price so a bad tick cannot open a position at a NaN/Inf entry. calc_qty_for_type moved to protected so the guard test can exercise it directly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Eight new ctests (+~1450 assertions; 45 -> 53 ctest) pinning claims a
skeptic would challenge, all green, no TradingView needed:
- determinism_reproducibility : bit-identical fresh-handle reruns
- handle_reuse_reset : reused handle == fresh (guards the fix)
- exit_path_segment_tiebreak : same-bar TP+SL / gap priority is
deterministic (analytic OHLC oracle)
- accounting_reconciliation : gross+gross==net, counts, independent
per-trade PnL recompute
- ta_volume_state_oracle : MFI/CMO/WPR bounds + OBV/PVT/AccDist
forward-sum identities
- market_structure_fills : mintick FLOOR snap at ES/gold/FX ticks
- calendar_aggregation_wm : W/M aggregation (leap Feb, year rollover)
- adversarial_ohlcv : NaN/Inf/zero/empty feeds stay finite,
no silent qty fallback (guards the fix)
Plus scripts/verify_self_test.py: the validator-of-the-validator —
proves verify_corpus.py fails on gross-corrupted trade lists, and
discloses its sub-1% / trailing-block-trim tolerances honestly.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…0, unmatched) verify_corpus.py historically compared 5 of 10 TradeC fields and gated at p90. It now ALSO parses + reports qty, pnl_pct, MFE, MAE deltas, plus p100 worst-case and an unmatched-in-window count — report-only, the tier gate is unchanged (re-verified 233 excellent + 1 anomaly). Immediately surfaces previously-hidden divergence (e.g. MAE p90 ~200%, a pnl_pct tail) feeding findings O5/O7. Also corrects the pnl_pct ABI doc to match the actual gross price-return formula (was: 'net % of entry capital'). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
PINEFORGE_ENABLE_SANITIZERS existed but CI never set it, so the leak / NaN / double-free probes ran un-instrumented. Adds a dedicated ubuntu ASan+UBSan job (library built with sanitizers PUBLIC so instrumentation propagates into every test binary) running ctest under detect_leaks=1:halt_on_error=1. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ion)
Automated commit security review flagged reset_run_state() as an
incomplete state-reset fanout — a reused handle still leaked:
- input.source ring buffers _src_ohlc4_ / _src_hlcc4_ (the two newest
canonical series were missed)
- trace buffers trace_buffer_ / trace_names_ / trace_name_index_
- session-predicate state prev_in_session_ / session_ismarket_ /
session_isfirstbar_ / session_islastbar_
All now reset (trace_enabled_ preserved — it is configuration). Comment
added requiring EVERY _src_*_ member be listed to prevent the same miss
recurring. ctest 53/53; corpus 233 excellent + 1 anomaly, 0 regressions.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
docs/superpowers/ holds maintainer-only process artifacts (not referenced by README, the docs site, or CI). The production-readiness design spec I added there is internal; its reader-facing content lives in docs/production-readiness-findings.md + docs/tv-parity-probe-spec.md. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Untrack docs/superpowers/ (11 brainstorming plans/specs) and docs/production-readiness-findings.md and add both to .gitignore, matching the existing HANDOFF.md / BENCH_REFRESH_HANDOFF.md policy — these are maintainer-only artifacts not referenced by the README, the docs site (Doxyfile ships only docs/pages/* + the public header), or CI. Files are kept on disk locally, removed from tracking only. Scrub the now-internal findings.md references from the public surface (pineforge.h pnl_pct doc, verify_corpus.py comment, tv-parity-probe-spec) so those stay self-contained. No behaviour change; ctest 53/53. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ree) The ASan lane failed on Linux: test_matrix aborted with AddressSanitizer 'attempting free on address which was not malloc()-ed' at the PineMatrix destructor. Root cause: sanitizer COMPILE flags were PRIVATE to the library, so a consumer TU (the test) linked the instrumented lib but compiled without -fsanitize -> a different Eigen alignment view than matrix.cpp. An Eigen matrix allocated in the library and freed (header-inlined) in the test then mis-freed the aligned offset pointer. macOS's allocator masked it; Linux caught it. Fix: make -fsanitize compile options PUBLIC so lib + tests + strategy .so are instrumented identically, and define EIGEN_MAX_ALIGN_BYTES=0 under the sanitizer build so Eigen uses plain malloc/free (no offset pointers). Sanitizer-lane only; normal builds keep full alignment. Local ASan/UBSan: 53/53 pass incl. test_matrix. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A gap analysis of the corpus (deep on engine mechanics, but all one Binance ETH/USDT 15m feed) turned into engine-only probes that verify green now + two real engine fixes they revealed + an honest validator extension. TradingView-parity probes (new instruments, leverage, TA-family) are specced as a handoff (
docs/tv-parity-probe-spec.md) since they need a TV export.Engine fixes
run()never reset per-run state, so a reused handle (an advertised sweep path) accumulated trades/PnL and could start already in a position or risk-halted. Newreset_run_state()resets the full surface (config preserved); completed after a security-review fanout catch (source-seriesohlc4/hlcc4, trace buffers, session predicates).calc_qty*returned the raw percent/cash number as a contract count on a$0/NaN fill; now rejects (qty 0).execute_market_entrydrops non-finite fills.New probes (8 ctests, +~1450 assertions; 45 → 53)
determinism/bit-identical · handle-reuse guard · same-bar TP+SL/gap tie-break (analytic OHLC oracle) · accounting reconciliation · TA bounds + forward-sum identities · mintick FLOOR snap (ES/gold/FX) · W/M calendar aggregation · adversarial OHLCV ·
scripts/verify_self_test.py(validator-of-the-validator).Validator + CI
verify_corpus.pynow also reports qty / pnl_pct / MFE / MAE + p100 worst-case + unmatched-count (report-only, gate unchanged) — already surfaced a hidden MAE divergence.Verification
ctest53/53 ·scripts/run_corpus.sh233 excellent + 1 documented anomaly, 0 regressions, 0 submodule churn.Notes for review
🤖 Generated with Claude Code