Expand description
PM.5: the build service — a plugin source directory becomes a cached
.wasm component.
Design: plugin-manager.md
§5. One primitive with two callers (§6): every user plugin, and the
user’s own init.rs.
§The requirement that shapes everything here
A warm boot with an unchanged source must not rebuild. A cold
component build is seconds to minutes; paying that on every start
would make the editor unusable, so the service is a cache with a
build fallback, not a build step with a cache in front. That is what
the .build-stamp is for: it records what the artifact was built
from and (WT.3) what it was built against, and a stamp matching on
both short-circuits to a pure load.
The second half is not symmetry for its own sake. A source that did
not change, compiled against an ABI that did, looked current under a
source-only stamp — so it was loaded, failed to instantiate, and
said nothing at all. That is the whole of the failure
wit-ownership.md was written for, and no amount of source
fingerprinting can see it.
§Failure is a skip, never a stall
Three failure modes, three different answers, and the middle one is the one worth naming:
- No artifact, build fails →
BuildOutcome::Failed. The plugin does not load. Logged, surfaced in:plugins; boot continues. - An artifact exists, a stale rebuild fails →
BuildOutcome::StaleKept. The previous artifact keeps loading. A user who pushes a broken revision to a plugin they depend on should lose the new code, not the working editor they had five minutes ago. - Stamp matches →
BuildOutcome::Cached. No toolchain is invoked at all, so a machine with no Rust installed still boots every already-built plugin.
Nothing in this module panics and nothing blocks: the caller runs
build_plugin on spawn_blocking (paramount goal #1 / #4 — never
the boot or actor thread).
Structs§
- Cargo
Component Builder - The real builder:
cargo build --release --target wasm32-wasip2. - Stamp
- WT.3: what a cached artifact was built from and against.
Enums§
- Build
Outcome - What
build_plugindid.
Traits§
- Component
Builder - Produces a
.wasmcomponent from a source directory.
Functions§
- artifact_
path - Where a plugin’s cached artifact lives.
- build_
plugin - Build
namefromsource_dirintouser_root, unless the cached artifact is already current. - source_
stamp - A fingerprint of
source_dir’s contents, for staleness comparison.