Extending the gate
A package of your own can add to the gate: a runner for another test framework, a reporter, a proof store, a config format, a static analyser, a CI, a preset or a set of mutators. The gate’s own adapters are registered the same way, and are held to the same contracts.
An extension
An extension is a class that implements
NightWorksIO\MutationGate\Extension\Extension, constructed with no
arguments. Its extend() answers the registry it is handed with what it adds:
use NightWorksIO\MutationGate\Core\Config\Name;use NightWorksIO\MutationGate\Extension\Extension;use NightWorksIO\MutationGate\Extension\Extensions;
final readonly class AcmeExtension implements Extension{ public function extend(Extensions $extensions): Extensions { return $extensions->withReporter(Name::of('acme-chat'), AcmeChat::fromOptions(...)); }}The gate finds it in either of two places (ADR-0001):
extra.mutation-gate.extensionsin thecomposer.jsonof an installed package, a list of class names, which is how a package offers one;extensionsin the project’s config, a list of class names, for an extension the project keeps in its own code.
--no-extensions loads only the gate’s own and its first-party plugins, and
no third-party code. Two packages that register one name at one extension
point are refused, naming both.
Extension points
| Extension point | Registered with | A config chooses it by | Its contract |
|---|---|---|---|
| Runner | withRunner() | runner | Runners |
| Reporter | withReporter() | reports | Reporters |
| Proof store | withProofStore() | proofs.store | Proof stores |
| Config loader | withConfigLoader() | the config file’s extension | Config loaders |
| Mutator set | withMutators() | mutators.sets | Mutators |
| Static checker | withStaticChecker() | staticCheck.tool | Other ports |
| Tree source | withTreeSource() | treeSource | Other ports |
| CI plan | withCiPlan() | ci.plan, or the CI a job runs in | Other ports |
| Preset | withPreset() | preset | Other ports |
| Cost model | withCostModel() | none: the gate takes its own, learned | Other ports |
| Change source, repository | withChangeSource(), withRepository() | none: the gate takes its own, git, or github under GitHub Actions | Other ports |
Adapters says how a config chooses an adapter, by its registered name or by its class, and how an adapter reads its options.
What you may use
What an extension may use is the extension API: every type under
NightWorksIO\MutationGate\Attribute, Port, Mutator, Config and
Extension, and every type their public methods, properties and doc blocks
name, followed through the types those name in turn, but
Mutator\Engine and Extension\Checks. Semantic versioning covers it, and
everything else says @internal
(compatibility,
ADR-0043).
Holding an adapter to its contract
Each port with a kit in NightWorksIO\MutationGate\Extension has its
adapters held to its contract by it, the gate’s own among them: a kit’s
failures() answers every way an adapter breaks the contract, one sentence
each, and none where it keeps it, so a test in any framework asserts that it
answers none:
expect([...ProofStoreContract::failures($store)])->toBe([]);The kits are RunnerContract, ProofStoreContract and
ConfigLoaderContract. Mutators are tested with
NightWorksIO\MutationGate\Mutator\Testing\Mutates.
Examples
The first-party mutator sets under
plugins/
are extensions written against this API, each with a composer.json of its own:
default, security, laravel and symfony.