RL Trust Boundary JSON Loader #
This module contains the JSON-lines/interchange side of the RL trust boundary. The contract itself
lives in NN.Runtime.RL.Boundary.Core; this file only explains how to parse a small Python-friendly
rollout schema and immediately validate it against that contract.
Keeping JSON separate matters because proof files usually need the contract/checker semantics, not the parser or PyTorch import layer. Runtime bridges can import this file when they need external rollout loading.
JSON loading (one simple interchange format) #
We provide a small JSON schema that is easy to emit from Python:
{
"transitions": [
{
"obs": <nested arrays matching obsShape>,
"action": <nat>,
"reward": <float>,
"terminated": <bool>,
"truncated": <bool>,
"next_obs": <nested arrays matching obsShape>
},
...
]
}
This is one supported integration path, using a practical “lowest common denominator” that is easy to diff and validate.
JSON Primitive Parsers #
These are small helpers used by the trust-boundary JSON loader and by runtime bridges (e.g. a Gymnasium subprocess client).
They return Except String ... so they can be used from both pure loaders and IO code that wants
to convert errors into IO.userError.
Parse a JSON value as a typed tensor of shape s.
This relies on TorchLean's JSON tensor encoding used by Python bridges.
Instances For
Parse a single transition object using the schema described above.
Instances For
Load and validate a rollout file, returning an array of typed transitions.
Instances For
Load a rollout file and validate every transition, returning per-transition results.
Unlike loadRollout, this function does not stop at the first bad transition. Instead it
returns an array aligned with the input JSON transitions array:
ok tmeans the transition decoded and passed the contract check.error msgmeans decoding or contract checking failed for that transition.
This is useful for widget-style debugging where users want to see a summary of violations rather than only the first failure.