Skip to content

Build, Codegen, Wasm & Supervision

Build orchestration (vertebra.build), schema and client code generation, reproducible standalone and onefile packaging, WebAssembly plugin sandboxes (vertebra.wasm), and multi-worker process supervision (vertebra.supervisor). See Packaging & Deployment for CLI and deployment workflows.

Area Purpose
Build Orchestration Coordinate Rust extension builds, TypeScript codegen, and frontend asset bundling from pyproject.toml.
Schema & Client Codegen Generate .d.ts types, Zod and Valibot validators, OpenAPI 3.1 JSON, .proto schemas, and typed RPC clients from Python routes.
Standalone & Onefile Packaging Package an app into a relocatable directory or self-extracting binary with reproducible builds, independent of the package manager.
Wasm Sandbox & Supervisor Run fuel- and memory-bounded WASI plugins and supervise multi-worker OS processes.

Build Configuration & Orchestration

JsConfig

Bases: Struct

JavaScript dependency configuration from [tool.vertebra.js].

Attributes:

Name Type Description
dependenciestuple[str, ...]
Default: ()
dev_dependenciestuple[str, ...]
Default: ()

BuildConfig

Bases: Struct

Build configuration loaded from [tool.vertebra] in pyproject.toml.

Attributes:

Name Type Description
entrystr
Default: ''
outdirstr
Default: 'dist'
bundlerstr
Default: 'native'
dev_portint | None
Default: None
codegenbool
Default: False
codegen_outputstr
Default: '.vertebra/generated'
appstr
Default: ''
jsJsConfig
has_frontendbool

Return True if a frontend entrypoint is configured.

BuildOrchestrator

Orchestrate frontend builds with native-first, Vite-fallback strategy.

Attributes:

Name Type Description
is_watchingbool

Return True when the native bundler dev watcher loop is actively running.

stop

stop()

Stop background dev watchers, dev threads, and Vite server processes.

build

build()

Run a production build, returning True if a frontend entry was built.

dev

dev()

Start dev mode with native watcher and HMR.

codegen_only

codegen_only(*, output_dir=None)

Run only type codegen and return the output directory.

export_litestar_artifacts

export_litestar_artifacts(app, *, output_dir=None)

Auto-export litestar-vite and litestar-asyncapi artifacts when present on app.

BundleConfig

Attributes:

Name Type Description
entrystr
outdirstr
minifybool
sourcemapbool
targetstr

BundleDevConfig

Attributes:

Name Type Description
entrystr
watch_dirslist[str]
hmr_portint
extensionslist[str]
debounce_msint

BundleResult

Attributes:

Name Type Description
outputslist[BundleOutput]
duration_msint
warningslist[str]

BundleOutput

Attributes:

Name Type Description
pathstr
sizeint
is_entrybool

Bundler

Attributes:

Name Type Description
configBundleConfig | None
dev_configBundleDevConfig | None

from_config

from_config(config, *, dev_config=None)

build

build(config=None)

start_dev

start_dev(config=None)

stop_dev

stop_dev()

poll_events

poll_events(timeout_ms=None)

transform_file

transform_file(path, source)

check_file

check_file(path, source)

notify_type_change

notify_type_change(version=None)

notify_reload

notify_reload()

hmr_url

hmr_url()

is_dev_mode

is_dev_mode()

Schema & Client Codegen

CodegenConfig

Bases: Struct

Configuration controlling multi-target schema and RPC client emission.

Attributes:

Name Type Description
output_dirPath
Default: Path('src/generated')
enable_valibotbool
Default: True
enable_zodbool
Default: True
enable_openapibool
Default: True
enable_protobufbool
Default: False
enable_proceduresbool
Default: True
openapi_titlestr
Default: 'Vertebra API'
openapi_versionstr
Default: '1.0.0'
protobuf_packagestr
Default: 'vertebra.v1'
protobuf_servicestr
Default: 'VertebraService'

TypeScriptGenerator

Bases: SchemaEmitter

Generate TypeScript ambient declarations and WebSocket channel type declarations from collected routes.

generate

generate(routes)

Render TypeScript interfaces, Procedures namespace, and ambient route declarations.

ZodGenerator

Bases: _BaseValidatorEmitter

Generate Zod schemas from RouteMetadata, TypeNode IR, or JSON Schema dictionaries.

ValibotGenerator

Bases: _BaseValidatorEmitter

Generate Valibot v1 schemas from RouteMetadata, TypeNode IR, or JSON Schema dictionaries.

OpenAPIGenerator

Bases: SchemaEmitter

Generate OpenAPI 3.1.0 specifications from collected RouteMetadata.

ProtobufGenerator

Bases: SchemaEmitter

Bidirectional .proto v3 generator and parser for routes, procedures, and msgspec structs.

ProcedureClientGenerator

Bases: SchemaEmitter

Emit typed TypeScript RPC client declarations from ProcedureRegistry.

Standalone & Onefile Packaging

BuildTarget

