{
 "notes": "EPISODE 1 (nothing had run; no notes, no results, no requester notes).\n\nCHECKED THIS EPISODE (by download, not from memory)\n- An artifact's id is the sha256 of its file: sha256sum of the HA download = 2801efc8...b690, same for T, RS2, replica, port. So a result handed to you is published at https://api.imd.fun/artifacts/<sha256sum of that file>: curl it to confirm, then name that URL in the next brief as the file to start from. Fallback if a result is not served there: pack its weights into the brief as 1e6 fixed-point integers (130 weights is about 1,000 characters).\n- HA artifact fields: `code` (25,543 chars, sha256 99e3a2ec... confirmed), `params` (W1 8x13, b1, W2 2x8, b2, feature_order/multipliers/offsets, clips +-4 inputs and 0..4 hidden, output unit 1 bps, anchor constants), `evidence` (URLs) and `input_sha256`. HA has NO Python port in it: every leg-1 item re-ports (RS2 port -> T -> HA), which is why leg-1 results must carry `port_zb64`.\n- Files and field hashes (all confirmed): T 6ac5e013b7b1fb4c5e7bdcdfec0aba28b16824e18ccf39500f258533879faffe `code` ebd9de9b...19b3; RS2 19f2ec857df536e8ab62ab1da89ec6623332521ce46849f15bccff402c63e1e5 `code` f24b6ca1...eaf2; RS2 float port d845a4b94eab87f23956fd1939c0135d955df212d1f3037f2a761c178cef7a0e `port_source` 9eac3553...e271 (also `differential_test_source`, the Gate A harness); replica e8a7a2af9039c24b8bb2d3b5fa1c9113606cbf5a480ac07d02ca26750f1752ea `replica_source` 1e4c44b4...040c (run_many(TH, seeds, procs) -> rows [edge, retail, arb, retail volume]; strategy functions strat_init/strat_after are swapped for the port); decomposition harness 33f54e81f3372088e9eced52c0174f310ac348af98ef5727b73785c088679194 `harness_source` (its `commands.setup_source` is the OLD setup script without numba and cma).\n- HA numbers from its artifact: replica speed 759 markets/s (8 processes, T port); pilot search = CMA-ES pop 16, 256 markets/generation, 413 generations in 44.3 min, monitor gain over T 1.15 (seeds 30000000-30002047), still rising; real +1.257 se 0.062 on 6020000-6020511 (retail +4.20, arb -2.94 vs T); gas afterSwap peak 231,381, init 243,147 (T: 225,483 / 243,115). So the 8-unit network costs about 5.9k gas, roughly 740 a unit, and about 13.6k is left under 245,000: room for some 16 more units without touching T. Init gas is already 243k: never add afterInitialize writes.\n- HA network in Solidity: 13 inputs in 1e6 fixed point from state at the end of afterSwap, clipped ReLU units, two outputs added to bid and ask fee in units of 1 bps, then clamped to [0, MAX_FEE]. The network does not see T's own bid/ask fee and is one network for every trade: leg 1 tests both gaps.\n- Repo commit and wheel URL answer 200. I did not run the setup here.\n- A brief is at most 3,000 characters filled, and the setup script alone is 960, so briefs lean on the goal text (SETUP, GATES, REAL ENGINE) being shown to each item. I ASSUMED items see the goal text; the brief gives a fallback (old setup script + `numba cma`). If leg-1 items report they could not see it, embed the rules in the next brief and cut the variant text.\n\nDECIDED\n- One batch `leg1`, 18 items, one brief with a per-item variant, all starting from HA's weights with the start policy equal to HA: net8-a/b/c/d (same 13-8-2, longer training, different optimisers), th-a/b/c (weights plus T's gas-free constants; th-c constants only), gated-a/b (two networks chosen by first-in-step), gated-c (two, chosen by trade side; four copies would push the result past 64,000 bytes), wide-a (16 units), wide-b (24), deep-a (second hidden layer), feat-a/b/c (extra inputs incl. T's own fees), mult-a/b (multiplicative outputs). Canary = first five (net8-a, th-a, gated-a, wide-a, feat-a). groupSize 25, so items are handed raw, not merged; all 18 are in `read`.\n- Why wide and not deep on one idea: +3.1 over HA is 2.5x what 44 minutes of training gave, and the pilot curve was rising slowly (1.04 at generation 220, 1.15 at 410), so longer training of the same 130 weights alone is unlikely to get there. Leg 1 finds which change of structure climbs fastest; later legs put the items into long training of the winner from its saved weights, as the requester asks.\n- Each result carries: gates A/B/C, curve, `holdout` (replica seeds 40000000-40008191, n 8192, gain over T and over HA: the common yardstick, never trained or selected on), `real` (T, HA and candidate on 512 fresh seeds: vs_T, vs_HA paired, retail/arb deltas), gas, `code`, `params`, `port_zb64` + `port_sha256` (zlib+base64 Python float port so the next leg resumes without re-porting), notes. Result size is the tight limit (64,000 bytes): HA `code` is 25.5k and each extra 8-unit network adds about 5k, so keep structures to what fits or ask for `code` zlib+base64 too.\n- Seeds used by leg1: real 7000000 + 1000*i .. +511 for item i = 0..17 (7,000,000-7,017,511); replica training from 100000000 + 10000000*i; monitor 30000000-30002047; holdout 40000000-40008191. NEXT real seeds: episode e starts at 7,000,000 + (e-1)*100,000 (episode 2 from 7,100,000), 1,000 apart per item, never reused. Keep the same monitor and holdout seeds in every leg so scores stay comparable; pick winners on holdout and real, since the monitor is selected on.\n\nNEXT EPISODE\n1. If the canary paused the batch: read `failures`; if the cause is the brief (goal text not visible, result over 64,000 bytes, time ran out before freezing), mend it and re-run with itemsFrom both; if it was machines, resume.\n2. Otherwise rank the 18 by holdout gain_over_HA (se about 0.01-0.02), check each against real vs_HA (se about 0.06) and discard any with a failed gate, any OOG, afterSwap peak over 245,000 or replica-vs-real disagreement over 0.15. Verify the winner yourself: sha256 of `code`, and that `port_zb64` unpacks to `port_sha256`.\n3. Spawn leg 2, about 40 items, from the best result's artifact URL (its `code`, `params`, `port_zb64`): most items long training of the winning structure with different seeds and optimisers; a few from the runner-up; a few that combine structures that each helped (for example gated + T's fees as inputs + constants). Tell items to check Gate A of the unpacked port against the winner's `code` (minutes, not a re-port) and to spend the rest on training. Ask again for `port_zb64` in every result.\n4. If no variant beats HA by more than about 0.3 on holdout, long training alone will not reach +3.1: spend a small batch on a gas-lean rewrite of T (identical fees, lower afterSwap peak) to fit a much larger network, and on training T's constants on the replica.\n\nPLAN FOR THE GOAL (10 episodes, 400 items; 18 spent now, 382 left)\n- Episodes 2-8: one leg each, about 40 items, always from the best frozen candidate so far (weights by artifact URL). Keep at least 40 items for the end.\n- Episode 9: confirmation batch: the best 2-3 frozen candidates, each on 2,048 or more fresh real seeds split over several items (64-seed chunks, T and HA run alongside), with gas_stats; a table batch fits (columns: candidate sha256, seed_start, n, mean_diff_vs_HA, se, oog, afterswap_max).\n- Episode 10: finish. The target is real gain over HA of about +3.1 (about +4.36 over T, board about 524.7) with 0 OOG and afterSwap peak <= 245,000. If it is not reached, finish with the best confirmed candidate and say how far it got.\n- wake is the batch settling, with 480 minutes as the backstop (canary plus the rest is two item-lengths; an early wake would burn an episode).",
 "spawn": [
  {
   "name": "leg1",
   "brief": "One training leg from fee policy HA. SETUP, GATES and REAL ENGINE of the goal text given with this brief apply in full. (Not given it? Setup is `commands.setup_source` of HA's `evidence.real_decomposition` artifact plus `numba cma` on its pip line.)\nFILES at https://api.imd.fun/artifacts/<id>, each download's sha256sum equal to its id: HA 2801efc8190e86318dd922d4a7179f63684d77a226047fc2f3c78232963eb690 (`code`, `params`, the others' field hashes in `input_sha256`); T 6ac5e013b7b1fb4c5e7bdcdfec0aba28b16824e18ccf39500f258533879faffe (`code`); RS2 port d845a4b94eab87f23956fd1939c0135d955df212d1f3037f2a761c178cef7a0e (`port_source`); replica e8a7a2af9039c24b8bb2d3b5fa1c9113606cbf5a480ac07d02ca26750f1752ea (`replica_source`).\n1 PORT. Extend the RS2 port to T, then to HA (13 inputs, 8 units, 2 outputs), run it in the replica, pass Gate A against HA `code` and Gate B (HA's real gain over T is 1.257: the replica's must be 1.107 to 1.407 on 4096+ markets). Measure markets per second.\n2 VARIANT {{variant}}. {{what}} The start policy must give HA's fees exactly (new parameters start neutral). Before training, compile a Solidity of this structure and run 16 real markets: 0 OOG, afterSwap peak <= 245,000, or shrink it and say so.\n3 TRAIN on the replica to maximise mean edge minus T's on shared market seeds: random seed {{seed}}, markets from replica seed {{train_start}} up, a fresh block each generation. Search 35 minutes or more, as long as your time limit allows with 30 minutes kept for step 4, in saved segments under 8 minutes. About every 5 minutes score the best so far on monitor seeds 30000000-30002047: [minutes, gain over T, se]. Choose the final policy by monitor score only.\n4 FREEZE. Round to fixed point, write the full Solidity (contract Strategy, `amm-match validate` passes), pass Gate C, score the frozen port once on replica holdout seeds 40000000-40008191, then run T, HA and the frozen Solidity once each on real seeds {{real_start}} to +511.\nRESULT, one JSON object under 60,000 bytes: `variant`, `blocked` (null or {step,error}), `gates` (A, B, C: passed, number), `sim_markets_per_s`, `search_minutes`, `curve`, `holdout` {n, gain_over_T, se, gain_over_HA, se_HA}, `real` {seeds, vs_T and vs_HA (paired), retail_delta and arb_delta vs HA}, `gas` {afterSwap_max_ok, init_max_ok, oog, other_failures}, `valid`, `code` (the full Solidity), its `sha256`, `params` (every trained number, with shapes and scaling), `port_zb64` (base64 of the zlib-compressed source of your frozen float port, one Python module whose docstring says how to load `params` and score seeds: the next leg resumes from it), `port_sha256`, `notes` (what failed, what to train next). Measured numbers only: report a failed gate, an OOG or a loss to HA as it is, `valid` false.",
   "items": [
    {
     "key": "net8-a",
     "vars": {
      "variant": "net8-a",
      "what": "Structure unchanged: train the 130 network weights from HA's values, T untouched. Use CMA-ES from a small initial step (about 0.05), raising the markets per generation as gains shrink.",
      "seed": "101",
      "train_start": "100000000",
      "real_start": "7000000"
     }
    },
    {
     "key": "th-a",
     "vars": {
      "variant": "th-a",
      "what": "Train the 130 network weights together with T's numeric constants, which cost no gas (fee coefficients, decays, caps, the anchor's k's and N), each within 0.5x to 2x of its HA value, decays below 1.",
      "seed": "102",
      "train_start": "110000000",
      "real_start": "7001000"
     }
    },
    {
     "key": "gated-a",
     "vars": {
      "variant": "gated-a",
      "what": "Use two copies of the 13-8-2 network, one for the first trade of a step (firstInStep) and one for later trades: one copy runs per call, so gas stays flat. Each starts as HA's weights; train them all.",
      "seed": "103",
      "train_start": "120000000",
      "real_start": "7002000"
     }
    },
    {
     "key": "wide-a",
     "vars": {
      "variant": "wide-a",
      "what": "Widen the hidden layer to 16 units (more if your gas probe allows; report gas per unit): new units get small random input weights and zero output weights; train all weights.",
      "seed": "104",
      "train_start": "130000000",
      "real_start": "7003000"
     }
    },
    {
     "key": "feat-a",
     "vars": {
      "variant": "feat-a",
      "what": "Add up to 6 inputs the contract already holds, weights starting at zero: T's own bid and ask fee must be among them. Keep 8 units; name each input and its scaling in `params`.",
      "seed": "105",
      "train_start": "140000000",
      "real_start": "7004000"
     }
    },
    {
     "key": "net8-b",
     "vars": {
      "variant": "net8-b",
      "what": "Structure unchanged: train the 130 network weights from HA's values, T untouched. Use an antithetic evolution strategy with Adam (population 64 or more), not CMA-ES.",
      "seed": "106",
      "train_start": "150000000",
      "real_start": "7005000"
     }
    },
    {
     "key": "net8-c",
     "vars": {
      "variant": "net8-c",
      "what": "Structure unchanged: train the 130 network weights from HA's values, T untouched. Use CMA-ES with population 32 and 512+ markets a generation, restarting the step size when the monitor stalls.",
      "seed": "107",
      "train_start": "160000000",
      "real_start": "7006000"
     }
    },
    {
     "key": "net8-d",
     "vars": {
      "variant": "net8-d",
      "what": "Structure unchanged: train the 130 network weights from HA's values, T untouched. Optimiser and block size are yours: whatever climbs fastest at your measured speed.",
      "seed": "108",
      "train_start": "170000000",
      "real_start": "7007000"
     }
    },
    {
     "key": "th-b",
     "vars": {
      "variant": "th-b",
      "what": "Train the 130 weights and T's numeric constants, which cost no gas (fee coefficients, decays, caps, the anchor's k's and N), each within 0.5x to 2x of its HA value, decays below 1, in alternating phases.",
      "seed": "109",
      "train_start": "180000000",
      "real_start": "7008000"
     }
    },
    {
     "key": "th-c",
     "vars": {
      "variant": "th-c",
      "what": "Freeze the network; train only T's numeric constants, which cost no gas (fee coefficients, decays, caps, the anchor's k's and N), each within 0.5x to 2x of its HA value, decays below 1.",
      "seed": "110",
      "train_start": "190000000",
      "real_start": "7009000"
     }
    },
    {
     "key": "gated-b",
     "vars": {
      "variant": "gated-b",
      "what": "Use two copies of the 13-8-2 network, one for the first trade of a step (firstInStep) and one for later trades: one copy runs per call, so gas stays flat. Each starts as HA's weights; train them all.",
      "seed": "111",
      "train_start": "200000000",
      "real_start": "7010000"
     }
    },
    {
     "key": "gated-c",
     "vars": {
      "variant": "gated-c",
      "what": "Use two copies of the 13-8-2 network, one for trade.isBuy true and one for false: one copy runs per call, so gas stays flat. Each starts as HA's weights; train them all.",
      "seed": "112",
      "train_start": "210000000",
      "real_start": "7011000"
     }
    },
    {
     "key": "wide-b",
     "vars": {
      "variant": "wide-b",
      "what": "Widen the hidden layer to 24 units, or the most your gas probe allows (report gas per unit): new units get small random input weights and zero output weights; train all weights.",
      "seed": "113",
      "train_start": "220000000",
      "real_start": "7012000"
     }
    },
    {
     "key": "deep-a",
     "vars": {
      "variant": "deep-a",
      "what": "Add a second hidden layer of 8 clipped units before the outputs, starting as an exact pass-through of HA; train all weights.",
      "seed": "114",
      "train_start": "230000000",
      "real_start": "7013000"
     }
    },
    {
     "key": "feat-b",
     "vars": {
      "variant": "feat-b",
      "what": "Add up to 6 inputs the contract already holds, weights starting at zero, among them T's own bid and ask fee, the fast-slow price gap and the step's trade count; name each input and its scaling in `params`.",
      "seed": "115",
      "train_start": "240000000",
      "real_start": "7014000"
     }
    },
    {
     "key": "feat-c",
     "vars": {
      "variant": "feat-c",
      "what": "Add T's own bid and ask fee as inputs (weights zero) and widen to 12 units: new units get small random input weights and zero output weights; train all weights.",
      "seed": "116",
      "train_start": "250000000",
      "real_start": "7015000"
     }
    },
    {
     "key": "mult-a",
     "vars": {
      "variant": "mult-a",
      "what": "Give the network 4 outputs so it scales as well as shifts: fee = T fee x (1 + m) + shift for bid and for ask, m clipped to -0.5..1, its weights zero at the start; train all weights.",
      "seed": "117",
      "train_start": "260000000",
      "real_start": "7016000"
     }
    },
    {
     "key": "mult-b",
     "vars": {
      "variant": "mult-b",
      "what": "Give the network 4 outputs so it scales as well as shifts: fee = T fee x (1 + m) + shift for bid and for ask, m clipped to -0.5..1, its weights zero at the start; add T's bid and ask fee as inputs; train all weights.",
      "seed": "118",
      "train_start": "270000000",
      "real_start": "7017000"
     }
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "merge": {
    "groupSize": 25,
    "brief": "One row per item: variant, valid, gates passed, search_minutes, holdout gain_over_HA and its se, real vs_HA mean_diff and se, afterSwap_max_ok, oog. Copy the numbers as given; add nothing."
   }
  }
 ],
 "read": [
  "leg1/net8-a",
  "leg1/th-a",
  "leg1/gated-a",
  "leg1/wide-a",
  "leg1/feat-a",
  "leg1/net8-b",
  "leg1/net8-c",
  "leg1/net8-d",
  "leg1/th-b",
  "leg1/th-c",
  "leg1/gated-b",
  "leg1/gated-c",
  "leg1/wide-b",
  "leg1/deep-a",
  "leg1/feat-b",
  "leg1/feat-c",
  "leg1/mult-a",
  "leg1/mult-b"
 ],
 "cancel": [],
 "wake": {
  "batches": [
   "leg1"
  ],
  "afterMinutes": 480
 },
 "finish": false
}