Plugin manifests and extension contracts
A plugin supplies application code through a PluginRegistry. Its manifest declares the capabilities it will register; the registry checks that declaration against the calls made by the plugin. Your application supplies both the manifest and an object implementing PluginInterface. Reading a manifest does not discover or instantiate a plugin automatically.
This reference covers the manifest and the extension signatures. Plugin architecture and lifecycle explains how to compose them into an application.
Manifest fields
Section titled “Manifest fields”registerPlugin(PluginInterface $plugin, array $manifest): void accepts a decoded manifest. registerPluginFromManifest(string $manifestPath, PluginInterface $plugin): void reads a JSON object from a file and rejects malformed JSON, a non-object root and duplicate object keys.
| Field | Type and presence | Contract |
|---|---|---|
name |
Required string | Nonempty, with no surrounding whitespace. Unique within the registry. Registering the same plugin object again is also rejected. |
version |
Required string | Three numeric components, X.Y.Z, accepted by VersionNumber::semver(). This is the plugin’s version. |
requires |
Optional object or null |
Only the execkernel key is supported. It declares an engine range, not dependencies on other plugins or Composer packages. |
requires.execkernel |
String when requires is non-null |
Whitespace-separated exact-version, >=X.Y.Z or <=X.Y.Z tokens. At most one lower and one upper bound. An exact version sets both. |
engine_min_version |
Optional string or null |
Inclusive lower bound, using three numeric components. |
engine_max_version |
Optional string or null |
Inclusive upper bound. It must not be lower than the minimum. |
provides |
Required object | Contains only the seven sections listed below. Each supplied section is a list of distinct nonempty strings with no surrounding whitespace. Omitted sections become empty lists. |
At least one engine bound must result from requires or the explicit fields. When both forms specify the same bound, their strings must agree. Operators such as ^, ~, >, <, wildcards, disjunctions and prerelease versions are not part of this grammar.
The registry constructor accepts engineVersion and compatibilityMode. Their defaults are '1.0.0' and CompatibilityMode::LOOSE; they are not inferred from the installed package version. An engine outside the manifest’s bounds produces warning EK-WARN-033 in loose mode and an InvalidArgumentException in strict mode. Invalid manifest structure is rejected in either mode.
Seven capability sections
Section titled “Seven capability sections”Class names must identify existing classes, use their canonical PHP spelling and implement the indicated interface. Each class can be registered only once in its section. Every class-registration method also accepts ?callable $factory = null and returns void; the table preserves its class parameter name.
provides section |
Registration method | Extension contract |
|---|---|---|
rules |
addRule(string $ruleClass, ?callable $factory = null): void |
ExecKernel\Domain\Engine\Rules\RuleInterface: getType(): string and evaluate(array $params, Edge $edge, SessionState $state, ?DateTimeImmutable $now = null): ConditionEvaluationResult. |
validators |
addValidator(string $validatorClass, ?callable $factory = null): void |
ExecKernel\Domain\Engine\GraphValidatorInterface: validate(array $graphDefinition): void. Throw to reject the definition. |
listeners |
addListener(string $listenerClass, ?callable $factory = null): void |
ExecKernel\Domain\Engine\RuntimeEventListenerInterface: subscribe(FlowEventsDispatcher $dispatcher): void. Register callbacks with the dispatcher. |
loaders |
addLoader(string $loaderClass, ?callable $factory = null): void |
ExecKernel\Domain\Graph\GraphLoaderInterface: load(string|int $graphCode): Graph. Return a complete graph. |
outputs |
addOutputHook(string $hookClass, ?callable $factory = null): void |
ExecKernel\Domain\Engine\PayloadOutputHookInterface: apply(Graph $graph, SessionState $state, string $lang, array $payload): array. Return the presentation payload. |
webhooks |
addWebhookDispatcher(string $dispatcherClass, ?callable $factory = null): void |
ExecKernel\Domain\Engine\WebhookDispatcherInterface: dispatch(array $webhookConfig, array $payload): void. Configuration and event data are separate arguments. |
terminal_outputs |
addTerminalOutputType(string $type, callable $validator): void |
Type names, rather than class names. The callable receives one output declaration and must return the boolean true for that declaration to be valid. |
The plugin validator receives an array. The import pipeline’s GraphValidationRuleInterface::validate(RawGraphData $data): void is a different interface: PluginGraphValidatorRule adapts it by passing $data->toArray() to the plugin validator.
An output hook changes the payload built for an existing node or terminal. A terminal-output validator declares the validity of an output type such as receipt; it does not render that output or execute its effect. See payload output hooks and custom terminal outputs for the corresponding integration procedures.
Minimal manifest and matching registration
Section titled “Minimal manifest and matching registration”This example adds a receipt output containing an application’s receipt reference. The manifest declares a type name because no component class needs to be constructed for this capability.
{ "name": "reference-receipt", "version": "1.0.0", "requires": {"execkernel": ">=0.2.0 <=0.2.0"}, "provides": {"terminal_outputs": ["receipt"]}}Download plugin-extension-manifest.json. With $manifest holding that decoded document, the matching registration is:
use ExecKernel\Domain\Engine\PluginInterface;use ExecKernel\Domain\Engine\PluginRegistry;use ExecKernel\Domain\Versioning\CompatibilityMode;
$plugin = new class implements PluginInterface { public function register(PluginRegistry $registry): void { $registry->addTerminalOutputType( 'receipt', static fn(array $output): bool => is_string($output['reference'] ?? null) && $output['reference'] !== '', ); }
public function boot(): void {}};
$registry = new PluginRegistry( engineVersion: '0.2.0', compatibilityMode: CompatibilityMode::STRICT,);$registry->registerPlugin($plugin, $manifest);The declared range matches the engine version explicitly supplied to this registry. The type accepts {"type":"receipt","reference":"R-42"} and rejects a numeric reference. The registry requires the set of capabilities added by register() to equal the manifest’s declared set: declaring receipt without adding it, or adding another type instead, fails registration.
Factories and lifecycle
Section titled “Factories and lifecycle”A component with required constructor arguments needs an explicit factory. The factory can require zero arguments, or one argument receiving the registry. Optional parameters are not supplied automatically. The returned object must be an instance of the declared component class.
| Operation | Effect and restriction |
|---|---|
PluginInterface::register(PluginRegistry $registry): void |
Adds the declared capabilities. Nested plugin registration and consuming the incomplete registry are rejected. |
| Capability comparison | Runs after register() and before boot(). Every declared addition must be present, with no extra additions. |
PluginInterface::boot(): void |
Runs synchronously during registration. The registry cannot be mutated from boot(). |
| Successful registration | Retains the plugin object and its normalized manifest. |
| Registration or boot throws | Restores registry capabilities, factories, terminal types and warnings to their previous state, then rethrows. This restoration concerns registry state; application code remains responsible for any external work it performed. |
seal(): void |
Permanently prevents further capability registration. isSealed(): bool reports the state. |
| Instantiating components or consuming terminal types | Seals the registry. This includes applyRules(), attachListeners(), ruleTypes(), instantiateValidators(), instantiateOutputHooks(), instantiateWebhookDispatchers(), instantiateLoader() and terminalOutputRegistry(). |
| Repeated attachment | Rules are applied once per evaluator and listeners once per dispatcher. Registry collection accessors do not instantiate components. |
Factories cannot be replaced with a different callable for the same class. A factory cannot recursively instantiate its own component or mutate the registry while construction is in progress. A class without a factory must be instantiable without required constructor arguments.
terminalOutputRegistry() returns a clone of the registry’s terminal-type collection. Changing that clone does not reopen or change the sealed plugin registry.
Reserved names, loader aliases and failures
Section titled “Reserved names, loader aliases and failures”| Boundary | Rejected condition |
|---|---|
Rule type returned by getType() |
Empty or padded name; a type already supplied by another plugin; any reserved type in RuleParameterContract::TYPES. The built-in rule reference identifies the built-in contract. |
| Repeated rule construction | A factory changes the rule type it previously returned. |
| Terminal-output type | Empty or padded name, or a duplicate. The default names redirect, url, content and mixed are already registered. |
| Capability declaration | Unknown provides section, repeated entry, undeclared registration or missing declared registration. |
| Factory | More than one required argument; wrong returned component; replacement of an existing factory. |
| Lifecycle | Registration after sealing, mutation during boot or construction, nested registration, or consuming an incomplete registry. |
Manifest, capability, class and name failures normally raise InvalidArgumentException; lifecycle and recursive-construction failures raise LogicException. Exceptions thrown by plugin code are propagated.
PluginLoaderFactory accepts the registry and an optional map of aliases to registered loader classes. create(string $identifier): GraphLoaderInterface resolves either an exact registered class name or an explicit alias. An alias must be nonempty, unpadded and unique, and cannot shadow a registered class name. An alias does not register a loader, and create() does not scan files or Composer metadata.
For the callback data received by listeners and webhook adapters, use the event catalogue and webhook contracts.