@systemfsoftware/stryker-js-plugin-runtime
v6.0.2
Published
The mutation-testing plugin runtime — the worker's RPC server layer, its OTel bootstrap, the worker-options wire codec, and the trace-context middleware implementations a plugin process runs.
Downloads
3,053
Readme
@systemfsoftware/stryker-js-plugin-runtime
The mutation-testing plugin runtime — the worker-side implementation of the
boundary described by
@systemfsoftware/stryker-js-plugin-interface.
A plugin's main.ts launches this package's workerServerLayer; nothing here is
contract, so a host that only spawns plugins never imports it.
This package owns:
- the worker RPC server layer a plugin process launches —
workerServerLayerand itsWorkerServerParams; - the telemetry a worker process exports with — the
WorkerTelemetryConfigshape and the OTLP endpoint ruleTracesUrlinworker-telemetry.schema.ts, read through theWorkerTelemetryservice a worker's program root binds its own OTel SDK from; - the worker-options wire schema —
WorkerOptionsWire— and theWorkerOptionsservice a worker reads itsoptions.jsonthrough; - the trace-context middleware implementations that carry W3C
traceparent/tracestateacross the process split —layerTraceContextClient,layerTraceContextServer,withLinkedSpan,tracePartsOf,partsOfEffectSpan.
The symbols these implement — the RPC groups, the payload schemas, the typed
errors, the spawn contract, and the trace-context contract
(TraceContextMiddleware, PropagatedTrace, TracedRpc) — are owned by
@systemfsoftware/stryker-js-plugin-interface and re-exported by nothing: a
consumer imports each symbol from the package that owns it.
Install
pnpm add @systemfsoftware/stryker-js-plugin-runtimeThe entry a plugin ships
Worker.workerServerLayer builds the RpcServer for one kind's RPC group over a socket,
file system, and path the program root provides, restricts the socket file to
its owner, and provides the server-side trace-context middleware:
import { Plugin } from '@systemfsoftware/stryker-js-plugin-interface'
import { Worker } from '@systemfsoftware/stryker-js-plugin-runtime'
NodeRuntime.runMain(
Layer.launch(
Worker.workerServerLayer({
rpcs: Plugin.TestRunnerRpcs,
handlers: testRunnerHandlers,
schemaServices: Layer.empty,
}),
).pipe(Effect.provideService(Logger.LogToStderr, true)),
)Worker options
The host writes the run's options to options.json in the worker directory it
creates; Worker.WorkerOptions, read through Worker.WorkerOptions.layer, decodes that file
into the same StrykerOptions a local stryker run uses, so a worker's
handlers see the run's options without the host passing them over the wire.
Trace context
A synchronous RPC call is the parent of the spans it invokes: the client
middleware injects the active trace context into the request headers as W3C
traceparent/tracestate, and the server middleware continues that trace for
the handler. Asynchronous plugin work — anything that outlives its call — is
linked instead of parented, through Trace.withLinkedSpan.
License
Apache-2.0. Part of systemfsoftware.
