Skip to content

Host concepts ​

This reference describes the core types, traits, and components that make up a composable host. It is intended to be read while working with the handl-platform API.

Traits ​

TraitRole
PluginThe universal, object-safe base trait. Every loaded component implements this.
RuleAcceptorA sub-trait of Plugin for components that accept contributions. RuleAcceptor::Rule is the associated contribution type.
OperationA marker trait for a cross-cutting concern such as Format, Lint, or Cli.
Behavior<Op>A rule that contributes to a specific Operation for a specific AstNode.kind.
HostThe composer that owns the PluginRegistry and drives loading.
HostApplierReads external configuration and applies it to a Host as a HostConfig.
ContributionBase trait for rules such as OptionSchema and DataType.

Core types ​

TypeDescription
PluginRegistryStores Box<dyn Plugin> and resolves capabilities and dependencies.
ContributionContextPassed to Plugin::contribute. Provides register_plugin and contribute::<P: RuleAcceptor>(rule).
PluginContextPassed to Plugin::run. Gives the plugin access to the host while running a capability.
CapabilityRequestA request to execute a capability, carrying the capability id and a JSON payload.
CapabilityResponseThe result of executing a capability.
CapabilityIdThe string identifier for a capability.
AstNodeA generic AST node with kind, span, and payload.
KitA manifest of plugins to load, plus metadata.
KitManifestThe on-disk or embedded TOML manifest for a kit.
HostConfigIn-memory description of kits to load, plugins to include or exclude, and option overrides.
OptionSchemaA plugin-contributed option definition with id, scope, default, and allowed values.
ResolvedOptionsThe merged and validated option values available during run and Behavior::apply.
DataTypeA plugin-contributed runtime data type.

Plugin lifecycle ​

  1. Register — plugins are added to PluginRegistry from kits, direct registration, or another plugin's contribute.
  2. Resolve dependencies — the host topologically sorts plugins by requires and optional.
  3. Contribute — Plugin::contribute is called for each plugin, passing a ContributionContext.
  4. Fixed point — if a contribute step registers new plugins, the host returns to step 2 until no new plugins appear.
  5. Resolve options — the Options plugin merges defaults, kit, host, and user values and validates them.
  6. Run — Host::execute dispatches a CapabilityRequest to the plugin that provides the requested capability.

Operation categories ​

OperationCrateTypical RuleAcceptor
Formathandl-ext-fmtBasicFormatter accepts Behavior<Format>.
Linthandl-ext-lintBasicLinter accepts Behavior<Lint>.
Lexerhandl-ext-lexerBasicLexer accepts Behavior<Lexer>.
Parserhandl-ext-parserBasicParser accepts Behavior<Parser>.
Typecheckhandl-ext-typeBasicTypechecker accepts Behavior<Typecheck>.
Evalhandl-ext-evalhandl-target-rust-interpreter provides Behavior<Eval>.
Clihandl-ext-cliBasicCli accepts CliCommand rules.
Lsphandl-ext-lspBasicLsp accepts LspHandler rules.
Dochandl-ext-docBasicDoc accepts Behavior<Doc>.
Optionshandl-platformOptions accepts OptionSchema rules.
DataTypeshandl-platformDataTypes accepts DataType rules.

Common plugin kinds ​

KindWhat it does in contribute
Library pluginCalls ContributionContext::register_plugin to load more plugins.
Target pluginRegisters target-specific operations and contributes OptionSchema values.
Rule pluginCalls ContributionContext::contribute::<P>(rule) to add a rule to an existing RuleAcceptor.
Operation pluginAccepts rules and executes them when a capability is requested.
Executable hostLoads kits, applies config, and calls Host::execute for Cli or Lsp.