@systemfsoftware/stryker-js-plugin-interface 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Copyright (c) 2026 Ryan Lee (systemfsoftware)
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright 2026 Ryan Lee (systemfsoftware)
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @systemfsoftware/stryker-js-plugin-interface
2
+
3
+ The mutation-testing plugin **contract**. A worker plugin — a test runner,
4
+ checker, or reporter — ships a spawn entrypoint whose target hosts an `RpcServer`
5
+ for its kind's `@effect/rpc` group; the host resolves that entrypoint from the
6
+ project's config, spawns it, and drives it over NDJSON. Every payload crossing
7
+ the boundary is a schema this package owns, and every failure is a typed variant.
8
+ The concept modules a plugin implements live in
9
+ `@systemfsoftware/stryker-js-language`.
10
+
11
+ The boundary ships as two packages:
12
+
13
+ - **`@systemfsoftware/stryker-js-plugin-interface`** (this one) — what both sides
14
+ of the process split must agree on: the RPC groups, their payload and error
15
+ schemas, the spawn contract, and the trace-context contract.
16
+ - **[`@systemfsoftware/stryker-js-plugin-runtime`](../stryker-js-plugin-runtime/README.md)**
17
+ — the worker-side implementation a plugin process runs: the RPC server layer,
18
+ its Node module port, its OTel bootstrap, the worker-options wire codec, and the
19
+ trace-context middleware implementations.
20
+
21
+ ## Install
22
+
23
+ ```sh
24
+ pnpm add @systemfsoftware/stryker-js-plugin-interface
25
+ ```
26
+
27
+ A plugin process also installs the runtime package:
28
+
29
+ ```sh
30
+ pnpm add @systemfsoftware/stryker-js-plugin-runtime
31
+ ```
32
+
33
+ ## Entry point
34
+
35
+ The interface package publishes the per-kind RPC groups (`TestRunnerRpcs`,
36
+ `CheckerRpcs`, `ReporterRpcs`), the boundary payload schemas
37
+ (`TestRunnerDryRunRequest`, `CheckerRequest`, `ReporterEventBatch`,
38
+ `ReporterInitOptions`, …), the typed error taxonomy (`BoundaryPayloadRejected`,
39
+ `BoundaryUnrecognizedSignal`), the spawn contract (`WorkerPluginKind`,
40
+ `WorkerPluginSpawn`, `WorkerPluginSpawnSchema`, `WorkerEntryUrl`), and the
41
+ trace-context contract the groups carry (`TraceContextMiddleware`,
42
+ `PropagatedTrace`, `TracedRpc`, `TraceContextReference`, `TraceContextParts`,
43
+ `formatTraceparent`, `parseTraceparent`, `Traceparent`, `TRACEPARENT_HEADER`,
44
+ `TRACESTATE_HEADER`):
45
+
46
+ ```ts
47
+ import { ReporterRpcs, TestRunnerRpcs } from '@systemfsoftware/stryker-js-plugin-interface'
48
+ ```
49
+
50
+ The runtime package publishes the worker server layer a plugin's `main.ts`
51
+ launches (`workerServerLayer`, `WorkerServerParams`), the Node module port
52
+ (`nodeModuleLayer`), the worker's OTel exporter layer
53
+ (`workerTelemetryLayer`, merged inside `workerServerLayer`), the worker-options
54
+ wire codec (`encodeWorkerOptions`, `decodeWorkerOptions`,
55
+ `readWorkerOptionsFromEnv`), and the trace-context implementations
56
+ (`layerTraceContextClient`, `layerTraceContextServer`, `withLinkedSpan`,
57
+ `tracePartsOf`, `partsOfEffectSpan`):
58
+
59
+ ```ts
60
+ import { layerTraceContextServer, workerServerLayer } from '@systemfsoftware/stryker-js-plugin-runtime'
61
+ ```
62
+
63
+ Telemetry is a layer everywhere: the worker's exporter is merged inside
64
+ `workerServerLayer`, and a host provides its own `NodeSdk.layer`-based layer at
65
+ its composition root. Both are no-ops unless `OTEL_ENABLED` is `true`.
66
+
67
+ ## The entry a plugin ships
68
+
69
+ A worker plugin ships one process entrypoint, `src/main.ts`. That file launches
70
+ `workerServerLayer(...)` through its platform's `runMain` — the single place the
71
+ worker program is interpreted, the same shape the `stryker` CLI's own `main.ts`
72
+ takes — and the package declares the built artifact at the `./worker` subpath of
73
+ its exports map, which is where the host resolves a worker entry from.
74
+
75
+ ```ts
76
+ import { TestRunnerRpcs } from '@systemfsoftware/stryker-js-plugin-interface'
77
+ import { workerServerLayer } from '@systemfsoftware/stryker-js-plugin-runtime'
78
+
79
+ NodeRuntime.runMain(
80
+ Layer.launch(
81
+ workerServerLayer({ rpcs: TestRunnerRpcs, handlers: testRunnerHandlers, schemaServices: Layer.empty }),
82
+ ).pipe(Effect.provideService(Logger.LogToStderr, true)),
83
+ )
84
+ ```
85
+
86
+ ## Trust boundary
87
+
88
+ The host executes a plugin's _library_ module in its own process to read the
89
+ plugin's descriptor, its ignorers, and its validation-schema contribution: that
90
+ module is trusted code, the same as any other dependency the project installs.
91
+ Only the plugin's _runtime work_ crosses into its own process — the RPC groups in
92
+ this package are what the host drives there, and a worker that crashes, runs out
93
+ of memory, or never boots is reported as a typed boundary error instead of
94
+ taking the run down.
95
+
96
+ A spawned worker inherits the host's environment and reads the run's options from
97
+ `options.json` in the worker directory the host creates, so a plugin sees the
98
+ same options and environment a local `stryker` run has. Test-runner and checker
99
+ workers are started in the run's sandbox directory; a reporter worker is started
100
+ in the project root it reports on.
101
+
102
+ The worker channel is a unix socket the host restricts to its owner on POSIX. On
103
+ Windows it is a named pipe: the pipe's name embeds a random UUID, and its default
104
+ security descriptor (creator owner, LocalSystem, administrators, read for
105
+ Everyone) is not tightened, because `node:net` exposes no API for it. That
106
+ residual is recorded, not closed.
107
+
108
+ ## License
109
+
110
+ Apache-2.0. Part of [systemfsoftware](https://github.com/systemfsoftware/stryker-js-effect/tree/main/packages/stryker-js-plugin-interface#readme).
@@ -0,0 +1,108 @@
1
+ import { CheckResultSchema, CheckerFailed, CheckerFailed as CheckerFailed$1, DryRunResultSchema, DryRunResultSchema as DryRunResultSchema$1, Mutant, MutantRunResultSchema, MutantRunResultSchema as MutantRunResultSchema$1, ReporterEventUnion, ReporterFailed, ReporterFailed as ReporterFailed$1, TestRunnerCapabilitiesSchema, TestRunnerCapabilitiesSchema as TestRunnerCapabilitiesSchema$1, TestRunnerFailed, TestRunnerFailed as TestRunnerFailed$1 } from "@systemfsoftware/stryker-js-language";
2
+ import * as Rpc from "effect/unstable/rpc/Rpc";
3
+ import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
4
+ import * as S from "effect/Schema";
5
+ import * as Context from "effect/Context";
6
+ import * as RpcMiddleware from "effect/unstable/rpc/RpcMiddleware";
7
+ import * as Option from "effect/Option";
8
+ import { Schema } from "effect";
9
+ //#region src/Plugin.schema.d.ts
10
+ export declare const WorkerPluginKind: S.Literals<readonly ["TestRunner", "Checker", "Reporter"]>;
11
+ export type WorkerPluginKind = typeof WorkerPluginKind.Type;
12
+ export declare const TestRunnerDryRunRequest: S.Struct<{
13
+ readonly options: S.Struct<{
14
+ readonly timeout: S.Finite;
15
+ readonly disableBail: S.Boolean;
16
+ readonly coverageAnalysis: S.Literals<readonly ["off", "all", "perTest"]>;
17
+ readonly files: S.optionalKey<S.$Array<S.String>>;
18
+ readonly testFiles: S.optionalKey<S.$Array<S.String>>;
19
+ }>;
20
+ }>;
21
+ export type TestRunnerDryRunRequest = typeof TestRunnerDryRunRequest.Type;
22
+ export declare const TestRunnerMutantRunRequest: S.Struct<{
23
+ readonly options: S.Struct<{
24
+ readonly timeout: S.Finite;
25
+ readonly disableBail: S.Boolean;
26
+ readonly activeMutant: typeof Mutant;
27
+ readonly sandboxFileName: S.String;
28
+ readonly mutantActivation: S.Literals<readonly ["runtime", "static"]>;
29
+ readonly reloadEnvironment: S.Boolean;
30
+ readonly testFilter: S.optionalKey<S.$Array<S.String>>;
31
+ readonly hitLimit: S.optionalKey<S.Finite>;
32
+ }>;
33
+ }>;
34
+ export type TestRunnerMutantRunRequest = typeof TestRunnerMutantRunRequest.Type;
35
+ export declare const CheckerRequest: S.Struct<{
36
+ readonly checkerName: S.String;
37
+ readonly mutants: S.$Array<typeof Mutant>;
38
+ }>;
39
+ export type CheckerRequest = typeof CheckerRequest.Type;
40
+ export declare const CheckerCheckResult: S.$Record<S.String, S.Union<readonly [S.Struct<{
41
+ readonly status: S.Literal<"passed">;
42
+ }>, S.Struct<{
43
+ readonly status: S.Literal<"compileError">;
44
+ readonly reason: S.String;
45
+ }>]>>;
46
+ export declare const CheckerGroupResult: S.$Array<S.$Array<S.String>>;
47
+ export declare const ReporterInitOptions: S.Struct<{
48
+ readonly traceparent: S.optionalKey<S.String>;
49
+ readonly tracestate: S.optionalKey<S.String>;
50
+ }>;
51
+ export type ReporterInitOptions = typeof ReporterInitOptions.Type;
52
+ export declare const ReporterEventBatch: S.$Array<S.Union<readonly [typeof import("@systemfsoftware/stryker-js-language").DryRunCompleted, typeof import("@systemfsoftware/stryker-js-language").MutationTestingPlanReady, typeof import("@systemfsoftware/stryker-js-language").MutantTested, typeof import("@systemfsoftware/stryker-js-language").MutationTestReportReady]>>;
53
+ export type ReporterEventBatch = typeof ReporterEventBatch.Type;
54
+ export declare const ReporterAck: S.Void;
55
+ export declare const ReporterDrained: S.Void;
56
+ declare const BoundaryPayloadRejected_base: S.Class<BoundaryPayloadRejected, S.TaggedStruct<"BoundaryPayloadRejected", {
57
+ readonly pluginName: S.String;
58
+ readonly method: S.String;
59
+ readonly cause: S.String;
60
+ }>, import("effect/Cause").YieldableError>;
61
+ export declare class BoundaryPayloadRejected extends BoundaryPayloadRejected_base {}
62
+ declare const BoundaryUnrecognizedSignal_base: S.Class<BoundaryUnrecognizedSignal, S.TaggedStruct<"BoundaryUnrecognizedSignal", {
63
+ readonly pluginName: S.String;
64
+ readonly method: S.String;
65
+ readonly signal: S.String;
66
+ }>, import("effect/Cause").YieldableError>;
67
+ export declare class BoundaryUnrecognizedSignal extends BoundaryUnrecognizedSignal_base {}
68
+ export declare const BoundaryErrorSchema: S.Union<readonly [typeof BoundaryPayloadRejected, typeof BoundaryUnrecognizedSignal, typeof TestRunnerFailed$1, typeof CheckerFailed$1, typeof ReporterFailed$1]>;
69
+ type BoundaryError = typeof BoundaryErrorSchema.Type;
70
+ export declare const WorkerEntryUrl: S.String;
71
+ export type WorkerEntryUrl = typeof WorkerEntryUrl.Type;
72
+ export declare const WorkerPluginSpawnSchema: S.Struct<{
73
+ readonly kind: S.Literals<readonly ["TestRunner", "Checker", "Reporter"]>;
74
+ readonly entrypoint: S.String;
75
+ }>;
76
+ type WorkerPluginSpawn = typeof WorkerPluginSpawnSchema.Type;
77
+ //#endregion
78
+ //#region src/TraceContext.schema.d.ts
79
+ declare const Traceparent: S.String;
80
+ type Traceparent = typeof Traceparent.Type;
81
+ //#endregion
82
+ //#region src/TraceContext.d.ts
83
+ export declare const TRACEPARENT_HEADER = "traceparent";
84
+ export declare const TRACESTATE_HEADER = "tracestate";
85
+ interface TraceContextParts {
86
+ readonly version: string;
87
+ readonly traceId: string;
88
+ readonly spanId: string;
89
+ readonly traceFlags: number;
90
+ readonly traceState?: string | undefined;
91
+ }
92
+ export declare const formatTraceparent: (parts: TraceContextParts) => Traceparent;
93
+ export declare const parseTraceparent: (value: string) => Option.Option<TraceContextParts>;
94
+ export declare const TraceContextReference: Context.Reference<Option.Option<TraceContextParts>>;
95
+ //#endregion
96
+ //#region src/TraceContextRpc.d.ts
97
+ declare const PropagatedTrace_base: Context.ServiceClass<PropagatedTrace, "@systemfsoftware/stryker-js-plugin-interface/TraceContextRpc/PropagatedTrace", Option.Option<TraceContextParts>>;
98
+ export declare class PropagatedTrace extends PropagatedTrace_base {}
99
+ declare const TraceContextMiddleware_base: RpcMiddleware.ServiceClass<TraceContextMiddleware, "@systemfsoftware/stryker-js-plugin-interface/TraceContextMiddleware", typeof PropagatedTrace, Schema.Never, never, never, true>;
100
+ export declare class TraceContextMiddleware extends TraceContextMiddleware_base {}
101
+ type TracedRpc<Tag extends string, Payload extends Schema.Top = Schema.Void, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never> = Rpc.Rpc<Tag, Payload, Success, Error, typeof TraceContextMiddleware, RpcMiddleware.ApplyServices<typeof TraceContextMiddleware['Identifier'], never>>;
102
+ //#endregion
103
+ //#region src/Plugin.d.ts
104
+ export declare const TestRunnerRpcs: RpcGroup.RpcGroup<TracedRpc<'capabilities', Schema.Void, typeof TestRunnerCapabilitiesSchema$1, typeof TestRunnerFailed$1> | TracedRpc<'dryRun', typeof TestRunnerDryRunRequest, typeof DryRunResultSchema$1, typeof TestRunnerFailed$1> | TracedRpc<'mutantRun', typeof TestRunnerMutantRunRequest, typeof MutantRunResultSchema$1, typeof TestRunnerFailed$1>>;
105
+ export declare const CheckerRpcs: RpcGroup.RpcGroup<TracedRpc<'check', typeof CheckerRequest, typeof CheckerCheckResult, typeof CheckerFailed$1> | TracedRpc<'group', typeof CheckerRequest, typeof CheckerGroupResult, typeof CheckerFailed$1>>;
106
+ export declare const ReporterRpcs: RpcGroup.RpcGroup<TracedRpc<'init', typeof ReporterInitOptions, typeof ReporterAck, typeof ReporterFailed$1> | TracedRpc<'onEventBatch', typeof ReporterEventBatch, typeof ReporterAck, typeof ReporterFailed$1> | TracedRpc<'flush', Schema.Void, typeof ReporterDrained, typeof ReporterFailed$1>>;
107
+ //#endregion
108
+ export { type BoundaryError, CheckResultSchema, CheckerFailed, DryRunResultSchema, MutantRunResultSchema, ReporterEventUnion, ReporterFailed, TestRunnerCapabilitiesSchema, TestRunnerFailed, type TraceContextParts, type TracedRpc, type Traceparent, type WorkerPluginSpawn };
package/dist/index.mjs ADDED
@@ -0,0 +1,132 @@
1
+ import { CheckResultSchema, CheckResultSchema as CheckResultSchema$1, CheckerFailed, CheckerFailed as CheckerFailed$1, DryRunOptionsSchema, DryRunResultSchema, DryRunResultSchema as DryRunResultSchema$1, Mutant, MutantRunOptionsSchema, MutantRunResultSchema, MutantRunResultSchema as MutantRunResultSchema$1, ReporterEventUnion, ReporterEventUnion as ReporterEventUnion$1, ReporterFailed, ReporterFailed as ReporterFailed$1, TestRunnerCapabilitiesSchema, TestRunnerCapabilitiesSchema as TestRunnerCapabilitiesSchema$1, TestRunnerFailed, TestRunnerFailed as TestRunnerFailed$1 } from "@systemfsoftware/stryker-js-language";
2
+ import * as Rpc from "effect/unstable/rpc/Rpc";
3
+ import * as RpcGroup from "effect/unstable/rpc/RpcGroup";
4
+ import * as S from "effect/Schema";
5
+ import * as Context from "effect/Context";
6
+ import * as RpcMiddleware from "effect/unstable/rpc/RpcMiddleware";
7
+ import * as Option from "effect/Option";
8
+ //#region src/Plugin.schema.ts
9
+ const WorkerPluginKind = S.Literals([
10
+ "TestRunner",
11
+ "Checker",
12
+ "Reporter"
13
+ ]);
14
+ const TestRunnerDryRunRequest = S.Struct({ options: DryRunOptionsSchema });
15
+ const TestRunnerMutantRunRequest = S.Struct({ options: MutantRunOptionsSchema });
16
+ const CheckerRequest = S.Struct({
17
+ checkerName: S.String,
18
+ mutants: S.Array(Mutant)
19
+ });
20
+ const CheckerCheckResult = S.Record(S.String, CheckResultSchema$1);
21
+ const CheckerGroupResult = S.Array(S.Array(S.String));
22
+ const ReporterInitOptions = S.Struct({
23
+ traceparent: S.optionalKey(S.String),
24
+ tracestate: S.optionalKey(S.String)
25
+ });
26
+ const ReporterEventBatch = S.Array(ReporterEventUnion$1);
27
+ const ReporterAck = S.Void;
28
+ const ReporterDrained = S.Void;
29
+ var BoundaryPayloadRejected = class extends S.TaggedError()("BoundaryPayloadRejected", {
30
+ pluginName: S.String,
31
+ method: S.String,
32
+ cause: S.String
33
+ }) {};
34
+ var BoundaryUnrecognizedSignal = class extends S.TaggedError()("BoundaryUnrecognizedSignal", {
35
+ pluginName: S.String,
36
+ method: S.String,
37
+ signal: S.String
38
+ }) {};
39
+ const BoundaryErrorSchema = S.Union([
40
+ BoundaryPayloadRejected,
41
+ BoundaryUnrecognizedSignal,
42
+ TestRunnerFailed$1,
43
+ CheckerFailed$1,
44
+ ReporterFailed$1
45
+ ]);
46
+ const WorkerEntryUrl = S.String.check(S.isPattern(/^file:\/\//, { expected: "a file: URL of the worker program" }));
47
+ const WorkerPluginSpawnSchema = S.Struct({
48
+ kind: WorkerPluginKind,
49
+ entrypoint: WorkerEntryUrl
50
+ });
51
+ //#endregion
52
+ //#region src/TraceContextRpc.ts
53
+ var PropagatedTrace = class extends Context.Service()("@systemfsoftware/stryker-js-plugin-interface/TraceContextRpc/PropagatedTrace") {};
54
+ var TraceContextMiddleware = class extends RpcMiddleware.Service()("@systemfsoftware/stryker-js-plugin-interface/TraceContextMiddleware", { requiredForClient: true }) {};
55
+ //#endregion
56
+ //#region src/Plugin.ts
57
+ const TestRunnerRpcs = RpcGroup.make(Rpc.make("capabilities", {
58
+ success: TestRunnerCapabilitiesSchema$1,
59
+ error: TestRunnerFailed$1
60
+ }), Rpc.make("dryRun", {
61
+ payload: TestRunnerDryRunRequest,
62
+ success: DryRunResultSchema$1,
63
+ error: TestRunnerFailed$1
64
+ }), Rpc.make("mutantRun", {
65
+ payload: TestRunnerMutantRunRequest,
66
+ success: MutantRunResultSchema$1,
67
+ error: TestRunnerFailed$1
68
+ })).middleware(TraceContextMiddleware);
69
+ const CheckerRpcs = RpcGroup.make(Rpc.make("check", {
70
+ payload: CheckerRequest,
71
+ success: CheckerCheckResult,
72
+ error: CheckerFailed$1
73
+ }), Rpc.make("group", {
74
+ payload: CheckerRequest,
75
+ success: CheckerGroupResult,
76
+ error: CheckerFailed$1
77
+ })).middleware(TraceContextMiddleware);
78
+ const ReporterRpcs = RpcGroup.make(Rpc.make("init", {
79
+ payload: ReporterInitOptions,
80
+ success: ReporterAck,
81
+ error: ReporterFailed$1
82
+ }), Rpc.make("onEventBatch", {
83
+ payload: ReporterEventBatch,
84
+ success: ReporterAck,
85
+ error: ReporterFailed$1
86
+ }), Rpc.make("flush", {
87
+ success: ReporterDrained,
88
+ error: ReporterFailed$1
89
+ })).middleware(TraceContextMiddleware);
90
+ //#endregion
91
+ //#region src/TraceContext.ts
92
+ const TRACEPARENT_HEADER = "traceparent";
93
+ const TRACESTATE_HEADER = "tracestate";
94
+ const formatTraceparent = (parts) => `${parts.version}-${parts.traceId}-${parts.spanId}-${(parts.traceFlags & 255).toString(16).padStart(2, "0")}`;
95
+ const HEX_VERSION = /^[0-9a-f]{2}$/;
96
+ const HEX_TRACE_ID = /^[0-9a-f]{32}$/;
97
+ const HEX_SPAN_ID = /^[0-9a-f]{16}$/;
98
+ const HEX_FLAGS = /^[0-9a-f]{2}$/;
99
+ const ALL_ZERO = /^0+$/;
100
+ const FORBIDDEN_VERSION = "ff";
101
+ const CURRENT_VERSION = "00";
102
+ const TRACEPARENT_FIELD_COUNT = 4;
103
+ const fieldAt = (fields, index) => fields[index] ?? "";
104
+ const traceparentFields = (parts) => ({
105
+ version: fieldAt(parts, 0),
106
+ traceId: fieldAt(parts, 1),
107
+ spanId: fieldAt(parts, 2),
108
+ flags: fieldAt(parts, 3)
109
+ });
110
+ const acceptsFieldCount = (version, count) => version !== CURRENT_VERSION || count === TRACEPARENT_FIELD_COUNT;
111
+ const isKnownVersion = (version) => HEX_VERSION.test(version) && version !== FORBIDDEN_VERSION;
112
+ const isNonZeroHex = (pattern, value) => pattern.test(value) && !ALL_ZERO.test(value);
113
+ const isWellFormedTraceparent = (fields, fieldCount) => [
114
+ acceptsFieldCount(fields.version, fieldCount),
115
+ isKnownVersion(fields.version),
116
+ isNonZeroHex(HEX_TRACE_ID, fields.traceId),
117
+ isNonZeroHex(HEX_SPAN_ID, fields.spanId),
118
+ HEX_FLAGS.test(fields.flags)
119
+ ].every((check) => check);
120
+ const parseTraceparent = (value) => {
121
+ const parts = value.split("-");
122
+ const fields = traceparentFields(parts);
123
+ return Option.map(Option.liftPredicate(fields, (candidate) => isWellFormedTraceparent(candidate, parts.length)), (wellFormed) => ({
124
+ version: wellFormed.version,
125
+ traceId: wellFormed.traceId,
126
+ spanId: wellFormed.spanId,
127
+ traceFlags: Number.parseInt(wellFormed.flags, 16)
128
+ }));
129
+ };
130
+ const TraceContextReference = Context.Reference("@systemfsoftware/stryker-js-plugin-interface/TraceContextReference", { defaultValue: () => Option.none() });
131
+ //#endregion
132
+ export { BoundaryErrorSchema, BoundaryPayloadRejected, BoundaryUnrecognizedSignal, CheckResultSchema, CheckerCheckResult, CheckerFailed, CheckerGroupResult, CheckerRequest, CheckerRpcs, DryRunResultSchema, MutantRunResultSchema, PropagatedTrace, ReporterAck, ReporterDrained, ReporterEventBatch, ReporterEventUnion, ReporterFailed, ReporterInitOptions, ReporterRpcs, TRACEPARENT_HEADER, TRACESTATE_HEADER, TestRunnerCapabilitiesSchema, TestRunnerDryRunRequest, TestRunnerFailed, TestRunnerMutantRunRequest, TestRunnerRpcs, TraceContextMiddleware, TraceContextReference, WorkerEntryUrl, WorkerPluginKind, WorkerPluginSpawnSchema, formatTraceparent, parseTraceparent };
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@systemfsoftware/stryker-js-plugin-interface",
3
+ "version": "4.0.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/systemfsoftware/stryker-js-effect.git",
7
+ "directory": "packages/stryker-js-plugin-interface"
8
+ },
9
+ "homepage": "https://github.com/systemfsoftware/stryker-js-effect/tree/main/packages/stryker-js-plugin-interface#readme",
10
+ "bugs": "https://github.com/systemfsoftware/stryker-js-effect/issues",
11
+ "description": "The mutation-testing plugin boundary — the @effect/rpc groups, boundary payload schemas, typed failures, and worker plugin spawn contract.",
12
+ "type": "module",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "license": "Apache-2.0",
17
+ "engines": {
18
+ "node": ">=20.0.0"
19
+ },
20
+ "dependencies": {
21
+ "effect": "4.0.0-rc.112",
22
+ "@systemfsoftware/stryker-js-language": "^4.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@microsoft/api-extractor": "^7",
26
+ "@systemfsoftware/all": "^2",
27
+ "@systemfsoftware/arethetypeswrong-cli": "^4",
28
+ "@systemfsoftware/effect-schema-law": "^2",
29
+ "@systemfsoftware/effect-schema-vite": "^2",
30
+ "@systemfsoftware/tsconfig": "^1",
31
+ "@types/node": "^24",
32
+ "oxlint": "^1",
33
+ "oxlint-tsgolint": "^7",
34
+ "rimraf": "^6.1.3",
35
+ "tsdown": "^0.23.0",
36
+ "typescript": "^7",
37
+ "vitest": "^4",
38
+ "@effect/tsgo": "^0.45.0",
39
+ "@systemfsoftware/vitest-config": "^0.1.0",
40
+ "@systemfsoftware/tsdown-config": "^0.1.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public",
44
+ "provenance": true
45
+ },
46
+ "exports": {
47
+ ".": {
48
+ "types": "./dist/index.d.mts",
49
+ "default": "./dist/index.mjs"
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "scripts": {
54
+ "clean": "rimraf dist",
55
+ "build": "tsdown",
56
+ "typecheck": "tsc --noEmit --incremental && tsc -p tsconfig.node.json --noEmit",
57
+ "test": "vitest run",
58
+ "attw": "attw --pack .",
59
+ "lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",
60
+ "api:check": "api-extractor run",
61
+ "api:update": "api-extractor run --local",
62
+ "lint:tsgo": "effect-tsgo diagnostics --project tsconfig.json --format ${TSGO_FORMAT:-text}"
63
+ }
64
+ }