Splendor
Reference

Python Bindings

Python-facing runtime ergonomics and the Rust/Python boundary.

Python Bindings

Splendor provides Python-facing runtime ergonomics for local policies, perceptors, constraints, adapters, traces, and replay. Python is for proposal and domain logic; Rust remains responsible for runtime-critical enforcement.

Python SDK

The primary public Python path is the SDK described in SDK & API and demonstrated by examples/python-sdk-basic.

Python policy callbacks propose actions. KernelRuntime.run_once performs the runtime checks before adapter callbacks execute.

PyO3 bindings

The compiled bindings expose a thin wrapper around the Python SDK runtime for projects that need a native extension boundary. When built with the Python feature, the module exports:

  • KernelRuntime: wrapper over splendor.runtime.KernelRuntime.
  • KernelRuntimeConfig: Python config class.
  • QuotaPolicy: Python quota policy class.
  • __version__: package version string.

Build

From python/bindings:

maturin develop --features python

This installs the extension module into your active Python environment.

Example

import splendor_bindings

runtime = splendor_bindings.KernelRuntime()
tenant_id = runtime.create_tenant(
    allowed_actions=["noop"],
    allowed_adapters=["noop"],
)
agent_id = runtime.create_agent(tenant_id)

runtime.register_adapter("noop", lambda action: {"output": {"ok": True}})
runtime.register_perceptor(agent_id, lambda agent: [])
runtime.register_policy(
    agent_id,
    lambda state, percepts: [
        {
            "name": "noop",
            "params": {},
            "side_effect_class": "read_only",
            "adapter": "noop",
        }
    ],
)

runtime.run_once(agent_id)
print(splendor_bindings.__version__)

Boundary rule

Python code must not bypass Splendor's enforcement boundary for privileged side effects. Official examples route actions through the runtime and gateway path.

On this page