Bases: Struct

Resolved platform triple and python-build-standalone release coordinates.

Attributes:

Name Type Description
os_namestr
archstr
libcstr
python_versionstr
rust_triplestr
is_freethreadedbool

Return True when targeting a free-threaded Python build (e.g. 3.14t).

pbs_archive_namestr

Return the python-build-standalone .tar.zst archive filename.

pbs_urlstr

Return the full download URL for the python-build-standalone archive.

python_executablestr

Return the relative Python interpreter binary name inside the PBS distribution.

StandaloneBuilder

Build a standalone relocatable directory distribution for a Vertebra application.

build

build(output_dir)

Stage application sources, compile hash-checked .pyc files, and write manifest.json and main.py.

Bytecode uses PycInvalidationMode.CHECKED_HASH and app-relative source paths, so .pyc files carry neither mtimes nor build-machine paths and repeated builds of the same tree produce identical bytes. Lockfiles (*.lock, pylock.toml, pyproject.toml) are staged as-is for whichever package manager the project uses.

OnefileBuilder

Package a standalone distribution directory into a single-file executable with a VTB1FILE footer.

Attributes:

Name Type Description
compressionLiteral['zlib', 'zstd']
Default: compression

build

build(output_path)

Create a single-file executable containing a launcher stub, compressed tar archive, and 48-byte footer.

inspect_trailer

inspect_trailer(binary_path)

Read and verify the 48-byte VTB1FILE footer at the end of a onefile executable.

extract_to

extract_to(binary_path, destination)

Verify the VTB1FILE trailer and extract the embedded archive into destination.

WebAssembly Sandbox & Supervisor

WASMSandboxPolicy

Bases: Struct

Capability-based WASI 0.2 sandbox policy for untrusted Wasm plugins and agent tools.

Attributes:

Name Type Description
max_memory_bytesint
Default: 64 * 1024 * 1024
max_fuelint
Default: 10000000
epoch_timeout_msint
Default: 500
allow_networkbool
Default: False
allowed_preopen_dirstuple[str, ...]
Default: ()
env_varsdict[str, str]

WASMModuleConfig

Bases: Struct

Configuration for a registered WebAssembly guest module.

Attributes:

Name Type Description
namestr
wasm_sourcestr | Path | bytes
policyWASMSandboxPolicy

WASMExecutionError

Bases: RuntimeError

Raised when a WebAssembly guest module traps or exceeds its fuel/memory budget.

WASMPluginHost

Host registry and sandboxed executor for WASI 0.2 WebAssembly guest modules.

Attributes:

Name Type Description
registered_modulestuple[str, ...]

Return the names of all registered Wasm modules.

register_module

register_module(config, *, exports=None)

Validate and register a WebAssembly module and its exported host/guest bindings.

get_module

get_module(name)

Retrieve a registered WASMModuleConfig by name.

call_export

call_export(module_name, export_name, *args, fuel_cost=100)

Invoke an exported function under the module's configured fuel and memory budget.

call_json

call_json(module_name, export_name, payload, *, return_type=Any, fuel_cost=100)

Encode payload into a reusable buffer via msgspec.json.Encoder.encode_into and decode the guest response.

call_msgpack

call_msgpack(
    module_name, export_name, payload, *, return_type=Any, fuel_cost=100
)

Encode payload into a reusable buffer via msgspec.msgpack.Encoder.encode_into and decode the guest response.

dispatch_http

dispatch_http(
    module_name, request, *, export_name="handle_http", fuel_cost=100
)

Dispatch an HTTP Request to a Wasm guest handler using a compact array_like MsgPack envelope.

EmbeddedPythonRuntime

Bases: Struct

Host CPython embedding metadata exported to vertebra-server subprocesses.

Attributes:

Name Type Description
python_homePath
library_dirPath | None
library_namestr | None
is_sharedbool
platformstr
Default: sys.platform
detect
detect()

Inspect the running CPython interpreter for PYTHONHOME and shared libpython paths.

require_shared_library
require_shared_library(binary)

Fail loudly when a packaged POSIX vertebra-server lacks a shared libpython runtime.

apply
apply(env)

Export PYTHONHOME and prepend library_dir to the platform dynamic loader variable.

run_supervisor

run_supervisor(
    *,
    server_cmd,
    env,
    drain_timeout_ms=5000,
    shutdown_timeout_ms=30000,
    tui=False,
)

Spawn the Rust server binary and wait for it to exit.

When tui=True, stderr is piped and fed into a Rich Live display for the dev TUI experience. When tui=False (default), stderr is inherited from the parent process.

build_server_command

build_server_command(binary=None)

Build command to start the Rust server.

find_server_binary

find_server_binary()

Find the vertebra-server binary, honoring CARGO_TARGET_DIR and freshest release artifacts.

find_repo_root

find_repo_root(start)

Find the repository root by looking for pyproject.toml.

worker_main

worker_main()

Initialize a worker process and start the batch runner loop.