Files
foxhunt/docs
jgrusewski 17cfbb2503 fix(sp12): per-trade event-driven reward composition
Three architectural changes in one atomic commit per spec ecab584c3:

1. Asymmetric bounded cap (REWARD_NEG_CAP=-10, REWARD_POS_CAP=+5):
   restores prospect-theory loss aversion (2:1 ratio) erased by SP11
   symmetric cap. Per pearl_audit_unboundedness_for_implicit_asymmetry.

2. Min-hold soft penalty with temperature curriculum:
   patience requirement on voluntary exits via deficit/(deficit+T) soft
   factor. Temperature anneals 50->5 across ~100 epochs (curriculum,
   half-life 20 epochs). Trail-fire exits exempted (preserves stop-loss
   design). Penalty flows through r_popart so SP11 controller weighs it
   consistently with other voluntary-exit terms.

3. Zero per-bar shaping (Change 3):
   r_micro = 0 entirely on positioned-non-event bars (per-bar shaping is
   anti-pattern; Q-learning handles credit assignment via TD).
   Per-bar Flat opp_cost zeroed (was the symmetric counterpart to micro).
   r_opp_cost preserved as lump-sum at exit:
     r_opp_cost = -shaping_scale * holding_cost_rate * |position| * hold_time
   on segment_complete (both voluntary and trail-fire). Preserves
   carrying-cost economic concept without per-bar density bias.
   Per pearl_event_driven_reward_density_alignment.

Empirical motivation: train-multi-seed-pmbwn 50-epoch on 6a259942e
showed sharpe-gaming (PnL -30% over 8 epochs while sharpe held at 80).
Three causes: lost loss aversion (Change 1), per-bar gradient (Change
3), no commitment (Change 2). Unified per-trade event-driven design
fixes all three together.

Constants live in state_layout.cuh as Invariant-1 numerical anchors
(REWARD_POS_CAP, REWARD_NEG_CAP, MIN_HOLD_TARGET, MIN_HOLD_PENALTY_MAX,
MIN_HOLD_TEMPERATURE_{START,END,DECAY}). Min-hold temperature is
recomputed in Rust per epoch via min_hold_temperature_for_epoch in
training_loop.rs and passed as a launch scalar. New HEALTH_DIAG line
sp12_event_reward emits the constants per epoch alongside sp11_reward.

Phase 1 = constants only. Phase 2 (ISV adaptive bounds per
feedback_isv_for_adaptive_bounds) deferred until validation results
indicate adaptive need.

LOC: ~344 added (includes spec-required documentation comments)
across experience_kernels.cu, state_layout.cuh,
gpu_experience_collector.rs, training_loop.rs, dqn-wire-up-audit.md.

Build: SQLX_OFFLINE=true cargo check -p ml --lib clean.
Tests: SQLX_OFFLINE=true cargo test -p ml --lib — 938 passed,
13 failed (same 13 failures pre-existing on HEAD ecab584c3, none
related to SP12 changes).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 19:04:26 +02:00
..