Skip to content

Plugin contract with metadata model - #31

Merged
rian-be merged 20 commits into
developmentfrom
plugin-contract-with-metadata-model
Sep 8, 2026
Merged

rian-be merged 20 commits into
developmentfrom
plugin-contract-with-metadata-model

Conversation

@rian-be

@rian-be rian-be commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR extends the AuthKit plugin contract with first-class metadata, semantic versioning, manifest support, and contract validation.

  • expands IAuthKitPlugin with stable identity, descriptive metadata, versioning, capabilities, dependencies, activation priority, enablement, and host compatibility
  • introduces strongly typed PluginMetadata and PluginManifest models
  • adds a complete SemanticVersion implementation following SemVer 2.0.0 precedence rules
  • moves plugin contract types into explicit Contracts and Models namespaces
  • adds plugin metadata and manifest extension helpers
  • introduces PluginContractValidator with dedicated validation rules for plugin metadata, middleware, health, registration, and security schemes
  • updates host plugin discovery/loading to consume manifests and validate loaded plugins against their declared metadata
  • updates the DevTokens plugin and Docker build layout for the new contract structure

Plugin Contract

  • extends IAuthKitPlugin with stable plugin identity through Id and Name
  • adds optional DisplayName and Description for human-readable plugin information
  • replaces string-based version information with strongly typed SemanticVersion
  • adds optional Author, License, LicenseUrl, Homepage, and RepositoryUrl metadata
  • adds Tags for plugin classification and catalog filtering
  • adds Priority for activation ordering among dependency-ready plugins
  • adds IsEnabled to allow plugins to be disabled before activation
  • adds Capabilities for feature/capability declaration and negotiation
  • adds MinHostVersion for host compatibility checks
  • adds DependsOn for explicit plugin dependency declaration
  • keeps service registration, health checks, middleware, and OpenAPI security scheme contributions within the plugin contract

Plugin Metadata & Manifest Models

  • introduces PluginMetadata as the normalized metadata representation of a plugin
  • introduces PluginManifest for metadata available before plugin assembly activation
  • separates manifest/discovery data from the runtime IAuthKitPlugin implementation
  • enables the host to perform compatibility and consistency checks before activating a plugin
  • adds extension helpers for converting plugin instances and manifests into metadata representations
  • keeps plugin metadata strongly typed instead of relying on loosely structured dictionaries or strings

Semantic Versioning

  • introduces immutable SemanticVersion implementing SemVer 2.0.0 parsing and precedence comparison
  • supports major, minor, patch, pre-release, and build metadata components
  • ignores build metadata when determining version precedence
  • provides equality and comparison semantics suitable for host/plugin compatibility checks
  • adds SemanticVersionJsonConverter for manifest and configuration serialization
  • uses semantic versions consistently across plugin contracts and host compatibility checks

Plugin Validation

  • introduces the PluginContractValidator tool for validating plugin assemblies independently of the host
  • adds a dedicated contract validation pipeline with composable validation rules
  • validates plugin metadata and required contract invariants
  • validates middleware declarations and ASP.NET Core middleware compatibility
  • validates plugin health-check contributions
  • validates service registration requirements
  • validates contributed OpenAPI security schemes
  • provides explicit load and validation result models for tooling and diagnostics
  • adds an isolated plugin assembly loader for validating plugins without coupling the validator to the host runtime

Host Discovery & Loading

  • updates plugin discovery/loading to consume plugin manifests before activation
  • passes host version information into plugin loading for compatibility checks
  • validates enabled state, metadata consistency, dependencies, capabilities, and host version requirements
  • preserves dependency-aware plugin activation ordering with priority used among dependency-ready plugins
  • validates manifest metadata against the metadata exposed by the loaded IAuthKitPlugin
  • keeps plugin loading centralized in the host plugin pipeline
  • updates LoadedPlugin to carry the expanded plugin metadata required by the new contract

Plugin Organization

  • moves IAuthKitPlugin into Contracts
  • moves security scheme contract types into Contracts.SecuritySchemes
  • introduces explicit Contracts.Plugins helpers for plugin operations and metadata
  • introduces dedicated Models namespace for PluginMetadata, PluginManifest, and semantic version types
  • removes the previous root-level IAuthKitPlugin location in favor of the structured contract namespace
  • updates project references and compilation configuration to include the new contract/model structure

