Repository navigation
Conversation
noise64
force-pushed
the
runtime-baseline
branch
from
November 16, 2026 23:05
1cfe609 to
90cbde9
Compare
noise64
force-pushed
the
prepared-assets
branch
from
November 16, 2026 23:05
e0c838f to
505e405
Compare
ComponentGenerator::generate now binds the WIT world, links the libraries and initializes the result as separate steps. Initialization follows an InitPlan: owned import stubs instead of the borrowed Resolve, the environment, preopens and entropy. The linker takes the adapter as input, and the Python path search sorts directory entries so that the library order does not depend on the file system.
BindingsPreparer resolves a WIT world once and returns Prepared assets: the bindings module, the generated Python bindings, the runtime libraries, the standard library, and the symbols and import stubs that initialization needs. Prepared::write stores them as content-addressed blobs and a manifest whose digest is their identity. Prepared::read verifies every blob, the manifest form and the initialization WIT before use. Assembler links prepared assets with an app and its native extensions without WIT processing. Each Python path entry has a mount name, so the library names of extensions do not depend on the order of the entries. An app that carries a componentize-py.toml file is rejected, because it would change the bindings. Assembly::initialize_with lets the caller supply the engine that runs initialization. The prepare and assemble subcommands expose this from the command line.
Golem's engine uses Wasmtime 50.0.1, so the crate can run initialization on an engine that Golem configures.
Assembly::initialize takes an Initializer: the engine, an optional linker setup and an optional store setup, such as fuel or an epoch deadline that the engine requires. componentize and assemble use default_engine. The embedded-runtime feature, on by default, builds CPython and the runtime into the crate. Without it the crate reads and assembles prepared assets, which carry their own runtime, and preparing or componentize fail with a clear error. The binary requires the feature.
Golem's Wasmtime has its own WASI implementation, so the crate cannot build the WASI context for it. Assembly::initialize now takes the caller's store and linker, and add_trapping_stubs adds the plan's import stubs to any linker. initialize_component runs initialization for either. Without the embedded-runtime feature the crate does not depend on wasmtime-wasi, and Assembly::initialize_default keeps the crate's own WASI setup for the CLI. Allow the deprecated filetime::set_file_times call: newer filetime releases deprecate it, and the std replacement does not set directory times on every platform.
Without the embedded-runtime feature the crate only reads, assembles and initializes prepared assets, so the WIT generator, registry client, CLI and async runtime become optional dependencies of that feature. An embedder that links the assembler then pulls in fewer crates.
noise64
force-pushed
the
runtime-baseline
branch
from
November 16, 2026 23:51
90cbde9 to
3cf6e79
Compare
noise64
force-pushed
the
prepared-assets
branch
from
November 16, 2026 23:51
eb5a558 to
189e903
Compare
# Conflicts: # src/lib.rs
Unpacking a prepared blob created any symlink or hard link in it, and setting the build mtimes then followed the link to host files. Preparation writes only files and directories, so unpacking now rejects every other entry. The digest of the initialization WIT now normalizes CRLF, so assets prepared on one platform match an assembler built from a checkout that converted line endings. InitPlan::new takes the build entropy from its caller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Touches GOL-1850 (PY-02): the separate prepare and assemble steps that Golem's Python build uses. It does not resolve the issue.
Persisted prepare/assemble API for the Golem Python SDK. Stacked on #1 (
runtime-baseline).ComponentGenerator::generatebinds the WIT world, links the libraries and initializes the result. Initialization follows anInitPlan: owned import stubs instead of the borrowedResolve, the environment, the preopens, and the entropy derived from the linked component, the app name and the Python path files. The Python path search sorts directory entries, so the library order does not depend on the file system.BindingsPreparer::prepareresolves a WIT world once and returnsPrepared: the bindings module, the generated Python bindings, the runtime libraries, the WASI adapter, the standard library, and the symbols and import stubs for initialization.Prepared::writestores content-addressed blobs and a manifest. The SHA-256 of the manifest is the identity.Prepared::readrejects a changed or missing blob, an extra file, a non-canonical manifest, another format and another initialization WIT. The initialization WIT digest normalizes CRLF, so a checkout that converts line endings builds a matching assembler. Unpacking a blob accepts only regular files and directories, so a link in a blob cannot point the build-time mtime update at host files.Assembler::assemblelinks the prepared assets with an app and its native extensions, without WIT processing or code generation. Each Python path entry has a mount name, and the library name of an extension is/{name}/{path}, so the names do not depend on the order of the entries. An app that carries acomponentize-py.tomlfile is rejected, because it would change the bindings.Assembly::initializetakes the caller'sStoreandLinker, built on the caller's engine with its own WASI implementation, asInitPlandescribes: environment, preopens, entropy and build clocks.add_trapping_stubsadds the plan's import stubs to any linker. The crate does not choose engine settings or WASI for the caller.componentizeandassemblekeep this crate's WASI setup anddefault_engine. Wasmtime moves to 50.0.1, the version that Golem's engine uses; this change alone needs no source change.embedded-runtimefeature, on by default, builds CPython and the runtime into the crate. Without the feature, the crate reads and assembles prepared assets, which carry their own runtime, does not build CPython and does not depend onwasmtime-wasi. Preparing andcomponentizeare then not compiled. The binary requires the feature.componentize-py prepare <dir>prints the identity.componentize-py assemble --prepared <dir> [--expect-identity <id>] <app> -p [name=]dirlinks and initializes.Tests in
tests/componentize.rsprepare once and assemble two unrelated apps in separate processes, check that the prepared files do not change, and check that rejected assets do not import the app: the app writes a marker on import, and the marker appears only for intact assets.Known gaps: the
embedded-runtimecheck at the start ofbindcannot fail, becausebindexists only with the feature. Theinitialize_componentdocs do not say that the caller's engine needswasm_component_model_map. No test covers support-library linking with prepared assets, finalization of exported resources, a non-canonical manifest, a missing blob or another format; the digest-mismatch test corrupts the first blob thatread_dirreturns.Not solved here: two assemblies of the same input can still differ in a few bytes. The difference follows host metadata of the build directories that assembly creates.
Verification
On this head, cad25ee (Linux x86_64, local, with the CPython build from the cache cases of #1). This head merges #1's head 7389c59, which takes wit-component from the wasm-tools fork. The merge brings the same change as #1 and no other change.
cargo test --release -- --skip http_p3_example: passed (119 lib, 21 bindings, 12 componentize tests).prepared::tests::unpack_rejects_linkscovers symlink and hard-link entries.bash .github/workflows/lint.sh: passed.componentize-py prepareruns with the binary from this head gave identical files and the identitya120875a…0234. The previous identity,b1d3997f…, differs only in the blob oflibcomponentize_py_runtime.so(20 bytes longer). Its strings differ only in.llvm.<n>symbol suffixes. The wit-component package changed from a path source to a git source, so the build hashes of the wit-bindgen crates and the runtime crate change. This is the probable cause of the suffix changes. No rebuild proved it.http_p3_example, because its port is taken on the build machine.main, so this stacked PR has no checks. A missing result is not a pass.