evalmut 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: evalmut
3
+ Version: 0.1.0
4
+ Summary: Mutation testing for evals: inject known defects into the system under test and report which grader checks stay green. A surviving mutation is a hole in the eval.
5
+ Author-email: Erik Hill <erik.hill0987@gmail.com>
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/egnaro9/evalmut
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Topic :: Software Development :: Testing
11
+ Classifier: Intended Audience :: Developers
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: gradecore>=0.10.0
16
+ Dynamic: license-file
17
+
18
+ # evalmut — mutation testing for evals
19
+
20
+ **Your eval suite passes. Does it actually check anything?**
21
+
22
+ You write a grader, watch it pass on a good output, and ship it. You never ask the
23
+ other question: would it *also* pass on a plausibly-broken output? A `contains("42")`
24
+ check passes `"the total is 42"` — and it passes `"I did NOT reach 42"` just as
25
+ happily. A JSON check that confirms a `count` field is present says nothing about
26
+ whether `count` is a number or the string `"three"`. A refusal check that scans for
27
+ "I can't help" is fooled by a reply that refuses in its first line and then delivers
28
+ the harm below. These aren't hypotheticals; each is a real defect that shipped past a
29
+ real check.
30
+
31
+ `evalmut` finds them. It takes an eval case your grader passes, injects a *known*
32
+ defect into the output — a defect **mined from a documented real-world eval failure**,
33
+ not invented — and reruns the grader. If the grader still passes a genuinely-wrong
34
+ output, that's a **hole**: a class of regression your eval would let ship green.
35
+
36
+ It's the same idea as code mutation testing (PIT, Stryker, mutmut), which nobody had
37
+ built for the model-plus-prompt-plus-grader stack — because there a "mutation" isn't a
38
+ flipped boolean, it's a semantic perturbation whose ground truth you have to establish.
39
+ That's the hard part, and it's what `evalmut` does.
40
+
41
+ ```
42
+ $ evalmut run suite.py # your suite; see 'Install & use' below
43
+ ────────────────────────────────────────────────────────────────────────
44
+ evalmut — does your eval actually check anything?
45
+ ────────────────────────────────────────────────────────────────────────
46
+ mutation score 91.4% (32 caught / 35 applied; 150 n/a)
47
+ holes 3 (1 blind, 2 coverage-gap)
48
+
49
+ BLIND SPOTS — a real defect shipped green; the check is present and broken
50
+ • contains / contains
51
+ mutation : keyword_present_but_negated — the checked keyword appears,
52
+ but in a context that means the opposite
53
+ mined from: a CI proof-gate that greps its own transcript for a
54
+ token; the block message contains it, so mentioning it passes
55
+ COVERAGE GAPS — no check guards this shape (a missing grader, not a broken one)
56
+ • valid_json / valid_json
57
+ mutation : json_value_type_flip — a required field's value coerced to
58
+ the wrong type (number -> string)
59
+ • valid_json / valid_json
60
+ mutation : json_value_corruption — a required field's value changed to a
61
+ different value of the same type (3 -> 4)
62
+ mined from: gradecore valid_json checks key PRESENCE only, never value
63
+ ```
64
+
65
+ That run is `evalmut` pointed at **its own dependency's** graders. It found three real
66
+ holes and — this is the point — it was **fair about them**: it called the `contains`
67
+ weakness a *blind spot* (a present check that's broken) and the two `valid_json` scopings
68
+ *coverage gaps* (a missing check, not a broken one), because `valid_json` only ever
69
+ claimed to check key presence. A tool that cries "broken!" at a correctly-scoped check
70
+ is a tool you learn to ignore.
71
+
72
+ ## The two ways an eval lies
73
+
74
+ Most eval tooling only asks the first of these. Both are real, and `evalmut` tests both:
75
+
76
+ - **Blind spot** — a real defect ships green. Inject a *wrong* output; a sound grader
77
+ must reject it. If it passes, the check is present and broken.
78
+ - **Brittle spot** — a correct output gets flagged. Inject an *equivalent* change (a
79
+ trailing disclaimer after a complete answer, cosmetic whitespace, a JSON code fence);
80
+ a sound grader must still pass it. If it fails, the check false-positives, and a
81
+ false-positive check is quietly recalibrated until it stops catching the real thing.
82
+
83
+ ## The honesty guarantee
84
+
85
+ The whole tool rests on one rule, and it is what defeats the classic equivalent-mutant
86
+ problem:
87
+
88
+ > **It never infers a hole from a verdict flip. It infers a hole from
89
+ > `(output-proven-wrong AND grader-passed)`, where wrongness is established against the
90
+ > case's own ground truth — independently of the grader being tested.**
91
+
92
+ An operator applies to a case *only* where it can establish the mutant's polarity for
93
+ that case: provably wrong (a defect) or provably still-correct (an equivalent). Where it
94
+ can't — no number to corrupt, no answer span to truncate, a field the grader doesn't
95
+ judge — it returns **N/A** and is excluded from the score. So a reported hole is never a
96
+ guess about an ambiguous mutant; by construction the mutant had a known correct answer
97
+ and the grader disagreed with it.
98
+
99
+ When the bar that decides wrongness lives inside the grader's closure — a numeric
100
+ tolerance, an expected tool plan, whether whitespace is cosmetic for the task — the
101
+ operator does **not** guess it from a module default or trust a label the grader reports
102
+ about itself (a composite grader can honestly carry a primitive's id yet enforce more).
103
+ The suite *declares* that bar on the case (`num_tol`, `expected_trajectory`, `tolerates`,
104
+ `content_required`), and the operator uses it — cross-checking it against the grader where
105
+ it can — or declines. This is the discipline **eight rounds of adversarial cold-critique**
106
+ paid for: every false hole those passes found was an operator asserting polarity without
107
+ recomputing the graded property against the grader's *real* acceptance condition — a
108
+ hardcoded threshold, a self-reported id, a fixed-magnitude mutant that tripped an
109
+ orthogonal constraint, a formatting quirk that defeated a cross-check, a text
110
+ transformation the grader's own tokenizer re-read differently, a decline-gate one operator
111
+ carried and its siblings didn't. The early rounds fixed the bulk (a dozen at the peak);
112
+ by round six the tool-fault false positives on a well-formed suite reached **zero** and
113
+ held through rounds seven and eight, which surfaced only gate-symmetry issues that bite a
114
+ misdeclared case, never a well-formed one. The regression tests (`test_D1`–`D4`,
115
+ `test_P2A`–`P2K`, `test_P3F1`–`F8`, `test_P4_*`, `test_P5_*`, `test_P6_*`, `test_P7_*`) pin
116
+ every one. The through-line is a single invariant:
117
+ **an operator asserts a hole only where it can recompute the graded property against the
118
+ grader's real acceptance condition; everywhere else it declines.**
119
+
120
+ ## Mined, not authored
121
+
122
+ Every operator names the concrete, documented failure it reproduces — and that citation
123
+ is enforced as a test (`test_every_operator_names_a_real_origin`). This is not
124
+ decoration. An *authored* mutation only tests what its author already imagined a check
125
+ might miss, which is exactly the blind spot you're trying to find. A *mined* operator
126
+ reproduces a defect that actually happened. `evalmut`'s operators come from a real
127
+ corpus: model-drift's 429/MNAR truncation finding, a property test that ran with
128
+ `tries=1`, a proof gate that grepped a transcript for a token, an assertion that read
129
+ `assertTrue(result || !result)`, and gradecore's own documented grader scoping.
130
+
131
+ ```
132
+ $ evalmut operators # every one, with its provenance
133
+ ```
134
+
135
+ ## Install & use
136
+
137
+ ```bash
138
+ pip install evalmut # from PyPI (or: pip install -e . from a clone)
139
+ ```
140
+
141
+ ```python
142
+ from gradecore import GradeInput, contains
143
+ from evalmut import EvalCase, run
144
+
145
+ suite = [EvalCase("sum", contains("42"),
146
+ GradeInput(text="the total is 42", expected="42"),
147
+ tags=("presence_check",))]
148
+
149
+ report = run(suite)
150
+ print(f"{report.score:.0%} — {len(report.blind_spots)} blind spots")
151
+ for h in report.blind_spots:
152
+ print(h.grader_id, "is blind to", h.operator_id, "—", h.real_origin)
153
+ ```
154
+
155
+ Or from the shell, with a CI-worthy exit code (nonzero on any vacuous/blind/brittle hole):
156
+
157
+ ```bash
158
+ evalmut run path/to/your_suite.py -v
159
+ evalmut run your_suite.py --short # one line for CI
160
+ evalmut run your_suite.py --json # machine-readable
161
+ ```
162
+
163
+ A suite file just defines `suite` (a list of `EvalCase`) and, optionally, `operators`.
164
+
165
+ > **Security — evalmut executes your suite.** Loading a suite imports and runs it, and
166
+ > mutation runs invoke your grader code, so `evalmut run` executes arbitrary Python from
167
+ > the suite file (the same trust model as `pytest`). Only run suites you trust. If you wire
168
+ > it into CI as a PR gate, do **not** run it against forks/untrusted PRs, and give the job no
169
+ > secrets it doesn't need — a malicious suite file would otherwise run with your CI credentials.
170
+ > Prefer a sandboxed/isolated runner for untrusted input.
171
+
172
+ ## Design
173
+
174
+ - `outcome.py` — the four outcomes (caught / missed / flagged / n-a), the two polarities,
175
+ the three operator types (KILL / DIAGNOSTIC / SANITY) that separate a *broken* check
176
+ from a *missing* one.
177
+ - `case.py` — an `EvalCase`: a grader, the reference-correct input it passes, which
178
+ fields it judges, and the declared contract bars (`num_tol`, `tolerates`,
179
+ `expected_trajectory`, `content_required`) an operator reads instead of guessing.
180
+ - `operator.py` / `operators.py` — the operator contract and the mined catalog.
181
+ - `runner.py` — baseline-green enforcement, apply, regrade, classify. Deterministic, no
182
+ LLM-as-judge, so a run reproduces exactly.
183
+ - `score.py` / `report.py` — the score, and the holes grouped by how alarming they are.
184
+
185
+ Built on [`gradecore`](../gradecore), the deterministic no-LLM-judge grading engine — so
186
+ `evalmut`'s own verdicts are as reproducible as the graders it tests.
@@ -0,0 +1,16 @@
1
+ evalmut/__init__.py,sha256=aHmXPHnVyqkq7ipwDM2JwLcxD81-1waXzDAPX0rhK9w,2397
2
+ evalmut/case.py,sha256=_63g-nHkntd-S0pUMGOJHlUkLqhjcExH4pkOu2FGMTw,6778
3
+ evalmut/cli.py,sha256=JzodkImYFh6VlZVpqN_Nd0Hj-bGAoDv7FYOAvMcYsbY,6326
4
+ evalmut/operator.py,sha256=8wdmhV4tazLiH6R27vEE_Ahv6YZdYESM6qmKNWBPOh4,6239
5
+ evalmut/operators.py,sha256=dv3UFPO0qjE0RaC3mULVvtNK44sR_uQXt8Ayq0W1Ie8,45916
6
+ evalmut/outcome.py,sha256=OAdXq4-9Kzf322yuBkuS4iPu7fuPOq1D0reUS3chsxg,5411
7
+ evalmut/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ evalmut/report.py,sha256=6XirivS7wiMso5m8wrKlcUqBrtdGLyETh9pTz1lgeY8,4860
9
+ evalmut/runner.py,sha256=RTIvnI3m9uQwUrdk9E1oyiIWpSp3JEhCmV49JfD0WsU,7482
10
+ evalmut/score.py,sha256=I6d5n1OmTN3y58TrET4Jm79JAm8BqaV8I08jZg88trs,7282
11
+ evalmut-0.1.0.dist-info/licenses/LICENSE,sha256=CnIk5G479AgPApCDBo6OvTu2bwt2qieKpnapEtPSlX4,1066
12
+ evalmut-0.1.0.dist-info/METADATA,sha256=KsOBG_Beji4kgYsNahpkXyprkvWNQ6KFoTIsYF0z3xU,10354
13
+ evalmut-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
14
+ evalmut-0.1.0.dist-info/entry_points.txt,sha256=lH_6TzuFJUslwnemUiWHKFc3g49qoerikdZ74N3yqEU,45
15
+ evalmut-0.1.0.dist-info/top_level.txt,sha256=NGnhcMiHHRPbhgwWISm4gaJbR4E0tZSj8u7dZ9nPOVc,8
16
+ evalmut-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ evalmut = evalmut.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Erik Hill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ evalmut