{"variant":"rep-a / 64-bin latent first-callback posterior; router likelihood on","status":"completed replica evaluation; target missed","seeds_configs":{"development":[0,1,2,3,4,5,6,7],"development_steps":10000,"holdout":{"first":10000,"last":10255,"n":256,"steps":10000},"ablation":{"first":10000,"last":10063,"n":64,"steps":10000},"reserved_seeds_touched":false,"config":"replica.run default cfg; seed-derived size_mean uniform 19..21, lambda uniform 0.6..1.0, sigma uniform 0.000882..0.001008, independent of policy. Config values are hidden from the filter.","freeze":"model.py and run.py frozen before holdout; no retuning on holdout or ablation","models":"Filtered is closed-loop estimated-price table; oracle is closed-loop true-price true-flag table; diagnostic is closed-loop true-price inferred-flag table with its own estimator and actual fees."},"references":{"urls":{"brief":"https://raw.githubusercontent.com/gtmcknight/amm-sim/main/research/filter-brief.md","table":"https://raw.githubusercontent.com/gtmcknight/amm-sim/main/research/oracle_table.json","replica":"https://raw.githubusercontent.com/gtmcknight/amm-sim/main/research/replica.py","setup":"https://raw.githubusercontent.com/gtmcknight/amm-sim/main/research/setup.sh","checkout":"https://github.com/benedictbrady/amm-challenge/tree/6b6921f8d463314aa7c96234e1be25a25245f704"},"sha256":{"brief":"0ef2200226b68aa58de6aad268442ba09ada710c54b3fb0ec35c77b491f78a4b","table":"3e9d1fc8874c6d796d4c26948d486b587f2a6b5610b20fba99923a60954cf4b5","replica":"d079712fa1f4850ad8337e656e7ee8dbdde806cd4762d597fae50f547ef9c7c4","setup":"dc7fa6a1e59f5b043d3954cf68d538318b7affaf5c0db3ca69a1822680f300d4","frozen_numpy_model":"11bce2cea6bf8c8c33cb52bc93172549a8679e02f2aa80bd01ab2d04d784ed69","frozen_measured_harness":"9d9d8736ee7b04c186592a44d0aaceffc58f6afcb81adef200172ca12c910d4d"}},"parameters":"64 bins; width 0.0004 log price; nominal 256 bp total range; mass-conserving integer recenter and clipping to boundary; Gaussian kernel bin integrals, offsets -16..16, renormalized; initial sigma .000945, EWMA variance weight .005, clamp .0006..0014; arb probability threshold .5 and pin-update threshold .9; router quadrature 5 rival displacements (0, +/-45, +/-90 bp), 9 lognormal-size points, 0.65 log-fill bandwidth, likelihood floor .25. Exact knot values and all constants are in source.","per_seed_columns":["seed","filtered_edge","oracle_edge","diagnostic_edge","filtered_retail_edge","filtered_arb_edge","filtered_retail_volume_y","filtered_arb_volume_y","filtered_squared_log_error_sum","filtered_callback_count","filtered_1sd_covered","filtered_2sd_covered","filtered_cumulative_clipped_mass","filtered_diffusions"],"per_seed":[[10000,338.179,445.678,444.996,461.984,-123.805,60516.614,28548.045,0.13130935,8141,3467,6372,287.1395,9998],[10001,472.711,572.593,571.442,597.836,-125.125,87487.394,36282.646,0.17388824,11447,5134,8751,465.2377,9997],[10002,385.753,527.968,526.916,559.364,-173.611,68073.196,33339.266,0.19060146,9232,3794,6851,388.1262,10000],[10003,448.132,573.642,572.596,599.694,-151.562,81765.037,35928.86,0.19205492,10656,4441,7908,465.671,9994],[10004,409.836,524.586,523.51,548.672,-138.836,72339.6,32846.032,0.15916824,9602,4104,7366,367.7188,10000],[10005,412.537,527.731,527.07,555.441,-142.904,71863.733,33430.551,0.1815059,9539,4008,7134,453.1444,9998],[10006,405.841,487.623,486.89,509.152,-103.311,74001.343,31926.879,0.15122985,9951,4549,7710,385.9047,9995],[10007,412.355,527.209,526.326,549.256,-136.9,76196.525,32837.931,0.17122981,10109,4340,7590,426.1429,10000],[10008,513.522,664.107,663.156,685.759,-172.237,94543.803,39434.446,0.21233484,11680,4880,8730,501.9165,9997],[10009,508.415,653.735,652.574,682.261,-173.846,92241.683,39719.436,0.22147168,11748,4960,8577,518.5269,10000],[10010,399.865,479.558,478.981,495.597,-95.732,74499.99,31379.937,0.15252392,10431,4529,8106,390.0324,10000],[10011,315.709,371.522,370.282,385.841,-70.132,57908.971,25182.731,0.11374272,8128,3419,6235,302.2203,10000],[10012,383.554,459.004,458.018,476.447,-92.893,73178.489,31180.568,0.13839106,10035,4292,7832,321.3952,10000],[10013,311.552,402.852,402.056,420.642,-109.09,56465.093,26009.683,0.12675817,8020,3460,6398,263.7046,9999],[10014,489.733,702.859,702.138,734.157,-244.425,86254.385,37541.917,0.20656112,10779,4686,8406,440.1738,9997],[10015,494.135,632.334,631.582,655.489,-161.354,91673.423,38675.042,0.19602328,11396,4643,8571,462.956,9999],[10016,391.393,569.337,568.373,634.594,-243.201,70350.563,32414.914,0.24807003,9332,4008,7219,349.9637,9999],[10017,391.933,494.51,493.268,512.356,-120.423,71555.328,32507.648,0.17263157,9735,4071,7337,437.7845,9999],[10018,386.957,482.169,480.877,505.245,-118.288,69035.275,32273.1,0.14876002,9194,3757,6957,352.9356,10000],[10019,342.236,455.466,454.474,473.404,-131.168,60649.163,27735.848,0.13597126,8234,3492,6452,270.3678,10000],[10020,383.458,498.151,496.867,519.018,-135.559,67416.398,30925.4,0.15490486,8929,3897,6872,357.5213,9999],[10021,305.851,413.41,412.805,430.598,-124.747,55729.21,25545.86,0.11769709,8049,3352,6576,218.3222,9998],[10022,335.016,442.037,441.266,459.703,-124.687,60815.432,27999.569,0.14348154,8492,3468,6547,287.1937,9999],[10023,479.957,635.303,634.344,668.726,-188.769,86636.479,36906.122,0.18718753,10642,4703,8276,435.3508,10000],[10024,392.375,483.676,482.5,498.919,-106.543,72052.006,31491.045,0.1605853,10120,4142,7633,388.6855,10000],[10025,333.923,447.671,446.649,464.385,-130.462,61198.453,27166.265,0.14864791,8789,3718,6959,293.6519,10000],[10026,286.338,347.393,346.918,359.875,-73.536,52779.248,23491.844,0.10732678,8014,3575,6415,260.7748,10000],[10027,413.643,549.706,548.923,574.67,-161.027,73059.386,34234.255,0.19393273,9858,3985,7233,425.9695,9999],[10028,388.713,527.766,526.601,557.121,-168.408,67490.893,32566.675,0.18204612,8921,3690,6619,419.8142,9998],[10029,373.953,444.584,444.144,458.364,-84.411,71454.098,28218.85,0.13055352,9898,4569,7849,298.6192,10000],[10030,480.923,597.818,597.041,620.812,-139.889,88853.223,37090.075,0.18316431,11315,5015,8748,447.3764,10000],[10031,289.291,343.561,343.55,355.356,-66.065,56621.157,25377.68,0.10410526,8322,3241,6496,182.0534,10000],[10032,477.569,637.938,636.985,666.452,-188.883,85709.292,38681.61,0.22108644,10590,4461,7830,543.5026,10000],[10033,446.103,536.445,535.119,559.584,-113.481,81283.086,35057.715,0.16567744,10539,4408,7858,413.0179,10000],[10034,453.825,566.542,565.752,588.466,-134.641,83303.392,34393.863,0.17564124,11061,4883,8436,396.4173,10000],[10035,508.374,636.15,634.321,666.883,-158.509,93645.578,40142.987,0.2035012,11866,4726,8613,499.8881,9998],[10036,440.042,546.64,546.132,570.063,-130.021,81003.884,34811.258,0.1703413,10762,4442,8022,436.1582,10000],[10037,361.1,445.185,444.559,464.191,-103.091,65963.75,30109.603,0.14064477,9143,3736,7033,340.8477,9998],[10038,501.928,620.608,619.563,650.2,-148.272,91471.019,37893.842,0.20267502,12057,4979,9103,507.2859,10000],[10039,426.0,590.585,588.967,618.533,-192.532,77375.553,34368.092,0.23168314,10348,4203,7818,395.7639,10000],[10040,495.873,609.988,609.187,637.978,-142.106,90423.885,38277.731,0.19283406,11892,5215,8897,513.6864,10000],[10041,487.328,632.276,631.694,663.246,-175.919,86009.814,37167.601,0.21102194,10804,4672,8157,476.4315,9999],[10042,530.315,711.211,709.182,745.147,-214.833,93050.912,41455.499,0.24124915,11718,5023,8579,594.6056,10000],[10043,483.347,639.262,638.79,666.723,-183.376,88049.565,37825.22,0.23503591,11153,4825,8236,472.7722,9999],[10044,335.393,421.89,421.054,438.026,-102.633,60332.486,27491.989,0.1258837,8184,3440,6326,289.7037,10000],[10045,320.578,388.107,387.74,404.136,-83.558,59951.0,27570.582,0.11984093,8519,3410,6587,258.8264,10000],[10046,363.007,434.193,432.941,451.559,-88.552,68243.302,31564.41,0.13689445,9732,3957,7454,301.3398,9997],[10047,496.361,599.636,598.296,626.02,-129.66,91495.582,38959.396,0.18884604,11661,4898,8617,489.0924,10000],[10048,385.63,497.208,495.751,517.097,-131.466,70614.061,31389.558,0.16225691,9803,3946,7419,319.7504,10000],[10049,313.423,385.908,385.125,401.673,-88.25,56627.821,25094.896,0.1129428,8233,3591,6602,286.8304,9992],[10050,306.441,378.549,378.081,392.369,-85.929,56911.374,25041.635,0.11532425,8363,3510,6747,229.3083,10000],[10051,334.34,424.732,424.251,439.989,-105.649,59854.866,27884.234,0.13613446,8273,3513,6380,304.9807,9998],[10052,355.492,431.547,431.192,446.769,-91.277,67488.913,28693.145,0.12944101,9668,4134,7525,294.6025,10000],[10053,399.926,537.967,537.035,562.431,-162.505,72433.365,32995.698,0.16969132,9706,4178,7485,389.7459,9999],[10054,340.258,444.331,443.817,468.387,-128.129,63111.214,28537.435,0.13548713,8821,3711,6912,277.0839,9998],[10055,535.0,710.744,709.233,742.978,-207.977,95306.041,42234.522,0.24038133,11948,4760,8521,581.2729,10000],[10056,471.403,583.459,582.512,611.582,-140.18,83893.672,37076.177,0.19533212,10482,4394,7659,531.1089,10000],[10057,380.498,510.841,510.343,530.436,-149.938,68053.167,31665.697,0.17969746,9213,3914,7241,394.3674,10000],[10058,320.181,440.074,438.483,457.329,-137.147,57266.338,27506.529,0.1480732,8479,3517,6476,277.5897,10000],[10059,396.609,509.438,508.748,534.708,-138.099,71729.499,33332.505,0.18103618,9514,3823,7110,332.0178,10000],[10060,512.947,928.773,927.956,2093.227,-1580.28,90928.929,41027.629,0.74983986,11305,4693,8582,446.5081,9998],[10061,451.039,562.903,561.848,583.165,-132.126,82268.495,34355.713,0.16965324,10808,4787,8228,438.5624,10000],[10062,482.848,610.983,610.208,637.097,-154.249,89705.692,36619.481,0.19413818,11471,5042,8771,437.9521,9999],[10063,343.597,429.331,428.43,446.554,-102.957,63090.2,27317.015,0.1256624,8885,3900,7101,293.5128,10000],[10064,518.603,662.162,660.311,692.566,-173.963,94250.224,41441.629,0.22283013,11689,4912,8349,607.2778,9998],[10065,450.707,586.343,584.653,617.019,-166.312,81456.695,35759.051,0.19023405,10491,4333,7791,469.786,10000],[10066,395.592,486.2,485.368,506.071,-110.479,72826.231,31676.191,0.14947882,9679,4167,7438,422.3146,9998],[10067,465.577,635.013,633.866,668.84,-203.262,80398.68,36748.338,0.21755228,10194,4271,7528,508.7863,10000],[10068,346.776,504.957,503.843,526.732,-179.956,59571.418,30270.824,0.17721168,8127,3433,6337,349.3293,10000],[10069,449.587,623.176,622.321,645.76,-196.173,81016.58,35360.514,0.21350131,10532,4506,7972,468.4156,10000],[10070,321.153,413.641,412.922,432.72,-111.568,57680.964,27939.63,0.13055035,7952,3237,6134,285.2112,10000],[10071,336.362,437.317,436.589,452.89,-116.529,62095.954,28360.211,0.14575928,8689,3544,6697,334.1362,10000],[10072,426.323,605.872,605.054,650.316,-223.993,77114.005,32609.273,0.19734025,10135,4563,7865,377.5609,10000],[10073,450.617,567.737,566.535,593.564,-142.947,80682.029,35246.592,0.17330256,10383,4479,7863,406.9807,10000],[10074,404.162,533.084,532.526,556.524,-152.362,73655.422,33076.188,0.18382451,9787,4257,7538,379.801,10000],[10075,435.048,562.432,561.5,582.412,-147.365,78828.703,34401.925,0.18274925,10719,4610,8144,439.8664,10000],[10076,428.023,530.845,529.745,558.001,-129.977,78169.841,34234.838,0.17444624,10383,4458,7787,435.8582,10000],[10077,354.452,430.334,430.173,448.449,-93.996,65669.614,28389.455,0.13057007,9381,3988,7388,317.3874,10000],[10078,484.733,622.077,620.919,647.056,-162.323,88962.756,37247.955,0.19525128,11099,4618,8168,491.2555,9999],[10079,497.447,650.612,649.24,684.055,-186.608,88506.76,40598.955,0.23433838,11269,4589,8106,558.6673,10000],[10080,375.519,488.069,487.743,512.572,-137.053,69527.27,32207.362,0.16554324,9284,3762,6976,344.3417,10000],[10081,432.477,567.41,566.829,601.734,-169.257,75399.474,34803.23,0.18681213,9807,4242,7400,432.3485,10000],[10082,434.1,566.73,564.852,594.268,-160.168,76100.341,35322.136,0.20412872,10083,4264,7434,507.7613,10000],[10083,396.745,467.22,466.728,488.851,-92.106,72793.639,31052.516,0.15183959,9978,4280,7481,389.2043,10000],[10084,377.326,476.214,475.292,498.593,-121.268,67960.157,31071.424,0.15120756,8902,3746,6837,387.6253,10000],[10085,349.727,455.709,455.088,474.653,-124.925,62164.359,29127.95,0.14476181,8678,3576,6817,310.4309,10000],[10086,453.064,573.838,572.391,596.55,-143.486,83814.861,36546.551,0.19913797,10938,4389,7979,489.3237,10000],[10087,463.703,571.98,571.467,599.779,-136.076,86495.507,34853.681,0.17618791,11480,4982,8810,450.9367,10000],[10088,359.192,442.478,441.503,461.915,-102.724,65747.128,30717.134,0.14074831,9039,3652,6877,342.9467,9999],[10089,331.571,414.895,413.93,430.881,-99.31,59884.607,27738.419,0.12118152,8229,3356,6362,258.8582,9997],[10090,466.39,587.682,587.041,617.544,-151.154,86658.65,37965.31,0.20140073,11548,4846,8446,444.3304,9997],[10091,359.225,486.854,486.126,506.928,-147.703,66815.565,30811.031,0.15645167,9334,3823,7219,330.1598,9999],[10092,417.824,557.743,557.142,581.414,-163.59,74130.08,34227.244,0.18416469,9675,4094,7396,447.8035,9998],[10093,507.152,663.402,662.748,698.87,-191.718,92252.529,39360.909,0.2368174,11745,5034,8917,503.6894,9999],[10094,381.533,480.64,480.055,505.359,-123.826,68211.576,32016.62,0.15669328,9208,3881,7105,358.5804,9997],[10095,466.605,597.949,596.234,623.119,-156.514,84896.001,37880.837,0.20596148,10985,4459,8050,467.7501,10000],[10096,379.227,492.088,490.941,515.018,-135.791,66296.18,31031.001,0.16005012,8901,3641,6722,412.1838,10000],[10097,397.822,512.788,511.851,535.821,-138.0,72466.727,31363.182,0.16611069,9775,4317,7583,362.6476,10000],[10098,412.227,503.264,502.716,520.605,-108.378,75467.117,31907.368,0.15116918,10478,4612,8099,364.9747,10000],[10099,394.351,470.458,469.086,489.96,-95.609,71344.398,30092.812,0.1430378,9441,4123,7195,329.5004,9999],[10100,336.784,444.104,443.035,466.121,-129.337,60774.982,29592.52,0.14787308,8403,3212,6165,314.8876,10000],[10101,422.363,536.949,536.054,556.798,-134.435,75224.153,32844.789,0.16780524,9880,4426,7572,405.8568,9996],[10102,554.617,737.237,735.157,777.815,-223.198,98127.669,43262.12,0.29020752,12161,5041,8576,665.5528,10000],[10103,531.425,741.534,740.142,775.214,-243.789,93340.269,41624.839,0.26974939,11587,4787,8380,563.0648,10000],[10104,549.303,703.146,702.703,737.335,-188.033,96979.272,43068.321,0.24516827,11851,4960,8525,605.6734,10000],[10105,354.409,472.241,471.337,493.194,-138.785,62350.058,29528.169,0.15154276,8742,3681,6892,299.9871,10000],[10106,325.411,429.582,428.439,451.406,-125.995,58164.76,27816.152,0.14898703,8114,3284,6179,301.4293,9996],[10107,393.851,491.967,491.257,514.623,-120.772,71298.183,33031.667,0.15968108,9774,3994,7183,403.4685,10000],[10108,404.228,535.474,534.628,561.621,-157.393,74190.306,33490.219,0.18077619,10097,4229,7821,385.7576,10000],[10109,534.6,738.836,737.002,784.974,-250.373,95655.196,41786.716,0.25632832,11550,4916,8466,573.6396,10000],[10110,475.977,572.963,571.579,601.611,-125.634,88609.646,36427.801,0.18948839,11803,5164,8880,504.8483,10000],[10111,336.452,406.305,405.851,427.221,-90.769,60771.116,29082.78,0.12946378,8583,3447,6559,299.9702,10000],[10112,363.443,464.069,463.183,486.856,-123.412,64915.632,29990.681,0.14768832,8619,3599,6532,316.4731,9999],[10113,336.562,436.54,435.654,453.2,-116.638,61466.642,27599.195,0.13657103,8631,3583,6744,294.9634,10000],[10114,434.145,535.085,534.536,560.322,-126.178,80775.974,33948.52,0.16564099,10962,4761,8454,367.5403,9999],[10115,518.397,663.16,662.563,693.714,-175.317,93367.126,40818.379,0.21997757,11653,5078,8804,542.4085,10000],[10116,414.135,526.868,525.371,547.178,-133.043,73734.746,32738.603,0.15082649,9257,3914,7053,388.8615,10000],[10117,334.909,413.049,411.812,428.01,-93.101,60994.179,28272.414,0.13147071,8331,3415,6381,304.0275,10000],[10118,337.569,424.538,424.258,444.159,-106.59,60646.428,29081.324,0.13072953,8322,3384,6432,317.3363,10000],[10119,337.412,416.958,416.553,435.158,-97.745,61895.762,28827.843,0.12546739,8407,3622,6460,300.0411,9997],[10120,448.391,553.446,552.689,574.485,-126.094,83568.996,35943.601,0.17420835,11006,4465,8190,453.878,10000],[10121,437.806,536.696,535.053,562.63,-124.824,79181.956,33832.124,0.16946375,10664,4664,8324,385.3603,10000],[10122,476.639,587.929,586.793,620.963,-144.324,86430.92,37380.423,0.19613317,11085,4476,8155,479.7577,10000],[10123,389.83,506.72,505.521,527.862,-138.032,70866.958,33571.728,0.15673651,9166,3750,6965,351.3705,10000],[10124,401.313,533.838,532.81,555.923,-154.609,73696.122,33969.915,0.17059347,9896,3996,7593,360.9385,10000],[10125,375.484,455.322,454.761,469.657,-94.173,70168.28,30949.756,0.13267398,9521,3791,7194,288.89,9999],[10126,348.837,460.692,459.657,476.95,-128.113,64608.375,27727.167,0.14127053,9051,3916,7119,327.1077,10000],[10127,390.642,495.769,495.41,519.599,-128.956,72215.823,31937.285,0.16350476,10029,4176,7718,369.9675,10000],[10128,552.625,732.523,730.631,772.543,-219.917,97560.801,42941.781,0.31639079,12149,4956,8701,643.7175,10000],[10129,424.016,535.31,534.524,561.673,-137.658,77647.125,34485.701,0.16655743,10223,4294,7844,392.6934,10000],[10130,372.153,461.712,462.028,485.076,-112.923,67690.088,30102.213,0.1563067,9470,4006,7299,362.3477,10000],[10131,376.384,499.678,498.107,519.98,-143.596,67055.952,30795.741,0.17485534,8983,3674,6736,339.7851,10000],[10132,374.17,503.602,503.188,525.913,-151.742,65086.108,30396.424,0.16484535,8750,3664,6715,371.9978,9998],[10133,477.65,631.506,631.331,659.937,-182.287,85460.036,35798.329,0.20604362,10955,4796,8597,453.3484,10000],[10134,422.473,536.231,535.052,557.455,-134.982,76821.818,35478.539,0.18523937,10372,4309,7760,444.7355,9999],[10135,378.641,459.544,459.78,481.049,-102.408,68953.761,30990.306,0.14056912,9487,3846,7177,337.9267,9997],[10136,486.321,620.373,618.514,646.169,-159.848,89805.278,37701.197,0.20476816,11604,5027,8732,499.1995,9999],[10137,481.055,622.653,621.063,648.133,-167.078,85929.814,37954.678,0.20527989,10788,4605,8110,506.8571,10000],[10138,369.255,501.361,500.516,522.41,-153.155,66948.465,31409.517,0.15798885,9291,3899,7202,332.4974,9999],[10139,371.826,467.564,466.961,489.811,-117.984,68019.632,30381.938,0.14771114,9161,3899,7100,322.5873,10000],[10140,435.101,552.849,551.732,577.913,-142.812,79069.368,33830.631,0.16643461,10201,4725,7869,443.2039,10000],[10141,439.389,580.663,579.745,613.993,-174.604,78505.943,33821.648,0.18193814,10135,4337,7629,424.9063,9999],[10142,502.317,628.244,626.785,655.411,-153.094,92666.654,40166.679,0.21009718,11621,4759,8415,554.9361,10000],[10143,364.198,471.452,470.495,491.116,-126.918,64744.438,28923.65,0.14655598,8408,3461,6550,344.872,9998],[10144,361.326,440.813,439.765,459.916,-98.59,65730.671,29306.385,0.14231112,9071,3856,6898,332.3584,10000],[10145,372.328,481.602,481.143,502.524,-130.196,66269.58,29841.821,0.15126761,9309,3894,7210,356.5761,9999],[10146,498.876,765.799,765.916,1037.089,-538.212,86990.836,39548.634,0.51172809,11138,4675,8253,498.4174,10000],[10147,383.611,469.594,468.801,491.674,-108.063,68099.995,32182.943,0.15289766,9246,3844,6928,373.9951,10000],[10148,510.772,692.341,690.463,723.283,-212.511,89041.545,39238.156,0.21823466,10638,4541,7883,516.6098,9999],[10149,405.445,523.633,522.731,546.283,-140.839,76449.855,34902.296,0.18728106,10276,3990,7644,383.4708,10000],[10150,456.361,589.246,587.274,610.821,-154.46,82952.569,36175.13,0.19057053,10927,4447,8248,410.6251,10000],[10151,374.836,474.551,473.59,497.148,-122.312,68260.266,30303.132,0.14820567,9439,4116,7413,317.8607,10000],[10152,330.136,418.111,417.903,429.799,-99.662,59644.576,28806.989,0.13003233,8256,3371,6371,307.552,10000],[10153,435.078,555.947,554.965,578.5,-143.422,79878.634,34720.492,0.18359231,10814,4656,8182,415.9563,10000],[10154,386.856,490.948,490.298,513.575,-126.719,71187.693,30318.974,0.15403839,9673,4233,7648,343.3109,10000],[10155,374.105,478.568,477.805,497.182,-123.078,68093.883,28771.183,0.13993172,9615,4487,7777,302.9991,10000],[10156,381.395,534.106,533.333,563.973,-182.578,68730.715,31336.829,0.17087887,9367,3931,7123,324.8099,10000],[10157,413.335,537.986,536.924,557.107,-143.772,75186.578,31979.201,0.15705622,9624,4141,7508,357.8987,9998],[10158,342.18,437.871,437.294,457.654,-115.475,61592.545,29943.215,0.13934938,8177,3231,6269,300.6053,9998],[10159,350.136,439.387,438.728,458.653,-108.516,63394.295,30058.858,0.14278446,8928,3662,6818,326.1583,9999],[10160,338.263,422.61,422.122,442.001,-103.737,61241.346,29110.365,0.12945191,8391,3454,6444,275.7229,9989],[10161,360.957,458.62,457.329,479.385,-118.428,64980.139,31594.057,0.15741196,8957,3556,6838,369.8491,9996],[10162,546.956,721.72,720.209,752.858,-205.903,99176.83,42724.101,0.23834535,11781,4947,8361,624.2987,10000],[10163,524.494,669.134,667.699,699.798,-175.304,95162.361,41694.559,0.22495575,11956,4993,8725,580.9311,9998],[10164,462.003,684.243,682.376,799.675,-337.672,83332.399,38022.083,0.34372063,10659,4430,7924,469.3385,9999],[10165,364.424,441.788,441.289,458.176,-93.752,68247.982,29380.803,0.14560907,9520,4058,7357,350.3328,10000],[10166,329.357,419.535,418.993,438.537,-109.18,58634.395,28538.186,0.1453879,8324,3230,6228,326.9222,10000],[10167,371.572,494.243,493.135,516.905,-145.333,66975.018,30543.791,0.16367005,9460,3971,7270,344.2357,10000],[10168,400.612,627.247,625.42,740.559,-339.946,70598.004,33631.415,0.24989402,9484,3696,7027,371.7909,10000],[10169,458.1,572.888,571.379,594.299,-136.199,84558.742,35771.211,0.18097847,10746,4397,8015,454.4219,10000],[10170,328.386,389.702,389.162,406.595,-78.209,61893.367,27463.664,0.11727226,8937,3732,6992,275.7035,10000],[10171,419.755,568.418,567.066,599.107,-179.352,72830.334,34955.391,0.19931568,9545,4151,7155,430.4032,9999],[10172,520.341,686.935,685.164,723.309,-202.968,94980.046,41484.852,0.22145738,11661,4757,8486,531.476,9999],[10173,306.402,398.481,397.555,413.805,-107.403,55595.084,25842.419,0.12649723,8142,3413,6401,267.2461,9997],[10174,443.491,544.061,543.496,568.283,-124.792,82437.909,35093.319,0.16560697,10905,4782,8403,430.05,9998],[10175,398.035,505.173,504.16,527.143,-129.108,72503.045,31347.428,0.15927348,9495,4167,7083,399.3833,10000],[10176,360.465,449.156,448.231,469.281,-108.816,67072.978,29936.058,0.1409127,9233,3950,7113,313.6303,10000],[10177,467.156,656.153,654.669,725.515,-258.359,83465.281,35885.983,0.24563858,10811,4578,8074,485.4922,10000],[10178,496.727,664.203,663.006,694.983,-198.256,90660.514,38526.698,0.21216382,11058,4681,8258,483.3586,10000],[10179,307.683,382.432,381.002,399.679,-91.996,56823.071,27865.633,0.12591491,8152,3247,6156,272.2613,9996],[10180,448.307,585.733,584.434,614.313,-166.006,82059.267,37457.762,0.20246518,10545,4269,7704,480.8851,10000],[10181,365.755,463.986,463.301,480.978,-115.223,69567.962,30782.838,0.1404867,9743,3968,7577,288.9067,10000],[10182,465.652,575.178,574.149,600.469,-134.817,83681.049,37565.746,0.1774891,10689,4357,7957,453.185,10000],[10183,473.155,633.113,631.54,660.982,-187.827,85372.888,38341.304,0.20857104,11147,4607,8175,485.0884,10000],[10184,369.949,522.573,521.925,555.093,-185.145,65225.007,31015.256,0.16652104,8800,3665,6911,318.8497,9997],[10185,410.28,545.627,544.474,570.824,-160.544,76657.195,32928.267,0.18709406,10320,4322,7903,329.8598,9999],[10186,409.569,575.461,573.232,598.865,-189.296,71774.783,33933.92,0.19034375,9657,3889,7300,385.1043,10000],[10187,415.565,551.656,551.79,588.264,-172.699,75616.005,31991.705,0.16969916,9643,4252,7377,371.7791,10000],[10188,433.819,533.394,531.852,556.436,-122.617,78513.735,34849.902,0.16066551,10344,4499,7932,419.2366,10000],[10189,522.414,717.578,715.961,755.383,-232.969,94074.039,40916.947,0.24095237,11849,4949,8807,557.3243,10000],[10190,477.837,661.695,660.594,694.654,-216.817,86101.431,37882.115,0.22132982,11039,4831,8350,463.0994,9999],[10191,493.273,662.47,662.064,701.413,-208.139,88165.351,38174.887,0.28079675,11335,5065,8464,534.8567,9999],[10192,506.014,665.826,663.998,697.038,-191.024,92011.729,39428.375,0.2295935,11736,4946,8471,567.591,10000],[10193,463.821,583.345,582.626,606.726,-142.904,84670.726,35649.987,0.18681279,11351,4935,8553,421.869,10000],[10194,422.028,512.129,511.493,537.261,-115.233,79277.24,34280.207,0.1545074,10667,4537,8301,352.0857,9998],[10195,433.617,554.515,553.56,580.027,-146.41,79558.332,35006.725,0.18842156,10629,4593,8131,445.4688,10000],[10196,465.992,587.121,586.1,617.023,-151.031,84920.316,38076.248,0.19673546,11407,4683,8287,454.2671,9999],[10197,352.062,443.348,442.487,462.831,-110.769,63130.513,30005.873,0.13274365,8524,3297,6485,305.6712,10000],[10198,417.343,558.382,557.369,588.2,-170.857,73779.251,33955.981,0.20488972,10138,4258,7607,417.2719,9999],[10199,352.498,483.706,482.929,512.574,-160.076,62972.631,29555.006,0.15567643,8544,3709,6701,326.6905,10000],[10200,446.771,563.07,562.062,587.229,-140.457,81989.038,34707.282,0.18335039,10806,4653,8074,423.6201,10000],[10201,399.608,482.416,481.516,501.874,-102.266,73270.739,30554.066,0.13121978,9773,4410,7749,328.1059,10000],[10202,438.377,570.124,568.453,591.876,-153.499,79860.644,34948.525,0.18992095,10452,4333,7799,448.0055,9998],[10203,475.234,618.454,617.823,646.11,-170.875,85988.066,37456.868,0.18727393,10721,4500,8170,452.7288,9999],[10204,368.709,456.701,455.707,476.483,-107.774,66179.742,31194.42,0.14996874,9049,3747,6841,375.3384,9999],[10205,341.414,420.641,419.984,435.23,-93.816,62927.581,27205.003,0.13251546,9129,3883,7102,303.0808,10000],[10206,423.968,523.623,522.999,548.286,-124.317,77541.083,33924.729,0.16851648,10015,4061,7456,396.6494,10000],[10207,499.322,637.318,636.19,669.601,-170.279,88021.665,40278.421,0.21643191,10996,4400,7938,545.9412,10000],[10208,395.307,629.587,628.39,697.832,-302.525,68890.035,32267.292,0.21800059,9117,3786,6975,339.2039,9999],[10209,413.036,554.049,552.011,579.5,-166.464,73476.741,33450.595,0.17962865,9551,4085,7141,387.123,10000],[10210,341.605,427.148,426.243,445.844,-104.239,62032.696,28449.594,0.12658602,8351,3620,6505,323.081,10000],[10211,339.549,441.707,441.126,454.583,-115.033,61431.812,27424.95,0.13570666,8699,3634,6760,298.3221,10000],[10212,491.881,630.229,628.507,657.336,-165.455,89078.583,38322.795,0.18550117,11123,4731,8435,454.3914,10000],[10213,451.793,583.88,582.903,607.76,-155.968,83021.281,35770.295,0.18729681,11218,4747,8564,419.7211,9999],[10214,480.56,578.585,577.456,600.948,-120.387,90468.663,36514.823,0.1785056,11564,4878,8715,440.2123,10000],[10215,358.855,457.417,456.738,483.063,-124.207,64415.595,30731.18,0.16636448,9248,3767,6877,396.406,9999],[10216,342.652,454.856,453.688,478.339,-135.687,59422.24,29950.455,0.15342726,8265,3391,6266,330.364,10000],[10217,514.095,668.575,667.086,698.239,-184.145,92437.334,42188.368,0.23512099,11582,4626,8254,560.0314,9999],[10218,498.228,633.666,633.231,666.812,-168.584,89651.697,38714.029,0.22235399,11710,4931,8561,532.2964,10000],[10219,437.774,524.932,523.982,547.521,-109.747,81961.732,34293.783,0.159426,10810,4511,8314,379.5993,9998],[10220,352.042,518.445,517.195,550.596,-198.554,61995.767,30569.95,0.17695907,8366,3329,6310,310.3166,10000],[10221,377.181,536.974,535.508,569.982,-192.801,65752.646,32587.397,0.18832802,8640,3439,6568,379.9214,9998],[10222,448.162,621.732,620.718,641.724,-193.563,81884.992,38044.607,0.2118733,10273,4114,7525,431.827,9998],[10223,472.682,664.045,663.603,695.451,-222.768,85469.691,37757.862,0.2261139,11493,4857,8630,482.7299,9999],[10224,337.219,436.889,435.747,453.44,-116.221,63454.231,27165.121,0.12730697,9112,3893,7245,247.7816,9999],[10225,391.974,484.099,482.813,504.018,-112.044,71558.766,31121.312,0.14886826,9969,4436,7820,368.9794,10000],[10226,518.317,707.781,706.531,744.213,-225.896,91953.795,39104.223,0.21610837,11098,4875,8430,483.1919,10000],[10227,343.733,446.773,445.22,459.5,-115.767,63120.365,27927.929,0.13339234,8756,3735,6991,283.9093,10000],[10228,438.085,542.258,540.815,559.951,-121.866,82332.623,33810.297,0.16646423,10954,4698,8404,401.3991,10000],[10229,357.0,433.689,433.04,444.856,-87.856,68446.2,28183.962,0.12353774,9583,4235,7628,293.8795,9998],[10230,505.785,633.958,632.587,663.715,-157.93,92773.687,40348.556,0.2066568,11433,4650,8264,528.8643,9998],[10231,514.365,696.751,694.781,728.091,-213.726,90198.938,40590.546,0.24405384,11310,4689,8171,581.7,9999],[10232,386.123,502.618,501.234,524.044,-137.921,71071.608,31464.652,0.16493588,9848,4258,7591,356.0935,10000],[10233,368.966,448.727,448.011,467.931,-98.964,66578.805,30209.659,0.13658097,8813,3756,6749,339.6578,9999],[10234,415.235,539.897,540.715,570.043,-154.808,74085.343,33588.914,0.1914841,10000,4164,7585,374.0178,9997],[10235,478.532,663.134,661.041,701.606,-223.074,84470.585,37866.193,0.21552252,10207,4176,7639,483.5245,9998],[10236,368.894,445.657,444.657,463.339,-94.445,69190.863,29147.164,0.13766855,9706,4122,7514,319.5045,10000],[10237,489.103,645.703,644.227,680.249,-191.146,86583.389,40267.785,0.23072467,11130,4453,7872,575.4668,10000],[10238,326.598,454.815,454.128,479.791,-153.193,57724.916,29703.883,0.15450106,8201,3169,6171,302.1107,10000],[10239,454.269,603.895,602.869,627.39,-173.12,82473.918,36307.367,0.20483525,10886,4587,8268,454.8326,10000],[10240,440.148,603.95,603.004,636.845,-196.697,81620.762,35332.857,0.20925347,10881,4597,8253,407.9564,10000],[10241,317.66,406.789,406.54,423.034,-105.374,58706.49,25839.212,0.11678626,8543,3573,6825,217.5586,10000],[10242,329.03,425.495,424.668,444.268,-115.238,58493.983,27718.389,0.14700788,8391,3586,6438,328.2414,10000],[10243,408.381,621.367,620.738,685.31,-276.929,72032.763,34099.903,0.30429485,9620,3903,7248,384.6626,10000],[10244,350.989,440.855,440.263,459.754,-108.765,62992.148,29041.913,0.14227214,8941,3851,6991,308.2121,9996],[10245,458.29,600.109,598.644,626.627,-168.337,82810.513,36177.363,0.20760067,10648,4505,7960,481.4948,10000],[10246,433.673,563.339,562.853,588.479,-154.806,81027.813,35225.371,0.17551899,10813,4588,8403,374.8466,10000],[10247,411.796,504.918,503.671,525.019,-113.223,75901.433,33540.449,0.1547761,10104,4233,7599,386.857,10000],[10248,413.414,499.503,498.522,516.811,-103.397,77655.197,32884.455,0.14725263,10186,4313,7914,356.5969,9997],[10249,425.899,536.977,536.156,564.739,-138.84,76470.15,33694.285,0.17150194,10080,4390,7640,420.9577,10000],[10250,323.838,407.054,406.431,420.488,-96.651,59546.801,25744.269,0.11615257,8632,3912,7027,233.3293,9999],[10251,309.182,386.212,385.737,402.921,-93.739,58301.253,27435.444,0.12658613,8605,3522,6699,243.326,10000],[10252,319.835,399.768,398.819,414.735,-94.9,58633.367,26852.519,0.11798426,8267,3416,6507,261.6127,9997],[10253,469.827,581.53,580.749,601.452,-131.625,87674.663,35532.178,0.17388158,11613,5068,8951,431.5598,10000],[10254,368.706,502.475,501.888,525.885,-157.18,65254.946,32329.499,0.17363348,8632,3294,6343,366.6201,10000],[10255,479.891,601.81,600.362,630.868,-150.977,86341.925,36823.263,0.19653818,10899,4673,8215,454.2078,10000]],"aggregates":{"filtered":{"edge":413.2518866480023,"retail_edge":565.8218125723574,"arb_edge":-152.56992592435518,"retail_volume_y":74933.80087958962,"arb_volume_y":33338.14930464427,"callback_count":2547133,"callback_rms_bps":42.33603054762967,"coverage_1sd":0.42077151055716366,"coverage_2sd":0.7584888578649014,"sum_clipped_mass_over_diffusions":0.03963759156896039,"max_single_diffusion_tail":0.42482441551889316,"empty_normalizations":0},"oracle":{"edge":535.2169861452262,"retail_edge":566.7139982810816,"arb_edge":-31.49701213585545,"retail_volume_y":76276.09986144274,"arb_volume_y":23965.941748709884,"callback_count":0,"callback_rms_bps":null,"coverage_1sd":null,"coverage_2sd":null,"sum_clipped_mass_over_diffusions":null,"max_single_diffusion_tail":0.0,"empty_normalizations":0},"diagnostic":{"edge":534.2455884288743,"retail_edge":567.9587198240524,"arb_edge":-33.713131395178145,"retail_volume_y":77316.56398095473,"arb_volume_y":25233.849442426694,"callback_count":2663565,"callback_rms_bps":67.16560586770163,"coverage_1sd":0.40460623262432116,"coverage_2sd":0.7470806982371371,"sum_clipped_mass_over_diffusions":0.028326791482081125,"max_single_diffusion_tail":0.42288860064236666,"empty_normalizations":350},"oracle_minus_filtered":{"mean":121.96509949722385,"se":2.5082412427243557,"ci95_normal":[117.04894666148411,126.88125233296358]},"oracle_minus_diagnostic":{"mean":0.9713977163518877,"se":0.029213557815611954,"ci95_normal":[0.9141391430332882,1.0286562896704872]},"target_gap_le_2":false,"ci_method":"Normal 1.96*sample SE over independent paired seeds; no multiplicity correction."},"ablation":{"description":"Router likelihood disabled, same frozen parameters, filtered arm only. Compare to corresponding on-arm seeds.","columns":["seed","edge","retail_edge","arb_edge","retail_volume_y","arb_volume_y","squared_log_error_sum","callback_count"],"per_seed":[[10000,339.827,462.659,-122.832,60848.274,28477.413,0.13389715,8184],[10001,471.494,596.354,-124.859,88002.384,36371.556,0.17834053,11478],[10002,384.487,558.116,-173.629,68484.802,33501.513,0.19493911,9254],[10003,449.964,600.093,-150.129,82034.941,35732.432,0.19139885,10657],[10004,411.097,547.915,-136.817,72703.035,32923.163,0.16126209,9598],[10005,411.108,554.086,-142.979,72097.91,33483.514,0.18529146,9516],[10006,405.242,508.225,-102.984,74432.371,32252.043,0.15585581,9962],[10007,412.354,548.278,-135.924,76598.578,33037.028,0.17476315,10189],[10008,511.933,684.273,-172.339,95077.838,39645.505,0.21663364,11748],[10009,508.162,681.017,-172.855,92527.71,39704.869,0.22757899,11791],[10010,399.806,495.454,-95.648,74807.758,31409.411,0.15500001,10456],[10011,315.561,385.176,-69.615,58250.268,25318.545,0.11597416,8139],[10012,381.829,474.429,-92.601,73680.314,31156.789,0.14163529,10062],[10013,310.242,420.167,-109.925,56892.464,26193.351,0.13079253,8098],[10014,490.496,734.305,-243.808,86936.693,37778.529,0.20994521,10854],[10015,495.567,655.457,-159.89,92179.87,38918.023,0.20043847,11456],[10016,395.067,636.432,-241.365,70891.191,32626.999,0.25185782,9386],[10017,391.697,511.87,-120.173,71735.634,32505.205,0.17650413,9755],[10018,385.935,504.161,-118.227,69415.657,32326.153,0.15099199,9236],[10019,342.735,473.394,-130.659,60804.945,27909.137,0.13756906,8277],[10020,382.836,518.469,-135.632,67751.604,31193.086,0.15823143,8944],[10021,304.019,429.996,-125.977,56089.221,25805.541,0.12258002,8094],[10022,334.956,459.278,-124.322,61051.138,28066.172,0.14608801,8521],[10023,478.49,667.448,-188.958,87155.799,36851.02,0.19024501,10709],[10024,391.834,498.164,-106.33,72527.653,31650.746,0.16427356,10231],[10025,333.151,464.403,-131.251,61461.817,27339.797,0.15283983,8778],[10026,285.384,359.818,-74.435,53070.357,23711.08,0.1105993,8078],[10027,412.263,573.98,-161.717,73453.055,34319.468,0.19763751,9895],[10028,388.778,557.403,-168.624,67728.839,32733.403,0.18543433,8875],[10029,374.649,458.335,-83.686,71996.407,28237.89,0.13178066,9930],[10030,481.547,620.632,-139.085,89326.235,37139.846,0.18673348,11350],[10031,289.425,354.322,-64.896,56766.118,25453.378,0.10566795,8392],[10032,478.827,666.805,-187.977,86098.932,38803.108,0.22432907,10613],[10033,447.21,559.394,-112.184,81874.882,34940.026,0.16718241,10590],[10034,453.539,587.486,-133.947,83568.46,34083.794,0.17287545,11013],[10035,507.876,666.119,-158.243,93840.515,40080.176,0.20660883,11888],[10036,438.583,569.532,-130.949,81444.048,35027.635,0.17545039,10758],[10037,360.405,463.988,-103.583,66243.064,30416.673,0.14213364,9178],[10038,501.519,648.859,-147.34,91957.898,37722.854,0.20516467,12100],[10039,422.998,616.609,-193.611,77838.032,34480.302,0.23469979,10368],[10040,496.14,637.39,-141.25,90915.222,38515.39,0.19563514,11946],[10041,488.057,662.993,-174.937,86336.584,37208.628,0.21237789,10854],[10042,527.84,742.658,-214.818,93409.146,41461.445,0.24523378,11697],[10043,482.143,666.085,-183.942,88441.871,38137.732,0.24046318,11183],[10044,336.178,437.941,-101.763,60432.358,27547.029,0.12829303,8162],[10045,319.961,403.686,-83.725,60289.273,27810.891,0.12259008,8560],[10046,363.096,450.942,-87.846,68526.519,31671.848,0.1403471,9775],[10047,497.269,626.738,-129.469,91938.757,38975.856,0.19031057,11672],[10048,386.121,516.915,-130.794,70949.76,31226.835,0.16458254,9851],[10049,311.919,401.294,-89.375,56794.529,25076.861,0.1148847,8169],[10050,306.852,392.305,-85.453,57205.141,25107.771,0.11684534,8406],[10051,334.761,439.55,-104.789,60011.667,28111.57,0.1399104,8316],[10052,356.951,447.262,-90.312,67860.781,28994.905,0.13160583,9748],[10053,400.022,561.8,-161.777,72956.836,33174.669,0.17524275,9726],[10054,338.263,467.223,-128.96,63307.098,28897.43,0.14060306,8838],[10055,534.863,742.217,-207.354,95688.452,42273.685,0.24369583,11933],[10056,471.494,611.436,-139.943,84221.324,37040.391,0.20014101,10503],[10057,378.826,528.591,-149.765,68379.911,31849.908,0.18445518,9217],[10058,319.041,455.932,-136.89,57468.599,27468.261,0.14790717,8500],[10059,393.779,532.695,-138.916,72099.706,33697.686,0.19004492,9547],[10060,507.758,2091.546,-1583.788,91359.51,41327.556,0.75750468,11338],[10061,450.748,582.408,-131.66,82708.853,34543.534,0.17484549,10908],[10062,482.951,636.382,-153.431,90241.031,36555.074,0.196046,11502],[10063,342.842,445.567,-102.725,63319.639,27433.879,0.12687271,8850]],"aggregate":{"edge":407.98081757006616,"retail_edge":566.4759098496775,"arb_edge":-158.49509227961084,"retail_volume_y":74601.7075419914,"arb_volume_y":32866.18763081079,"callback_count":635602,"callback_rms_bps":42.63140348964429,"coverage_1sd":0.45876035632361134,"coverage_2sd":0.7672490017337894,"sum_clipped_mass_over_diffusions":0.04069314468294194,"max_single_diffusion_tail":0.4227933626817867,"empty_normalizations":0},"on_minus_off_edge":{"mean":0.3718106908673473,"se":0.16756504438074799,"ci95_normal":[0.043383203881081245,0.7002381778536133]}},"full_runnable_source":{"replica.py":"\"\"\"Pure-Python replica of benedictbrady/amm-challenge @6b6921f8 (engine.rs, cfmm.rs,\narbitrageur.rs, router.rs, retail.rs), written from the source for ceiling experiments.\nRNG streams differ from the Rust engine, so absolute scores move by the seed set;\ncompare policies paired on the same seeds.\n\nA policy gets a callback after every trade on its own pool (arb or retail), like afterSwap,\nplus an oracle view (true fair price p and the 30 bps pool's spot s2 after the pending\naction of the same event), and returns (bid_fee, ask_fee).\"\"\"\nimport math, random\n\nK = 100.0 * 10000.0\nMAXF = 0.1\nNF = 0.003  # normalizer fee\n\n\ndef clampf(f):\n    return 0.0 if f < 0.0 else (MAXF if f > MAXF else f)\n\n\ndef run(seed, policy, n_steps=10000, cfg=None):\n    cr = random.Random(10_000_000 + seed)\n    size_mean = cr.uniform(19.0, 21.0)\n    lam = cr.uniform(0.6, 1.0)\n    sigma = cr.uniform(0.000882, 0.001008)\n    if cfg:\n        size_mean, lam, sigma = cfg\n    pr = random.Random(seed)\n    rr = random.Random(seed + 1)\n    drift = -0.5 * sigma * sigma\n    mu_ln = math.log(size_mean) - 0.5 * 1.2 * 1.2\n    emlam = math.exp(-lam)\n    p = 100.0\n    x1, y1 = 100.0, 10000.0\n    x2, y2 = 100.0, 10000.0\n    fb, fa = policy.init(sigma, lam, size_mean)\n    fb, fa = clampf(fb), clampf(fa)\n    e1 = e2 = 0.0\n    ret1 = arb1 = 0.0  # our retail / arb edge\n    rv1 = av1 = 0.0\n    sum_fb = sum_fa = 0.0\n    g2 = 1.0 - NF\n    sqrt = math.sqrt\n    for t in range(n_steps):\n        p *= math.exp(drift + sigma * pr.gauss(0.0, 1.0))\n        # --- arbitrage, normalizer first (pools are independent), then ours\n        s2 = y2 / x2\n        if s2 < p:\n            nx = sqrt(K / (g2 * p)); ax = x2 - nx\n            if ax > 0:\n                ax = min(ax, x2 * 0.99)\n                nrx = x2 - ax; nry = K / nrx; net_y = nry - y2; ty = net_y / g2\n                prof = ax * p - ty\n                if prof > 0:\n                    x2, y2 = nrx, nry; e2 -= prof\n        elif s2 > p:\n            xv = sqrt(K * g2 / p); ax = (xv - x2) / g2\n            if ax > 0:\n                nrx = x2 + ax * g2; nry = K / nrx; yo = y2 - nry\n                prof = yo - ax * p\n                if yo > 0 and prof > 0:\n                    x2, y2 = nrx, nry; e2 -= prof\n        s1 = y1 / x1\n        if s1 < p:\n            g = 1.0 - fa\n            if g > 0:\n                nx = sqrt(K / (g * p)); ax = x1 - nx\n                if ax > 0:\n                    ax = min(ax, x1 * 0.99)\n                    nrx = x1 - ax; nry = K / nrx; net_y = nry - y1; ty = net_y / g\n                    prof = ax * p - ty\n                    if prof > 0:\n                        x1, y1 = nrx, nry; e1 -= prof; arb1 -= prof; av1 += ty\n                        fb, fa = policy.on_trade(False, ax, ty, t, x1, y1, True, p, y2 / x2)\n                        fb, fa = clampf(fb), clampf(fa)\n        elif s1 > p:\n            g = 1.0 - fb\n            if g > 0:\n                xv = sqrt(K * g / p); ax = (xv - x1) / g\n                if ax > 0:\n                    nrx = x1 + ax * g; nry = K / nrx; yo = y1 - nry\n                    prof = yo - ax * p\n                    if yo > 0 and prof > 0:\n                        x1, y1 = nrx, nry; e1 -= prof; arb1 -= prof; av1 += yo\n                        fb, fa = policy.on_trade(True, ax, yo, t, x1, y1, True, p, y2 / x2)\n                        fb, fa = clampf(fb), clampf(fa)\n        # --- retail\n        n = 0; q = rr.random()\n        while q > emlam:\n            n += 1; q *= rr.random()\n        for _ in range(n):\n            size = rr.lognormvariate(mu_ln, 1.2)\n            buy = rr.random() < 0.5\n            if buy:  # trader buys X with Y\n                ga = 1.0 - fa\n                a1 = sqrt(x1 * ga * y1); a2 = sqrt(x2 * g2 * y2); r = a1 / a2\n                d = ga + r * g2\n                u1 = (r * (y2 + g2 * size) - y1) / d if d != 0 else size / 2\n                u1 = 0.0 if u1 < 0 else (size if u1 > size else u1)\n                u2 = size - u1\n                if u2 > 1e-4:\n                    nry = y2 + u2 * g2; nrx = K / nry; xo = x2 - nrx\n                    if xo > 0:\n                        e2 += u2 - xo * p; x2, y2 = nrx, nry\n                if u1 > 1e-4:\n                    nry = y1 + u1 * ga; nrx = K / nry; xo = x1 - nrx\n                    if xo > 0:\n                        ed = u1 - xo * p; e1 += ed; ret1 += ed; rv1 += u1\n                        x1, y1 = nrx, nry\n                        fb, fa = policy.on_trade(False, xo, u1, t, x1, y1, False, p, y2 / x2)\n                        fb, fa = clampf(fb), clampf(fa)\n            else:  # trader sells X\n                tx = size / p\n                gb = 1.0 - fb\n                b1 = sqrt(y1 * gb * x1); b2 = sqrt(y2 * g2 * x2); r = b1 / b2\n                d = gb + r * g2\n                v1 = (r * (x2 + g2 * tx) - x1) / d if d != 0 else tx / 2\n                v1 = 0.0 if v1 < 0 else (tx if v1 > tx else v1)\n                v2 = tx - v1\n                if v2 > 1e-4:\n                    nrx = x2 + v2 * g2; nry = K / nrx; yo = y2 - nry\n                    if yo > 0:\n                        e2 += v2 * p - yo; x2, y2 = nrx, nry\n                if v1 > 1e-4:\n                    nrx = x1 + v1 * gb; nry = K / nrx; yo = y1 - nry\n                    if yo > 0:\n                        ed = v1 * p - yo; e1 += ed; ret1 += ed; rv1 += yo\n                        x1, y1 = nrx, nry\n                        fb, fa = policy.on_trade(True, v1, yo, t, x1, y1, False, p, y2 / x2)\n                        fb, fa = clampf(fb), clampf(fa)\n        sum_fb += fb; sum_fa += fa\n    return dict(edge=e1, norm=e2, retail=ret1, arb=arb1, rv=rv1, av=av1,\n                fb=sum_fb / n_steps * 1e4, fa=sum_fa / n_steps * 1e4,\n                sigma=sigma, lam=lam, size=size_mean)\n\n\nclass Fixed:\n    def __init__(self, f): self.f = f\n    def init(self, *a): return self.f, self.f\n    def on_trade(self, *a): return self.f, self.f\n\n\nclass OracleQuote:\n    \"\"\"Quote ask p(1+m) and bid p(1-m) around the TRUE fair price after every own trade.\"\"\"\n    def __init__(self, m): self.m = m\n    def init(self, *a): return 0.003, 0.003\n    def on_trade(self, is_buy, ax, ay, t, x, y, arb, p, s2):\n        s = y / x\n        fa = 1.0 - s / (p * (1 + self.m))\n        fb = 1.0 - p * (1 - self.m) / s\n        return fb, fa\n\n\nclass OracleCompete:\n    \"\"\"Know p and the 30 bps pool's spot s2. Ask quote: undercut the rival's ask by u,\n    but never below p(1+mlo); bid quote: outbid the rival's bid by u, never above p(1-mlo).\"\"\"\n    def __init__(self, mlo, u, mhi=1.0):\n        self.mlo, self.u, self.mhi = mlo, u, mhi\n    def init(self, *a): return 0.003, 0.003\n    def on_trade(self, is_buy, ax, ay, t, x, y, arb, p, s2):\n        s = y / x\n        ra = s2 / (1 - NF); rb = s2 * (1 - NF)\n        qa = max(p * (1 + self.mlo), min(ra * (1 - self.u), p * (1 + self.mhi)))\n        qb = min(p * (1 - self.mlo), max(rb * (1 + self.u), p * (1 - self.mhi)))\n        return 1.0 - qb / s, 1.0 - s / qa\n","model.py (offline standard library)":"\"\"\"Dependency-free translation of the frozen NumPy grid; slower, for offline reproduction.\"\"\"\nimport math\nASK=[-0.8836,-0.9345,-0.8159,-0.7282,-0.6342,-0.5652,-0.2453,0.7252,1.1735,1.4444,1.6154,2.7552,2.9767,3.3159,4.4695,5.071,5.7838]\nBID=[5.6921,5.1279,4.4766,4.0233,3.3293,2.4659,1.7209,1.4329,1.2125,0.7478,-0.2275,-0.5564,-0.6444,-0.7169,-0.7926,-0.8617,-0.8452]\nN=64; H=.0004; CENTERS=[(i-(N-1)/2)*H for i in range(N)]\ndef cdf(x):return .5*(1+math.erf(x/math.sqrt(2)))\ndef interp(x,arr):\n x=min(16,max(0,x));i=int(x)\n if i==16:return arr[16]\n return arr[i]*(1-(x-i))+arr[i+1]*(x-i)\ndef fee(z,arb):\n d=-z/.003+8;a=interp(d,ASK)+.1463*arb;b=interp(d,BID)+.1463*arb\n return max(0.,min(.1,1-math.exp(z-b*.003))),max(0.,min(.1,1-math.exp(-z-a*.003)))\nclass Grid:\n def __init__(self,router=True):\n  self.router=router;self.fb=self.fa=.003;self.spot=100.;self.t=-1;self.center=0.;self.w=[0.]*N;self.w[31]=self.w[32]=.5\n  self.sig=.000945;self.last_pin=None;self.last_pin_t=None;self.tail=0.;self.tail_max=0.;self.n_diff=0;self.zero=0;self.arb_p=0.;self.set_kernel()\n def set_kernel(self):\n  self.kernel=[cdf((k+.5)*H/self.sig)-cdf((k-.5)*H/self.sig) for k in range(-16,17)];s=sum(self.kernel);self.kernel=[v/s for v in self.kernel]\n def diffuse(self):\n  full=[0.]*(N+32)\n  for i,a in enumerate(self.w):\n   for j,b in enumerate(self.kernel):full[i+j]+=a*b\n  lost=sum(full[:16])+sum(full[16+N:]);self.tail+=lost;self.tail_max=max(self.tail_max,lost);self.n_diff+=1\n  self.w=full[16:16+N];self.w[0]+=sum(full[:16]);self.w[-1]+=sum(full[16+N:]);self.center-=.5*self.sig*self.sig\n def recenter(self):\n  shift=int(round(-self.center/H))\n  if not shift:return\n  new=[0.]*N\n  for i,v in enumerate(self.w):\n   j=i-shift;new[min(N-1,max(0,j))]+=v\n   if j<0 or j>=N:self.tail+=v\n  self.w=new;self.center+=shift*H\n def band(self,weights):\n  lo=math.log1p(-self.fb);hi=-math.log1p(-self.fa)\n  return [v*min(1,max(0,(min(z+self.center+H/2,hi)-max(z+self.center-H/2,lo))/H)) for z,v in zip(CENTERS,weights)]\n def norm(self,w):\n  s=sum(w)\n  if s<=1e-300:self.zero+=1;return [1/N]*N\n  return [v/s for v in w]\n def router_like(self,z,is_buy,ax,ay,prex,prey):\n  rv=[k*.0045 for k in [-2.,-1.,0.,1.,2.]];rw=[.06136,.24477,.38774,.24477,.06136]\n  q=[-2.2,-1.5,-.9,-.45,0,.45,.9,1.5,2.2];qw=[math.exp(-a*a/2) for a in q];qsum=sum(qw);qw=[a/qsum for a in qw]\n  g=1-(self.fb if is_buy else self.fa);gr=.997;likes=[]\n  for zz in z:\n   p=self.spot*math.exp(zz);like=0.\n   for r,wr in zip(rv,rw):\n    rival=p*math.exp(r);rx=math.sqrt(1000000./rival);ry=math.sqrt(1000000.*rival)\n    for qi,wq in zip(q,qw):\n     size=20*math.exp(-.72+1.2*qi)\n     if not is_buy:\n      ratio=math.sqrt(prex*g*prey/(rx*gr*ry));pred=(ratio*(ry+gr*size)-prey)/(g+ratio*gr);obs=ay\n     else:\n      size/=p;ratio=math.sqrt(prey*g*prex/(ry*gr*rx));pred=(ratio*(rx+gr*size)-prex)/(g+ratio*gr);obs=ax\n     pred=max(1e-12,min(size,pred));like+=wr*wq*math.exp(-.5*(math.log(pred/max(obs,1e-12))/.65)**2)\n   likes.append(like)\n  m=max(likes)+1e-30;return [.25+.75*a/m for a in likes]\n def on_trade(self,is_buy,ax,ay,t,x,y):\n  oldspot=self.spot;newspot=y/x;g=1-(self.fb if is_buy else self.fa)\n  if is_buy:prex=x-ax*g;prey=y+ay\n  else:prex=x+ax;prey=y-ay*g\n  first=t!=self.t\n  if first:\n   for _ in range(max(0,t-self.t-1)):self.diffuse();self.w=self.norm(self.band(self.w))\n   self.diffuse()\n  z=[self.center+a for a in CENTERS];retail=self.band(self.w) if first else self.w[:]\n  if self.router:retail=[a*b for a,b in zip(retail,self.router_like(z,is_buy,ax,ay,prex,prey))]\n  pr=0.;pin=newspot*g if is_buy else newspot/g\n  if first and pin>0 and prex>0 and prey>0:\n   zp=math.log(pin/oldspot);i=(zp-z[0])/H\n   if i<0 or i>N-1:density=0.\n   elif i==N-1:density=self.w[-1]/H\n   else:\n    j=int(i);density=(self.w[j]*(1-(i-j))+self.w[j+1]*(i-j))/H\n   outside=zp<math.log1p(-self.fb) if is_buy else zp>-math.log1p(-self.fa)\n   jac=2*ax*g/max(x,1e-30) if is_buy else 2*ax/max(x,1e-30)\n   amount=ay if not is_buy else ax*pin\n   rd=.8/(1.2*math.sqrt(2*math.pi))*math.exp(-.5*((math.log(max(amount,1e-12)/20)+.72)/1.2)**2)\n   ad=density*jac if outside else 0.;pr=ad/(ad+rd+1e-30)\n  self.arb_p=pr;self.center+=math.log(oldspot/newspot);retail=self.norm(retail);self.w=[v*(1-pr) for v in retail]\n  zpafter=math.log(pin/newspot);u=(zpafter-self.center)/H+(N-1)/2;j=math.floor(u);frac=u-j\n  for jj,mass in [(j,pr*(1-frac)),(j+1,pr*frac)]:\n   if not 0<=jj<N:self.tail+=mass\n   self.w[min(N-1,max(0,jj))]+=mass\n  self.w=self.norm(self.w);self.recenter();self.spot=newspot;self.t=t\n  if pr>.9:\n   if self.last_pin is not None and t>self.last_pin_t:\n    dt=t-self.last_pin_t;r=math.log(pin/self.last_pin);v=.995*self.sig**2+.005*min(.003**2,r*r/dt);self.sig=min(.0014,max(.0006,math.sqrt(v)));self.set_kernel()\n   self.last_pin=pin;self.last_pin_t=t\n  mean=sum(a*(self.center+z) for a,z in zip(self.w,CENTERS));self.fb,self.fa=fee(mean,pr>.5);return self.fb,self.fa\n def stats(self):\n  z=[self.center+a for a in CENTERS];mean=sum(a*b for a,b in zip(self.w,z));return mean,math.sqrt(sum(a*(b-mean)**2 for a,b in zip(self.w,z)))\n","model_numpy.py (used in evaluation; save as model.py)":"import math\nimport numpy as np\n\nASK=np.array([-0.8836,-0.9345,-0.8159,-0.7282,-0.6342,-0.5652,-0.2453,0.7252,1.1735,1.4444,1.6154,2.7552,2.9767,3.3159,4.4695,5.071,5.7838])\nBID=np.array([5.6921,5.1279,4.4766,4.0233,3.3293,2.4659,1.7209,1.4329,1.2125,0.7478,-0.2275,-0.5564,-0.6444,-0.7169,-0.7926,-0.8617,-0.8452])\nN=64\nH=.0004\nCENTERS=(np.arange(N)-(N-1)/2)*H\nSQRT2=math.sqrt(2)\ndef cdf(x): return .5*(1+math.erf(x/SQRT2))\ndef fee(z,arb):\n    d=-z/.003\n    a=np.interp(d,np.arange(-8,9),ASK)+.1463*arb\n    b=np.interp(d,np.arange(-8,9),BID)+.1463*arb\n    return max(0.,min(.1,1-math.exp(z-b*.003))),max(0.,min(.1,1-math.exp(-z-a*.003)))\n\nclass Grid:\n    def __init__(self,router=True):\n        self.router=router; self.fb=self.fa=.003; self.spot=100.; self.t=-1\n        self.center=0.; self.w=np.zeros(N); self.w[31:33]=.5\n        self.sig=.000945; self.last_pin=None; self.last_pin_t=None\n        self.tail=0.; self.tail_max=0.; self.n_diff=0; self.zero=0; self.arb_p=0.\n        self.set_kernel()\n    def set_kernel(self):\n        # Gaussian bin-integrated transition, with omitted tails accumulated at edge.\n        self.kernel=np.array([cdf((k+.5)*H/self.sig)-cdf((k-.5)*H/self.sig) for k in range(-16,17)])\n        self.kernel/=sum(self.kernel)\n    def diffuse(self):\n        w=np.convolve(self.w,self.kernel,'full'); cut=16\n        lost=float(sum(w[:cut])+sum(w[cut+N:])); self.tail+=lost; self.tail_max=max(self.tail_max,lost); self.n_diff+=1\n        self.w=w[cut:cut+N].copy(); self.w[0]+=sum(w[:cut]); self.w[-1]+=sum(w[cut+N:]); self.center-=.5*self.sig*self.sig\n    def recenter(self):\n        # Translate by integer buckets; conserve clipped mass at the nearest edge.\n        shift=int(round(-self.center/H))\n        if not shift: return\n        old=self.w.copy(); new=np.zeros(N)\n        for i in range(N):\n            j=min(N-1,max(0,i-shift)); new[j]+=old[i]\n            if i-shift<0 or i-shift>=N: self.tail+=old[i]\n        self.w=new; self.center+=shift*H\n    def band(self,weights):\n        z=self.center+CENTERS\n        lo=math.log1p(-self.fb); hi=-math.log1p(-self.fa)\n        frac=np.clip((np.minimum(z+H/2,hi)-np.maximum(z-H/2,lo))/H,0,1)\n        return weights*frac\n    def norm(self,w):\n        s=float(np.sum(w))\n        if s<=1e-300:\n            self.zero+=1; w=np.ones(N); s=N\n        return w/s\n    def router_like(self,z,is_buy,ax,ay,prex,prey):\n        # Quadrature over unknown order size and rival pre-retail displacement.\n        # Rival's spread may exceed 30bp after prior retail in this step; use a broad prior.\n        rv=np.array([-2.,-1.,0.,1.,2.])*.0045\n        rw=np.array([.06136,.24477,.38774,.24477,.06136])\n        q=np.array([-2.2,-1.5,-.9,-.45,0,.45,.9,1.5,2.2])\n        qw=np.exp(-q*q/2); qw/=sum(qw)\n        p=(self.spot*np.exp(z))[:,None,None]\n        rival=p*np.exp(rv[None,:,None]); rx=np.sqrt(1000000./rival); ry=np.sqrt(1000000.*rival)\n        size=20*np.exp(-.72+1.2*q)[None,None,:]\n        g=1-(self.fb if is_buy else self.fa); gr=.997\n        if not is_buy:\n            ratio=np.sqrt(prex*g*prey/(rx*gr*ry)); pred=(ratio*(ry+gr*size)-prey)/(g+ratio*gr); obs=ay\n        else:\n            size=size/p; ratio=np.sqrt(prey*g*prex/(ry*gr*rx)); pred=(ratio*(rx+gr*size)-prex)/(g+ratio*gr); obs=ax\n        pred=np.maximum(1e-12,np.minimum(size,pred))\n        # Kernel density in log fill magnitude; include route-to-zero in the quadrature.\n        like=np.exp(-.5*(np.log(pred/max(obs,1e-12))/.65)**2)\n        like=(like*rw[None,:,None]*qw[None,None,:]).sum(axis=(1,2))\n        return .25+.75*like/(float(np.max(like))+1e-30)\n    def on_trade(self,is_buy,ax,ay,t,x,y):\n        oldspot=self.spot; newspot=y/x; g=1-(self.fb if is_buy else self.fa)\n        # Reverse the net reserve change using callback-visible values.\n        if is_buy: prex=x-ax*g; prey=y+ay\n        else: prex=x+ax; prey=y-ay*g\n        first=t!=self.t\n        if first:\n            for _ in range(max(0,t-self.t-1)):\n                self.diffuse(); self.w=self.norm(self.band(self.w))\n            self.diffuse()\n        z=self.center+CENTERS\n        retail=self.band(self.w) if first else self.w.copy()\n        if self.router:\n            retail*=self.router_like(z,is_buy,ax,ay,prex,prey)\n        pr=0.\n        pin=(newspot*g if is_buy else newspot/g)\n        if first and pin>0 and prex>0 and prey>0:\n            zp=math.log(pin/oldspot)\n            density=float(np.interp(zp,z,self.w,left=0,right=0))/H\n            outside=zp<math.log1p(-self.fb) if is_buy else zp>-math.log1p(-self.fa)\n            jac=2*ax*g/max(x,1e-30) if is_buy else 2*ax/max(x,1e-30)\n            # First-callback alternative: density in log fill size vs retail lognormal prior.\n            amount=ay if not is_buy else ax*pin\n            retail_density=.8/(1.2*math.sqrt(2*math.pi))*math.exp(-.5*((math.log(max(amount,1e-12)/20)+.72)/1.2)**2)\n            arb_density=density*jac if outside else 0.\n            pr=arb_density/(arb_density+retail_density+1e-30)\n        self.arb_p=pr\n        # Both branches are carried on the same relative-price grid after the reserve move.\n        self.center+=math.log(oldspot/newspot)\n        retail=self.norm(retail)\n        self.w=retail*(1-pr)\n        zpafter=math.log(pin/newspot)\n        u=(zpafter-self.center)/H+(N-1)/2\n        j=math.floor(u); frac=u-j\n        if 0<=j<N: self.w[j]+=pr*(1-frac)\n        else: self.w[0 if j<0 else -1]+=pr*(1-frac); self.tail+=pr*(1-frac)\n        if 0<=j+1<N: self.w[j+1]+=pr*frac\n        else: self.w[0 if j+1<0 else -1]+=pr*frac; self.tail+=pr*frac\n        self.w=self.norm(self.w); self.recenter(); self.spot=newspot; self.t=t\n        if pr>.9:\n            if self.last_pin is not None and t>self.last_pin_t:\n                dt=t-self.last_pin_t; r=math.log(pin/self.last_pin)\n                # Strong shrinkage and bounds: selection biases and ambiguous pins remain.\n                v=.995*self.sig**2+.005*min(.003**2,r*r/dt)\n                self.sig=min(.0014,max(.0006,math.sqrt(v))); self.set_kernel()\n            self.last_pin=pin; self.last_pin_t=t\n        mean=float(np.dot(self.w,self.center+CENTERS)); self.fb,self.fa=fee(mean,pr>.5)\n        return self.fb,self.fa\n    def stats(self):\n        z=self.center+CENTERS; mean=float(np.dot(self.w,z)); sd=math.sqrt(float(np.dot(self.w,(z-mean)**2)))\n        return mean,sd\n","run.py":"import json, math, sys, time\nfrom model import Grid,fee\nimport replica\n\nclass Harness:\n    def __init__(self,mode='filtered',router=True):\n        self.f=Grid(router); self.mode=mode; self.err=0.; self.count=0; self.cover1=0; self.cover2=0; self.flags=0; self.flagcorrect=0\n    def init(self,*hidden): return .003,.003\n    def on_trade(self,b,ax,ay,t,x,y,arb,p,s2):\n        if self.mode=='oracle': return fee(math.log(p/(y/x)),arb)\n        fb,fa=self.f.on_trade(b,ax,ay,t,x,y)\n        mean,sd=self.f.stats(); truth=math.log(p/(y/x)); err=mean-truth\n        self.err+=err*err; self.count+=1; self.cover1+=abs(err)<=sd; self.cover2+=abs(err)<=2*sd\n        pred=self.f.arb_p>.5; self.flags+=pred; self.flagcorrect+=pred==arb\n        if self.mode=='diagnostic': fb,fa=fee(truth,pred)\n        self.f.fb,self.f.fa=fb,fa\n        return fb,fa\n\ndef one(seed,steps,router=True, modes=('filtered','oracle','diagnostic')):\n    row={'seed':seed}\n    for mode in modes:\n        h=Harness(mode,router); out=replica.run(seed,h,steps)\n        row[mode]={k:out[k] for k in ('edge','retail','arb','rv','av')}\n        row[mode].update(sq=h.err,n=h.count,cover1=h.cover1,cover2=h.cover2,flagcorrect=h.flagcorrect,flags=h.flags,tail=h.f.tail,tail_max=h.f.tail_max,diff=h.f.n_diff,zero=h.f.zero)\n    return row\nif __name__=='__main__':\n    start=int(sys.argv[1]); stop=int(sys.argv[2]); steps=int(sys.argv[3]); router=int(sys.argv[4]); out=sys.argv[5]\n    with open(out,'a') as f:\n        for seed in range(start,stop):\n            t=time.monotonic(); r=one(seed,steps,bool(router)); f.write(json.dumps(r,separators=(',',':'))+'\\n'); f.flush(); print(seed,round(time.monotonic()-t,2),r['filtered']['edge'],r['oracle']['edge'],flush=True)\n","ablate.py":"import json,sys,time\nfrom run import one\nstart=int(sys.argv[1]);stop=int(sys.argv[2]);out=sys.argv[3]\nwith open(out,'a') as f:\n for seed in range(start,stop):\n  t=time.monotonic();r=one(seed,10000,False,('filtered',));f.write(json.dumps(r,separators=(',',':'))+'\\n');f.flush();print(seed,round(time.monotonic()-t,2),flush=True)\n","test_model.py":"import math\nimport numpy as np\nfrom model import Grid,fee,H\nfrom run import Harness\n\ndef event(up=True,p=100.4):\n x0,y0=100.,10000.; k=x0*y0; g=.997\n if up:\n  x=math.sqrt(k/(g*p)); y=k/x; return False,x0-x,(y-y0)/g,x,y,p\n x=math.sqrt(k*g/p); y=k/x; return True,(x-x0)/g,y0-y,x,y,p\n\ndef test():\n fb,fa=fee(.002,False)\n assert fb>=0 and fa>=0 and abs(fb-fa)>.0001\n for up in (True,False):\n  b,ax,ay,x,y,p=event(up,100.4 if up else 99.6); g=Grid(False)\n  g.on_trade(b,ax,ay,0,x,y)\n  recovered=(y/x)*(1-.003) if b else (y/x)/(1-.003)\n  assert abs(recovered/p-1)<1e-12 and g.arb_p>0\n  nd=g.n_diff; g.on_trade(b,ax*.01,ay*.01,0,x,y)\n  assert g.n_diff==nd and g.arb_p==0\n g=Grid(False); b,ax,ay,x,y,p=event(); g.on_trade(b,ax,ay,0,x,y)\n nd=g.n_diff; g.on_trade(b,ax*.01,ay*.01,4,x,y); assert g.n_diff-nd==4\n a=Harness('filtered',False); c=Harness('filtered',False)\n assert a.init(.01,0,1)==c.init(.5,8,9)\n for t in (0,0,4):\n  o=a.on_trade(b,ax,ay,t,x,y,True,90.,23.)\n  q=c.on_trade(b,ax,ay,t,x,y,False,120.,200.)\n  assert o==q and np.array_equal(a.f.w,c.f.w)\n g=Grid(False); g.center=.03; g.recenter(); assert abs(g.w.sum()-1)<1e-12 and g.tail>0\n print('PASS: signs, latent first/repeated, skipped steps, hidden isolation, recenter conservation')\nif __name__=='__main__':test()\n"},"reproduction":"Save source strings using names replica.py, model.py, run.py, ablate.py in one directory. Offline standard-library version: python3 -S run.py 10000 10001 10000 1 out.jsonl; repeat ranges 10000..10256 and use ablate.py 10000 10064 ablation.jsonl. For measured speed use model_numpy.py saved as model.py, with NumPy installed. run.py appends results, so start with fresh output files. Each mode is a separate replica.run call with the same seed and unchanged replica semantics. Full offline version is much slower; floating roundoff can cause closed-loop divergence.","harness_changes":"Wrapper discards all init arguments and forwards only side, amounts, timestamp and post reserves to Grid. p and true arb are used only by external metrics/oracle arms; rival spot is ignored. Diagnostic feeds actual selected oracle-price fees back into its Grid. Replica source is unchanged. Callback errors are measured after posterior update; coverages use posterior mean +/- sd and +/- 2sd.","tests":[{"command":"OPENBLAS_NUM_THREADS=1 python test_model.py","result":"PASS: ask/bid fee signs, both pin signs, first and repeated timestamps, four-step gap diffusion, identical public observations with differing hidden inputs, recenter conservation."},{"command":"instrument Grid.band after callback at t=0, then callback at t=4","result":"PASS: three intervening diffusion/truncations and one current-step retail-band truncation."},{"command":"python3 -S run.py 0 1 40 1 smoke.jsonl; compare NumPy run at same seed","result":"PASS: all logged fields agree within 1e-8; separate 16-callback NumPy/stdlib grid comparison maximum difference 6.56e-15."}],"runtime":{"holdout_wall_seconds_approx":133,"ablation_wall_seconds_approx":7,"measurement":"elapsed file creation to last modification across eight workers; setup and training excluded"},"port_estimate":"64 floating weights plus center, last timestamp/fees, sigma, last pin and counters; O(64*33) work per elapsed step for naive diffusion and O(64*45) router quadrature per callback, plus band and recenter. No Solidity implementation or gas measurement; this direct implementation is unlikely to fit a 245k gas callback budget without a different numerical representation and optimization.","dead_ends_and_limitations":["Early development implementation accidentally returned ask/bid in reverse order; on training seed 0 the purported oracle edge was 251.149. Correcting the order produced 549.912; early numbers are invalid and excluded.","Before recentering, development seed 0 callback RMS was 59.0 bp and there were 1138 empty normalizations; corrected recentering gave 42.6 bp and zero empty normalizations on that seed.","This is an approximate grid filter, not an exact posterior: Gaussian bin approximation, capped finite window, hand-built first-event likelihood and router quadrature, Gaussian-kernel observation smoothing, discrete arb threshold, and assumed rather than inferred rival liquidity/state distribution. The current code assumes an uncapped pin and does not explicitly detect the 99% reserve cap.","Grid rounding has nominal half-bin resolution 2 bp per projection; this is not a bound on accumulated posterior error. Clipped mass is accumulated each time it is pushed to a boundary, so its normalized sum is a diagnostic, not a probability or rigorous error bound. Transition tails outside the 33-point kernel are discarded and renormalized.","Prior rival displacement is broad (45 bp scale) and is not constrained to the 30 bp post-arbitrage band after arbitrary retail; the prior does not explicitly track rival history. Pin-derived sigma is selected on likely arbs, strongly shrunk and subject to classification and stopping-time bias; its uncertainty is not propagated.","The router likelihood off ablation is only 64 seeds and its paired difference is observational for this frozen policy. RMS and coverage are callback weighted, not time weighted. Counts exclude true-price oracle callbacks because no estimator runs in that arm.","No real-engine strategy, real-engine validation, 4000-seed RS2 comparison, Solidity gas numbers, or 256-seed Python/Solidity equality test were attempted; this poor replica result does not support a leaderboard claim."]}
