Built-in sandbox SHIM: a minimal matplotlib.pyplot-compatible module for the
model's Python sandbox, backed by a host-side vector renderer. The agent
sandbox ships no CPython matplotlib wheel (it needs numpy's native core +
freetype, all blocked by the deny-by-default Context); this extension instead
contributes a :ext/sandbox-shims entry whose Python preamble accumulates the
familiar pyplot artists (plot/scatter/bar/hist/fill_between/step/
pie/axhline/axvline/title/xlabel/… plus the OO subplots/Axes
API) and whose savefig DELEGATES the whole figure spec across the boundary
to the host callable __vis_mpl_render__, which draws it with
com.blockether/imaging and returns a base64 PNG. The Python side
base64-decodes and writes it (to a path, confined to the sandbox roots, or to
any file-like buffer).
Rendering uses NO java.desktop: imaging is FFM over a Rust cdylib
(tiny-skia + embedded Noto faces), so there is no AWT toolkit, no headless
dance and no system fontconfig anywhere in this path.
It is a SUBSET, not real matplotlib: line/scatter/bar/hist/fill/step/pie with title, axis labels, grid, legend, dashed line styles, markers, log scales and text annotations — enough for the model to visualize data. Rendering runs entirely in-process (no pip, no native wheels), and any render failure surfaces to Python as a catchable exception (never crashes the sandbox).
Together with shim-yaml this demonstrates the sandbox-shim mechanism: an
extension turns a host / JVM capability into a real importable Python module
while env-python stays completely generic about which shims exist.
Built-in sandbox SHIM: a minimal `matplotlib.pyplot`-compatible module for the model's Python sandbox, backed by a host-side vector renderer. The agent sandbox ships no CPython matplotlib wheel (it needs numpy's native core + freetype, all blocked by the deny-by-default Context); this extension instead contributes a `:ext/sandbox-shims` entry whose Python preamble accumulates the familiar pyplot artists (`plot`/`scatter`/`bar`/`hist`/`fill_between`/`step`/ `pie`/`axhline`/`axvline`/`title`/`xlabel`/… plus the OO `subplots`/`Axes` API) and whose `savefig` DELEGATES the whole figure spec across the boundary to the host callable `__vis_mpl_render__`, which draws it with `com.blockether/imaging` and returns a base64 PNG. The Python side base64-decodes and writes it (to a path, confined to the sandbox roots, or to any file-like buffer). Rendering uses NO `java.desktop`: `imaging` is FFM over a Rust cdylib (tiny-skia + embedded Noto faces), so there is no AWT toolkit, no headless dance and no system fontconfig anywhere in this path. It is a SUBSET, not real matplotlib: line/scatter/bar/hist/fill/step/pie with title, axis labels, grid, legend, dashed line styles, markers, log scales and text annotations — enough for the model to visualize data. Rendering runs entirely in-process (no pip, no native wheels), and any render failure surfaces to Python as a catchable exception (never crashes the sandbox). Together with `shim-yaml` this demonstrates the sandbox-shim mechanism: an extension turns a host / JVM capability into a real importable Python module while `env-python` stays completely generic about which shims exist.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |