Files
foxhunt/docs
jgrusewski 034ba16801 feat(sp11): B1b — structural reward composition refactor (production flip)
Per spec §3.5.3 amended at 7ddaf9c51 on main: experience_env_step
reward composition decomposed from 8+ inline accumulation sites into
explicit per-component locals (r_popart, r_cf, r_trail, r_micro,
r_opp_cost, r_bonus), then composed as Σ w_i × r_i with controller
weights from ISV[340..346).

Trail reward extraction (§3.5.4): trail-fire P&L now flows through
r_trail (forced-exit signal) instead of r_popart (voluntary-exit
signal). REWARD_TRAIL_WEIGHT_INDEX has real signal — controller can
weight forced-exit vs voluntary-exit P&L differently. rc[2] (the
prior structural-placeholder slot) now carries trail magnitude.

Universal post-composition modifiers (§3.4.4): drawdown / capital-
floor / inventory / churn / conviction-scale / cf-flip apply AFTER
the weighted Σ, unweighted. They are risk constraints and structural
operators, NOT learning components — agent cannot weigh them away.

Mean=1 normalization (B0, §3.4.3): weights normalize to mean=1 so per-
bar `w_active × r_active` ≈ pre-SP11 absolute scale on average.

Sentinel-defense: experience_env_step runs at start of epoch, SP11
controller runs at end (training_loop.rs ~3475). At fold 0 epoch 0
step 0 the controller has not yet emitted, so ISV[340..346) hold
sentinel 0. Defense: fmaxf(w_raw, 0.01) — same Invariant-1 hard floor
the controller enforces post-renorm. Cold-start scale = 1% of
pre-SP11; Pearl A bootstrap on first emit replaces sentinel.

cf_reward path: out_rewards[cf_off] now writes controller-weighted
cf reward (w_cf × r_cf with sentinel-defense). Loss-kernel
cf_weight=0.3f at mse:318/c51:789 (structural Q-blend, NOT reward
weight) UNTOUCHED per §3.5 amendment.

Mutual exclusivity preserved (popart / trail / micro / opp_cost):
exactly one path fires per bar; others stay 0. The cascade scalar
`reward` mirrors per-component locals so C.4/D.4b bonus blocks that
read in-progress trade reward (Q-cap pattern from
pearl_one_unbounded_signal_per_reward) keep bit-identical compounding.
After cascade, `reward` is overwritten with r_weighted; post-
composition modifiers operate on r_weighted as before.

This is the production-flip commit. Trainer is now on the SP11
controller end-to-end (modulo replay-time curiosity which lands in
B1c after Layer C audit per §3.5.5).

Verification:
  - cargo check + build clean (1m32s release).
  - 6/6 SP11 GPU oracle tests pass (none exercise env_step directly).
  - 14/14 contract tests pass (sp5_isv_slots=10, state_reset_registry=4).
  - Local smoke (RTX 3050 Ti, 20-epoch magnitude_distribution) verifies
    HEALTH_DIAG sp11_reward weights drift epoch-over-epoch:
      epoch 0: w_pop=1.000 w_cf=1.000 w_tr=1.000 ...   (uniform sentinel-defense floor → mean=1)
      epoch 3: w_pop=1.991 w_cf=2.036 w_tr=0.493 ...   (controller redistributes)
      epoch 9: w_pop=1.823 w_cf=1.887 w_tr=0.572 ...   (mean ≈ 1.0 preserved, Σ ≈ 6)
    EVAL_DIST bit-identical to B1a baseline (eq=0.803 eh=0.197 ef=0.000)
    — pre-existing magnitude eval-collapse pathology
    (project_magnitude_eval_collapse_kelly_capped) unchanged by B1b.

Audit doc updated (Invariant 7): docs/isv-slots.md SP11 section now
reflects Layer B status with B0/B1a/B1b/B1c rollout timeline.
2026-05-04 09:46:53 +02:00
..