@sackville-mcp/mutate 0.0.1-alpha.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 +201 -0
- package/dist/index.d.mts +347 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +793 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Curtis Autery
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
//#region src/config.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Diff-scoping config EMITTERS for the Python mutation tools (ADR 0010 addendum 2). These turn a
|
|
4
|
+
* selected-file scope into a per-run tool config, PINNED to the slice-0 captures of the installed
|
|
5
|
+
* cosmic-ray 8.4.6 / mutmut 3.5.0 (see `test/fixtures/README.md`) — never doc-derived guesses:
|
|
6
|
+
*
|
|
7
|
+
* - cosmic-ray scopes via a `module-path` FILE LIST (Fork A — verified 8.4.6 accepts a list); its
|
|
8
|
+
* `excluded-modules` SUBTRACTS from the scope via exact path AND fnmatch glob, so an inherited
|
|
9
|
+
* exclusion that matches a selected file is reconciled (stripped), never copied blind (blocker #3).
|
|
10
|
+
* - mutmut scopes via `paths_to_mutate` (Fork B was WRONG — 3.5.0 has NO `only_mutate`/`source_paths`;
|
|
11
|
+
* `paths_to_mutate` + `do_not_mutate` are the real keys, Fork F). Scoping a subset breaks the
|
|
12
|
+
* baseline unless the rest of the source tree is `also_copy`'d so unscoped tests still import; an
|
|
13
|
+
* inherited `do_not_mutate` glob matching a selected file is stripped (blocker #3, mutmut form).
|
|
14
|
+
*
|
|
15
|
+
* Both emitters are PURE (TOML in → TOML out via `smol-toml`). They reduce SPURIOUS inconclusives by
|
|
16
|
+
* reconciling exclusions up front; the load-bearing under-scope guarantee is the POST-SPAWN
|
|
17
|
+
* {@link reconcileScope} guard in the runner, which folds any genuinely-unmutated selected file to
|
|
18
|
+
* inconclusive regardless of why (absence-is-never-a-pass).
|
|
19
|
+
*/
|
|
20
|
+
/** Thrown when a scoped config cannot be safely synthesized (empty scope, missing base table, etc.). */
|
|
21
|
+
declare class ScopeEmitError extends Error {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The operator's declared source tree, read from a cosmic-ray base config's `module-path` (a single
|
|
26
|
+
* string or a list). Used as the default `ownedRoots` to confine the diff scope (Fork C): a changed
|
|
27
|
+
* `.py` outside this tree is `unmatched` (report-gap), never silently scoped. Pure.
|
|
28
|
+
*/
|
|
29
|
+
declare function cosmicModulePathRoots(baseToml: string): string[];
|
|
30
|
+
interface ScopedCosmicRayConfig {
|
|
31
|
+
/** The synthesized per-run `cosmic-ray.toml` text. */
|
|
32
|
+
toml: string;
|
|
33
|
+
/** The selected file list written to `module-path` (canonical form). */
|
|
34
|
+
modulePath: string[];
|
|
35
|
+
/** Inherited `excluded-modules` entries removed because they would subtract a selected file. */
|
|
36
|
+
strippedExclusions: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Synthesize a per-run cosmic-ray config from a base config + the selected files. Overrides
|
|
40
|
+
* `module-path` to the canonical selected FILE LIST and reconciles `excluded-modules`: any entry
|
|
41
|
+
* (exact or fnmatch glob) that matches a selected file is stripped (it would otherwise silently
|
|
42
|
+
* subtract that file — blocker #3); non-colliding entries are preserved. All other keys/tables
|
|
43
|
+
* (`timeout`, `test-command`, `[cosmic-ray.distributor]`, …) are preserved verbatim. Pure.
|
|
44
|
+
*/
|
|
45
|
+
declare function synthesizeScopedCosmicRayConfig(baseToml: string, selectedFiles: string[]): ScopedCosmicRayConfig;
|
|
46
|
+
/** The operator's `[tool.mutmut] paths_to_mutate` — the default `ownedRoots` for a scoped mutmut run. */
|
|
47
|
+
declare function mutmutPathsToMutate(basePyproject: string): string[];
|
|
48
|
+
/** The operator's inherited `[tool.mutmut] do_not_mutate` globs (reconciled against the scope). */
|
|
49
|
+
declare function mutmutDoNotMutate(basePyproject: string): string[];
|
|
50
|
+
interface MutmutScopePlan {
|
|
51
|
+
/** The selected files written to `paths_to_mutate` (canonical form). */
|
|
52
|
+
pathsToMutate: string[];
|
|
53
|
+
/** Sibling source files to `also_copy` so unscoped tests still import (source tree minus scope). */
|
|
54
|
+
alsoCopy: string[];
|
|
55
|
+
/** Inherited `do_not_mutate` globs preserved (those that do NOT collide with the scope). */
|
|
56
|
+
doNotMutate: string[];
|
|
57
|
+
/** Inherited `do_not_mutate` globs removed because they would exclude a selected file (blocker #3). */
|
|
58
|
+
strippedDoNotMutate: string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Plan a scoped mutmut run. `paths_to_mutate` = the selected files; `also_copy` = every other source
|
|
62
|
+
* file in `allSourceFiles` (so a test importing an unscoped sibling module still resolves in mutmut's
|
|
63
|
+
* `mutants/` sandbox — verified necessary in slice 0). An inherited `do_not_mutate` glob that matches
|
|
64
|
+
* a selected file is stripped (it would otherwise exclude a file we deliberately scoped). Pure given
|
|
65
|
+
* `allSourceFiles` (the runner derives it by walking the owned roots).
|
|
66
|
+
*/
|
|
67
|
+
declare function planMutmutScope(selectedFiles: string[], allSourceFiles: string[], inheritedDoNotMutate?: string[]): MutmutScopePlan;
|
|
68
|
+
/**
|
|
69
|
+
* Render a `pyproject.toml` for a scoped mutmut run: merge the {@link MutmutScopePlan}'s
|
|
70
|
+
* `paths_to_mutate`/`also_copy` (+ reconciled `do_not_mutate`) into the base pyproject's
|
|
71
|
+
* `[tool.mutmut]` table (Fork F: only slice-0-verified keys), preserving every other section and any
|
|
72
|
+
* other verified `[tool.mutmut]` key the operator set (e.g. `pytest_add_cli_args`). An empty
|
|
73
|
+
* `do_not_mutate` is omitted entirely. Pure.
|
|
74
|
+
*/
|
|
75
|
+
declare function synthesizeScopedMutmutPyproject(basePyproject: string, plan: MutmutScopePlan): string;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/summarize.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* Pure mutation-report summarizer — the first slice of `@sackville-mcp/mutate`, and the one
|
|
80
|
+
* with no I/O and no Stryker dependency.
|
|
81
|
+
*
|
|
82
|
+
* Mutation testing asks "are the tests meaningful?" — it perturbs the source (a `+`
|
|
83
|
+
* becomes `-`, a `true` becomes `false`) and re-runs the suite; a mutant that survives is
|
|
84
|
+
* a behaviour the tests do not actually pin down. Under Sackville's TDD gate the agent
|
|
85
|
+
* wrote a passing test, but a passing test can still assert nothing useful — surviving
|
|
86
|
+
* mutants are the catch for that, the natural complement to coverage's forgotten-assertion
|
|
87
|
+
* catch (covered-but-unkilled vs added-but-uncovered).
|
|
88
|
+
*
|
|
89
|
+
* This module reads the **mutation-testing-elements report schema** (`schemaVersion`,
|
|
90
|
+
* `files[path].mutants[].status`) that Stryker emits as `mutation-report.json`. The schema
|
|
91
|
+
* is stable and decoupled from the Stryker version (ADR 0010 update 2026-06-01), so this
|
|
92
|
+
* core carries no `@stryker-mutator/*` import — it is unit-tested against a committed
|
|
93
|
+
* golden report. Producing a real report is a gated, injected `stryker run` (a later slice).
|
|
94
|
+
*
|
|
95
|
+
* Metric definitions mirror mutation-testing-elements exactly:
|
|
96
|
+
* detected = killed + timeout
|
|
97
|
+
* undetected = survived + noCoverage
|
|
98
|
+
* covered = detected + survived (NoCoverage excluded — it was never run)
|
|
99
|
+
* valid = detected + undetected
|
|
100
|
+
* invalid = compileErrors + runtimeErrors
|
|
101
|
+
* total = valid + invalid + ignored + pending
|
|
102
|
+
* mutationScore = detected / valid (null when valid === 0)
|
|
103
|
+
* mutationScoreBasedOnCoveredCode = detected / covered (null when covered === 0)
|
|
104
|
+
*/
|
|
105
|
+
/** Mutant statuses from the mutation-testing-elements schema. */
|
|
106
|
+
type MutantStatus = 'Killed' | 'Survived' | 'NoCoverage' | 'Timeout' | 'CompileError' | 'RuntimeError' | 'Ignored' | 'Pending';
|
|
107
|
+
interface MutantPosition {
|
|
108
|
+
line: number;
|
|
109
|
+
column?: number;
|
|
110
|
+
}
|
|
111
|
+
interface Mutant {
|
|
112
|
+
id: string;
|
|
113
|
+
mutatorName: string;
|
|
114
|
+
status: MutantStatus;
|
|
115
|
+
replacement?: string;
|
|
116
|
+
location?: {
|
|
117
|
+
start: MutantPosition;
|
|
118
|
+
end?: MutantPosition;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
interface MutationFile {
|
|
122
|
+
language?: string;
|
|
123
|
+
source?: string;
|
|
124
|
+
mutants: Mutant[];
|
|
125
|
+
}
|
|
126
|
+
interface MutationReport {
|
|
127
|
+
schemaVersion?: string;
|
|
128
|
+
thresholds?: {
|
|
129
|
+
high: number;
|
|
130
|
+
low: number;
|
|
131
|
+
};
|
|
132
|
+
files: Record<string, MutationFile>;
|
|
133
|
+
}
|
|
134
|
+
interface StatusCounts {
|
|
135
|
+
killed: number;
|
|
136
|
+
survived: number;
|
|
137
|
+
timeout: number;
|
|
138
|
+
noCoverage: number;
|
|
139
|
+
compileErrors: number;
|
|
140
|
+
runtimeErrors: number;
|
|
141
|
+
ignored: number;
|
|
142
|
+
pending: number;
|
|
143
|
+
}
|
|
144
|
+
interface MutationMetrics {
|
|
145
|
+
counts: StatusCounts;
|
|
146
|
+
detected: number;
|
|
147
|
+
undetected: number;
|
|
148
|
+
covered: number;
|
|
149
|
+
valid: number;
|
|
150
|
+
invalid: number;
|
|
151
|
+
totalMutants: number;
|
|
152
|
+
/** detected / valid (percent); null when there are no valid mutants. */
|
|
153
|
+
mutationScore: number | null;
|
|
154
|
+
/** detected / covered (percent); null when no covered mutants. */
|
|
155
|
+
mutationScoreBasedOnCoveredCode: number | null;
|
|
156
|
+
}
|
|
157
|
+
interface FileSummary {
|
|
158
|
+
path: string;
|
|
159
|
+
metrics: MutationMetrics;
|
|
160
|
+
}
|
|
161
|
+
/** A surviving (or never-covered) mutant — the actionable test gap. */
|
|
162
|
+
interface Survivor {
|
|
163
|
+
file: string;
|
|
164
|
+
mutatorName: string;
|
|
165
|
+
status: 'Survived' | 'NoCoverage';
|
|
166
|
+
line: number;
|
|
167
|
+
}
|
|
168
|
+
interface MutationSummary {
|
|
169
|
+
metrics: MutationMetrics;
|
|
170
|
+
files: FileSummary[];
|
|
171
|
+
/** Survived + NoCoverage mutants, sorted by file then line — what to go fix. */
|
|
172
|
+
survivors: Survivor[];
|
|
173
|
+
}
|
|
174
|
+
/** Summarize a Stryker mutation report into aggregate + per-file metrics and the survivor list. Pure. */
|
|
175
|
+
declare function summarizeMutation(report: MutationReport): MutationSummary;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/cosmic-ray.d.ts
|
|
178
|
+
/** Parse `cosmic-ray dump <session.sqlite>` JSON-lines into a mutation-testing-elements report. Pure. */
|
|
179
|
+
declare function parseCosmicRayDump(jsonl: string): MutationReport;
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/mutmut.d.ts
|
|
182
|
+
/** Parse `mutmut results --all true` text into a mutation-testing-elements report. Pure. */
|
|
183
|
+
declare function parseMutmutResults(text: string): MutationReport;
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/run.d.ts
|
|
186
|
+
/** Thrown when the paired operator gate denies a run. */
|
|
187
|
+
declare class MutateGateError extends Error {
|
|
188
|
+
constructor(message: string);
|
|
189
|
+
}
|
|
190
|
+
interface RunMutationConfig {
|
|
191
|
+
/** The project to run Stryker in. */
|
|
192
|
+
projectRoot: string;
|
|
193
|
+
/** OPERATOR allowlist of roots the runner may execute in. Load-bearing even with allowRun. */
|
|
194
|
+
allowedRoots: string[];
|
|
195
|
+
/** OPERATOR opt-in to actually run mutation testing. Deny-by-default. */
|
|
196
|
+
allowRun: boolean;
|
|
197
|
+
/** Wall-clock cap (ms) passed to the runner. */
|
|
198
|
+
timeoutMs?: number;
|
|
199
|
+
}
|
|
200
|
+
interface RunMutationInput {
|
|
201
|
+
/**
|
|
202
|
+
* Changed source files to scope mutation to. Stryker → `--mutate`; the Python tools → a synthesized
|
|
203
|
+
* scoped config (cosmic-ray `module-path` list / mutmut `paths_to_mutate`). `undefined` ⇒ the
|
|
204
|
+
* project default (whole project, today's behavior); a supplied list scopes the run, and a selection
|
|
205
|
+
* that resolves to no mutable in-tree `.py` is a pre-spawn noop (`ran:false`, never a spawn).
|
|
206
|
+
*/
|
|
207
|
+
mutateFiles?: string[];
|
|
208
|
+
/** Reuse Stryker's incremental cache (`--incremental`) — faster re-runs. */
|
|
209
|
+
incremental?: boolean;
|
|
210
|
+
/** cosmic-ray config path (relative to projectRoot). Default `cosmic-ray.toml`. */
|
|
211
|
+
configPath?: string;
|
|
212
|
+
/**
|
|
213
|
+
* OPTIONAL operator source roots the diff scope is confined to (Fork C). A changed `.py` outside
|
|
214
|
+
* them is `unmatched` (report-gap), never scoped. Default: the tool config's declared source tree
|
|
215
|
+
* (cosmic-ray `module-path`).
|
|
216
|
+
*/
|
|
217
|
+
ownedRoots?: string[];
|
|
218
|
+
}
|
|
219
|
+
/** Injected command runner — executes `stryker <argv>` and yields its exit status. */
|
|
220
|
+
type MutationRunner = (argv: string[], opts: {
|
|
221
|
+
cwd: string;
|
|
222
|
+
timeoutMs?: number;
|
|
223
|
+
}) => Promise<{
|
|
224
|
+
exitCode: number;
|
|
225
|
+
stdout: string;
|
|
226
|
+
stderr: string;
|
|
227
|
+
}>;
|
|
228
|
+
interface RunMutationResult {
|
|
229
|
+
ran: boolean;
|
|
230
|
+
exitCode: number;
|
|
231
|
+
/** Files mutation was scoped to (empty ⇒ the project's configured set). */
|
|
232
|
+
scopedFiles: string[];
|
|
233
|
+
/** Which mutation tool produced the summary. */
|
|
234
|
+
tool?: 'stryker' | 'mutmut' | 'cosmic-ray';
|
|
235
|
+
/**
|
|
236
|
+
* The on-disk JSON report path (Stryker). Optional: the Python tools (mutmut/cosmic-ray) emit
|
|
237
|
+
* their report to STDOUT, so there is no report file to surface.
|
|
238
|
+
*/
|
|
239
|
+
reportPath?: string;
|
|
240
|
+
summary: MutationSummary;
|
|
241
|
+
/** A scope was requested but resolved to no mutable in-tree `.py` ⇒ pre-spawn noop (case (a)). */
|
|
242
|
+
scopeEmpty?: boolean;
|
|
243
|
+
/** Changed `.py` files outside the owned tree / deleted — surfaced as a gap (Fork C), never scoped. */
|
|
244
|
+
unmatched?: string[];
|
|
245
|
+
/** The files the run was SELECTED to mutate (before reconciliation) — what we asked the tool for. */
|
|
246
|
+
requestedFiles?: string[];
|
|
247
|
+
}
|
|
248
|
+
/** Default live runner: spawn the local `stryker` as a subprocess (used by the bin, not the gate). */
|
|
249
|
+
declare const defaultStrykerRunner: MutationRunner;
|
|
250
|
+
/** Default live runner: spawn the local `mutmut` as a subprocess (used by the bin, not the gate). */
|
|
251
|
+
declare const defaultMutmutRunner: MutationRunner;
|
|
252
|
+
/** Default live runner: spawn the local `cosmic-ray` as a subprocess (used by the bin, not the gate). */
|
|
253
|
+
declare const defaultCosmicRayRunner: MutationRunner;
|
|
254
|
+
/**
|
|
255
|
+
* Run mutation testing behind the operator gate and summarize the report. The actual
|
|
256
|
+
* `stryker` invocation is the injected `runner` (default {@link defaultStrykerRunner}); the
|
|
257
|
+
* JSON report is read from `deps.reportPath` (default: Stryker's
|
|
258
|
+
* `<projectRoot>/reports/mutation/mutation.json`).
|
|
259
|
+
*/
|
|
260
|
+
declare function runMutation(config: RunMutationConfig, input: RunMutationInput, deps?: {
|
|
261
|
+
runner?: MutationRunner;
|
|
262
|
+
reportPath?: string;
|
|
263
|
+
}): Promise<RunMutationResult>;
|
|
264
|
+
/**
|
|
265
|
+
* mutmut sibling of {@link runMutation} (ADR 0010 addendum, the lightweight Python option). Spawns
|
|
266
|
+
* `mutmut run` (mutate + test; a non-zero exit just means survivors exist, not an error) then reads
|
|
267
|
+
* `mutmut results --all true` from STDOUT and feeds the pure {@link parseMutmutResults}. No report
|
|
268
|
+
* file. (Diff-scoping is staged — mutmut 3.x scopes via its own config, not a clean CLI file list.)
|
|
269
|
+
*/
|
|
270
|
+
declare function runMutmut(config: RunMutationConfig, input: RunMutationInput, deps?: {
|
|
271
|
+
runner?: MutationRunner; /** Existence check for the selected files (FS by default; injected in tests). */
|
|
272
|
+
exists?: (path: string) => boolean; /** Enumerate the `.py` files under the owned roots (for `also_copy`); FS walk by default. */
|
|
273
|
+
listSourceFiles?: (ownedRoots: string[], projectRoot: string) => string[]; /** The fresh sandbox cwd to run in (the sticky `mutants/` cache can't leak). Default mkdtemp. */
|
|
274
|
+
sandboxDir?: string;
|
|
275
|
+
}): Promise<RunMutationResult>;
|
|
276
|
+
/**
|
|
277
|
+
* cosmic-ray sibling of {@link runMutation} (ADR 0010 addendum, the PRIMARY Python tool — its dump
|
|
278
|
+
* carries real file:line:operator, so survivors are actionable). Drives the three-step workflow
|
|
279
|
+
* against an operator-authored config (`input.configPath`, default `cosmic-ray.toml` — it carries
|
|
280
|
+
* the project's test-command + module scope) over a throwaway session DB: `init` → `exec` → `dump`,
|
|
281
|
+
* reading the `dump` JSON-lines from STDOUT and feeding the pure {@link parseCosmicRayDump}. The
|
|
282
|
+
* {@link assertComplete} guard makes an empty or partially-executed session inconclusive, never a
|
|
283
|
+
* clean pass. (Diff-scoping by synthesizing the per-run config from `mutateFiles` is staged.)
|
|
284
|
+
*/
|
|
285
|
+
declare function runCosmicRay(config: RunMutationConfig, input: RunMutationInput, deps?: {
|
|
286
|
+
runner?: MutationRunner;
|
|
287
|
+
sessionDir?: string; /** Existence check for the selected files (FS by default; injected in tests). */
|
|
288
|
+
exists?: (path: string) => boolean; /** Scoped config filename written into projectRoot (relative). Default `.sackville-cosmic.toml`. */
|
|
289
|
+
scopedConfigName?: string;
|
|
290
|
+
}): Promise<RunMutationResult>;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/scope.d.ts
|
|
293
|
+
interface MutationScope {
|
|
294
|
+
/** Mutable, existing, in-tree `.py` files to scope the run to (repo-relative, normalized, deduped, sorted). */
|
|
295
|
+
files: string[];
|
|
296
|
+
/** Changed `.py` files that are out-of-tree, deleted, or otherwise unplaceable — surfaced as a
|
|
297
|
+
* gap (report-gap), NEVER silently folded into `files` (that would be absence-as-a-pass). */
|
|
298
|
+
unmatched: string[];
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Derive the mutation scope from the changed files. A changed file is selected only when it is a
|
|
302
|
+
* `.py` file, lives under one of the operator's `ownedRoots`, AND exists on disk (`exists`,
|
|
303
|
+
* injected — FS by default in the runner, faked in tests, mirroring `selectPytestScope`'s
|
|
304
|
+
* `testExists`). A `.py` file that is out-of-tree or non-existent (deleted/renamed/typo) is
|
|
305
|
+
* `unmatched`, never scoped. Non-`.py` files are irrelevant to mutation and dropped. Pure given
|
|
306
|
+
* `exists`. Whole-project fallback is NOT decided here — it is the caller's (`mutateFiles ===
|
|
307
|
+
* undefined`) or the cosmic-ray emitter's (`no-scope` on the base config) concern.
|
|
308
|
+
*/
|
|
309
|
+
declare function selectMutationScope(mutateFiles: string[], ownedRoots: string[], exists: (path: string) => boolean): MutationScope;
|
|
310
|
+
interface ScopeReconciliation {
|
|
311
|
+
/** Selected files the tool ACTUALLY mutated (≥1 mutant) — report this as the run's true scope,
|
|
312
|
+
* never the merely-requested set. */
|
|
313
|
+
mutatedFiles: string[];
|
|
314
|
+
/** Selected files the tool NEVER SAW (absent from the per-file summary) — partial under-scope.
|
|
315
|
+
* A non-empty `missing` MUST make the run inconclusive (absence-as-a-pass otherwise). */
|
|
316
|
+
missing: string[];
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Post-spawn partial-under-scope guard. Given the files the run was SELECTED to mutate and the
|
|
320
|
+
* tool's {@link MutationSummary} (whose `files[]` carries a per-file record for every file the
|
|
321
|
+
* tool SAW — even one it found no mutants in), determine which selected files were genuinely
|
|
322
|
+
* mutated and which the tool never saw at all. A selected file present in the summary with zero
|
|
323
|
+
* mutants is SEEN-BUT-EMPTY (benign — no mutable code); a selected file ABSENT from the summary
|
|
324
|
+
* was never mutated (the partial-scope sentinel) and goes in `missing`. Paths are normalized on
|
|
325
|
+
* both sides before comparison. Pure.
|
|
326
|
+
*/
|
|
327
|
+
declare function reconcileScope(selected: string[], summary: MutationSummary): ScopeReconciliation;
|
|
328
|
+
/**
|
|
329
|
+
* Convert a Python source PATH to its dotted module form (`pkg/calc.py` → `pkg.calc`,
|
|
330
|
+
* `pkg/__init__.py` → `pkg`). The package-relative prefix is unknown here, so this is the FULL
|
|
331
|
+
* relative-path dotted form; {@link reconcileMutmutScope} matches it against mutmut's module names
|
|
332
|
+
* by suffix to tolerate src-layout projects.
|
|
333
|
+
*/
|
|
334
|
+
declare function pyPathToModule(path: string): string;
|
|
335
|
+
/**
|
|
336
|
+
* The mutmut-specific post-spawn guard. Unlike cosmic-ray, mutmut's {@link MutationSummary} is keyed
|
|
337
|
+
* by DOTTED MODULE (`pkg.calc`), not path, AND it emits NO record for a scoped file that produced
|
|
338
|
+
* zero mutants (slice 0: seen-but-empty is INDISTINGUISHABLE from never-seen — Fork B2). So this is
|
|
339
|
+
* deliberately CONSERVATIVE: a selected file is "mutated" only if some module with ≥1 mutant matches
|
|
340
|
+
* its dotted form (equal, or a suffix either way — tolerating flat AND src layouts); every other
|
|
341
|
+
* selected file is `missing` (⇒ the runner throws inconclusive). Some false-inconclusives, ZERO
|
|
342
|
+
* false-passes (absence-is-never-a-pass). Pure.
|
|
343
|
+
*/
|
|
344
|
+
declare function reconcileMutmutScope(selectedPaths: string[], summary: MutationSummary): ScopeReconciliation;
|
|
345
|
+
//#endregion
|
|
346
|
+
export { type FileSummary, type Mutant, type MutantPosition, type MutantStatus, MutateGateError, type MutationFile, type MutationMetrics, type MutationReport, type MutationRunner, type MutationScope, type MutationSummary, type MutmutScopePlan, type RunMutationConfig, type RunMutationInput, type RunMutationResult, ScopeEmitError, type ScopeReconciliation, type ScopedCosmicRayConfig, type StatusCounts, type Survivor, cosmicModulePathRoots, defaultCosmicRayRunner, defaultMutmutRunner, defaultStrykerRunner, mutmutDoNotMutate, mutmutPathsToMutate, parseCosmicRayDump, parseMutmutResults, planMutmutScope, pyPathToModule, reconcileMutmutScope, reconcileScope, runCosmicRay, runMutation, runMutmut, selectMutationScope, summarizeMutation, synthesizeScopedCosmicRayConfig, synthesizeScopedMutmutPyproject };
|
|
347
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/config.ts","../src/summarize.ts","../src/cosmic-ray.ts","../src/mutmut.ts","../src/run.ts","../src/scope.ts"],"mappings":";;AAsBA;;;;;;;;AAC6B;AAkE7B;;;;AAAsD;AAUtD;;;;cA7Ea,cAAA,SAAuB,KAAK;cAC3B,OAAA;AAAA;;AAkFM;AAUpB;;;iBA1BgB,qBAAA,CAAsB,QAAgB;AAAA,UAUrC,qBAAA;EAkBf;EAhBA,IAAA;EAiBsB;EAftB,UAAA;EAuDc;EArDd,kBAAA;AAAA;;AAqDuD;AAMzD;;;;AAAuD;iBAjDvC,+BAAA,CACd,QAAA,UACA,aAAA,aACC,qBAAqB;;iBAwCR,mBAAA,CAAoB,aAAqB;;iBAMzC,iBAAA,CAAkB,aAAqB;AAAA,UAKtC,eAAA;EAMf;EAJA,aAAA;EAMmB;EAJnB,QAAA;EAcc;EAZd,WAAA;;EAEA,mBAAA;AAAA;;;;;AAcgB;AA0BlB;;iBA9BgB,eAAA,CACd,aAAA,YACA,cAAA,YACA,oBAAA,cACC,eAAe;;;;;;AA4BK;;iBAFP,+BAAA,CACd,aAAA,UACA,IAAA,EAAM,eAAe;;;;AArMvB;;;;;;;;AAC6B;AAkE7B;;;;AAAsD;AAUtD;;;;;;;;AAMoB;AA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