Skip to main content

Crate hyprstream_workers_python

Crate hyprstream_workers_python 

Source
Expand description

RustPython engine + /lang/python 9P shell for the hyprstream VFS namespace.

This crate is the ONE python-aware layer over the generic, language-agnostic wasm sandbox engine ([hyprstream_workers_wasmtime]). It runs untrusted Python on the RustPython guest (hyprstream-workers-python-guest, compiled to wasm32-unknown-unknown) inside a Profile-A Sandbox. The engine knows nothing about Python; everything python-specific (the eval/py_op ABI, the result decoding, the /lang/python mount) lives here.

Module shape mirrors hyprstream-workers-tcl:

§Guest ABI used here

  • eval(ptr,len) -> i32 — run UTF-8 source in a FRESH interpreter; 0 = ok, nonzero = a Python error. Driven via Sandbox::call_export.
  • py_op(op, ptr, len) -> i64 — run an operation against the PERSISTENT interpreter, returning a packed (out_ptr<<32)|out_len reply whose first byte is a status tag. Driven by PythonShell over the generic PersistentInstance.

§Security

The guest only ever reaches the host capabilities the engine’s Linker grants (env::host_random + the Subject-scoped env::vfs_*); everything else traps. DoS bounds (fuel / epoch) are enforced by the engine. import os; os.system(...) is inert — there is no syscall surface.

Re-exports§

pub use mount::PyCommand;
pub use mount::PythonMount;

Modules§

mount
/lang/python/ VFS mount backed by the wasm-sandboxed python guest.

Structs§

PythonShell
A persistent python shell over a single wasm guest instance.

Enums§

PyResult
The outcome of a py_op: a status tag plus the UTF-8 payload.

Functions§

eval
Run Python source in a FRESH interpreter with the given fuel budget.
eval_with_epoch_deadline
Run Python source (FRESH interpreter) with a WALL-CLOCK epoch deadline of ticks epoch increments.