systemprompt-extension 0.21.1

Compile-time extension framework for systemprompt.io AI governance infrastructure. Built on the inventory crate — registers schemas, API routes, jobs, and providers in the MCP governance pipeline.
Documentation

Production infrastructure for AI agents

Website · Documentation · Guides · Core · Template · Discord


systemprompt-extension

Crates.io Docs.rs codecov License: BSL-1.1

Every route, schema, job, and provider that runs in your governance engine is declared here, at compile time, and collected into one audited startup path. No dynamic plugin loading, no runtime surprises. What links into the binary is what runs.

Layer: Shared: foundational types and traits with no dependencies on other layers. Part of the systemprompt-core workspace.

Overview

An extension declares its schemas, API routes, scheduled jobs, providers, seeds, and assets through the Extension trait. Authors register each one with the register_extension! macro, which submits it to the inventory linker collector. At startup the runtime gathers every registration, validates the dependency graph, and merges the resulting wiring into the host binary. Dependency ordering is enforced at compile time through a typestate builder, so an extension that names a missing dependency fails to build rather than to boot.

Module Map

Module Purpose
any Type-erased wrappers (AnyExtension, ApiExtensionWrapper, SchemaExtensionWrapper).
asset AssetDefinition, AssetDefinitionBuilder, AssetPaths, AssetType.
build Build-script helper (emit_migrations) that generates Extension::migrations() from schema/migrations/*.sql, paired with the extension_migrations! macro.
builder ExtensionBuilder: fluent builder enforcing dependency ordering via typestate.
capabilities CapabilityContext, FullContext, and the Has* capability traits.
context ExtensionContext and DynExtensionContext handed to extensions during router resolution.
error LoaderError, ConfigError.
frame_options Per-route X-Frame-Options override (FrameOptions, stamp_frame_options) honoured by the host security-headers middleware.
hlist Heterogeneous-list machinery (TypeList, Contains, Subset, NotSame) backing the dependency typestate.
metadata ExtensionMetadata, ExtensionRole, SchemaDefinition.
migration Migration value type for versioned extension migrations.
registry ExtensionRegistry, ExtensionRegistration, discovery, queries, validation.
router ExtensionRouter, ExtensionRouterConfig, SiteAuthConfig.
runtime_config Process-level fallback injection of extensions when the inventory collector is stripped (for example by LTO).
seed Seed: idempotent post-migration data fixtures applied on every boot, outside migration tracking.
traits The Extension trait and register_extension! macro.
typed Compile-time-checked sub-traits: SchemaExtensionTyped, ApiExtensionTyped, ConfigExtensionTyped, JobExtensionTyped, ProviderExtensionTyped.
typed_registry TypedExtensionRegistry and RESERVED_PATHS.
types Dependencies, DependencyList, ExtensionMeta, ExtensionType, NoDependencies.

Usage

[dependencies]
systemprompt-extension = "0.21"
use systemprompt_extension::prelude::*;

#[derive(Default)]
struct MyExtension;

impl Extension for MyExtension {
    fn metadata(&self) -> ExtensionMetadata {
        ExtensionMetadata {
            name: "my-extension".into(),
            version: "0.1.0".into(),
            role: ExtensionRole::Domain,
            ..Default::default()
        }
    }
}

register_extension!(MyExtension);

Feature Flags

None. This crate has no Cargo features; everything compiles into every build.

Dependencies

  • inventory: Compile-time extension registration.
  • axum: Router types for ExtensionRouter and the frame-options middleware.
  • reqwest: HTTP client types exposed through capability traits.
  • serde / serde_json: Metadata and configuration serialisation.
  • thiserror: Typed error enums.
  • tracing: Structured logging.
  • systemprompt-provider-contracts: Provider trait definitions re-exported from the prelude.
  • systemprompt-traits (with web feature): Core shared traits.

License

BSL-1.1 (Business Source License). Source-available for evaluation, testing, and non-production use. Production use requires a commercial license. Each version converts to Apache 2.0 four years after publication. See LICENSE.


systemprompt.io · Documentation · Guides · Live Demo · Template · crates.io · docs.rs · Discord

Shared layer · Own how your organization uses AI.