Skip to main content

Module subsystem_boot

Module subsystem_boot 

Source
Expand description

SubsystemBoot — the capability surface a subsystem wires against at boot.

Boot-composition BC.3b. Every subsystem (the Claude Code IDE peer, LSP, multibuffer, terminal, …) self-installs through one crate-owned entry point

pub fn install(boot: &mut impl SubsystemBoot) that does all of its wiring — modes, commands, services, the off-keystroke inbound bus, event wakes — against the generic primitives this trait exposes. The host (editor_boot) then has a single Phase-B install list: one line per subsystem. Adding a subsystem touches the host in exactly that one place and zero host internals (no Editor:: method, no host Action variant) — the mode-ownership acid test, and the property that keeps host churn flat as the mode count grows into the hundreds.

§Why a trait (not the concrete context)

The concrete bundle (lattice_host::boot_context::BootContext) lives in lattice-host, which depends on every subsystem crate — so a subsystem crate cannot name it without a dependency cycle. SubsystemBoot lives here in lattice-mode (below every subsystem crate), exposes only the generic install surface, and is implemented by BootContext. Subsystems depend on the capability, not the host. Host-only lifecycle (registry freezing, tick-token hand-off, the LSP-specific diagnostics handle) stays inherent on BootContext and never leaks into this surface — the LSP diagnostics handle, for instance, is reached through the generic service lookup, so this trait never names a lattice-lsp type.

The generic methods make the trait non-object-safe; installs take &mut impl SubsystemBoot (static dispatch), so object safety is not needed.

§Examples

A complete install for a subsystem with one mode and one off-thread producer. The producer’s results reach the screen with no keystroke because the wake lives inside InboundBus::send:

use lattice_grammar::effect::{EchoLevel, Effect};
use lattice_mode::inbound::InboundBus;
use lattice_mode::{LifecycleFuture, Mode, ModeContext, ModeId, ModeKind, SubsystemBoot};

struct WeatherMode;
impl Mode for WeatherMode {
    type Guard = ();
    fn id(&self) -> ModeId { ModeId::new("weather-mode") }
    fn kind(&self) -> ModeKind { ModeKind::Minor }
    fn on_activate(&self, _ctx: ModeContext) -> LifecycleFuture<'_, ()> {
        Box::pin(async { Ok(()) })
    }
}

/// A report from the off-thread fetcher.
struct Report(String);

/// The one line the host's install list calls.
pub fn install(boot: &mut impl SubsystemBoot) {
    if let Err(e) = boot.modes_mut().register(WeatherMode) {
        tracing::warn!(%e, "weather-mode not registered"); // log + skip, never panic
    }
    // The handler runs on the editor actor, once per drained item.
    let bus: InboundBus<Report> = boot.inbound(|Report(text)| {
        vec![Effect::Echo { level: EchoLevel::Info, text }]
    });
    boot.runtime_handle().spawn(async move {
        // … fetch off-thread, then:
        let _ = bus.send(Report("sunny".into())); // wakes the editor
    });
}

Traits§

SubsystemBoot
The generic-primitive surface a subsystem’s install(boot) wires against.