# Setup Credit Taylor (gtmcknight) for the policy, filter, qm tables and replica. This item builds and runs the Gate F harness; it does not change qt1 or measure a new strategy. Pinned checkouts were placed side by side under `test/scratch/`: amm-challenge at `6b6921f8d463314aa7c96234e1be25a25245f704` and amm-sim at `4812a6382311624e1506aca131ca35c378f930d9`. All execution state and dependencies remained in that disposable scratch area. The [pinned setup script](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/setup-fast.sh) ran once from amm-challenge, exited 0, and validated StarterStrategy. Later Python execution sourced `scratch/env.sh`. Versions observed: Python 3.12.3, pyrevm 0.3.7, py-solc-x 2.1.0, amm-sim-rs 0.1.0.post1, solc 0.8.24. Instrumented engine shared-object SHA-256 matched `ff88b6353c2aad7342f0a26194f7347e78b9c3b38d683a7449006d423978cd14`. Extracted [qt1](https://api.imdnotdead.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40) Solidity is exactly 42,990 bytes with SHA-256 `c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca`. Its Python reference was extracted unchanged from the same artifact. The decoded [table blob](https://api.imdnotdead.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc) is exactly 10,167 bytes with SHA-256 `3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e`. Both hashes match the artifacts. Compiler output runtime is 20,605 bytes (cap 24,576). Before replay, unmodified [Taylor gates.py](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/gates.py) reproduced all four columns using `python3 -I`: ```text seed perfect-info gaussian+plain gaussian+qm lattice+qm 10000 448.261189 443.455598 443.522608 443.663520 10001 576.779199 571.463409 571.623551 571.977293 10002 531.886497 525.168028 525.865859 526.411631 ``` Unchanged qt1 QMRef also reproduced replica edges `443.101741 / 571.454483 / 525.908441` on seeds 10000..10002, with each absolute error below 0.0000005 against the stated six-decimal checks. These scores use the full default 10,000-step replica run. Calibration on seed 70032 reproduced the published pyrevm peak exactly: 194,051 gas, max fee difference 1.44775174487632e-06 bps, mean callback gas 123644.6815, no failures. Calibration is excluded from the requested 50-run totals. The complete 70000..70049 baseline was subsequently reproduced with the corrected harness: 50 runs, 100,000 callbacks, 200,000 fee-side comparisons; max error 5.82591715267335e-06 bps (seed 70031), peak 194,051 gas (seed 70032), mean 124776.889520 gas; no reverts or OutOfGas. These reproduce the published rounded baseline of 5.83e-6 bps / 194,051 peak / 124,776.9 mean. The requested-set maximum on seed 70091 is slightly larger, but the original calibration figures reproduce and every effective-fee comparison remains well below 0.01 bps. Baseline runs are also excluded from Gate F totals below. # Gate F **PASS for effective fees used by the replica.** Every requested callback was replayed and every bid/ask fee was compared. The following JSON contains local measurements from this harness, not copied performance claims from qt1's artifact. ```json { "contract": "qt1 Strategy.sol; sha256 c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca", "seeds": "70050..70099 (inclusive)", "runs": 50, "callbacks": 100000, "comparisons": 200000, "max_bps": 6.713282269497911e-06, "max_seed": 70091, "mean_bps": 1.6990309059933327e-07, "init_diff_bps": 0.0, "pyrevm_peak": 193983, "pyrevm_peak_seed": 70057, "pyrevm_mean": 124961.8586, "reverts": 0, "oog": 0 } ``` `comparisons` counts callback sides: 100,000 callbacks × two fees = 200,000. In addition, both initialization fees were compared on all 50 fresh deployments (100 side comparisons); their maximum absolute difference is `init_diff_bps`. `mean_bps` is the arithmetic mean of absolute callback-side errors. Gas peak and mean cover afterSwap only, using `evm.result.gas_used`, not the upstream adapter's rough gas estimates. Initialization used the same 245,000 call limit and cost 90,858 gas on every run. Deployment used 10,000,000 gas. No failure occurred in initialization, deployment or callbacks. Each seed drives [replica2.run](https://raw.githubusercontent.com/gtmcknight/amm-sim/4812a6382311624e1506aca131ca35c378f930d9/research/solved/replica2.py) through QMRef for the full default run. The wrapper records init fees and exactly the first 2,000 own-pool callbacks and their effective reference fees after `replica2.clampf`, preserving order. The wrapper forwards the original outputs unchanged to the replica, which applies the same clamp itself. Oracle fields are forwarded only to the Python policy; Solidity receives only the six TradeInfo fields. Amounts/reserves are converted exactly as `int(float * 1e18)`; timestamps remain integer steps. Each recorded trace is replayed on a fresh EVM deployment, initialized at 100e18 / 10000e18. The raw QMRef return is not always capped even though its internal fee state is capped; this matters at one callback, detailed under Problems. ABI selectors and WAD fee units follow the pinned [interface](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/IAMMStrategy.sol) and [executor](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/executor.py). Compilation uses the pinned [compiler](https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/evm/compiler.py): solc 0.8.24, optimizer 200, viaIR, Paris. Each afterSwap gets 245,000 gas. Per-run measurements (each row: 2,000 callbacks, 4,000 comparisons, zero reverts/OOG, zero init fee difference): | Seed | Max absolute error, bps | afterSwap peak gas | afterSwap mean gas | |---|---:|---:|---:| | 70050 | 1.49060760804877e-06 | 165238 | 125066.6980 | | 70051 | 1.57663248775974e-06 | 168204 | 125253.7785 | | 70052 | 1.3452681676962e-06 | 174183 | 125370.7965 | | 70053 | 1.74593685862978e-06 | 181685 | 124928.5980 | | 70054 | 1.1763419058286e-06 | 189139 | 125783.7360 | | 70055 | 1.57428846001006e-06 | 158909 | 123543.3650 | | 70056 | 1.2316495078598e-06 | 166488 | 126140.7855 | | 70057 | 8.91259444718573e-07 | 193983 | 126535.4805 | | 70058 | 2.79747051044887e-06 | 176814 | 126851.5290 | | 70059 | 1.41749461862441e-06 | 169396 | 124154.9035 | | 70060 | 1.23475784393097e-06 | 156177 | 122631.6110 | | 70061 | 2.92532777515508e-06 | 177847 | 126126.9420 | | 70062 | 1.17993545489803e-06 | 170463 | 126055.6135 | | 70063 | 3.21915729316335e-06 | 168657 | 125304.9905 | | 70064 | 1.26213356172605e-06 | 173739 | 126822.8125 | | 70065 | 1.4001417386611e-06 | 168962 | 123358.8470 | | 70066 | 1.58520399064221e-06 | 160794 | 122728.9215 | | 70067 | 1.87759449481184e-06 | 183458 | 126519.9545 | | 70068 | 1.18841203371189e-06 | 177337 | 125902.8930 | | 70069 | 1.51904274532308e-06 | 186949 | 123926.8115 | | 70070 | 3.75074026524869e-06 | 162202 | 123676.3990 | | 70071 | 1.06012551168155e-06 | 164055 | 124629.5540 | | 70072 | 1.21770444340983e-06 | 174407 | 123721.8750 | | 70073 | 1.18922428111665e-06 | 164984 | 123560.6820 | | 70074 | 1.46564229611297e-06 | 165191 | 125428.5890 | | 70075 | 1.42497880682713e-06 | 164568 | 123777.6795 | | 70076 | 1.35079778959546e-06 | 180744 | 126039.1520 | | 70077 | 1.195531213903e-06 | 185932 | 126336.7835 | | 70078 | 1.23616335917509e-06 | 168487 | 124374.7545 | | 70079 | 1.4473146563599e-06 | 160495 | 123899.6090 | | 70080 | 9.54354425347637e-07 | 173082 | 124972.3435 | | 70081 | 2.04628376743177e-06 | 172856 | 123934.8870 | | 70082 | 2.35701408477645e-06 | 168996 | 123234.9130 | | 70083 | 1.36747543844074e-06 | 169044 | 126027.5885 | | 70084 | 1.45425338438088e-06 | 185476 | 124925.8880 | | 70085 | 2.08036021786054e-06 | 175048 | 126109.4740 | | 70086 | 1.48306590098957e-06 | 175858 | 124150.3380 | | 70087 | 1.90927409407689e-06 | 175582 | 126004.7100 | | 70088 | 1.39661315932266e-06 | 176869 | 125092.2895 | | 70089 | 1.26179648327063e-06 | 178053 | 126266.1840 | | 70090 | 2.21946864532863e-06 | 192425 | 124483.4010 | | 70091 | 6.71328226949791e-06 | 168079 | 124257.1090 | | 70092 | 1.95129416097339e-06 | 165486 | 126106.3035 | | 70093 | 9.56485515790639e-07 | 162503 | 124803.6610 | | 70094 | 1.29955507292834e-06 | 173349 | 124639.7295 | | 70095 | 1.20431657701925e-06 | 192522 | 125823.6610 | | 70096 | 1.3033008526564e-06 | 172465 | 125945.4495 | | 70097 | 8.83874189117062e-07 | 165884 | 125198.6460 | | 70098 | 1.71899963014033e-06 | 168818 | 123047.7360 | | 70099 | 9.99780293275965e-07 | 170920 | 124614.4730 | Trace evidence: each trace is canonical JSON produced by the harness (`json.dumps` with separators `(',', ':')`, fields in insertion order). The SHA-256 of the ASCII concatenation of the 50 per-run SHA-256 hex strings, in ascending seed order, is `14857c5895cd8abf03f63f4e6ad946fbf4be7ef6f9fe802d4012797a83a4def8`. Traces are temporary scratch state; the complete harness below regenerates them. # Harness Complete `scratch/check.py`. Save this block in the pinned amm-challenge checkout. It requires the setup above, unchanged QMRef plus blob.bin, and the sibling pinned amm-sim checkout. Errors stop a seed's replay because later state would diverge; partial results fail the final completeness check. ```python #!/usr/bin/env python3 """Gate F harness. Credit Taylor (gtmcknight): policy, tables and replica. From amm-challenge, with scratch/env.sh sourced: python -I scratch/check.py STRATEGY.sol REFERENCE.py FIRST..LAST QMRef and blob.bin are colocated. Pinned replica is in sibling amm-sim. Traces and per-run measurements are persisted under scratch/. Compare effective replica fees: replica2 clamps returned values to [0, 0.1]. QMRef keeps clamped internal fees but can return an unclamped local variable. """ import argparse import hashlib import importlib.util import json from pathlib import Path import sys ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT.parent / 'amm-sim/research/solved')) import replica2 from amm_competition.evm.compiler import SolidityCompiler from pyrevm import EVM LIMIT = 245000 WAD = 10**18 # Local EVM caller identity; not an owner/recipient setting. CALLER = '0x2000000000000000000000000000000000000002' class Recorded: wants_j = True def __init__(self, policy): self.policy = policy self.rows = [] self.clipped = [] def init(self, *args): fees = self.policy.init(*args) self.initial = tuple(replica2.clampf(f) for f in fees) return fees def on_trade(self, *args): fees = self.policy.on_trade(*args) if len(self.rows) < 2000: effective = [replica2.clampf(f) for f in fees] if list(fees) != effective: self.clipped.append({"index":len(self.rows),"raw":list(fees),"effective":effective}) buy, ax, ay, t, x, y = args[:6] self.rows.append(([int(buy), int(ax*WAD), int(ay*WAD), int(t), int(x*WAD), int(y*WAD)], effective)) return fees def call(evm, address, selector, values): calldata = bytes.fromhex(selector)+b''.join(v.to_bytes(32,'big') for v in values) try: output = evm.message_call(caller=CALLER, to=address, calldata=calldata, value=0, gas=LIMIT) except Exception as exc: result = evm.result return None, getattr(result,'gas_used',LIMIT), str(exc)+' '+str(getattr(result,'reason','')) result = evm.result if not result.is_success or len(output)!=64: return None, result.gas_used, str(result.reason) return [int.from_bytes(output[i:i+32],'big')/WAD for i in (0,32)], result.gas_used, None def diffs(actual, expected): return [abs(a-b)*1e4 for a,b in zip(actual,expected)] def main(): ap=argparse.ArgumentParser(description=__doc__) ap.add_argument('contract',type=Path) ap.add_argument('reference',type=Path) ap.add_argument('seeds',help='inclusive FIRST..LAST') args=ap.parse_args() first,last=map(int,args.seeds.split('..')) if last.001: print(json.dumps({'mismatch_seed':seed,'index':index,'trade':trade,'expected':expected,'actual':actual,'delta':delta}),file=sys.stderr,flush=True) row['max_bps']=max(row['max_bps'],*delta) row['sum_bps']+=sum(delta); row['comparisons']+=2 runs.append(row) (directory/f'{seed}.json').write_text(json.dumps(row,indent=2)+'\n') print(json.dumps(row),file=sys.stderr,flush=True) maximum=max(runs,key=lambda r:r['max_bps']); peak=max(runs,key=lambda r:r['peak']) count=sum(r['comparisons'] for r in runs) summary={'contract':'qt1 Strategy.sol; sha256 '+hashlib.sha256(args.contract.read_bytes()).hexdigest(), 'seeds':args.seeds,'runs':len(runs),'callbacks':sum(r['callbacks'] for r in runs), 'comparisons':count,'max_bps':maximum['max_bps'],'max_seed':maximum['seed'], 'mean_bps':sum(r['sum_bps'] for r in runs)/count if count else None, 'init_diff_bps':max(r['init_diff_bps'] for r in runs), 'pyrevm_peak':peak['peak'],'pyrevm_peak_seed':peak['seed'], 'pyrevm_mean':sum(r['gas_sum'] for r in runs)/sum(r['gas_calls'] for r in runs), 'reverts':sum(r['reverts'] for r in runs),'oog':sum(r['oog'] for r in runs)} (directory/'summary.json').write_text(json.dumps(summary,indent=2)+'\n') print(json.dumps(summary,indent=2)) if (summary['max_bps']>.01 or summary['init_diff_bps']>.01 or summary['reverts'] or summary['oog'] or count!=len(runs)*4000): raise SystemExit(1) if __name__=='__main__': main() ``` # Commands Commands below record the work performed, including inspection and diagnostics. Repository-relative paths start at the assignment workspace unless a checkout working directory is stated. Polling running commands used the tool's session polling (no additional shell commands). File-writing heredoc bodies are identified where already included in this result instead of duplicating them. Download/install commands invoked inside setup-fast.sh are defined by the pinned script linked above; it was invoked only once. 1. Workspace inspection: ```sh pwd; rg --files -g '!*lock*' -g '!lib/**' | head -40 ``` 2. Pinned clones: ```sh mkdir -p test/scratch git clone https://github.com/benedictbrady/amm-challenge test/scratch/amm-challenge && git -C test/scratch/amm-challenge checkout 6b6921f8d463314aa7c96234e1be25a25245f704 git clone https://github.com/gtmcknight/amm-sim test/scratch/amm-sim && git -C test/scratch/amm-sim checkout 4812a6382311624e1506aca131ca35c378f930d9 cat test/scratch/amm-sim/setup-fast.sh rg --files test/scratch/amm-sim/research/solved cat test/scratch/amm-challenge/contracts/src/IAMMStrategy.sol ``` 3. From amm-challenge: `sh ../amm-sim/setup-fast.sh` (once, exit 0). 4. Fetch the two artifact inputs; inspect replica and an existing check: ```sh mkdir -p test/scratch/sources curl -fLsS https://api.imdnotdead.fun/artifacts/8a6e303b662e1a5ea9bb47f31acedd3988ef65b3ddb66d074517aa59ad41ca40 -o test/scratch/sources/Q.md curl -fLsS https://api.imdnotdead.fun/artifacts/17d249ab0c33fc44931d9b105cf3f9e3846a560bd518b67310c2a56defacdecc -o test/scratch/sources/Data.md cat test/scratch/amm-sim/research/solved/fixedcheck2.py cat test/scratch/amm-sim/research/solved/replica2.py head -25 test/scratch/sources/Q.md head -12 test/scratch/sources/Data.md rg -n '^##|sha256|class QMRef|pyrevm|EVM|def check|def compile' test/scratch/sources/Q.md rg -n '^##|sha256' test/scratch/sources/Data.md rg -n 'pyrevm|gas_used|message_call' test/scratch/amm-challenge/amm* -g '*.py' cat test/scratch/amm-challenge/amm_competition/evm/executor.py | head -165 sed -n '350,365p' test/scratch/sources/Q.md sed -n '446,545p' test/scratch/sources/Q.md cat test/scratch/amm-sim/research/solved/gates.py | head -70 ``` 5. Wrote `test/scratch/extract.py` with a Python heredoc, then ran `python3 -I test/scratch/extract.py`. Complete extraction logic: ```python # Credit Taylor (gtmcknight): policy and replica. import re, pathlib, base64, hashlib root=pathlib.Path(__file__).resolve().parent q=(root/'sources/Q.md').read_text(); d=(root/'sources/Data.md').read_text() s=root/'amm-challenge/scratch' for title,name in [('Strategy.sol','Strategy.sol'),('Python reference','qmref.py')]: section=q.split('## '+title,1)[1] code=re.search(r'```[^\n]*\n(.*?)```',section,re.S)[1] (s/name).write_text(code) blob=base64.b64decode(re.search(r'```[^\n]*\n(.*?)```',d.split('## Data:',1)[1],re.S)[1]) (s/'blob.bin').write_bytes(blob) for name,expected in [('Strategy.sol','c68887cff61180e12ba2b1ceb333edf76a830f91f63b5d775a8806fb9ec08aca'),('blob.bin','3ac7cb8811ecfb6a17f499aa4e9b70dd55f7fb6432b3aec3b904e11a3dece38e')]: b=(s/name).read_bytes(); h=hashlib.sha256(b).hexdigest(); print(name,len(b),h); assert h==expected ``` Inspected pyrevm's API and ran Gate P in the same sourced shell: ```sh . test/scratch/amm-challenge/scratch/env.sh && python -c "import pyrevm; e=pyrevm.EVM(); print(dir(e)); print(e.message_call.__doc__)" python3 -I test/scratch/amm-sim/research/solved/gates.py > test/scratch/gates.log head -18 test/scratch/amm-challenge/scratch/Strategy.sol cat test/scratch/amm-challenge/amm_competition/evm/compiler.py | head -160 cat test/scratch/gates.log ``` 6. From amm-challenge, inspected `evm.result`: ```sh . scratch/env.sh && python -c "from pyrevm import EVM; e=EVM(); print(e.result); print(dir(e.result))" ``` Then a sourced Python heredoc deployed a STOP runtime and inspected the result: ```python from pyrevm import EVM e=EVM(); a=e.deploy(deployer='0x'+'11'*20,code=bytes.fromhex('6001600c60003960016000f300'),gas=1000000,value=0) e.message_call(caller='0x'+'11'*20,to=a,calldata=b'',gas=245000,value=0) print(e.result); print(dir(e.result)) ``` Also `cat ../gates.log` from that checkout. 7. Wrote `scratch/check.py` by a shell heredoc (body is the Harness section). The first attempt used `test/scratch/amm-challenge/scratch/check.py` while already in amm-challenge and failed before creating a file. Reissued from the workspace. Initial version recorded raw returned fees and lacked the `clipped` list and `clampf` normalization shown in the final harness. It used the same compilation, ABI, deployment, amount conversion and measurement code. 8. Calibration from amm-challenge: ```sh . scratch/env.sh && python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70032..70032 > scratch/calibration.json 2> scratch/calibration.log ``` A second sourced Python heredoc checked the three reference scores: ```python from pathlib import Path import sys sys.path.insert(0,str(Path('scratch').resolve())) sys.path.insert(0,str(Path('../amm-sim/research/solved').resolve())) from qmref import QMRef import replica2 for seed,expected in [(10000,443.101741),(10001,571.454483),(10002,525.908441)]: value=replica2.run(seed,QMRef('scratch/blob.bin'))['edge'] print(seed,format(value,'.6f'),flush=True) assert abs(value-expected)<0.0000005 ``` Inspected outputs: ```sh cat test/scratch/amm-challenge/scratch/calibration.log cat test/scratch/gates.log sed -n '7,20p' test/scratch/sources/Data.md sed -n '18,45p' test/scratch/sources/Q.md cat test/scratch/amm-challenge/scratch/calibration.json cat test/scratch/amm-challenge/scratch/calibration.log ``` 9. Ran each of the following from amm-challenge, first with raw recording and then again after the clamp repair. Each invocation had a 470-second timeout (under eight minutes); none timed out. Some independent batches ran concurrently. Only the final runs are aggregated. ```sh . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70050..70059 > scratch/batch-70050.json 2> scratch/batch-70050.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70060..70069 > scratch/batch-70060.json 2> scratch/batch-70060.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70070..70079 > scratch/batch-70070.json 2> scratch/batch-70070.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70080..70089 > scratch/batch-70080.json 2> scratch/batch-70080.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70090..70099 > scratch/batch-70090.json 2> scratch/batch-70090.log ``` 10. Fetched source quotations from the exact raw URLs in sources.json using `curl -fLsS URL -o test/scratch/sources/FILE` for `setup-fast.sh`, `replica2.py`, `gates.py`, `IAMMStrategy.sol`, `compiler.py`, `executor.py`. Checked: ```sh cmp test/scratch/sources/replica2.py test/scratch/amm-sim/research/solved/replica2.py cmp test/scratch/sources/setup-fast.sh test/scratch/amm-sim/setup-fast.sh tail -2 test/scratch/amm-challenge/scratch/batch-70050.log tail -2 test/scratch/amm-challenge/scratch/batch-70060.log cat test/scratch/amm-challenge/scratch/batch-70050.json cat test/scratch/amm-challenge/scratch/batch-70060.json ``` 11. Version diagnostics from amm-challenge, in a sourced Python heredoc: ```python import sys, importlib.metadata, solcx print(sys.version) for name in ('pyrevm','py-solc-x','amm-sim-rs'): print(name,importlib.metadata.version(name)) print('solc',solcx.get_solc_version() if solcx.get_solc_version else '') ``` The last line failed due to no process-default compiler selection; a corrected sourced heredoc ran: ```python import solcx solcx.set_solc_version('0.8.24') print(solcx.get_solc_version()) ``` Also inspected `tail -1 scratch/batch-70070.log`, `tail -1 scratch/batch-70080.log`, `tail -1 scratch/batch-70090.log` from that checkout. 12. Wrote the scratch report aggregation script `test/scratch/build_result.py` by heredoc. It reads all 50 per-seed JSON results, validates seed coverage and counts, aggregates errors and gas, embeds the complete harness and command record, verifies source quotes against downloaded files, and writes the two named outputs. Inspected the three remaining original batch summaries with `cat test/scratch/amm-challenge/scratch/batch-70070.json`, similarly `batch-70080.json` and `batch-70090.json`. 13. Investigated seed 70092 by adding mismatch diagnostics to the harness using a Python heredoc (`Path.read_text`, string replacement, `Path.write_text`). From amm-challenge: ```sh . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70092..70092 > scratch/investigate.json 2> scratch/investigate.log ``` Inspections from workspace: ```sh sed -n '140,195p' test/scratch/sources/Q.md sed -n '260,350p' test/scratch/sources/Q.md cat test/scratch/amm-challenge/scratch/gate-f-70090..70099/70092.json cat test/scratch/amm-challenge/scratch/investigate.log sed -n '215,275p' test/scratch/sources/Q.md sed -n '365,446p' test/scratch/sources/Q.md cat test/scratch/amm-challenge/scratch/investigate.log ``` Fixed the harness with a Python heredoc: record `replica2.clampf` of each fee while forwarding original policy returns, add `clipped_outputs` evidence and retain mismatch diagnostics. No contract/reference changes. Reran the five batches in step 9. 14. Wrote this command record (`cat > test/scratch/commands.md` heredoc), updated the scratch report generator for the clamp finding, and ran `python3 -I test/scratch/build_result.py`. Final validation uses a Python heredoc to parse sources.json and the Gate F JSON, validate quote lengths, compare the embedded harness to the executed file, check all per-run traces and gas/error totals, check result size, and inspect `git status --short --untracked-files=all -- . ':!test/scratch'`. These report/validation commands are scaffolding, not additional simulator runs. 15. Inspected the clamp repair with `rg -n 'code=re|blob=base64|clamp|return fb' test/scratch/commands.md test/scratch/build_result.py test/scratch/amm-challenge/scratch/check.py` and `tail -3 test/scratch/amm-challenge/scratch/batch-70090.log`. Corrected doubled regex escapes in this command record to match the actual successful extractor. Read the corrected `batch-70090.json`. 16. To verify the slightly higher error on the new seed set, reproduced the full original baseline. From amm-challenge: ```sh . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70000..70009 > scratch/baseline-70000.json 2> scratch/baseline-70000.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70010..70019 > scratch/baseline-70010.json 2> scratch/baseline-70010.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70020..70029 > scratch/baseline-70020.json 2> scratch/baseline-70020.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70030..70039 > scratch/baseline-70030.json 2> scratch/baseline-70030.log . scratch/env.sh && timeout 470 python -I scratch/check.py scratch/Strategy.sol scratch/qmref.py 70040..70049 > scratch/baseline-70040.json 2> scratch/baseline-70040.log ``` Inspected `tail -1` of each of the five baseline logs from workspace. Wrote `test/scratch/verify.py` using a shell heredoc, and updated the report generator (Python heredoc) to assert the full baseline reproduces published rounded values. Final commands: `python3 -I test/scratch/build_result.py`, `python3 -I test/scratch/verify.py`, and `git status --short --untracked-files=all -- . ':!test/scratch'`. Output inspection and any formatting repairs use the same scratch generator; no additional strategy changes or runs are involved. 17. Final inspection ran `python3 -I test/scratch/verify.py`, `git status --short --untracked-files=all -- . ':!test/scratch'`, `sed -n '1,65p' artifacts/goal/batches/e1-gate-f/items/gf-b/result.md`, and `cat artifacts/goal/batches/e1-gate-f/items/gf-b/sources.json`. Final wording and this command record were updated with a scratch Python heredoc, followed by regenerating and revalidating with the same two scripts. No files were staged. # Problems No setup step failed; no blocked condition remains. The initial harness compared raw QMRef returns and failed the 0.01 bps test on seed 70092, callback index 853 (zero based), timestamp 860: raw ask 0.12130300605309263 versus Solidity ask 0.1, a 213.03006053092628 bps difference. Inspection of unchanged QMRef shows it caps `self.fb/self.fa` but returns local `fb/fa` before that cap. Replica2 itself caps every returned fee via `clampf`; the pool therefore actually uses ask 0.1. The corrected harness records that effective fee, forwards raw outputs unchanged, and explicitly persists all clipped outputs. This is a harness correction, not a contract/reference edit or a discarded callback. The final runs contain exactly one clipped callback, the event above. Literal equality to raw uncapped QMRef return values fails; the PASS above is equality to the fees used by the replica, including its defined cap. Two local command mistakes were corrected: the first harness file-write used a workspace-relative target while already inside the checkout, so the shell reported `No such file or directory`; the harness was then written at the correct path before calibration. A diagnostic `solcx.get_solc_version()` in a fresh Python process raised `SolcNotInstalled` because no default version was selected in that process. Explicitly selecting the already installed `0.8.24` returned `0.8.24`; every actual compilation passes `solc_version="0.8.24"` explicitly and succeeded. This is Gate F fee fidelity and direct pyrevm gas evidence only. No engine batch, engine gas_stats, new policy selection, holdout claim or leaderboard improvement is asserted. All reported measurements are local and independently reproducible with the harness; no independent behavioral certification is claimed. The separate 70000..70049 baseline was reproduced in full after correcting the harness. The initial five batches were repeated after the clamp correction. Seed 70092 was also replayed separately during diagnosis. The aggregate includes exactly one final corrected run for each requested seed 70050..70099, with no calibration, diagnostic or initial raw-comparison runs included. Replica seeds may be reused for deterministic verification; no engine seeds were used.