Skip to the content
Howdah

being built · no release yet

Search

Skip the list of pages

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.extensions in the composer.json of an installed package, a list of class names, which is how a package offers one;
  • extensions in 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 pointRegistered withA config chooses it byIts contract
RunnerwithRunner()runnerRunners
ReporterwithReporter()reportsReporters
Proof storewithProofStore()proofs.storeProof stores
Config loaderwithConfigLoader()the config file's extensionConfig loaders
Mutator setwithMutators()mutators.setsMutators
Static checkerwithStaticChecker()staticCheck.toolOther ports
Tree sourcewithTreeSource()treeSourceOther ports
CI planwithCiPlan()ci.plan, or the CI a job runs inOther ports
PresetwithPreset()presetOther ports
Cost modelwithCostModel()none: the gate takes its own, learnedOther ports
Change source, repositorywithChangeSource(), withRepository()none: the gate takes its own, git, or github under GitHub ActionsOther 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.