{
  "approach": "Submission readiness audit of unchanged B: static review of pinned sandbox/loader/API, 20-seed serial pilot, then 1000 serial simulations with a transparent callback timing wrapper. No candidate, oracle, sandbox execution or finalist seeds.",
  "tried": [
    {
      "name": "identity",
      "passed": true,
      "source": "https://api.imd.fun/artifacts/ecbc9087b4f238fc1b5b0d52f55af073f676c038bfb6756172b1e51480ac1741",
      "sha256": "baef955ec10728839f7c3357016ec9eb0550e7ec689bbd5171b1cdd5c9e37273"
    },
    {
      "name": "pilot",
      "n": 20,
      "seeds": [
        242000,
        242019
      ],
      "failures": 0,
      "seconds": 4.263242019049358,
      "projected_1000_seconds": 213.16210095246788,
      "decision": "Under 30 minutes; use full 1000-seed block."
    },
    {
      "name": "instrumentation_equivalence",
      "n": 20,
      "seeds": [
        242000,
        242019
      ],
      "identical": [
        "every SimulationResult field (including regime, all edges, failure flag, wealth and fills)"
      ],
      "max_abs_total_edge_difference": 0.0,
      "simulator_files_modified": false,
      "method": "Factory wraps B.on_step with perf_counter_ns and reads supplied state plus B bookkeeping sizes; returns original action list. No hidden state, process, market or RNG changes. Baseline via load_strategy_factory and run_batch.",
      "pilot_harness": "import sys,time,json,hashlib\nfrom pathlib import Path\nfrom dataclasses import asdict\nsys.path.insert(0,str(Path(__file__).parent/'simulator'))\nfrom orderbook_pm_challenge.config import ChallengeConfig,ParameterVariance\nfrom orderbook_pm_challenge.loader import load_strategy_factory\nfrom orderbook_pm_challenge.runner import run_batch\np=Path(__file__).parent\nassert hashlib.sha256((p/'B.py').read_bytes()).hexdigest()=='baef955ec10728839f7c3357016ec9eb0550e7ec689bbd5171b1cdd5c9e37273'\nf=load_strategy_factory(str(p/'B.py'))\nstart,end=map(int,sys.argv[1:3])\nwith (p/f'raw-{start}-{end}.jsonl').open('w') as out:\n for s in range(start,end):\n  t=time.perf_counter()\n  r=run_batch(f,base_config=ChallengeConfig(),variance=ParameterVariance(),n_simulations=1,seed_start=s,workers=1).simulation_results[0]\n  d=asdict(r);d['seconds']=time.perf_counter()-t\n  out.write(json.dumps(d)+'\\n');out.flush()\n  if (s-start+1)%20==0: print(s+1,d['seconds'],flush=True)\n",
      "pilot_edges": [
        {
          "seed": 242000,
          "total_edge": 7.0551850827,
          "retail_edge": 19.1572614757,
          "arb_edge": -12.102076393,
          "failed": false
        },
        {
          "seed": 242001,
          "total_edge": 23.218364451,
          "retail_edge": 65.9318475812,
          "arb_edge": -42.71348313,
          "failed": false
        },
        {
          "seed": 242002,
          "total_edge": 17.4958125767,
          "retail_edge": 42.8795068073,
          "arb_edge": -25.3836942305,
          "failed": false
        },
        {
          "seed": 242003,
          "total_edge": 103.1035457356,
          "retail_edge": 132.1221031488,
          "arb_edge": -29.0185574139,
          "failed": false
        },
        {
          "seed": 242004,
          "total_edge": 46.3193541557,
          "retail_edge": 64.1102402414,
          "arb_edge": -17.7908860862,
          "failed": false
        },
        {
          "seed": 242005,
          "total_edge": 0.4037716172,
          "retail_edge": 1.0155915594,
          "arb_edge": -0.6118199412,
          "failed": false
        },
        {
          "seed": 242006,
          "total_edge": 77.282016653,
          "retail_edge": 149.4353748399,
          "arb_edge": -72.1533581865,
          "failed": false
        },
        {
          "seed": 242007,
          "total_edge": 13.5886757475,
          "retail_edge": 36.5531962247,
          "arb_edge": -22.9645204771,
          "failed": false
        },
        {
          "seed": 242008,
          "total_edge": 11.8276422331,
          "retail_edge": 18.5576980483,
          "arb_edge": -6.7300558152,
          "failed": false
        },
        {
          "seed": 242009,
          "total_edge": 12.9859842864,
          "retail_edge": 47.2543772047,
          "arb_edge": -34.268392919,
          "failed": false
        },
        {
          "seed": 242010,
          "total_edge": 459.5090278512,
          "retail_edge": 499.4581961061,
          "arb_edge": -39.9491682548,
          "failed": false
        },
        {
          "seed": 242011,
          "total_edge": 0.2380319293,
          "retail_edge": 0.4436535027,
          "arb_edge": -0.2056215732,
          "failed": false
        },
        {
          "seed": 242012,
          "total_edge": 34.7995151933,
          "retail_edge": 42.5761012617,
          "arb_edge": -7.7765860681,
          "failed": false
        },
        {
          "seed": 242013,
          "total_edge": 14.6503850392,
          "retail_edge": 31.9518450871,
          "arb_edge": -17.301460049,
          "failed": false
        },
        {
          "seed": 242014,
          "total_edge": 84.2399103314,
          "retail_edge": 87.3983032796,
          "arb_edge": -3.1583929477,
          "failed": false
        },
        {
          "seed": 242015,
          "total_edge": 200.9134832958,
          "retail_edge": 237.8307202809,
          "arb_edge": -36.9172369849,
          "failed": false
        },
        {
          "seed": 242016,
          "total_edge": 44.4702908754,
          "retail_edge": 57.2067350996,
          "arb_edge": -12.736444225,
          "failed": false
        },
        {
          "seed": 242017,
          "total_edge": 33.8454849881,
          "retail_edge": 49.8512379625,
          "arb_edge": -16.0057529748,
          "failed": false
        },
        {
          "seed": 242018,
          "total_edge": 81.8049600298,
          "retail_edge": 85.2419387977,
          "arb_edge": -3.4369787689,
          "failed": false
        },
        {
          "seed": 242019,
          "total_edge": 421.472115812,
          "retail_edge": 443.5117688206,
          "arb_edge": -22.0396530071,
          "failed": false
        }
      ]
    }
  ],
  "next": [
    {
      "change": "Optionally prune self.ahead and self.res to currently live own-order IDs each step to bound bookkeeping growth. Filled orders are not removed by cancel(), so stale entries accumulate. No candidate was built.",
      "edge_at_stake": 0.0,
      "interpretation": "Intended semantics-preserving housekeeping: stale IDs are only consulted for live own_orders. Zero is the intended direct edge change, not a measured paired result; validate equivalence before adopting.",
      "measured_paired_gain": null
    }
  ],
  "code": "\"\"\"Run from this directory beside B.py and the unmodified pinned simulator/ checkout.\npython3 audit_run.py 242000 243000\nNo sandbox is executed. Timing wrapper returns exactly B's actions.\n\"\"\"\nimport sys,time,json,hashlib\nfrom pathlib import Path\nfrom dataclasses import asdict\np=Path(__file__).resolve().parent\nsys.path.insert(0,str(p/'simulator'))\nfrom orderbook_pm_challenge.config import ChallengeConfig,ParameterVariance\nfrom orderbook_pm_challenge.loader import load_strategy_factory\nfrom orderbook_pm_challenge.runner import run_batch\nassert hashlib.sha256((p/'B.py').read_bytes()).hexdigest()=='baef955ec10728839f7c3357016ec9eb0550e7ec689bbd5171b1cdd5c9e37273'\nf=load_strategy_factory(str(p/'B.py'))\nclass Timed:\n def __init__(self):\n  self.inner=f(); self.steps=0; self.ns=0; self.max_ns=0; self.max_orders=0; self.max_actions=0; self.min_cash=None; self.max_ahead=0; self.max_res=0\n def on_step(self,state):\n  self.max_orders=max(self.max_orders,len(state.own_orders))\n  self.min_cash=state.free_cash if self.min_cash is None else min(self.min_cash,state.free_cash)\n  t=time.perf_counter_ns()\n  actions=self.inner.on_step(state)\n  dt=time.perf_counter_ns()-t\n  self.ns+=dt;self.max_ns=max(self.max_ns,dt);self.steps+=1\n  self.max_actions=max(self.max_actions,len(actions))\n  self.max_ahead=max(self.max_ahead,len(self.inner.ahead));self.max_res=max(self.max_res,len(self.inner.res))\n  return actions\nstart,end=map(int,sys.argv[1:3]); assert 242000<=start<end<=243000\nwith (p/f'timed-{start}-{end}.jsonl').open('w') as out:\n for s in range(start,end):\n  instances=[]\n  def factory():\n   obj=Timed();instances.append(obj);return obj\n  t=time.perf_counter()\n  r=run_batch(factory,base_config=ChallengeConfig(),variance=ParameterVariance(),n_simulations=1,seed_start=s,workers=1).simulation_results[0]\n  wall=time.perf_counter()-t\n  d=asdict(r);d['seconds']=wall\n  d['timing']={k:v for k,v in vars(instances[0]).items() if k!='inner'}\n  out.write(json.dumps(d)+'\\n');out.flush()\n  if (s-start+1)%100==0: print(s+1,flush=True)\n",
  "code_sha256": "6cbda2f3516ee7035d20c89e99ca9e1d908b4260bdb4e1da0977146cf0470c47",
  "incumbent_code_sha256": "baef955ec10728839f7c3357016ec9eb0550e7ec689bbd5171b1cdd5c9e37273",
  "tuning": null,
  "seeds": {
    "start": 242000,
    "end_inclusive": 242999,
    "pilot_start": 242000,
    "pilot_end_inclusive": 242019,
    "finalist_seeds_used": false
  },
  "n": 1000,
  "complete": true,
  "incumbent": {
    "mean": 108.615826909827,
    "retail_mean": 135.0031322721823,
    "arb_mean": -26.3873053623726,
    "se": 5.623689634963503
  },
  "findings": [
    {
      "name": "all successful simulations",
      "count": 1000,
      "mean": 108.615826909827,
      "retail_mean": 135.0031322721823,
      "arb_mean": -26.3873053623726,
      "se": 5.623689634963503
    },
    {
      "name": "competitor_spread_ticks=1",
      "count": 239,
      "mean": 43.003408811701256,
      "retail_mean": 74.68767442404561,
      "arb_mean": -31.68426561230209,
      "se": 8.592968522434346
    },
    {
      "name": "competitor_spread_ticks=2",
      "count": 239,
      "mean": 96.98805624692511,
      "retail_mean": 117.33084489036486,
      "arb_mean": -20.342788643380754,
      "se": 9.837083327516169
    },
    {
      "name": "competitor_spread_ticks=3",
      "count": 237,
      "mean": 117.71977125674177,
      "retail_mean": 144.47108930545022,
      "arb_mean": -26.75131804877595,
      "se": 10.907778618055882
    },
    {
      "name": "competitor_spread_ticks=4",
      "count": 285,
      "mean": 165.81852972971052,
      "retail_mean": 192.53002803735615,
      "arb_mean": -26.711498307735088,
      "se": 12.780866287256886
    }
  ],
  "paired": null,
  "failures": [],
  "seconds_per_simulation": 0.21913529435015516,
  "audit": {
    "sources": {
      "sandbox": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/sandbox.py",
      "loader": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/loader.py",
      "_sandbox_worker": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/_sandbox_worker.py",
      "runner": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/runner.py",
      "engine": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/engine.py",
      "market": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/market.py",
      "types": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/types.py",
      "results": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/orderbook_pm_challenge/results.py",
      "rules": "https://raw.githubusercontent.com/danrobinson/prediction-market-challenge/b244530ee2a6247b5f930830eeca9dd950da0e7e/docs/orderbook_prediction_market_challenge.md"
    },
    "import_policy": {
      "ALLOWED_MODULES": [
        "abc",
        "array",
        "bisect",
        "cmath",
        "collections",
        "copy",
        "csv",
        "dataclasses",
        "datetime",
        "decimal",
        "enum",
        "fractions",
        "functools",
        "hashlib",
        "heapq",
        "itertools",
        "json",
        "math",
        "numbers",
        "numpy",
        "operator",
        "orderbook_pm_challenge",
        "pandas",
        "queue",
        "random",
        "re",
        "scipy",
        "statistics",
        "string",
        "struct",
        "time",
        "typing",
        "typing_extensions"
      ],
      "SAFE_ORDERBOOK_PM_IMPORTS": [
        "orderbook_pm_challenge",
        "orderbook_pm_challenge.config",
        "orderbook_pm_challenge.strategy",
        "orderbook_pm_challenge.types"
      ],
      "BLOCKED_BUILTINS": [
        "breakpoint",
        "open"
      ],
      "rule": "Direct absolute imports outside ALLOWED_MODULES are denied, except underscore-prefixed roots. orderbook_pm_challenge imports must match SAFE_ORDERBOOK_PM_IMPORTS exactly. Relative imports and transitive imports during an allowed import bypass direct checks. An allowlisted optional library still needs to be installed."
    },
    "builtin_policy": "Only open and breakpoint are replaced by raising stubs, both in the strategy module builtins from first execution and globally after load. No additional builtin blacklist or AST syntax ban exists in these files.",
    "constructs": "No forbidden Python syntax list. Classes, inheritance, nested functions, closures, nonlocal, comprehensions, generators, mutable globals, sets and dictionaries used by B are permitted. Loader needs an importable .py defining Strategy; Strategy() must instantiate without arguments and supply on_step(state). Return a sequence of supported action objects.",
    "B_imports": [
      "import math",
      "from orderbook_pm_challenge.strategy import BaseStrategy",
      "from orderbook_pm_challenge.types import CancelOrder, PlaceOrder, Side"
    ],
    "B_builtin_references": [
      "dict",
      "int",
      "max",
      "min",
      "range",
      "round",
      "set",
      "str",
      "sum",
      "zip"
    ],
    "B_static_verdict": "No prohibited import, blocked builtin, hidden engine access, filesystem/network I/O, subprocess use, printing or unsupported syntax found. Only math and framework types/base class are imported; no third-party dependencies.",
    "action_failure_rules": "Only PlaceOrder, CancelOrder and CancelAll supported; valid Side, integer configured tick 1..99, positive quantity after 0.01 rounding, unique active ID, sufficient free collateral required; cancel ID must belong to a current participant order. B cancels supplied own orders, returns framework action types, uses monotone b/a IDs, and floors new quantities. Runtime block checks exercise these rules.",
    "os_denied_syscalls": [
      "execve",
      "execveat",
      "fork",
      "vfork",
      "clone",
      "clone3",
      "socket",
      "socketpair",
      "connect",
      "accept",
      "accept4",
      "bind",
      "listen",
      "ptrace",
      "process_vm_readv",
      "process_vm_writev",
      "bpf",
      "userfaultfd",
      "perf_event_open",
      "mount",
      "umount2",
      "pivot_root",
      "setns",
      "unshare",
      "init_module",
      "finit_module",
      "delete_module"
    ],
    "resource_policy": {
      "sandbox_timeout_seconds": 300,
      "default_address_space_mb": 512,
      "stdout_limit_bytes": 1048576,
      "stderr_limit_bytes": 1048576,
      "nsjail_pid_limit": 32,
      "nsjail_max_cpus": 1,
      "nsjail_fsize_limit_mb": 1,
      "nsjail_open_files": 64,
      "filesystem": "Read-only installed Python, package and strategy mounts; writable /tmp tmpfs 16m; network namespace isolated; environment cleared. OS restrictions only apply if nsjail is found."
    },
    "remaining_risks": [
      "Sandbox compatibility is a source-review inference; sandbox was deliberately not executed. No assertion about actual leaderboard deployment or Python 3.12 sandbox behavior is made.",
      "Local in-process timings exclude sandbox startup and nsjail overhead; neither sandbox resource limits nor arbitrary seeds are certified by these runs.",
      "self.ahead and self.res retain IDs of fully filled orders. Their observed maxima are reported below; no failure observed over the specified 2000-step horizon.",
      "No promotion claim: this is a readiness check on a designated diagnostic block, not paired strategy improvement or finalist evidence."
    ],
    "ready_to_submit": "No B-specific blocker found in source audit or measured block; operational sandbox verification remains untested as required."
  },
  "timing": {
    "wall_seconds_distribution": {
      "mean": 0.21913529435015516,
      "p50": 0.22215650099678896,
      "p95": 0.26581268798327073,
      "p99": 0.2751638419867959,
      "max": 0.28312256099889055
    },
    "seconds_per_engine_step_including_simulator": 0.00010956764717507758,
    "on_step_calls": 2000000,
    "mean_on_step_seconds": 2.83300342295e-05,
    "per_simulation_mean_on_step_seconds_distribution": {
      "mean": 2.83300342295e-05,
      "p50": 2.8464640999999997e-05,
      "p95": 3.2454434e-05,
      "p99": 3.3483367e-05,
      "max": 3.4588876499999996e-05
    },
    "largest_single_on_step_seconds": 0.000523487,
    "max_live_own_orders": 195,
    "max_actions_in_callback": 54,
    "max_ahead_set_size": 696,
    "max_res_dict_size": 608,
    "min_observed_free_cash": 2.0001
  },
  "statistics": "Means over successful full simulations; SE = sample standard deviation / sqrt(n), not paired. Findings by spread are disjoint; all-success row is a summary. Timing spans all runs; callback timers exclude wrapper bookkeeping. Pilot duplicates first 20, excluded from n and score.",
  "scoreboard": {
    "current_best": "B combine-cash",
    "code_sha256": "baef955ec10728839f7c3357016ec9eb0550e7ec689bbd5171b1cdd5c9e37273",
    "candidates": [],
    "promotion": null
  }
}
