{
  "notes": "EPISODE 4 (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).\nSTATE AT START (16:56Z): no ep3 batch has run yet: ep3-base 3 waiting, ep3-oracle 2 waiting, ep3-mech canary 5 waiting + 11 held. ep1-rules/harness still running on the bad brief (expect blocked, ignore). ep2-oracle cancelled, its oracle-price item still running (ignore). Handed: ep2-board/top20-regimes and top20-families (both accepted, see BOARD below) and ep2-oracle/oracle-full = BLOCKED on the objective's gate line (no simulation; the rerun is ep3-oracle/oracle-full with the mended script). No refusals. Items used 33 before this episode; this episode adds 8 (41 of 400); 6 episodes left after this one.\nBOARD FINDINGS (data, from the public per-run files; requester confirmed 16:46Z that runs are the same 1,000 seeds in the same order, so positional d is a true paired difference; baselineEdge differs because the 30 bps pool's edge depends on the competitor):\n- #1 beats NP2 on every run: d +9.57 se 0.063, worst +3.59. #10: +5.83 se 0.049. Top 5 all +9.3..+9.6.\n- The gap scales with flow: #1's d is 8.10/9.54/11.07 by low/mid/high retail third; as a fraction of NP2's own edge it is flat (1.9/1.85/1.8%). No flow-free arb regime carries it (flat on the arb-residual cut).\n- Two rungs: NP2 -> #10 is retail (+1430 retail Y, arb +440, d 5.83). #10 -> #1 is arb (retail -50, arb -824 = -3.4%, mean mid fee +0.12 bps only, d +3.74). Across the top 20 d correlates -0.53 with arb change, +0.20 with retail change. Of #1's +9.57 about 7.1 is taken from the normalizer and 2.5 is new edge.\n- NP2's fee shape stands out twice: (1) step-end mid fee 33.71/35.74/37.79 bps by retail third, slope 1.755 bps per 10k retail Y vs #1 1.096 (34.12/35.45/36.68), #10 1.013; NP2 fee sd 1.97 vs #1 1.61, corr(fee, baselineEdge) 0.92 vs 0.76. (2) persistent bid-over-ask lean: mean bid-ask +1.02 bps (top 5 range -0.13..-0.02), median +0.81 vs -0.20, in every third (34.18/33.24 low; 38.33/37.25 high); per-run skew correlates 0.85 with #1's with the same sd 3.39, so the path response is right and the offset is the fault. In busy runs NP2 overprices and loses retail (T3: #1 +2695 retail); in quiet runs NP2's ask is too cheap and arbs take more (T1: #1 arb -1278, ask +0.91 bps).\n- Tails: run 476 d 18.41 with NP2 bid-ask 18.9 (#1 3.3); run 808 d 14.83, 17.0 vs 3.8; 90 NP2 runs with mean bid > 40 bps vs #1's 39; max bid 52.95 vs 43.33.\n- Board hypotheses still untested: quote by position within the step (arb trades first, then retail; the quote left at step end serves the next arb: lower after the first print, wider at step end; ep3's next-mix/router cover this family); classify first-in-step prints as arb vs retail before moving pHat (ep3's step-exact). Families: NP2 and #12 are the only \"high baseline coupling\" family; the whole top 10 is one low-variability family.\nDECIDED: the requester's 16:50Z note asks for two cheap deltas on NP2 and their combination, two machines each; added the stuck-side cap from the tail data. Two batches of 4 (<=5 so no canary), same template brief with the mended 1159-char script word for word and the 16:41Z instruction not to use the objective's script: ep4-flow (flat-a, flat-b = damp the flow terms to a mid slope ~1.1 bps per 10k retail Y as a shape change; both-a, both-b = flatten + zero lean together) and ep4-lean (lean-a, lean-b = find the term behind the +1.02 bps bid-over-ask lean by zeroing dirState skew / staleShift-attractShift / aligned boost one at a time, then remove only the mean; cap-a, cap-b = cap |bid-ask| and pull a side with no trades for k steps toward the other). Each returns delta, full code, sha256, tuning grid, paired{n,mean_diff,se,worst} on its own fresh block, fee_stats (mean bid/ask/bid-ask, mid slope per 10k retail, runs with bid>40) and blocked. No cancel, no pause.\nCONFIRM SEED BLOCKS (never reuse): ep1-mech 2000000..2229999 (cancelled, may have run); harness calibration ep1 2900000..2909999; ep2-oracle 2230000..2249999 (cancelled); ep3-base 2250000..2253999 and 2260000..2263999; ep3-oracle 2270000..2289999; ep3-mech item i (order: step-exact-a, kalman-a, ev-fee-a, next-mix-a, router-a, step-exact-b, kalman-b, ev-fee-b, next-mix-b, router-b, silence-a, arb-cover-a, flow-regime-a, silence-b, arb-cover-b, flow-regime-b) 2300000+i*10000..+9999 (to 2459999); ep4-flow flat-a 2460000, flat-b 2470000, both-a 2480000, both-b 2490000; ep4-lean lean-a 2500000, lean-b 2510000, cap-a 2520000, cap-b 2530000 (each ..+9999). NEXT FREE BLOCK: 2540000 (allocate 10000 per item; skip 2900000..2909999).\nBRIEF BUDGET (hard, <=3000 filled): the ep4 template (NP2 definition + mended script + pairing + return spec) is 2646 chars incl. placeholders, so a mechanism text must be <=350 chars with a 7-digit block. Reuse this template; cut before adding. Everything is in artifacts/goal/episodes/004/decisions.json.\nCH: the objective's \"CH on seeds 0..999 = 525.525882178\" names a strategy nobody has identified; briefs use the NP2 check 526.1156.\nREADS REQUESTED for ep5: ep3-base/decomp, harness-a, harness-b; ep3-oracle/oracle-price, oracle-full; ep3-mech/merge-01, merge-02; all 8 ep4 items.\nEP5 PLAN: (a) First check the mended script works: if ep3-base/ep4 items come back blocked, read the step (most likely rustup `curl|sh` or micromamba refused, or no x86_64), add a requester-visible note in the write-up and wait for the requester's fix; do not spawn more simulator items on a script that blocks. (b) If they ran: use harness-a/b for seconds per sim and se per 2,000 seeds (expect se ~0.1-0.15 on d, so t>=2 needs mean_diff >= ~0.3); rank every mechanism by t on its confirm block; a mechanism whose two copies both show mean_diff >= 2se is a winner; one positive copy = retune once from the better copy's delta; drop t<1 twice. (c) oracle-price vs oracle-full splits the +9.6 into tracking vs fee policy; if oracle-price is small, prioritise fee-policy mechanisms (ev-fee, next-mix, router, flat, lean) over tracking (step-exact, kalman, silence). (d) Stack: each stacking item = NP2 + winners' deltas (or api.imdnotdead.fun/artifacts/<sha256> addresses if `handed` gives them), confirm on a fresh block from 2540000; test step-position quoting and arb classification if ep3's next-mix/router/step-exact are weak. (e) Keep ~100 items for ep7-9 stacking and a final 4,000-seed confirmation; the requester submits any file >= +1.0 over NP2 on 4,000 fresh seeds and reports the board score as a note. 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}.\n",
  "spawn": [
    {
      "name": "ep4-flow",
      "mode": "research",
      "brief": "NP2 = `code` of https://api.imdnotdead.fun/artifacts/528a6da78583c6142644a552c86670f9d25c20e39e92f4de44deae05ddc8cecd with the block of `code` of https://api.imdnotdead.fun/artifacts/da313379a2e69e9286668865e06b18dfcae25732c82b934b0fd9c2ef0d8c2ff5 from `// Interior retail routing` to (excl.) `uint256 tradeRatio =` inserted before the former's `uint256 tradeRatio =`; sha256 51f1c1a9...; seeds 0..999 score 526.1156 (check).\nSETUP: clone github.com/benedictbrady/amm-challenge @6b6921f8d463314aa7c96234e1be25a25245f704 in your workspace (not /tmp); save EXACTLY this (not the objective's script) as scratch/setup.sh, run `sh scratch/setup.sh` once at the root, prefix later commands with `. scratch/env.sh && `:\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\nOn failure return blocked={step,error}, n 0.\nPAIR: amm_sim_rs.run_batch(candidate, np2, configs) with MatchRunner._build_configs's per-seed draws (default_rng(seed): size, rate, sigma; cfg.seed=seed); diff = candidate - NP2 edge per seed.\nTASK, one delta on NP2: {{mech}}\nTune only on seeds 10000..99999, other constants as NP2. Confirm ONCE vs NP2 on fresh seeds {{block}}..{{block}}+1999 (or more, to +9999).\nRETURN (markdown headings): delta (<=900 chars, each changed line); code (full Solidity, amm-match validate passes); sha256; tuning (grid, chosen, paired mean_diff per point); paired {n, mean_diff, se, worst} on the confirm seeds; fee_stats NP2 vs candidate: mean step-end bid, ask, bid-ask, mid slope per 10k retail Y, runs with bid>40 bps; blocked; next (<=300 chars).",
      "items": [
        {
          "key": "flat-a",
          "vars": {
            "mech": "FLATTEN THE FLOW RESPONSE. NP2's step-end mid fee is 33.71/35.74/37.79 bps by low/mid/high retail third (1.76 bps per 10k retail Y); rank 1's 34.12/35.45/36.68 (1.10). Damp the terms that raise the fee with flow (activity EMA, lambdaHat, sizeHat) by a shape change (concave transform, or flow over a slow EMA of itself) to slope ~1.1, low third unchanged.",
            "block": "2460000"
          }
        },
        {
          "key": "flat-b",
          "vars": {
            "mech": "FLATTEN THE FLOW RESPONSE. NP2's step-end mid fee is 33.71/35.74/37.79 bps by low/mid/high retail third (1.76 bps per 10k retail Y); rank 1's 34.12/35.45/36.68 (1.10). Damp the terms that raise the fee with flow (activity EMA, lambdaHat, sizeHat) by a shape change (concave transform, or flow over a slow EMA of itself) to slope ~1.1, low third unchanged.",
            "block": "2470000"
          }
        },
        {
          "key": "both-a",
          "vars": {
            "mech": "FLATTEN + ZERO LEAN. (a) NP2's step-end mid fee rises 1.76 bps per 10k retail Y, rank 1's 1.10: damp the flow terms (activity, lambdaHat, sizeHat) by a concave transform to slope ~1.1. (b) NP2's bid sits 1.02 bps over its ask, #1's are level: remove the mean lean (half up ask, half down bid, or a slow EMA of bid-ask), keep transient skew. Report a, b, both.",
            "block": "2480000"
          }
        },
        {
          "key": "both-b",
          "vars": {
            "mech": "FLATTEN + ZERO LEAN. (a) NP2's step-end mid fee rises 1.76 bps per 10k retail Y, rank 1's 1.10: damp the flow terms (activity, lambdaHat, sizeHat) by a concave transform to slope ~1.1. (b) NP2's bid sits 1.02 bps over its ask, #1's are level: remove the mean lean (half up ask, half down bid, or a slow EMA of bid-ask), keep transient skew. Report a, b, both.",
            "block": "2490000"
          }
        }
      ],
      "output": {
        "format": "markdown",
        "maxBytes": 64000
      },
      "merge": {
        "groupSize": 10,
        "brief": "Merge: one row per item (key, mechanism, confirm block, paired n, mean_diff, se, t=mean_diff/se, worst, fee_stats, blocked). Rank by t. Copy delta, sha256 and full code of every item with mean_diff >= 2*se."
      }
    },
    {
      "name": "ep4-lean",
      "mode": "research",
      "brief": "NP2 = `code` of https://api.imdnotdead.fun/artifacts/528a6da78583c6142644a552c86670f9d25c20e39e92f4de44deae05ddc8cecd with the block of `code` of https://api.imdnotdead.fun/artifacts/da313379a2e69e9286668865e06b18dfcae25732c82b934b0fd9c2ef0d8c2ff5 from `// Interior retail routing` to (excl.) `uint256 tradeRatio =` inserted before the former's `uint256 tradeRatio =`; sha256 51f1c1a9...; seeds 0..999 score 526.1156 (check).\nSETUP: clone github.com/benedictbrady/amm-challenge @6b6921f8d463314aa7c96234e1be25a25245f704 in your workspace (not /tmp); save EXACTLY this (not the objective's script) as scratch/setup.sh, run `sh scratch/setup.sh` once at the root, prefix later commands with `. scratch/env.sh && `:\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\nOn failure return blocked={step,error}, n 0.\nPAIR: amm_sim_rs.run_batch(candidate, np2, configs) with MatchRunner._build_configs's per-seed draws (default_rng(seed): size, rate, sigma; cfg.seed=seed); diff = candidate - NP2 edge per seed.\nTASK, one delta on NP2: {{mech}}\nTune only on seeds 10000..99999, other constants as NP2. Confirm ONCE vs NP2 on fresh seeds {{block}}..{{block}}+1999 (or more, to +9999).\nRETURN (markdown headings): delta (<=900 chars, each changed line); code (full Solidity, amm-match validate passes); sha256; tuning (grid, chosen, paired mean_diff per point); paired {n, mean_diff, se, worst} on the confirm seeds; fee_stats NP2 vs candidate: mean step-end bid, ask, bid-ask, mid slope per 10k retail Y, runs with bid>40 bps; blocked; next (<=300 chars).",
      "items": [
        {
          "key": "lean-a",
          "vars": {
            "mech": "ZERO THE BID-OVER-ASK LEAN. NP2's step-end bid sits 1.02 bps over its ask in every retail third; rank 1's are level (-0.13). Zero dirState skew, staleShift/attractShift and the aligned-trade boost one at a time (seeds 0..199) to find the lean's source; remove only its mean (half up ask, half down bid, or a slow EMA of bid-ask). Keep transient skew.",
            "block": "2500000"
          }
        },
        {
          "key": "lean-b",
          "vars": {
            "mech": "ZERO THE BID-OVER-ASK LEAN. NP2's step-end bid sits 1.02 bps over its ask in every retail third; rank 1's are level (-0.13). Zero dirState skew, staleShift/attractShift and the aligned-trade boost one at a time (seeds 0..199) to find the lean's source; remove only its mean (half up ask, half down bid, or a slow EMA of bid-ask). Keep transient skew.",
            "block": "2510000"
          }
        },
        {
          "key": "cap-a",
          "vars": {
            "mech": "CAP A STUCK SIDE. In run 476 NP2's mean bid was 18.9 bps above its ask (rank 1: 3.3); 90 NP2 runs have mean bid > 40 bps vs #1's 39. Add: cap |bid-ask| (tune 4..12 bps) and after k steps (tune 3..20, by timestamp) with no trade on a side pull it toward the other side by a fraction per step (tune 0.1..0.5). Report runs with bid>40.",
            "block": "2520000"
          }
        },
        {
          "key": "cap-b",
          "vars": {
            "mech": "CAP A STUCK SIDE. In run 476 NP2's mean bid was 18.9 bps above its ask (rank 1: 3.3); 90 NP2 runs have mean bid > 40 bps vs #1's 39. Add: cap |bid-ask| (tune 4..12 bps) and after k steps (tune 3..20, by timestamp) with no trade on a side pull it toward the other side by a fraction per step (tune 0.1..0.5). Report runs with bid>40.",
            "block": "2530000"
          }
        }
      ],
      "output": {
        "format": "markdown",
        "maxBytes": 64000
      },
      "merge": {
        "groupSize": 10,
        "brief": "Merge: one row per item (key, mechanism, confirm block, paired n, mean_diff, se, t=mean_diff/se, worst, fee_stats, blocked). Rank by t. Copy delta, sha256 and full code of every item with mean_diff >= 2*se."
      }
    }
  ],
  "read": [
    "ep3-base/decomp",
    "ep3-base/harness-a",
    "ep3-base/harness-b",
    "ep3-oracle/oracle-price",
    "ep3-oracle/oracle-full",
    "ep3-mech/merge-01",
    "ep3-mech/merge-02",
    "ep4-flow/flat-a",
    "ep4-flow/flat-b",
    "ep4-flow/both-a",
    "ep4-flow/both-b",
    "ep4-lean/lean-a",
    "ep4-lean/lean-b",
    "ep4-lean/cap-a",
    "ep4-lean/cap-b"
  ],
  "cancel": [],
  "wake": {
    "batches": [
      "ep3-base",
      "ep3-oracle",
      "ep4-flow",
      "ep4-lean"
    ],
    "afterMinutes": 240
  },
  "finish": false
}