{
  "notes": "EPISODE 6 (goal: lift NP2 on Paradigm AMM fee challenge; need paired +5.8 for top 10, +9.6 for 1st vs NP2 526.1156 on seeds 0..999; paired = each strategy SEPARATELY vs Vanilla on the same seeds).\nSTATE AT START (~18:00Z): handed ep3-oracle/oracle-price, ep3-oracle/oracle-full, ep4-lean/lean-b, ep2-oracle/oracle-price. Still running: ep3-base/decomp, ep4-flow x3, ep4-lean lean-a + cap-b, ep3-mech x4 and ep1-mech x1 (both cancelled). Waiting, not started: ep5-err (2), ep5-oracle (2), ep5-mech canary 5 + 7 held. No refusals, no stalls. Items: 46 used before this episode; cancel ep5-oracle (-2 waiting) and spawn 8 => 52 of 400; 4 episodes left after this one (7,8,9,10). Throughput, not the item budget, is the constraint: ~10 results landed in 2 hours, so I spawn batches of <=5 items (no canary) and keep ~100 items for ep8-9 confirmation.\nWHAT WAS LEARNED (all four results below are VALID separate-vs-Vanilla measurements except lean-b's confirm):\n1. ep3-oracle/oracle-price (n 2000, block 2270000): NP2 with pHat := true price before tradeRatio, mapping unchanged: -5.39 se 0.057; arb edge +15.57 (NP2 -32.1 -> -16.5), retail edge -20.96 (560.4 -> 539.4); arb volume 24.2k -> 13.2k, retail 77.5k -> 71.0k. ep2-oracle/oracle-price (n 2500, true gap only in tox/side tests, TOX_SCALE 0.9): -2.11 se 0.04; arb +9.39, retail -11.50; fees +2.9 bps both sides, mean |bid-ask| 54.6 -> 67.1 bps. So exact price knowledge saves more arb (+9 to +16) than the whole gap to 1st, but NP2's stale/attract mapping (0.685 x gap on both sides, nearly instant toxEma) over-shifts with a correct gap and gives back more retail. The requester (17:57Z) reads it the same way: re-tune the mapping jointly with the true price (the real ceiling), then apply that mapping to NP2's own pHat, plus a noise-shrunk gap.\n2. ep3-oracle/oracle-full (n 10000, block 2280000): fee per side = gap-to-fair + g, best g 25/25 bps: -33.48 se 0.07; arb +28.0 but retail -61.5, arb volume ~0 (71 Y vs 24k), retail volume -33%. Lesson: blocking every arb removes the pool's re-centering, the exposed-side fee then sits at a large gap and retail on that side goes to the normalizer. A ceiling family must let arbs trade (exposed fee below the gap) and discount the other side.\n3. ep4-lean/lean-b: the 0.20 bps half-transfer lean fix is -0.041 se 0.006 vanilla-paired (its +0.385 confirm was head-to-head, invalid). Its vanilla-paired ablations on n 200: skew = 0 (dirState skew removed) +0.061 se 0.012; staleShift = 0 -122.5; tradeBoost = 0 -0.81. The stale shift IS the strategy; the dirState skew is dead weight (a +0.06 cleanup for the final stack, not a lever).\n4. CH = ChengHua926/amm-challenge Strategy.sol @d34a5199 (525.525882178 reproduced again). Confirm blocks run ~5-10 min per 2,000 seeds at 8 workers.\nDECIDED:\n- cancel ep5-oracle: its two waiting items (oracle-price-c, oracle-full-c) are the same two designs ep3-oracle already measured validly (items 1 and 2 above).\n- ep6-oracle (4 items, no canary; simulator patched to pass the true price as a 7th calldata word, as the accepted oracle item did): ceil-a/ceil-b = true price as pHat + joint coordinate re-tune of STALE_DIR_COEF, STALE_ATTRACT_FRAC, TOX_COEF, TOX_QUAD_COEF, TRADE_TOX_BOOST, TOX_BLEND_DECAY (the requester's item 1; the tuned values are the mapping ep7 applies to NP2's own pHat); ev-a/ev-b = true price + closed-form per-side fees: exposed = a*gap + b, other = c - d*gap, a<1 so arbs still re-centre (a cleaner ceiling than NP2's coefficient family).\n- ep6-mech (4 items, legal strategies on NP2's own pHat): shrink-a/b = noise-shrunk gap tox = max(0, |spot-pHat|/pHat - K*sigmaHat*sqrt(1+elapsed)), with a second K2 for the stale/attract shift (the requester's item 2b); sitshift-a/b = separate stale/attract coefficients (and aligned boost) after arb-like prints (first in step, within the gate: fair = pImplied, displacement = feeUsed exactly) vs retail-like prints (displacement = impact), tuned by class.\n- Not spawned yet (needs the ceiling's tuned values): the re-tuned mapping with NP2's own pHat (requester's item 2a). ep7 spawns it, two machines, from ceil-a/ceil-b's reported constants.\nMETHOD (every brief carries it word for word; reuse from artifacts/goal/episodes/006/decisions.json): NP2 definition; SETUP with the requester's 1159-char script (no gate line); MEASURE = default_rng(seed) draws size, rate, sigma; build_config; Vanilla compiled from contracts/src/VanillaStrategy.sol; run_batch(cand, vanilla) and run_batch(np2, vanilla) separately, 20 seeds per call, d per seed, se = sd/sqrt(n); NEVER run_batch(cand, np2). Tune on 10000..99999 (<=256 seeds per point), confirm once on the item's block..block+1999. RETURN delta, code, sha256, tuning, paired{n,mean_diff,se,worst}, split{arb_edge,retail_edge}, fee_stats, blocked, next. Filled briefs are 2,949-2,994 chars: cut before adding.\nCONFIRM SEED BLOCKS (never reuse): ep1-mech 2000000..2229999 (cancelled, may have run); harness calibration ep1 2900000..2909999; ep2-oracle 2230000..2249999; ep3-base 2250000..2253999 and 2260000..2263999; ep3-oracle 2270000..2289999; ep3-mech 2300000..2459999 (cancelled, canary may have run); ep4-flow 2460000..2499999; ep4-lean 2500000..2539999; ep5-oracle 2540000..2551999 (cancelled); ep5-mech item i (order arbfirst-a, silence-a, kalman-a, prespot-a, evfee-a, nextmix-a, arbfirst-b, silence-b, kalman-b, prespot-b, evfee-b, nextmix-b) 2560000+i*10000..+1999 (to 2679999); ep6-oracle ceil-a 2680000, ceil-b 2690000, ev-a 2700000, ev-b 2710000; ep6-mech shrink-a 2720000, shrink-b 2730000, sitshift-a 2740000, sitshift-b 2750000 (each ..+1999). NEXT FREE BLOCK: 2760000 (allocate 10000 per item; skip 2900000..2909999). Tuning seeds: 10000..99999 (ep5-err uses 10000..10399).\nREADS REQUESTED for ep7 (28): ep3-base/decomp; ep4-flow/flat-a, flat-b, both-a; ep4-lean/lean-a, cap-b; ep5-err/err-a, err-b; ep5-mech/merge-01, merge-02 and its 12 items; ep6-oracle/ceil-a, ceil-b, ev-a, ev-b; ep6-mech/shrink-a, shrink-b, sitshift-a, sitshift-b.\nEP7 PLAN: (a) For every result check the method first: separate-vs-Vanilla counts; head-to-head does not (keep its delta only for re-measurement). Read `blocked` before counting an idea as tried. (b) Rank ep5-mech and ep6-mech by t = mean_diff/se on their confirm blocks; both copies at mean_diff >= 2se = winner; one positive copy = one retune from the better copy's delta; both t < 1 = drop. (c) From ceil-a/b: if the re-tuned mapping with the true price shows a large gain (>= +5) with retail preserved, spawn two items applying those constants to NP2's own pHat and two more combining them with the best gap denoiser (shrink) or classifier (sitshift, arbfirst); from ev-a/b read the ceiling's shape (a, b, c, d) and, if it beats ceil, brief a legal version driven by pHat and sigmaHat. If the ceiling itself is < +3, tracking cannot carry the goal: weight fee-policy mechanisms (evfee, nextmix) and say so in the write-up. (d) Use err-a/b to target the situation with the largest error-weighted loss. (e) ep8: stack winners pairwise and all together (each stacking item = NP2 + the winners' deltas copied from their results; also drop the dirState skew, +0.06), two machines each, fresh blocks from 2760000; ep9: final 4,000-seed confirmation of the best stack (two machines, two blocks), then finish; the requester submits any file >= +1.0 over NP2 on 4,000 fresh seeds and reports the board score as a note. Keep ~100 items for ep8-9. Finish when a candidate shows mean_diff - 2se >= 5.8 vs NP2 or the budget nears exhaustion; the write-up gives final code, sha256, paired{n,mean_diff,se,worst}, and the ceiling figures (items 1-2 above) as what is missing if no legal candidate reaches +5.8.",
  "spawn": [
    {
      "name": "ep6-oracle",
      "brief": "NP2 = TWO (`code` at https://api.imdnotdead.fun/artifacts/528a6da78583c6142644a552c86670f9d25c20e39e92f4de44deae05ddc8cecd) + `code` at https://api.imdnotdead.fun/artifacts/da313379a2e69e9286668865e06b18dfcae25732c82b934b0fd9c2ef0d8c2ff5 from `// Interior retail routing` to (excl.) `uint256 tradeRatio =`, inserted before TWO's `uint256 tradeRatio =`; 526.1156 on seeds 0..999.\nSETUP (this script, not the objective's): clone github.com/benedictbrady/amm-challenge @6b6921f8d463314aa7c96234e1be25a25245f704 in your workspace (not /tmp); save as scratch/setup.sh; run it once at the root; then `. scratch/env.sh && ...`; on failure return blocked={step,error}.\nset -eu;R=$PWD/scratch;mkdir -p $R/tmp $R/bin $R/solcx\necho \"export TMPDIR=$R/tmp XDG_CACHE_HOME=$R/xc UV_CACHE_DIR=$R/uvc UV_PYTHON_INSTALL_DIR=$R/uvpy RUSTUP_HOME=$R/rustup CARGO_HOME=$R/cargo SOLCX_BINARY_PATH=$R/solcx VIRTUAL_ENV=$PWD/.venv PATH=$PWD/.venv/bin:$R/bin:$R/cargo/bin:\\$PATH\" >$R/env.sh;. $R/env.sh\ncommand -v uv >/dev/null||{ curl -LsSf https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-unknown-linux-gnu.tar.gz|tar --no-same-owner -xz -C $R/tmp;cp $R/tmp/uv-*/uv $R/bin/;}\ncc --version >/dev/null 2>&1||{ curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest -o $R/tmp/mm.tbz;python3 -c \"import sys,tarfile;tarfile.open(sys.argv[1]).extract('bin/micromamba',sys.argv[2])\" $R/tmp/mm.tbz $R;MAMBA_ROOT_PREFIX=$R/mamba $R/bin/micromamba create -yq -p $R/cenv -c conda-forge gcc;ln -sf $(ls $R/cenv/bin/*gcc|head -n1) $R/bin/cc;}\ncommand -v cargo >/dev/null||{ curl -sSf https://sh.rustup.rs|sh -s -- -y --profile minimal --no-modify-path;}\nuv venv --python 3.12 .venv;uv pip install -e . maturin\nmaturin develop --release --uv --manifest-path amm_sim_rs/Cargo.toml\namm-match validate contracts/src/StarterStrategy.sol\nMEASURE: seed s: rng=numpy.default_rng(s); size=rng.uniform(19,21); rate=rng.uniform(.6,1); sigma=rng.uniform(.000882,.001008); build_config(seed=s,gbm_sigma=sigma,retail_arrival_rate=rate,retail_mean_size=size). Run cand and NP2 SEPARATELY, each vs compiled VanillaStrategy.sol via amm_sim_rs.run_batch (20 seeds a call), edges['submission']; d = cand - NP2 per seed; se = sd/sqrt(n). NEVER run_batch(cand, np2): that is flow stealing.\nTRUE PRICE p (simulator only): append U256(floor(fair_price*1e18)) of the step to after_swap's 196-byte calldata (engine.rs -> CFMM); Solidity: assembly { p := calldataload(196) }; unmodified NP2 stays bit-exact.\nTASK: {{mechanism}} Tune on seeds in 10000..99999 only; freeze; confirm ONCE vs NP2 on seeds {{block}}..{{block}}+1999.\nRETURN JSON: delta, code (+ simulator diff), sha256, tuning, paired{n,mean_diff,se,worst}, split{arb,retail edge diffs}, fee_stats{bid,ask}, blocked, next.",
      "items": [
        {
          "key": "ceil-a",
          "vars": {
            "block": "2680000",
            "mechanism": "CEILING: pHat := p just before `uint256 tradeRatio =` (the true gap then drives tox and the shifts). Jointly re-tune STALE_DIR_COEF, STALE_ATTRACT_FRAC, TOX_COEF, TOX_QUAD_COEF, TRADE_TOX_BOOST, TOX_BLEND_DECAY: coordinate search x0.25..x3 of NP2's values, 2 passes; report them."
          }
        },
        {
          "key": "ceil-b",
          "vars": {
            "block": "2690000",
            "mechanism": "CEILING: pHat := p just before `uint256 tradeRatio =` (the true gap then drives tox and the shifts). Jointly re-tune STALE_DIR_COEF, STALE_ATTRACT_FRAC, TOX_COEF, TOX_QUAD_COEF, TRADE_TOX_BOOST, TOX_BLEND_DECAY: coordinate search x0.25..x3 of NP2's values, 2 passes; report them."
          }
        },
        {
          "key": "ev-a",
          "vars": {
            "block": "2700000",
            "mechanism": "EV CEILING: with p, replace all fee logic after the state updates: g=|spot-p|/p; exposed side (bid if spot>=p else ask) = a*g+b; other = max(c-d*g,0); clampFee. Grid a {0.5,0.75,0.9,1,1.1}, b,c bps {10..40 by 5}, d {0,0.5,1}. a<1 keeps arbs re-centering (gap+g blocking arbs: -33)."
          }
        },
        {
          "key": "ev-b",
          "vars": {
            "block": "2710000",
            "mechanism": "EV CEILING: with p, replace all fee logic after the state updates: g=|spot-p|/p; exposed side (bid if spot>=p else ask) = a*g+b; other = max(c-d*g,0); clampFee. Grid a {0.5,0.75,0.9,1,1.1}, b,c bps {10..40 by 5}, d {0,0.5,1}. a<1 keeps arbs re-centering (gap+g blocking arbs: -33)."
          }
        }
      ],
      "output": {
        "format": "json",
        "maxBytes": 64000
      }
    },
    {
      "name": "ep6-mech",
      "brief": "NP2 = TWO (`code` at https://api.imdnotdead.fun/artifacts/528a6da78583c6142644a552c86670f9d25c20e39e92f4de44deae05ddc8cecd) + `code` at https://api.imdnotdead.fun/artifacts/da313379a2e69e9286668865e06b18dfcae25732c82b934b0fd9c2ef0d8c2ff5 from `// Interior retail routing` to (excl.) `uint256 tradeRatio =`, inserted before TWO's `uint256 tradeRatio =`; 526.1156 on seeds 0..999.\nSETUP (this script, not the objective's): clone github.com/benedictbrady/amm-challenge @6b6921f8d463314aa7c96234e1be25a25245f704 in your workspace (not /tmp); save as scratch/setup.sh; run it once at the root; then `. scratch/env.sh && ...`; on failure return blocked={step,error}.\nset -eu;R=$PWD/scratch;mkdir -p $R/tmp $R/bin $R/solcx\necho \"export TMPDIR=$R/tmp XDG_CACHE_HOME=$R/xc UV_CACHE_DIR=$R/uvc UV_PYTHON_INSTALL_DIR=$R/uvpy RUSTUP_HOME=$R/rustup CARGO_HOME=$R/cargo SOLCX_BINARY_PATH=$R/solcx VIRTUAL_ENV=$PWD/.venv PATH=$PWD/.venv/bin:$R/bin:$R/cargo/bin:\\$PATH\" >$R/env.sh;. $R/env.sh\ncommand -v uv >/dev/null||{ curl -LsSf https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-unknown-linux-gnu.tar.gz|tar --no-same-owner -xz -C $R/tmp;cp $R/tmp/uv-*/uv $R/bin/;}\ncc --version >/dev/null 2>&1||{ curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest -o $R/tmp/mm.tbz;python3 -c \"import sys,tarfile;tarfile.open(sys.argv[1]).extract('bin/micromamba',sys.argv[2])\" $R/tmp/mm.tbz $R;MAMBA_ROOT_PREFIX=$R/mamba $R/bin/micromamba create -yq -p $R/cenv -c conda-forge gcc;ln -sf $(ls $R/cenv/bin/*gcc|head -n1) $R/bin/cc;}\ncommand -v cargo >/dev/null||{ curl -sSf https://sh.rustup.rs|sh -s -- -y --profile minimal --no-modify-path;}\nuv venv --python 3.12 .venv;uv pip install -e . maturin\nmaturin develop --release --uv --manifest-path amm_sim_rs/Cargo.toml\namm-match validate contracts/src/StarterStrategy.sol\nMEASURE: seed s: rng=numpy.default_rng(s); size=rng.uniform(19,21); rate=rng.uniform(.6,1); sigma=rng.uniform(.000882,.001008); build_config(seed=s,gbm_sigma=sigma,retail_arrival_rate=rate,retail_mean_size=size). Run cand and NP2 SEPARATELY, each vs compiled VanillaStrategy.sol via amm_sim_rs.run_batch (20 seeds a call), edges['submission']; d = cand - NP2 per seed; se = sd/sqrt(n). NEVER run_batch(cand, np2): that is flow stealing.\nTASK: {{mechanism}} Tune on seeds in 10000..99999 only (<=256 per point); freeze; confirm ONCE vs NP2 on seeds {{block}}..{{block}}+1999.\nRETURN JSON: delta (<=900 chars, reproducible), code (full Strategy.sol), sha256, tuning, paired{n,mean_diff,se,worst}, split{arb,retail edge diffs} if measured, fee_stats{bid,ask}, blocked, next.",
      "items": [
        {
          "key": "shrink-a",
          "vars": {
            "block": "2720000",
            "mechanism": "NOISE-SHRUNK GAP (legal, NP2's own pHat): toxRaw=|spot-pHat|/pHat; noise=K*sigmaHat*sqrt(1+e), e = steps since the previous print (cap 8; 0 for a later print in the same step); tox = toxRaw>noise ? toxRaw-noise : 0; all else NP2. Tune K in {0,0.5,1,1.5,2,3}; then a separate K2 for the tox feeding only the stale/attract shift (K kept for fMid). Report d after arb-like vs retail-like prints if cheap."
          }
        },
        {
          "key": "shrink-b",
          "vars": {
            "block": "2730000",
            "mechanism": "NOISE-SHRUNK GAP (legal, NP2's own pHat): toxRaw=|spot-pHat|/pHat; noise=K*sigmaHat*sqrt(1+e), e = steps since the previous print (cap 8; 0 for a later print in the same step); tox = toxRaw>noise ? toxRaw-noise : 0; all else NP2. Tune K in {0,0.5,1,1.5,2,3}; then a separate K2 for the tox feeding only the stale/attract shift (K kept for fMid). Report d after arb-like vs retail-like prints if cheap."
          }
        },
        {
          "key": "sitshift-a",
          "vars": {
            "block": "2740000",
            "mechanism": "SITUATION SHIFT (legal, NP2's own pHat): class A print = firstInStep and ret<=adaptiveGate (arb-like: fair=pImplied, displacement=feeUsed exactly); R = any other (retail-like: fair barely moved, displacement=impact). Separate STALE_DIR_COEF and STALE_ATTRACT_FRAC after A vs after R prints (start at NP2's), coordinate search x0.5,0.75,1,1.25,1.5,2 each; then TRADE_TOX_BOOST by class the same way. All else NP2."
          }
        },
        {
          "key": "sitshift-b",
          "vars": {
            "block": "2750000",
            "mechanism": "SITUATION SHIFT (legal, NP2's own pHat): class A print = firstInStep and ret<=adaptiveGate (arb-like: fair=pImplied, displacement=feeUsed exactly); R = any other (retail-like: fair barely moved, displacement=impact). Separate STALE_DIR_COEF and STALE_ATTRACT_FRAC after A vs after R prints (start at NP2's), coordinate search x0.5,0.75,1,1.25,1.5,2 each; then TRADE_TOX_BOOST by class the same way. All else NP2."
          }
        }
      ],
      "output": {
        "format": "json",
        "maxBytes": 64000
      }
    }
  ],
  "read": [
    "ep3-base/decomp",
    "ep4-flow/flat-a",
    "ep4-flow/flat-b",
    "ep4-flow/both-a",
    "ep4-lean/lean-a",
    "ep4-lean/cap-b",
    "ep5-err/err-a",
    "ep5-err/err-b",
    "ep5-mech/merge-01",
    "ep5-mech/merge-02",
    "ep5-mech/arbfirst-a",
    "ep5-mech/silence-a",
    "ep5-mech/kalman-a",
    "ep5-mech/prespot-a",
    "ep5-mech/evfee-a",
    "ep5-mech/nextmix-a",
    "ep5-mech/arbfirst-b",
    "ep5-mech/silence-b",
    "ep5-mech/kalman-b",
    "ep5-mech/prespot-b",
    "ep5-mech/evfee-b",
    "ep5-mech/nextmix-b",
    "ep6-oracle/ceil-a",
    "ep6-oracle/ceil-b",
    "ep6-oracle/ev-a",
    "ep6-oracle/ev-b",
    "ep6-mech/shrink-a",
    "ep6-mech/shrink-b",
    "ep6-mech/sitshift-a",
    "ep6-mech/sitshift-b"
  ],
  "cancel": [
    "ep5-oracle"
  ],
  "wake": {
    "batches": [
      "ep6-oracle",
      "ep6-mech",
      "ep5-mech",
      "ep5-err"
    ],
    "afterMinutes": 300
  },
  "finish": false
}
