Skip to content

feat(runtime): Runtime preset bundling components and add-ons#194

Open
mfw78 wants to merge 1 commit into
feat/m0-runtime-builderfrom
feat/m0-runtime-preset
Open

feat(runtime): Runtime preset bundling components and add-ons#194
mfw78 wants to merge 1 commit into
feat/m0-runtime-builderfrom
feat/m0-runtime-preset

Conversation

@mfw78

@mfw78 mfw78 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #93.

Adds a Runtime preset trait to nexum-runtime that bundles a component set and an add-on list behind a single type, plus a RuntimeBuilder::runtime::<R>() shortcut that consumes a preset directly, so an embedder with no domain extensions can go from configuration to a running node in one call.

This is part of the epic #79 train and merges in stack order.

Changes

crates/nexum-runtime/src/preset.rs is new and defines the Runtime trait: an associated Types lattice, three associated component-builder types bounded by ComponentBuilder<Output = Types::Chain/Store/Ext>, and components()/add_ons() associated functions returning a ComponentsBuilder and an AddOns list. The same file defines CoreRuntime, the domain-free default preset (Chain = ProviderPool, Store = LocalStore, Ext = ()), which bundles PrometheusAddOn as its default add-on.

crates/nexum-runtime/src/builder.rs gains RuntimeBuilder::runtime::<R>(), a new terminal stage (PresetBuilder) reached directly from the initial builder. It exposes with_extensions, with_module_source, and launch. launch builds the preset's Components, keeps the preset's owned Vec<Box<dyn RuntimeAddOns>> alive alongside a borrowed &dyn RuntimeAddOns view across the launch await, and hands both into the existing AssembledRuntime/LaunchRuntime::launch path unchanged.

crates/nexum-runtime/src/addons.rs adds pub type AddOns = Vec<Box<dyn RuntimeAddOns>>, the return type the issue names for add_ons().

crates/nexum-runtime/src/lib.rs registers the new preset module.

crates/nexum-runtime/examples/embed.rs is rewritten to the one-line RuntimeBuilder::new(&cfg).runtime::<CoreRuntime>().launch().await?.wait().await. The prior example's components.logs read-back demo is kept as a module-doc note rather than dropped, since that path only makes sense against the explicit component builder, not a preset.

Test plan

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-features (all suites pass, including the wasm-backed cow_boot supervisor end-to-end fixture, built rather than skipped)
  • embed.rs example compiles and matches the one-liner in this description

Notes for reviewer

components() and add_ons() are associated functions with no self, since presets are zero-sized markers; runtime::<CoreRuntime>() needs no value to construct. The three associated builder types (rather than a single opaque return) exist because ComponentsBuilder<C, S, E> is generic over the concrete builder types, and the Output = Types::Chain/Store/Ext bounds are exactly what ComponentsBuilder::build needs, so no extra where-clauses leak to callers of the trait.

The default preset is named CoreRuntime, not the issue text's stale EthRuntime, to match the tree's existing domain-free CoreTypes naming and stay honest that this preset carries no chain-specific behaviour.

Two items from the issue are deliberately left out of scope. The CLI (nexum-cli) is not converted to a preset here: it needs the cow Extension linker hook, which the Runtime trait (components plus add-ons only) does not carry, and wiring that in is a separate decision about whether presets should also provide extensions. Shipping a cow-specific ReferenceRuntime preset in shepherd-cow-host is the natural follow-up once that question is settled; the issue only suggested it as a possible example, not a requirement.

AI Assistance: Claude Code (Opus 4.8 implementation and adversarial review, Sonnet 5 PR authoring) used for the full change.

Add a Runtime preset trait that names a lattice, its component builders,
and its add-on set as one bundle, plus the domain-free CoreRuntime default
preset. RuntimeBuilder::runtime binds a preset so an embedder launches with
RuntimeBuilder::new(cfg).runtime::<Preset>().launch(). Update the embed
example to use the preset.
@mfw78 mfw78 force-pushed the feat/m0-runtime-preset branch from fdd03a5 to f7c4c52 Compare July 5, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant