{
 "notes": "EPISODE 1 (of 12). Items used after this episode: at most 19 of 300. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, everywhere.\n\nWHAT I READ AND MEASURED BEFORE DECIDING (on the episode machine, from the named artifacts; no engine run, no report seed):\n1. Tables. QLX5 holds five tables in one QPL1 blob, 10,160 bytes, the same bytes in the replica's tables.hpp and in `bytes constant QPL` of the contract. Table = sd-level knots x row knots x column knots; per (level,row) record an int16 first node then int8 column deltas; node x scale = bps. t0 arbitrage 2x24x11 (528 nodes, scale 0.25 bps); t1 first-retail synced 3x43x30 (3,870, 0.5); t2 first-retail unsynced 4x28x13 (1,456, 0.5); t3 later-retail synced 3x36x26 (2,808, 1.0); t4 later-retail unsynced 3x17x10 (510, 0.5). Level knots are sd levels 0, 3 and 7 (0, 12 and 34 bps); t0 has 0 and 7 only. The contract reads nodes straight from the blob with knots and offsets in qt(): a corrected table with the same knots is a new hex literal of equal length, so source characters (47,230), deployed bytes (22,440) and gas should not move. A correction must keep each first node in int16 and each column delta in int8.\n2. Tables 2 and 4 look unused by QLX5: changing their scale by +-3% changed no edge at all on 256 seeds (64000..64255), difference exactly 0 on every seed. The synced flag is set on every non-arbitrage trade unless the rival price is exactly unchanged. So the search is on t0, t1, t3 only (7,206 nodes). The harness item is asked to confirm it by lookup counts.\n3. Global scale is already near its optimum (256 seeds, paired, gain vs base): t0 x0.97 -0.56 (se 0.05), x1.03 -0.89 (0.07); t1 -0.47 (0.03), -0.42 (0.03); t3 -0.23 (0.02), -0.15 (0.02). A quadratic through these puts the best rescale within 0.4% of 1, worth under +0.01 a table. So any gain must come from the shape of the tables (regions where the model was wrong), not their level; curvature is steep, so corrections of about a bps on a well-visited band are already large.\n4. Replica parity depends on the host. Built here with zig c++ (no g++ on the machine), QLX5 against the 512 engine rows gave mean diff -0.0016, se 0.0026, max |diff| 0.49, 104 of 512 within 1e-6; constant-fee edges differ from the engine at 1e-11. Last-bit libm differences flip rare tell decisions. No bias, so paired gains on one build stand; the briefs say to record parity and fail only when |mean diff| > 0.01.\n5. Compiler: the PyPI wheel ziglang 0.13.0 (sha256 3ce0c9f16547e5d61b32e0d226926e9a2552ef4b91fccf7ab5ea1a623a77824b), unzipped, builds the replica in 45 s with `zig c++ -O3 -std=c++20 -ffp-contract=off`. Speed here: 28 QLX5 runs a second on 8 CPUs (the artifact reports 6.4 per core-second with g++). The briefs' budgets assume 28.\n6. The replica's sim refuses seeds at or above 10,200,000. The kit's engine_eval accepts only 9700000..9700511; engine items work from a copy with the seed check widened to their block.\n7. Python reference port: https://api.imd.fun/artifacts/60dc237fa0a4d42f3b6e2d2bed61c1a2df08d27c31ccd95cce508ee9c8689de4 (qlxcore.py, mktables.py reading tables out of a .sol, evmdiff.py, pyreplay.py). Replica trace line: is_buy, amountX, amountY, timestamp, reserveX, reserveY, bidFee, askFee as WAD integers.\n\nGATES, AS I DEFINED THEM (the objective names T, F, G without defining them; say so in the write-up): T = the tables decoded from the new .sol equal base node + correction for every node (by the harness decoder in t1-sol, by the Python port's mktables.py in t1-tf) and the source differs from QLX5 in the hex literal and one comment line only. F = on seeds 9700000..9700003 every callback's bidFee and askFee from the compiled contract in a local EVM equal the replica's with the corrected tables, 0 mismatches, with a zero-correction control against QLX5. G = 0 OOG or revert, afterSwap peak <= 245,000, source <= 50,000 characters, runtime <= 24,576 bytes, on engine screening seeds 9700000..9700127. If the requester means something else by T, F or G, change the briefs.\n\nDECIDED: one pipeline, eight batches, each stage gated on `advance` (true), all {linux-x64, 8 CPUs}, at most 5 items a batch.\nt1-harness (h): sim with delta= and visits=, qpl.py (decode, encode, project, patch_sol), evalx.py, test.sh; result carries patch_zb64 to lay over the replica a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b, parity, table_use.\nt1-map (t0, t1a, t1b, t3a, t3b; waits on the harness, batch pairing): visit weights and +-1 bps finite differences on 48 groups each (level knot x row band x column band, bands of equal visit weight), choose seeds only; grad, z, curv, newton step and predicted gain per group; carries the harness by value. t0 = table 0 knots 0,1; t1a = table 1 knots 0,1; t1b = table 1 knot 2; t3a, t3b likewise.\nt1-es (same keys, item pairing): ES on the groups with |z| >= 1.5 (16 at most), 128-seed generations from 64000..65023, chosen on all 1,024, reported once on 10000..12047; result has delta_zb64, choose, gain_vs_base (report), map_url.\nt1-join (c; waits for t1-es settled): sums the corrections with choose gain - se > 0, also x0.5 and x0.75 and each alone; chooses on 64000..65023, reports once on 10000..12047; advance when the report gain >= 0.03.\nt1-sol (c) -> t1-tf (c) -> t1-gas (c): contract with gate T; gates T and F; gate G. Each carries code_zb64 and join_url forward.\nt1-engine (b0..b3; waits on t1-gas, batch pairing): 256 fresh engine seeds each against QLX5, early stop when mean + 2 se < 0.04; rows_zb64 per seed so the four blocks can be pooled exactly.\n\nSEED LEDGER. Replica: choose 64000..65023 (map and ES choose here; selection bias lives here), report 10000..12047 (one run per ES item and one for the join: six looks so far; count them). Engine fresh blocks handed out: 10,400,000..10,401,023 to t1-engine b0..b3. The next fresh block starts at 10,401,024. Never reuse a block for another candidate; a block run early-stopped is spent.\n\nNEXT EPISODE, BY OUTCOME.\n- Harness failed or advance false: read why; mend its brief (compiler, parity rule, patch size) and spawn the pipeline again under new names (t2-...).\n- t1-map refused or cancelled because of the check with batch pairing: the harness result will be handed; spawn the map with the harness's artifact URL (sha256 of the handed file) written into the brief, no `after`.\n- Map landed, ES weak (join advance false): read the map z-scores. If few groups reach |z| >= 3 on 768 seeds, the tables are near-optimal at this band size: go finer only where |z| is largest (split those bands in two along rows and columns, single knots for the most visited), and try shapes the bands cannot express (a tilt along rows within a band; a shift of the whole table along the row axis by a fraction of a knot, which is a price-offset error). Give the map 1,024 seeds for the top groups before more ES.\n- Join advance true but an engine block early-stopped or pooled gain < +0.04: compare replica report gain with engine gain per block; if the engine is lower by more than 2 se, suspect choose-set overfit, widen the choose set (add 60000..61023) and shrink the correction.\n- Pooled engine gain over the four blocks >= +0.04 with pooled mean - 2 se > 0, 0 OOG, peak <= 245,000: that contract is the one to bring back (>= 1,024 fresh seeds met). Keep searching for more only if items and episodes remain; never brief a submission (the requester asks the user).\n- The goal needs +0.12 and finding 3 says level changes give nothing; be ready to report that direct tuning yields less, with the map as evidence, and finish rather than spend items on noise.\nTo cite a result in a later brief use https://api.imd.fun/artifacts/<sha256 of the handed result file>, full 64 characters.",
 "spawn": [
  {
   "name": "t1-harness",
   "brief": "One item: build the table-tuning harness for QLX5. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nReplica: https://api.imd.fun/artifacts/a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b, whose `code_zb64` (base64 of zlib of tar) is a C++20 simulator (see its README). QLX5 source (sha256 e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40) is `code_zb64.QLX5` (base64 of zlib) of https://api.imd.fun/artifacts/1ef80bfb6d6791b877b1f4048a5e63cf2ae54153e6e8763ae3f8ab13132dfb15; its `rows_zb64` holds 512 engine rows (column QLX5, seeds 10010512..10011023).\nThe five fee tables are the QPL1 blob in tables.hpp (the 10,160 bytes of `bytes constant QPL` in the contract): per (level,row) record an int16 first node, then int8 column deltas.\n\nWrite under test/scratch/ (caches too):\n1. sim, extended: `delta=FILE` adds integer node deltas (lines `table level row col add`, knot indices) after the tables load; `visits=FILE` writes per node the summed interpolation weight of every fee lookup, bid and ask.\n2. qpl.py: decode blob to nodes; encode nodes to a blob of the same length and knots, raising when a first node leaves int16 or a column delta leaves int8; project(nodes) to the nearest encodable table; patch_sol(source, nodes) replacing the hex literal only.\n3. evalx.py: runs delta files and the base on given seeds on all CPUs, paired by seed: mean gain, se = sd(diff, n-1)/sqrt(n), n, per-seed rows; optional stop when mean + 2 se < bar at a 128-seed check.\n4. test.sh: runs the checks below, non-zero exit on any failure.\n\nChecks. (a) Zero delta equals the unpatched sim bit for bit on 64 seeds. (b) QLX5 against the 512 engine rows: mean diff, se, max |diff|, count within 1e-6. Hosts differ in libm's last bit (512 of 512 on the reference hosts; 104 elsewhere, mean -0.0016, se 0.0026): record it, and fail only when |mean diff| > 0.01. (c) Decode then encode is byte-identical; patch_sol with unchanged nodes returns the QLX5 source byte for byte. (d) +1 on one node changes that node only; each lookup's weights sum to 1.\nAlso measure on 64000..64255 each table's share of lookups (tables 2 and 4 look unused: confirm) and runs per second.\nNo g++: the PyPI wheel ziglang 0.13.0, unzipped, gives `ziglang/zig c++ -O3 -std=c++20 -ffp-contract=off` (set ZIG_GLOBAL_CACHE_DIR under test/scratch/); it builds the replica.\n\nresult.json must contain: credit; advance (true only when test.sh passes); gain_vs_base and se (the parity mean diff and its se; say so in `metric`); n; seeds; source_sha256 (QLX5's); patch_zb64 (base64 of zlib of a tar of only the files you added or changed, at most 24,000 characters); patch_sha256; build (exact commands, compiler, version); parity; table_use; runs_per_s; usage; not_done.",
   "items": [
    {
     "key": "h",
     "vars": {}
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   }
  },
  {
   "name": "t1-map",
   "brief": "One item: measure how QLX5's edge responds to the nodes of fee table {{table}}, level knots {{levels}} (knot indices), on the replica. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nSetup. The harness result of batch {{after.batch}} is among your inputs: unpack `code_zb64` (base64 of zlib of tar) of the replica https://api.imd.fun/artifacts/a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b under test/scratch/, unpack the harness `patch_zb64` over it, build as its `build` says, run its test.sh and follow its `usage`. If test.sh fails, write advance false with why and stop.\nSeeds: only 64000..65023 here. Never 10000..12047.\n\n1. Visits: run QLX5 on 64000..64255 with `visits`; for table {{table}} give each node its share of the table's total weight.\n2. Groups: for each level knot in {{levels}}, cut the row knots into {{rb}} contiguous bands and the column knots into {{cb}} contiguous bands, each band holding as nearly equal a share of that level's visit weight as whole knots allow (at least one knot a band). A group is one level knot x one row band x one column band: {{groups}} groups.\n3. For each group and each sign, the correction is +d or -d on all its nodes, d = 1 bps = {{unit}} node units, projected to encodable. Evaluate all against the base on 64000..64255, paired by seed (no early stop here). Per group: g_plus, g_minus with se; grad = (g_plus - g_minus)/2 per bps, its se from the per-seed half differences; z = grad/se; curv = g_plus + g_minus per bps squared.\n4. Refine: with the time left (stop computing 35 minutes after you began), measure the 12 groups of largest |z| again on 64256..64767 and give them pooled over all 768 seeds.\n5. For a group with |z| >= 2 and curv < 0: newton = -grad/(2 curv) bps, clipped to +-2; predicted = grad^2/(-4 curv).\n\nresult.json must contain: credit; table; levels; advance (true when steps 1 to 3 are complete); gain_vs_base (the sum of `predicted`: a prediction from this map, not a measured gain; say so in `metric`); se (root sum of squares of the predictions' errors); n; seeds; source_sha256 (e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40); base_mean; band_edges; groups, a list of [id, level, row_first, row_last, col_first, col_last, nodes, visit_share, g_plus, se_plus, g_minus, se_minus, grad, grad_se, z, curv, newton, predicted, n] with `group_fields` naming them; runs; minutes; harness, the object with patch_zb64, patch_sha256, build and usage copied unchanged from the harness result; not_done. Keep it under 60,000 bytes.",
   "items": [
    {
     "key": "t0",
     "vars": {
      "table": "0",
      "levels": "0,1",
      "rb": "6",
      "cb": "4",
      "groups": "48",
      "unit": "4"
     }
    },
    {
     "key": "t1a",
     "vars": {
      "table": "1",
      "levels": "0,1",
      "rb": "6",
      "cb": "4",
      "groups": "48",
      "unit": "2"
     }
    },
    {
     "key": "t1b",
     "vars": {
      "table": "1",
      "levels": "2",
      "rb": "8",
      "cb": "6",
      "groups": "48",
      "unit": "2"
     }
    },
    {
     "key": "t3a",
     "vars": {
      "table": "3",
      "levels": "0,1",
      "rb": "6",
      "cb": "4",
      "groups": "48",
      "unit": "1"
     }
    },
    {
     "key": "t3b",
     "vars": {
      "table": "3",
      "levels": "2",
      "rb": "8",
      "cb": "6",
      "groups": "48",
      "unit": "1"
     }
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-harness",
    "pairing": "batch",
    "check": {
     "path": "advance",
     "equals": true
    }
   }
  },
  {
   "name": "t1-es",
   "brief": "One item: search a correction to QLX5's fee table {{table}}, level knots {{levels}}, with an evolution strategy on the replica. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nSetup. This item's map result is {{after.result}} (also among your inputs). From its `harness`: unpack `code_zb64` (base64 of zlib of tar) of the replica https://api.imd.fun/artifacts/a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b under test/scratch/, unpack the harness `patch_zb64` over it, build as its `build` says, run its test.sh and follow its `usage`. Its `groups` and `group_fields` define the node groups and what the map measured.\nParameters: one offset in bps for each group whose map |z| >= 1.5, at most 16 of them, largest |z| first; every other group stays 0. A node moves by round(offset x {{unit}}) node units; project to encodable before every evaluation.\nStart: 0.5 x `newton` where the map gives one, else 0.\nSearch: an evolution strategy with antithetic pairs (CMA-ES or (mu/mu, lambda)), population 12, first step 0.3 bps. Each generation draws 128 seeds from the choose set 64000..65023 and runs the base and all its candidates on those same seeds, paired. Stop searching 25 minutes after you began.\nChoose: on all of 64000..65023, evaluate the strategy's final mean, its two best other candidates, the start and the start doubled (the full newton step); stop a candidate early when mean + 2 se < 0 at a 128-seed check. Take the highest mean gain; when none has mean - se > 0 the correction is empty.\nReport: run the chosen correction once on 10000..12047 against the base. Use those seeds for nothing else and choose nothing on them. With an empty correction skip that run and write gain_vs_base 0.\n\nresult.json must contain: credit; table; levels; gain_vs_base, se, n, seeds (the report run: 2,048 seeds 10000..12047); choose (gain, se, n, seeds, and the candidates compared); advance (true when gain_vs_base >= 0.03); source_sha256 (e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40); offsets (group id to bps); delta_zb64 (base64 of zlib of the lines `table level row col add` for every changed node, sorted); delta_sha256 (of those lines); nodes_changed; generations; evaluations; curve (generation, mean gain, se); map_url, exactly \"{{after.result}}\"; not_done.",
   "items": [
    {
     "key": "t0",
     "vars": {
      "table": "0",
      "levels": "0,1",
      "rb": "6",
      "cb": "4",
      "groups": "48",
      "unit": "4"
     }
    },
    {
     "key": "t1a",
     "vars": {
      "table": "1",
      "levels": "0,1",
      "rb": "6",
      "cb": "4",
      "groups": "48",
      "unit": "2"
     }
    },
    {
     "key": "t1b",
     "vars": {
      "table": "1",
      "levels": "2",
      "rb": "8",
      "cb": "6",
      "groups": "48",
      "unit": "2"
     }
    },
    {
     "key": "t3a",
     "vars": {
      "table": "3",
      "levels": "0,1",
      "rb": "6",
      "cb": "4",
      "groups": "48",
      "unit": "1"
     }
    },
    {
     "key": "t3b",
     "vars": {
      "table": "3",
      "levels": "2",
      "rb": "8",
      "cb": "6",
      "groups": "48",
      "unit": "1"
     }
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-map",
    "pairing": "item",
    "check": {
     "path": "advance",
     "equals": true
    }
   }
  },
  {
   "name": "t1-join",
   "brief": "One item: join the per-table corrections of batch {{after.batch}} into one correction to QLX5's fee tables and measure it on the replica. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nInputs: that batch's results are among your inputs (up to five; a failed item's is missing). Each gives `delta_zb64` (base64 of zlib of lines `table level row col add`, knot indices, node units), its `choose` and report gains, and `map_url`. Fetch one map_url; from its `harness`: unpack `code_zb64` (base64 of zlib of tar) of the replica https://api.imd.fun/artifacts/a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b under test/scratch/, unpack the harness `patch_zb64` over it, build as its `build` says, run its test.sh and follow its `usage`.\nCandidates: (1) the sum of every correction whose choose gain - se > 0 (their node sets do not overlap); (2) that sum scaled by 0.5 and by 0.75, rounded to node units; (3) each such correction alone. Project each to encodable.\nChoose: evaluate all on 64000..65023 against the base, paired by seed, stopping a candidate early when mean + 2 se < 0 at a 128-seed check; take the highest mean gain.\nReport: run the chosen one once on 10000..12047 against the base; choose nothing on those seeds.\nWith no usable correction, write advance false, gain_vs_base 0 and why.\n\nresult.json must contain: credit; gain_vs_base, se, n, seeds (the report run on 10000..12047); choose (per candidate: gain, se, n); chosen; parts (the item keys used); advance (true when gain_vs_base >= 0.03); source_sha256 (e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40, the base contract); delta_zb64 and delta_sha256 of the chosen correction, in the input format; nodes_changed; max_abs_bps; per_table (nodes changed and largest move); harness (copied unchanged from the map result); not_done.",
   "items": [
    {
     "key": "c",
     "vars": {}
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-es",
    "pairing": "batch",
    "when": "settled"
   }
  },
  {
   "name": "t1-sol",
   "brief": "One item: write the Solidity contract that carries the corrected fee tables. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nInputs. The joined correction is {{after.result}} (also among your inputs): `delta_zb64` (base64 of zlib of lines `table level row col add`) and `harness`, whose qpl.py decodes, encodes and patches the table blob (unpack `code_zb64` (base64 of zlib of tar) of the replica https://api.imd.fun/artifacts/a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b under test/scratch/, unpack the harness `patch_zb64` over it, build as its `build` says, run its test.sh and follow its `usage`). QLX5 source: `code_zb64.QLX5` (base64 of zlib) of https://api.imd.fun/artifacts/1ef80bfb6d6791b877b1f4048a5e63cf2ae54153e6e8763ae3f8ab13132dfb15, sha256 e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40.\nChange: replace only the hex literal of `bytes constant QPL` with the corrected tables in the same encoding (10,160 bytes, same knots and offsets; int16 first node and int8 column deltas per record), and add one comment line after the existing header comments: tables corrected by direct tuning on the engine-faithful replica, policy, filter and tables by Taylor (gtmcknight). Nothing else changes.\nCompile as the kit's engine_eval.py compiles a Strategy (pinned solc 0.8.24, optimizer 200 runs, viaIR, paris). Kit: github.com/identity-md-launches/goal-3178-build-shared-evaluation-kit at 45e7563d1a29ffca9d608fdf60c90bf2624d2d01 (archive tarball; `bash setup_fast.sh --platform linux-x86_64 --cache $PWD/test/scratch/cache --scratch $PWD/test/scratch/rt`, then `. test/scratch/rt/env.sh`; docs/engine.md).\nGate T (tables): decoding the blob taken from your .sol gives base node + delta for every node of all five tables, and a diff against QLX5 shows the literal and the comment line only.\nLimits: source at most 50,000 characters; deployed runtime at most 24,576 bytes.\n\nresult.json must contain: credit; advance (true when gate T passes and both limits hold); gates with T \"pass\" or \"fail\"; gain_vs_base, se, n, seeds (copied from the joined result: its replica report run); source_sha256 (the new .sol); base_source_sha256; source_chars; runtime_bytes; runtime_sha256; code_zb64 (base64 of zlib of the .sol); delta_sha256; join_url, exactly \"{{after.result}}\"; not_done.",
   "items": [
    {
     "key": "c",
     "vars": {}
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-join",
    "pairing": "item",
    "check": {
     "path": "advance",
     "equals": true
    }
   }
  },
  {
   "name": "t1-tf",
   "brief": "One item: gates T and F for the corrected-table contract, against the references. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nInputs. Contract: `code_zb64` (base64 of zlib of the .sol) of {{after.result}} (also among your inputs); check it against `source_sha256`. Its `join_url` gives the correction (`delta_zb64`) and `harness` (unpack `code_zb64` (base64 of zlib of tar) of the replica https://api.imd.fun/artifacts/a1eef2f3dbbcbc7a1de9d15a2b22d1d25ac6d316a72efde67275b5d5a16ab16b under test/scratch/, unpack the harness `patch_zb64` over it, build as its `build` says, run its test.sh and follow its `usage`). Python reference port of QLX5: https://api.imd.fun/artifacts/60dc237fa0a4d42f3b6e2d2bed61c1a2df08d27c31ccd95cce508ee9c8689de4 (`code_zb64`, a tar: qlxcore.py, mktables.py that reads the tables out of a .sol, evmdiff.py, pyreplay.py). Base QLX5: `code_zb64.QLX5` of https://api.imd.fun/artifacts/1ef80bfb6d6791b877b1f4048a5e63cf2ae54153e6e8763ae3f8ab13132dfb15, sha256 e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40.\nGate T (tables against the Python reference): the port's table reader on the new source gives exactly base node + delta for every node.\nGate F (fees): for seeds 9700000..9700003 take the replica's callback trace with the corrected tables (`delta=FILE trace=FILE`, one seed a run; a line is is_buy, amountX, amountY, timestamp, reserveX, reserveY, bidFee, askFee as WAD integers). Replay each seed's callbacks in order through the compiled contract, afterInitialize then every afterSwap with the same TradeInfo, in a local EVM (forge, pyrevm or the kit's), and compare bidFee and askFee with the trace as exact integers. F passes with 0 mismatches over all callbacks. Control: the same replay with no delta against the base QLX5 must also give 0. Where practical, confirm the Python port with the corrected tables returns the same fees on one seed.\nKit: github.com/identity-md-launches/goal-3178-build-shared-evaluation-kit at 45e7563d1a29ffca9d608fdf60c90bf2624d2d01 (archive tarball; `bash setup_fast.sh --platform linux-x86_64 --cache $PWD/test/scratch/cache --scratch $PWD/test/scratch/rt`, then `. test/scratch/rt/env.sh`; docs/engine.md).\n\nresult.json must contain: credit; advance (true when T and F pass and the control is clean); gates with T and F, each \"pass\" or \"fail\"; callbacks; mismatches; first_mismatch; control; evm (what replayed); gain_vs_base, se, n, seeds (copied from the input: the replica report run); source_sha256; code_zb64 and join_url copied unchanged; not_done.",
   "items": [
    {
     "key": "c",
     "vars": {}
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-sol",
    "pairing": "item",
    "check": {
     "path": "advance",
     "equals": true
    }
   }
  },
  {
   "name": "t1-gas",
   "brief": "One item: gate G, gas, size and a clean engine run, for the corrected-table contract. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nInputs. Contract: `code_zb64` (base64 of zlib of the .sol) of {{after.result}} (also among your inputs); check it against `source_sha256`. Base QLX5: `code_zb64.QLX5` of https://api.imd.fun/artifacts/1ef80bfb6d6791b877b1f4048a5e63cf2ae54153e6e8763ae3f8ab13132dfb15, sha256 e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40.\nKit: github.com/identity-md-launches/goal-3178-build-shared-evaluation-kit at 45e7563d1a29ffca9d608fdf60c90bf2624d2d01 (archive tarball; `bash setup_fast.sh --platform linux-x86_64 --cache $PWD/test/scratch/cache --scratch $PWD/test/scratch/rt`, then `. test/scratch/rt/env.sh`; docs/engine.md).\nRun `engine_eval.run_batch` on the screening seeds 9700000..9700127 for the contract and for QLX5, the same seeds for both. It raises on any out-of-gas, revert, halt or bad return: count them as oog and fail.\nGate G passes when: oog is 0; the largest after_swap_peak_gas of the contract is at most 245,000; the source is at most 50,000 characters; the deployed runtime is at most 24,576 bytes.\nAlso give the paired screening difference, contract minus QLX5, with se = sd(diff, n-1)/sqrt(n). It decides nothing: these seeds are screening only.\nUse no seed at or above 10,200,000.\n\nresult.json must contain: credit; advance (true when G passes); gates with G \"pass\" or \"fail\"; peak_gas; oog; base_peak_gas; gain_vs_base, se, n, seeds (the screening pairs; say so in `metric`); replica (gain_vs_base, se, n, seeds copied from the input); source_sha256; source_chars; runtime_bytes; code_zb64 and join_url copied unchanged; seconds_per_seed; not_done.",
   "items": [
    {
     "key": "c",
     "vars": {}
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-tf",
    "pairing": "item",
    "check": {
     "path": "advance",
     "equals": true
    }
   }
  },
  {
   "name": "t1-engine",
   "brief": "One item: engine run on the fresh seeds {{first}}..{{last}} (256), corrected-table contract against QLX5, paired by seed. Credit Taylor (gtmcknight), github.com/gtmcknight/amm-sim@4812a6382311624e1506aca131ca35c378f930d9 research/solved, in every file you write and in result.json (`credit`): the policy, filter and tables are his.\n\nInputs. The gate-G result of batch {{after.batch}} is among your inputs: its `code_zb64` (base64 of zlib of the .sol) is the candidate; check it against `source_sha256`. Base QLX5: `code_zb64.QLX5` of https://api.imd.fun/artifacts/1ef80bfb6d6791b877b1f4048a5e63cf2ae54153e6e8763ae3f8ab13132dfb15, sha256 e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40.\nKit: github.com/identity-md-launches/goal-3178-build-shared-evaluation-kit at 45e7563d1a29ffca9d608fdf60c90bf2624d2d01 (archive tarball; `bash setup_fast.sh --platform linux-x86_64 --cache $PWD/test/scratch/cache --scratch $PWD/test/scratch/rt`, then `. test/scratch/rt/env.sh`; docs/engine.md).\n`engine_eval.run_batch` accepts only 9700000..9700511. Work from a copy under test/scratch/ whose seed check is widened to your block and nothing else: the same compile, the same config for each seed, one `amm_sim_rs.run_batch(X, VanillaStrategy, [config], 8)` a seed, the same failure rules. Run both contracts on every seed, in ascending order, 64 seeds at a time. Use your block only; touch no other seed at or above 10,200,000.\nAfter every 64 seeds score the pairs, candidate minus QLX5, as the kit's score.py does (mean_diff; se = sd(diff, ddof 1)/sqrt(n)), and stop early when mean_diff + 2 se < 0.04: the bar cannot be met, write what was run with advance false.\nAn out-of-gas, revert or halt is counted in `oog`, never skipped.\n\nresult.json must contain: credit; gain_vs_base, se, n, seeds (first and last seed actually run); complete (true when all 256 ran); advance (true when complete, oog is 0, peak_gas <= 245,000 and gain_vs_base > 0); peak_gas (the candidate's largest afterSwap gas) and oog; base_peak_gas; source_sha256; base_source_sha256 (e183e5bc3fb794b7067703b10a7da9920267aa5f4caa968e16ca101b02338f40); rows_zb64 (base64 of zlib of csv seed,base,candidate, unrounded); seconds_per_seed; engine (commit, wheel sha256, solc); not_done.",
   "items": [
    {
     "key": "b0",
     "vars": {
      "first": "10400000",
      "last": "10400255"
     }
    },
    {
     "key": "b1",
     "vars": {
      "first": "10400256",
      "last": "10400511"
     }
    },
    {
     "key": "b2",
     "vars": {
      "first": "10400512",
      "last": "10400767"
     }
    },
    {
     "key": "b3",
     "vars": {
      "first": "10400768",
      "last": "10401023"
     }
    }
   ],
   "output": {
    "format": "json",
    "maxBytes": 64000
   },
   "requires": {
    "platform": [
     "linux-x64"
    ],
    "minCpus": 8
   },
   "after": {
    "batch": "t1-gas",
    "pairing": "batch",
    "check": {
     "path": "advance",
     "equals": true
    }
   }
  }
 ],
 "read": [
  "t1-harness/h",
  "t1-map/t0",
  "t1-map/t1a",
  "t1-map/t1b",
  "t1-map/t3a",
  "t1-map/t3b",
  "t1-es/t0",
  "t1-es/t1a",
  "t1-es/t1b",
  "t1-es/t3a",
  "t1-es/t3b",
  "t1-join/c",
  "t1-sol/c",
  "t1-tf/c",
  "t1-gas/c",
  "t1-engine/b0",
  "t1-engine/b1",
  "t1-engine/b2",
  "t1-engine/b3"
 ],
 "cancel": [],
 "wake": {
  "batches": [
   "t1-engine"
  ],
  "afterMinutes": 600
 },
 "finish": false
}