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 |
|---|---|---|
dependencies | tuple[str, ...] | Default: () |
dev_dependencies | tuple[str, ...] | Default: () |
BuildConfig
¶
Bases: Struct
Build configuration loaded from [tool.vertebra] in pyproject.toml.
Attributes:
| Name | Type | Description |
|---|---|---|
entry | str | Default: '' |
outdir | str | Default: 'dist' |
bundler | str | Default: 'native' |
dev_port | int | None | Default: None |
codegen | bool | Default: False |
codegen_output | str | Default: '.vertebra/generated' |
app | str | Default: '' |
js | JsConfig | |
has_frontend | bool | Return True if a frontend entrypoint is configured. |
BuildOrchestrator
¶
Orchestrate frontend builds with native-first, Vite-fallback strategy.
Attributes:
| Name | Type | Description |
|---|---|---|
is_watching | bool | Return True when the native bundler dev watcher loop is actively running. |
BundleConfig
¶
Attributes:
| Name | Type | Description |
|---|---|---|
entry | str | |
outdir | str | |
minify | bool | |
sourcemap | bool | |
target | str |
BundleDevConfig
¶
Attributes:
| Name | Type | Description |
|---|---|---|
entry | str | |
watch_dirs | list[str] | |
hmr_port | int | |
extensions | list[str] | |
debounce_ms | int |
BundleResult
¶
Attributes:
| Name | Type | Description |
|---|---|---|
outputs | list[BundleOutput] | |
duration_ms | int | |
warnings | list[str] |
BundleOutput
¶
Attributes:
| Name | Type | Description |
|---|---|---|
path | str | |
size | int | |
is_entry | bool |
Bundler
¶
Attributes:
| Name | Type | Description |
|---|---|---|
config | BundleConfig | None | |
dev_config | BundleDevConfig | None |
Schema & Client Codegen¶
CodegenConfig
¶
Bases: Struct
Configuration controlling multi-target schema and RPC client emission.
Attributes:
| Name | Type | Description |
|---|---|---|
output_dir | Path | Default: Path('src/generated') |
enable_valibot | bool | Default: True |
enable_zod | bool | Default: True |
enable_openapi | bool | Default: True |
enable_protobuf | bool | Default: False |
enable_procedures | bool | Default: True |
openapi_title | str | Default: 'Vertebra API' |
openapi_version | str | Default: '1.0.0' |
protobuf_package | str | Default: 'vertebra.v1' |
protobuf_service | str | Default: 'VertebraService' |
TypeScriptGenerator
¶
Bases: SchemaEmitter
Generate TypeScript ambient declarations and WebSocket channel type declarations from collected routes.
generate
¶
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_name | str | |
arch | str | |
libc | str | |
python_version | str | |
rust_triple | str | |
is_freethreaded | bool | Return True when targeting a free-threaded Python build (e.g. 3.14t). |
pbs_archive_name | str | Return the python-build-standalone .tar.zst archive filename. |
pbs_url | str | Return the full download URL for the python-build-standalone archive. |
python_executable | str | Return the relative Python interpreter binary name inside the PBS distribution. |
StandaloneBuilder
¶
Build a standalone relocatable directory distribution for a Vertebra application.
build
¶
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 |
|---|---|---|
compression | Literal['zlib', 'zstd'] | Default: compression |
build
¶
Create a single-file executable containing a launcher stub, compressed tar archive, and 48-byte footer.
inspect_trailer
¶
Read and verify the 48-byte VTB1FILE footer at the end of a onefile executable.
extract_to
¶
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_bytes | int | Default: 64 * 1024 * 1024 |
max_fuel | int | Default: 10000000 |
epoch_timeout_ms | int | Default: 500 |
allow_network | bool | Default: False |
allowed_preopen_dirs | tuple[str, ...] | Default: () |
env_vars | dict[str, str] |
WASMModuleConfig
¶
Bases: Struct
Configuration for a registered WebAssembly guest module.
Attributes:
| Name | Type | Description |
|---|---|---|
name | str | |
wasm_source | str | Path | bytes | |
policy | WASMSandboxPolicy |
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_modules | tuple[str, ...] | Return the names of all registered Wasm modules. |
register_module
¶
Validate and register a WebAssembly module and its exported host/guest bindings.
call_export
¶
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 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_home | Path | |
library_dir | Path | None | |
library_name | str | None | |
is_shared | bool | |
platform | str | Default: sys.platform |
run_supervisor
¶
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.
find_server_binary
¶
Find the vertebra-server binary, honoring CARGO_TARGET_DIR and freshest release artifacts.