> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alakazam.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Certify your own policy

> Submit any architecture (SNN, reactive, whatever) to the frozen exam as a sandboxed Python module.

You are not limited to the 9-float controller family. Any policy that
implements a two-method contract can be certified in the frozen Webots oracle.

## The contract

```python theme={null}
class Policy:
    def reset(self, seed: int) -> None:
        ...                       # fresh episode state (called once per episode)
    def act(self, obs: dict):
        ...                       # one control tick -> an action
```

`obs` carries the same fields your local-gym policy reads (`proximity` in
the same `{"left","right"}` dict form, `collision`, `sensor_valid`), so a
policy trained in `LocalDreamEnv` certifies unchanged. Two differences: the
exam adds `t` (tick index) and has no `frame` (the physics world has no
camera), and `sensor_valid` is always 1 there, because exact physics has no
post-reset settle window. Do not depend on it:

```python theme={null}
obs = {
  "proximity": {"left": 0.0..1.0, "right": 0.0..1.0},  # in-distribution readout
  "collision": 0 or 1,        # 1 at contact-grade proximity
  "sensor_valid": 1,          # always 1 in the exam (physics is exact)
  "t": <tick index>,
}
```

`act` returns an action in the wheel-fraction vocabulary:

```python theme={null}
return {"wheels": {"left": L, "right": R}}   # L, R in [0,1]  (or [L, R])
# or an int 0..4  (noop / forward / left / right / attack), mapped to wheels
```

A differential SNN maps its two motor populations onto `wheels`. The returned
wheels flow through the exact same downstream path as an evolved genome, so a
genome wrapped as a `Policy` reproduces its exam verdict bit for bit. This is
the acceptance test we run before every deploy.

## Submit it

```python theme={null}
from alakazam_gym import ExamClient, PolicyBundle

c = ExamClient("https://api.alakazam.gg/train", key=TRAIN_KEY)
bundle = PolicyBundle("my_policy.py")         # a .py file, or a directory (zipped)
job = c.submit_policy("my-cert-001", bundle)
print(c.wait(job["job_id"])["oracle"]["verdict"])
```

Or raw HTTP, with `policy` on an exam-only job:

```json theme={null}
{"job_id": "my-cert-001",
 "train": {"pop": 0, "gens": 0, "T": 0, "seed": 0},
 "exam":  {"episodes": 20},
 "policy": {"format": "python_module",
            "module_b64": "<base64 of your .py or .zip>",
            "entry": "policy", "class": "Policy"}}
```

## The sandbox

Partner code is trusted and key-gated, and it runs locked down:

* No network egress (blocked at the socket layer; the exam needs none).
* No subprocess or shell spawning.
* Resource-limited (memory + total CPU) and time-limited per call. A runaway
  or erroring policy fails the job; it never silently scores.

This is a trusted-partner posture, not a hostile-code jail (true isolation
would use seccomp/gVisor). The container ships numpy and onnxruntime; a
policy needing torch or norse will not import, so export your weights and run
a numpy forward pass in `act()`. Ship a Python module, not a converted graph.

## What stays frozen

The policy is the only new degree of freedom. The world, spawn slots, episode
count, control tick, proximity remap, scoring, and the anti-exploit control
arms (the cruiser that must fail) are identical to every other exam, so your
verdict is comparable to the whole program history.

<Note>
  Want an SNN-native observation (spike trains, richer sensor channels) rather
  than the proximity/collision contract? That is an extension we design with
  you. Tell us your policy's IO.
</Note>