DevTokens Plugin

  • updates DevTokensPlugin to implement the expanded plugin metadata contract
  • adds the plugin manifest used during discovery and pre-activation validation
  • aligns the plugin project with the new contracts and models namespaces
  • keeps plugin-specific implementation details behind the shared IAuthKitPlugin abstraction

Build & Development

  • updates the Docker build context and project paths for the src/ project layout
  • includes PluginContractValidator in the solution/container restore graph
  • updates development Docker configuration for the new project structure
  • keeps plugin validation and host loading aligned with the same contract definitions used by runtime plugins

Result

  • plugins now have a stable, strongly typed metadata contract shared between manifests, discovery, validation, and runtime loading
  • host compatibility can be evaluated using semantic versions before plugin activation
  • plugin dependencies and capabilities can be declared explicitly and validated consistently
  • plugin assemblies can be validated independently through PluginContractValidator
  • the contract structure provides a clear separation between plugin contracts, models, validation, and host loading
  • new plugins can declare their identity, compatibility, capabilities, dependencies, and descriptive metadata without extending the host directly

Closes #25
Closes #24
Closes #23
Closes #26

@rian-be
rian-be requested a review from RX-J September 3, 2026 19:52
@rian-be rian-be self-assigned this Sep 3, 2026
@rian-be rian-be added area/abstractions AuthKit.Plugins.Abstractions contract area/host Host-side runtime (DI, OpenAPI, health exec) area/devtokens DevTokens plugin contract Changes the plugin contract breaking-change Breaking contract change labels Sep 3, 2026
@rian-be
rian-be merged commit 288404a into development Sep 8, 2026
6 of 8 checks passed
Comment on lines -53 to +60
var pluginName = Path.GetFileName(pluginDir);
var entryDllPath = Path.Combine(pluginDir, $"{pluginName}.dll");
if (TryLoadPlugin(pluginDir, logger, hostVersion, loaded, out var plugin))
{
loaded.Add(plugin);
logger.LogInformation("Loaded plugin '{Name}' v{Version} from {Dir}", plugin.Plugin.Name, plugin.Plugin.Version.ToString(), pluginDir);
}
}

return loaded;
var pluginName = Path.GetFileName(pluginDir);
var entryDllPath = Path.Combine(pluginDir, $"{pluginName}.dll");

if (!File.Exists(entryDllPath))
Comment on lines +138 to 142
logger.LogError(ex, "Failed to load plugin from '{Dir}'.", pluginDir);
return false;
}
}

[
Path.Combine(pluginDir, "manifest.json"),
Path.Combine(pluginDir, $"{pluginName}.manifest.json")
];
Path.Combine(pluginDir, "manifest.json"),
Path.Combine(pluginDir, $"{pluginName}.manifest.json")
];

Comment on lines +310 to +314
foreach (var c in value)
{
if (c is < '0' or > '9')
return false;
}
Comment on lines +50 to +54
catch (Exception ex)
{
errors.Add($"health: ConfigureServices threw: {ex.Message}");
return errors;
}
Comment on lines +61 to +64
catch (Exception ex)
{
errors.Add($"health: CheckHealthAsync threw: {ex.Message}");
}
Comment on lines +46 to +52
foreach (var pair in schemes)
{
if (pair.Key != pair.Value.Name)
{
errors.Add($"security schemes: key '{pair.Key}' does not match descriptor Name '{pair.Value.Name}'");
}
}
Comment on lines +54 to +57
catch (Exception ex)
{
errors.Add($"security schemes: GetSecuritySchemes threw: {ex.Message}");
}
@rian-be
rian-be deleted the plugin-contract-with-metadata-model branch September 11, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/abstractions AuthKit.Plugins.Abstractions contract area/devtokens DevTokens plugin area/host Host-side runtime (DI, OpenAPI, health exec) breaking-change Breaking contract change contract Changes the plugin contract

Projects

None yet

2 participants