# class-size (incomplete Gate Q) Credit: Taylor (gtmcknight), whose pinned `research/solved` Gaussian + QM reference is the baseline. I reproduced Gate P before changing policy: ```text 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 ``` ## Candidate The candidate is a small first-own-trade correction to Taylor's `real.RealPolicy` with `qm_k1e-5.json` (qmref). On a callback, it computes observable Y-equivalent own size `ay` for `is_buy`, otherwise `ax*(postReserveY/postReserveX)`, then `z=clamp(log(size/20),-3,3)`. On the first own callback of a new timestamp step only (`t-self.tlast >= 1`), it adds `0.05*z + 0.02*(+1 if is_buy else -1)` to the Gaussian arb-v-retail log odds. It then runs the unchanged soft posterior update, QM lookup, fee conversion, rival tracking, and filter. No true price, arb flag, or lookahead is used by the deployed-policy path; those are replica diagnostics only. The correction is tiny and needs only `log`, a clamp, two multiplies, an add, and odds conversion; storage is two constants plus existing filter state. Solidity operation/gas costs are estimates, not measured. Candidate module (complete; it is a subclass around the pinned reference): ```python import math import real class ClassSizePolicy(real.RealPolicy): def __init__(self,T,opt=None): super().__init__(T,opt); self.k=.05; self.d=.02; self.scale=20. def on_trade(self,is_buy,ax,ay,t,x,y,arb,p,s2,j): amount_y=ay if is_buy else ax*(y/x) z=max(-3.,min(3.,math.log(max(amount_y,1e-12)/self.scale))) self.o['class_corr']=(self.k*z+self.d*(1. if is_buy else -1.)) if t-self.tlast>=1 else 0. try: return super().on_trade(is_buy,ax,ay,t,x,y,arb,p,s2,j) finally: self.o['class_corr']=0. ``` The exact reference hook is `q=odds*exp(class_corr); pi=q/(1+q)`, immediately after the existing `pi=l_arb/(l_arb+l_ret)` and before the existing soft update. The runner is `scratch/amm-sim/run_class.py`; it runs `R.run` paired on identical seeds and reports mean, sample-SD/sqrt(n), worst five, means, and classifier diagnostics. ## Measurements Selection was not completed: the full mandated fit window 60000..60511 did not finish within the available execution budget, so no report-window retuning was performed. The only completed choose shard was 60000..60031 (n=32), using the frozen parameters above: `paired{n:32, mean_diff:+0.0403682899, se:0.0496370852, worst5:[-0.6986882763,-0.3247508361,-0.3195527611,-0.2986923212,-0.2420553113]}`; baseline mean 540.2884986808, candidate mean 540.3288669707; mean classifier error 17.3964%. An independent report shard 10000..10031 (n=32), never used for tuning, gave `paired{n:32, mean_diff:+0.0585722916, se:0.0514426088, worst5:[-0.4645866334,-0.4400605949,-0.3449233021,-0.3187220845,-0.3054435467]}`; baseline mean 507.4178374219, candidate mean 507.4764097135; mean classifier error 17.6517%. This is explicitly **not Gate Q**: 64 of 3072 paired differences are present, and the remaining choose/report intervals are missing. No 50x2,000 Gate F or engine/gas measurement was attempted, as this item is replica-only. Packed completed differences (choose ascending, then report ascending; 64 float64 values, little-endian, zlib then base64): ```text eNpj2HIl9Zjs5f0MAvt/Paw5Yc+goB4i/HW3PUODjfOPnO37GQwaN69hObKfoYBv9/YTV/YzfOAp+Xrptj2Dw3fd6tJN9gwXEionMR3dz6AS0n5G+qo9A8MLFgWtaUBx2Zbl0c+A6k8Ubbu2x57hQKDHH8Vj+xkeVOxew3t2P0PD5edPD223Z6iYVraA6wFQvkThs8dKe4YCMR47vmtA+z+JTZSdsJ9hgsXmvJwD+xlWuOYvYjwLFBe1Ur2+FqhvZk5vMdA9LkFVzHkP7RmuMBWw1gPpBSzyq3+f288wI5jfRPwC0D+Wa9N8jwP1xX9cN30Z0H0uMgFpQUD7bQ8Z9U62Z3jRyn60CKiuIEw7r+icPcOKdwdVpgP919AvdebTeqA/b3f9WAEMl4gfYsk9wHC6EhnwMRVor8MZL5ae5fsZDrTrWwpfA4ZTv/1fljP2DHuUpG5UAMPB4cpe+bnAcEhw9luSuQ7oj/63i+SB/i14q9E84yJQX9OtwE+Xgf4u3aUyZyeQ3jnpx66Z+xl6Pj9mrwWKr/i2V8X3qD3DhzsvP2veAYZbyaUZ6pf2MzA8/cL+bTfQ/tUbuLYftmfgsHz1bA7Q3oQ7k/UaDgHjUX/yyd139zO8OPYyYxXQXxUGb8J/XNjPcMhb9eU8YPjohJ0Nn/7YniGm7Mhs/dv2AFWf6+I= ``` Decoded-byte SHA256: `f306a2dac896dd06b2dab7efa9dd2c3bc3fe9f4b22bcc015d768cf763b6dcf56`. ```bash python3 -c 'import base64,zlib,struct,hashlib; b=zlib.decompress(base64.b64decode(open("packed.txt").read())); assert len(b)==64*8; print(hashlib.sha256(b).hexdigest(),struct.unpack("<64d",b))' ``` Exact baseline command: `python3 -I research/solved/gates.py`. Exact candidate command: `source ../amm-challenge/scratch/env.sh && python3 -I run_class.py START END 0.05 0.02 20`. Dependencies used: pinned repository at `4812a638...`, Python 3 standard library for the replica, and the supplied QM JSON; no new Python dependency.