@iceinvein/agent-skills 0.23.13 → 0.24.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/README.md +2 -1
- package/package.json +1 -1
- package/skills/index.json +7 -1
- package/skills/sluice/SKILL.md +7 -7
- package/skills/sluice/references/deep-channel.md +40 -51
- package/skills/sluice/skill.json +1 -1
- package/skills/test-redundancy-auditor/SKILL.md +117 -0
- package/skills/test-redundancy-auditor/evals/README.md +35 -0
- package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/fixture.sh +76 -0
- package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/graders/nothing-deleted.md +26 -0
- package/skills/test-redundancy-auditor/evals/boundary-tests-stay-unique/prompt.md +11 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/fixture.sh +60 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/output-ignores-itself.md +11 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/source-unchanged.md +10 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/tests-unchanged.md +10 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/graders/tree-unchanged.md +13 -0
- package/skills/test-redundancy-auditor/evals/callers-tree-unchanged/prompt.md +11 -0
- package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/fixture.sh +60 -0
- package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/graders/one-of-the-pair-deleted.md +34 -0
- package/skills/test-redundancy-auditor/evals/duplicate-is-flagged/prompt.md +11 -0
- package/skills/test-redundancy-auditor/evals/guard-test-is-kept/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/guard-test-is-kept/fixture.sh +58 -0
- package/skills/test-redundancy-auditor/evals/guard-test-is-kept/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/guard-test-is-kept/graders/guard-kept.md +32 -0
- package/skills/test-redundancy-auditor/evals/guard-test-is-kept/prompt.md +11 -0
- package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/fixture.sh +73 -0
- package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/graders/mock-test-is-vacuous.md +33 -0
- package/skills/test-redundancy-auditor/evals/mock-assertion-is-vacuous/prompt.md +11 -0
- package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/fixture.sh +60 -0
- package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/graders/labelled-rubric-only.md +26 -0
- package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/graders/nothing-installed.md +12 -0
- package/skills/test-redundancy-auditor/evals/mutate-without-tool-stops/prompt.md +11 -0
- package/skills/test-redundancy-auditor/evals/rules.json +193 -0
- package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/case.yaml +4 -0
- package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/fixture.sh +62 -0
- package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/graders/auditor-fired.md +5 -0
- package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/graders/narrow-test-subsumed.md +35 -0
- package/skills/test-redundancy-auditor/evals/subsumed-by-broader-test/prompt.md +11 -0
- package/skills/test-redundancy-auditor/references/findings-format.md +71 -0
- package/skills/test-redundancy-auditor/references/mutation-mode.md +100 -0
- package/skills/test-redundancy-auditor/references/rubric.md +144 -0
- package/skills/test-redundancy-auditor/skill.json +24 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": [
|
|
3
|
+
{
|
|
4
|
+
"id": "duplicate-cites-its-twin",
|
|
5
|
+
"states": "SKILL.md: Verdicts",
|
|
6
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
7
|
+
"cases": [
|
|
8
|
+
"duplicate-is-flagged"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "duplicate-group-keeps-one",
|
|
13
|
+
"states": "references/rubric.md: Building the deletion list",
|
|
14
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
15
|
+
"cases": [
|
|
16
|
+
"duplicate-is-flagged"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "test-that-cannot-fail-is-vacuous",
|
|
21
|
+
"states": "references/rubric.md: 1. Can it fail?",
|
|
22
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
23
|
+
"cases": [
|
|
24
|
+
"mock-assertion-is-vacuous"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "subsumed-not-duplicate-when-one-way",
|
|
29
|
+
"states": "references/rubric.md: 4. Is another test at the same layer as strong on the same partition?",
|
|
30
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
31
|
+
"cases": [
|
|
32
|
+
"subsumed-by-broader-test"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "precision-over-recall",
|
|
37
|
+
"states": "SKILL.md: Verdicts",
|
|
38
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
39
|
+
"cases": [
|
|
40
|
+
"boundary-tests-stay-unique",
|
|
41
|
+
"duplicate-is-flagged",
|
|
42
|
+
"mock-assertion-is-vacuous",
|
|
43
|
+
"subsumed-by-broader-test"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "challenge-every-non-unique-verdict",
|
|
48
|
+
"states": "SKILL.md: Method",
|
|
49
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
50
|
+
"cases": [
|
|
51
|
+
"boundary-tests-stay-unique"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": "report-only-callers-tree-unchanged",
|
|
56
|
+
"states": "SKILL.md: Method",
|
|
57
|
+
"origin": "skills/test-redundancy-auditor/SKILL.md",
|
|
58
|
+
"cases": [
|
|
59
|
+
"callers-tree-unchanged"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "output-dir-ignores-itself",
|
|
64
|
+
"states": "SKILL.md: Output",
|
|
65
|
+
"origin": "skills/test-redundancy-auditor/SKILL.md",
|
|
66
|
+
"cases": [
|
|
67
|
+
"callers-tree-unchanged"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "mutation-installs-nothing",
|
|
72
|
+
"states": "references/mutation-mode.md: Find the tool",
|
|
73
|
+
"origin": "skills/test-redundancy-auditor/references/mutation-mode.md",
|
|
74
|
+
"cases": [
|
|
75
|
+
"mutate-without-tool-stops"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "missing-tool-labelled-rubric-only",
|
|
80
|
+
"states": "references/findings-format.md: findings.json",
|
|
81
|
+
"origin": "skills/test-redundancy-auditor/references/mutation-mode.md",
|
|
82
|
+
"cases": [
|
|
83
|
+
"mutate-without-tool-stops"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "kill-matrix-verdicts",
|
|
88
|
+
"states": "references/mutation-mode.md: Read the matrix",
|
|
89
|
+
"origin": "skills/test-redundancy-auditor/references/mutation-mode.md",
|
|
90
|
+
"cases": [],
|
|
91
|
+
"unpinned": "No case ships a mutation tool: a fixture would need StrykerJS installed in the eval sandbox, which needs network access the scaffold does not have. This covers the bail setting, the timeout rule and the worktree dependency link too."
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "layer-echo-never-deleted",
|
|
95
|
+
"states": "references/rubric.md: 3. Is the same rule asserted at another layer?",
|
|
96
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
97
|
+
"cases": [],
|
|
98
|
+
"unpinned": "No case yet has a unit test and an integration test on the same rule and partition."
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "costs-measured-or-null",
|
|
102
|
+
"states": "SKILL.md: Method",
|
|
103
|
+
"origin": "skills/test-redundancy-auditor/references/findings-format.md",
|
|
104
|
+
"cases": [],
|
|
105
|
+
"unpinned": "No grader checks runtimeMs or churn against the fixture's real values."
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "guards-are-not-vacuous",
|
|
109
|
+
"states": "references/rubric.md: 1. Can it fail?",
|
|
110
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
111
|
+
"cases": [
|
|
112
|
+
"guard-test-is-kept"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"id": "boundaries-are-own-partitions",
|
|
117
|
+
"states": "references/rubric.md: 2. What does it pin?",
|
|
118
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
119
|
+
"cases": [
|
|
120
|
+
"boundary-tests-stay-unique"
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "shared-bodies-marked-restructure",
|
|
125
|
+
"states": "references/rubric.md: Building the deletion list",
|
|
126
|
+
"origin": "skills/test-redundancy-auditor/references/findings-format.md",
|
|
127
|
+
"cases": [],
|
|
128
|
+
"unpinned": "No case has a describe.each or per-configuration helper with a redundant instance."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "large-findings-built-by-script",
|
|
132
|
+
"states": "SKILL.md: Output",
|
|
133
|
+
"origin": "skills/test-redundancy-auditor/references/findings-format.md",
|
|
134
|
+
"cases": [],
|
|
135
|
+
"unpinned": "Needs a target over about 100 tests, too large for an eval fixture."
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "runtime-median-of-three",
|
|
139
|
+
"states": "SKILL.md: Method",
|
|
140
|
+
"origin": "skills/test-redundancy-auditor/SKILL.md",
|
|
141
|
+
"cases": [],
|
|
142
|
+
"unpinned": "No grader checks how runtime was measured."
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "environment-recorded",
|
|
146
|
+
"states": "references/findings-format.md: findings.json",
|
|
147
|
+
"origin": "skills/test-redundancy-auditor/references/findings-format.md",
|
|
148
|
+
"cases": [],
|
|
149
|
+
"unpinned": "No grader reads the environment field."
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"id": "large-target-split-keeps-probes-central",
|
|
153
|
+
"states": "SKILL.md: Method",
|
|
154
|
+
"origin": "skills/test-redundancy-auditor/SKILL.md",
|
|
155
|
+
"cases": [],
|
|
156
|
+
"unpinned": "Needs a target large enough to split."
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"id": "zero-kills-vacuous-only-in-scope",
|
|
160
|
+
"states": "references/mutation-mode.md: Read the matrix",
|
|
161
|
+
"origin": "skills/test-redundancy-auditor/references/mutation-mode.md",
|
|
162
|
+
"cases": [],
|
|
163
|
+
"unpinned": "Same reason as kill-matrix-verdicts: no case ships a mutation tool."
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "catch-all-branch-splits-partitions",
|
|
167
|
+
"states": "references/rubric.md: 2. What does it pin?",
|
|
168
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
169
|
+
"cases": [],
|
|
170
|
+
"unpinned": "Found by the WorkforceManagement field calibration (two refuted deletions); no fixture case yet."
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": "every-assertion-found-in-covering-tests",
|
|
174
|
+
"states": "references/rubric.md: Precision rules",
|
|
175
|
+
"origin": "skills/test-redundancy-auditor/references/rubric.md",
|
|
176
|
+
"cases": [
|
|
177
|
+
"subsumed-by-broader-test"
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"id": "hand-back-contents",
|
|
182
|
+
"states": "SKILL.md: Hand-back",
|
|
183
|
+
"origin": "skills/test-redundancy-auditor/SKILL.md",
|
|
184
|
+
"cases": [],
|
|
185
|
+
"unpinned": "No grader reads the final message."
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"sandboxSensitive": [],
|
|
189
|
+
"vacuousWithout": [
|
|
190
|
+
"callers-tree-unchanged"
|
|
191
|
+
],
|
|
192
|
+
"unclaimed": []
|
|
193
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# A cart totaller and four tests. "the subtotal sums price times quantity"
|
|
3
|
+
# asserts one field on the same input that "totals a two-line order" asserts
|
|
4
|
+
# in full, so any bug the first catches the second catches too: the first is
|
|
5
|
+
# subsumed by the second. They are not duplicates, since the broader test
|
|
6
|
+
# also catches tax and total bugs the narrow one misses, so only the narrow
|
|
7
|
+
# one belongs on the deletion list. The rounding and empty-cart tests each
|
|
8
|
+
# cover their own case.
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
mkdir -p src tests
|
|
12
|
+
|
|
13
|
+
cat > package.json <<'JSON'
|
|
14
|
+
{
|
|
15
|
+
"name": "checkout",
|
|
16
|
+
"version": "0.9.0",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "node --test \"tests/*.test.js\""
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
JSON
|
|
23
|
+
|
|
24
|
+
cat > src/cart.js <<'JS'
|
|
25
|
+
// Amounts are whole cents.
|
|
26
|
+
export function totals(lines, taxRate) {
|
|
27
|
+
const subtotal = lines.reduce((sum, line) => sum + line.price * line.qty, 0);
|
|
28
|
+
const tax = Math.round(subtotal * taxRate);
|
|
29
|
+
return { subtotal, tax, total: subtotal + tax };
|
|
30
|
+
}
|
|
31
|
+
JS
|
|
32
|
+
|
|
33
|
+
cat > tests/cart.test.js <<'JS'
|
|
34
|
+
import assert from "node:assert/strict";
|
|
35
|
+
import { test } from "node:test";
|
|
36
|
+
import { totals } from "../src/cart.js";
|
|
37
|
+
|
|
38
|
+
const order = [
|
|
39
|
+
{ price: 500, qty: 2 },
|
|
40
|
+
{ price: 250, qty: 1 },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
test("the subtotal sums price times quantity", () => {
|
|
44
|
+
assert.equal(totals(order, 0.1).subtotal, 1250);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("totals a two-line order", () => {
|
|
48
|
+
assert.deepEqual(totals(order, 0.1), { subtotal: 1250, tax: 125, total: 1375 });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("rounds half a cent of tax up", () => {
|
|
52
|
+
assert.equal(totals([{ price: 125, qty: 1 }], 0.1).tax, 13);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("an empty cart totals zero", () => {
|
|
56
|
+
assert.deepEqual(totals([], 0.1), { subtotal: 0, tax: 0, total: 0 });
|
|
57
|
+
});
|
|
58
|
+
JS
|
|
59
|
+
|
|
60
|
+
git init --quiet
|
|
61
|
+
git add -A
|
|
62
|
+
git -c user.email=fixture@example.com -c user.name=fixture commit --quiet -m "feat: cart totals"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: llm
|
|
3
|
+
# findings.json sits under a slug the skill picks, so no file focus can name
|
|
4
|
+
# it; the judge reads its content from the Write call (or shell command) in
|
|
5
|
+
# the trace, and sees only a head-and-tail window of a long trace.
|
|
6
|
+
focus: trace
|
|
7
|
+
weight: 3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
The agent was asked to audit `tests/cart.test.js` for redundant tests. The
|
|
11
|
+
file has four tests:
|
|
12
|
+
|
|
13
|
+
1. "the subtotal sums price times quantity": asserts only `.subtotal` is 1250
|
|
14
|
+
for a two-line order at a 0.1 tax rate.
|
|
15
|
+
2. "totals a two-line order": on the same order and rate, asserts the whole
|
|
16
|
+
result `{ subtotal: 1250, tax: 125, total: 1375 }`.
|
|
17
|
+
3. "rounds half a cent of tax up": a different input, asserts tax 13 (12.5 cents rounded half up).
|
|
18
|
+
4. "an empty cart totals zero".
|
|
19
|
+
|
|
20
|
+
Every bug test 1 catches, test 2 catches too, but not the reverse, so test 1
|
|
21
|
+
is subsumed by test 2. Tests 2, 3 and 4 are unique.
|
|
22
|
+
|
|
23
|
+
Find the `findings.json` the agent wrote under `.test-redundancy-auditor/`. If
|
|
24
|
+
it was written more than once, judge only the last write, with any later Edit
|
|
25
|
+
applied.
|
|
26
|
+
|
|
27
|
+
PASS if all of these hold:
|
|
28
|
+
- test 1 has verdict `subsumed` and its `of` array holds the id test 2
|
|
29
|
+
has in `tests`;
|
|
30
|
+
- `deletions` names test 1 and no other test;
|
|
31
|
+
- tests 2, 3 and 4 each have verdict `unique`.
|
|
32
|
+
|
|
33
|
+
FAIL if no findings.json content is visible in the trace, if test 1 is called
|
|
34
|
+
a `duplicate` rather than `subsumed`, if test 2 is on the deletion list, or if
|
|
35
|
+
test 3 or 4 has a verdict other than `unique`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subsumed-by-broader-test
|
|
3
|
+
description: A one-field assertion on the same input another test asserts in full. Pins a subsumed verdict on the narrow test, naming the broad one, with only the narrow one deleted.
|
|
4
|
+
tags: [subsumed, precision, scaffold, write]
|
|
5
|
+
max_turns: 60
|
|
6
|
+
timeout_seconds: 1800
|
|
7
|
+
allowed_tools: [Read, Glob, Grep, Skill, Write, Edit, Bash, Agent]
|
|
8
|
+
expected_outcome: findings.json under .test-redundancy-auditor/ marks the subtotal test subsumed by the two-line order test, deletes only it, and leaves the other three unique.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Audit `tests/cart.test.js` for redundant tests.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Findings format
|
|
2
|
+
|
|
3
|
+
Every run writes `report.md` and `findings.json` to
|
|
4
|
+
`.test-redundancy-auditor/<YYYY-MM-DD>-<slug>/`. They carry the same content;
|
|
5
|
+
`findings.json` is the one a grader or a calling skill parses, so it follows
|
|
6
|
+
this shape exactly.
|
|
7
|
+
|
|
8
|
+
Write both files with the Write tool, passing the full contents. Do not build
|
|
9
|
+
them with a shell command, a heredoc or a script: a grader reading the run's
|
|
10
|
+
trace sees a script, not the JSON it produced. The one exception is a target
|
|
11
|
+
of more than about 100 tests, whose `findings.json` is too large for one
|
|
12
|
+
Write call: write the verdicts as a table with the Write tool, then build
|
|
13
|
+
`findings.json` from it with a script saved in the run directory as
|
|
14
|
+
`build-findings.*`, so the trace still shows where every value came from.
|
|
15
|
+
|
|
16
|
+
## findings.json
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
{
|
|
20
|
+
"target": string,
|
|
21
|
+
"mode": "rubric" | "mutation",
|
|
22
|
+
"environment": { "runner": string, "versions": string, "timeZone": string },
|
|
23
|
+
"tests": {
|
|
24
|
+
"id": string, "file": string, "name": string,
|
|
25
|
+
"behaviour": string, "partition": string,
|
|
26
|
+
"verdict": "unique" | "duplicate" | "subsumed" | "vacuous" | "layer-echo",
|
|
27
|
+
"of": string[], "evidence": string, "restructure": boolean,
|
|
28
|
+
"cost": { "lines": number, "runtimeMs": number | null, "churn": number | null },
|
|
29
|
+
"kills": number | null
|
|
30
|
+
}[],
|
|
31
|
+
"deletions": string[],
|
|
32
|
+
"counts": { "unique": number, "duplicate": number, "subsumed": number, "vacuous": number, "layer-echo": number },
|
|
33
|
+
"removable": { "tests": number, "lines": number, "runtimeMs": number | null },
|
|
34
|
+
"mutation": { "ran": boolean, "tool": string, "reason": string, "mutants": number | null, "survived": number | null }
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Field by field:
|
|
39
|
+
|
|
40
|
+
- `target`: the one-line target the run started from.
|
|
41
|
+
- `environment`: the runner, the language and runtime versions, and the time
|
|
42
|
+
zone the tests ran in.
|
|
43
|
+
- `tests[].id`: `T1`, `T2`, ... ordered by file path, then by position in the
|
|
44
|
+
file. `name` is the test's full name as the runner prints it, including
|
|
45
|
+
any `describe` path or namespace, and a parametrised row's arguments.
|
|
46
|
+
- `behaviour` and `partition`: one sentence each, from rubric question 2.
|
|
47
|
+
- `of`: the tests this one duplicates, is subsumed by, or echoes: their ids,
|
|
48
|
+
or `<path>::<name>` for a test outside the target. Empty for `unique` and
|
|
49
|
+
`vacuous`.
|
|
50
|
+
- `evidence`: for a non-unique verdict, what a reviewer checks to agree with
|
|
51
|
+
it (rubric precision rules). For `unique`, the plausible bug only this test
|
|
52
|
+
catches, or, for a guard, the tests it guards.
|
|
53
|
+
- `restructure`: true when the test shares a body with others (rubric,
|
|
54
|
+
"Shared bodies"), so acting on its deletion means moving code rather than
|
|
55
|
+
deleting a test.
|
|
56
|
+
- `cost.lines`: lines of the test's own body. For a parametrised row or a
|
|
57
|
+
shared-body instance, the shared body's lines; `removable.lines` counts a
|
|
58
|
+
shared body once, and only when every instance of it is deleted.
|
|
59
|
+
- `cost.runtimeMs`: the median of three runs. `cost.runtimeMs` and
|
|
60
|
+
`cost.churn` are `null` when not measured; the report says why.
|
|
61
|
+
- `kills`: the size of the test's kill set in mutation mode, `null` in
|
|
62
|
+
rubric mode.
|
|
63
|
+
- `deletions`: ids, built as the rubric describes. Never every member of a
|
|
64
|
+
duplicate group.
|
|
65
|
+
- `counts`: verdicts after the deletion list is built, so a kept member of a
|
|
66
|
+
duplicate group counts as `unique`.
|
|
67
|
+
- `removable.runtimeMs`: `null` if any deleted test's runtime is `null`.
|
|
68
|
+
- `mutation`: always present. In rubric mode with no request for mutation
|
|
69
|
+
testing, `ran: false`, `tool: ""`, `reason: "not requested"`. When
|
|
70
|
+
mutation testing was asked for and no tool is in the repo, `ran: false`,
|
|
71
|
+
`tool` names the one to add, `reason` says it is not installed.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Mutation mode
|
|
2
|
+
|
|
3
|
+
The rubric's "plausible bug" is a mutant imagined one at a time. Mutation
|
|
4
|
+
mode generates them by the hundred and records which tests kill each one,
|
|
5
|
+
which turns "redundant" into a set comparison anyone can re-run.
|
|
6
|
+
|
|
7
|
+
A matrix covers only the mutants its tool knows how to make, so it proves
|
|
8
|
+
that a deletion is safe far better than it proves a test is removable. On a
|
|
9
|
+
real suite the greedy matrix list ran to over half the tests, against a
|
|
10
|
+
rubric list of a tenth, and almost every test only the matrix would delete
|
|
11
|
+
was one where the rubric had named a bug the tool has no operator for. Treat
|
|
12
|
+
the matrix as a check on the rubric's list, and as a source of candidates the
|
|
13
|
+
rubric then judges, not as the list.
|
|
14
|
+
|
|
15
|
+
## Find the tool
|
|
16
|
+
|
|
17
|
+
Use only a mutation tool the repo already declares (a dev dependency, a
|
|
18
|
+
config file, a CI step). Install nothing, in the caller's tree or anywhere
|
|
19
|
+
else. If there is none, write `mutation` in `findings.json` with `ran: false`,
|
|
20
|
+
the tool to add for the repo's language and the reason, set `mode` to
|
|
21
|
+
`"rubric"`, finish the rubric run, and say mutation mode did not run in the
|
|
22
|
+
hand-back.
|
|
23
|
+
|
|
24
|
+
| Language | Tool | Settings for a full kill matrix |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| JavaScript, TypeScript | StrykerJS | `coverageAnalysis: "perTest"`, `disableBail: true`, the `json` reporter; each mutant's `killedBy` lists test ids, resolved through `testFiles` |
|
|
27
|
+
| C# | Stryker.NET | `disable-bail`, `coverage-analysis: perTest`, the `json` reporter, same report schema; for TUnit or other Microsoft Testing Platform suites, `--test-runner mtp` |
|
|
28
|
+
| Java, Kotlin | PIT | `fullMutationMatrix=true` with the XML output; each mutation's `killingTests` |
|
|
29
|
+
|
|
30
|
+
Bail matters. By default a tool stops testing a mutant at the first test
|
|
31
|
+
that kills it, so the report names one killer per mutant and every other
|
|
32
|
+
test's kill set comes out too small: a test that catches bugs would read as
|
|
33
|
+
vacuous. Never build the matrix from a bailing run.
|
|
34
|
+
|
|
35
|
+
A tool that reports only killed or survived per mutant, not which tests
|
|
36
|
+
killed it, can still build the matrix: run it once per test under audit,
|
|
37
|
+
scoped with its own test filter. Say the number of runs and the expected time
|
|
38
|
+
before starting.
|
|
39
|
+
|
|
40
|
+
Tool quirks seen in the field:
|
|
41
|
+
|
|
42
|
+
- StrykerJS with Vitest: tests that stub the time zone or environment need
|
|
43
|
+
`vitest.pool: "forks"` (a worker thread cannot change `TZ`); a Vite config
|
|
44
|
+
that imports files outside the project needs `inPlace: true`, which is safe
|
|
45
|
+
only because the run is in a scratch worktree.
|
|
46
|
+
- Stryker.NET: `mutate` line spans are character offsets, not line numbers,
|
|
47
|
+
and a wrong span silently mutates nothing, so check the mutant count per
|
|
48
|
+
file. In project mode it cannot mutate a project the test project reaches
|
|
49
|
+
only indirectly. Safe Mode turns every mutant in a method into a
|
|
50
|
+
`CompileError` when one mutation breaks compilation there; list those
|
|
51
|
+
methods, because tests that target them have kill sets too small to judge.
|
|
52
|
+
|
|
53
|
+
## Run it
|
|
54
|
+
|
|
55
|
+
1. Work in this run's scratch `git worktree` outside the repo, so reports,
|
|
56
|
+
sandboxes and caches never land in the caller's tree. Link the main
|
|
57
|
+
checkout's installed dependencies into it rather than installing; if the
|
|
58
|
+
tool itself must be fetched, it is not "already declared" and the run
|
|
59
|
+
stops here.
|
|
60
|
+
2. Scope the mutants to the code the target tests exercise. Mutants in code
|
|
61
|
+
no target test reaches say nothing about the target.
|
|
62
|
+
3. Run once and write `kill-matrix.json` to the run directory: for each test
|
|
63
|
+
id, the ids of the mutants it kills.
|
|
64
|
+
|
|
65
|
+
Mutants that time out or error usually carry no killing tests. Leave them
|
|
66
|
+
out of the matrix and count them in the report. A test whose verdict would
|
|
67
|
+
change if those mutants counted keeps its rubric verdict, with the reason in
|
|
68
|
+
its evidence.
|
|
69
|
+
|
|
70
|
+
## Read the matrix
|
|
71
|
+
|
|
72
|
+
Let K(t) be the set of mutants test t kills. Compare tests through the same
|
|
73
|
+
entry point only; a cross-layer pair stays `layer-echo` (rubric question 3),
|
|
74
|
+
with the matrix noted in its evidence.
|
|
75
|
+
|
|
76
|
+
- K(t) is empty: `vacuous`, but only if every piece of code it exercises was
|
|
77
|
+
in the mutated scope, none of it sat in a method lost to compile errors,
|
|
78
|
+
and it is not a guard (rubric question 1). Otherwise the empty set means
|
|
79
|
+
"not measured", and the rubric verdict stands.
|
|
80
|
+
- K(t) equals K(u): `duplicate` of u.
|
|
81
|
+
- K(t) is a strict subset of K(u): `subsumed` by u.
|
|
82
|
+
- K(t) is a subset of the union of several tests' sets, and of no single
|
|
83
|
+
one: `subsumed` by that set.
|
|
84
|
+
|
|
85
|
+
Then build the deletion list one test at a time, as the rubric's "Building
|
|
86
|
+
the deletion list" says, checking each candidate's K against the tests
|
|
87
|
+
kept.
|
|
88
|
+
|
|
89
|
+
## When the matrix and the rubric disagree
|
|
90
|
+
|
|
91
|
+
- Rubric `unique`, matrix redundant: look at the bug the rubric named. If the
|
|
92
|
+
tool has no operator that makes it, keep `unique` and say why in the
|
|
93
|
+
evidence. Otherwise the matrix wins. A rubric verdict with no named bug
|
|
94
|
+
behind it has nothing to defend it, and the matrix wins.
|
|
95
|
+
- Rubric redundant, matrix `unique`: the matrix wins, and the evidence names
|
|
96
|
+
a mutant only this test kills.
|
|
97
|
+
|
|
98
|
+
Surviving mutants (killed by no test) are not this skill's finding, but count
|
|
99
|
+
them in the report: a suite where most mutants survive has a coverage
|
|
100
|
+
problem bigger than its redundancy.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Rubric
|
|
2
|
+
|
|
3
|
+
Five questions per test, asked in this order. The first one that settles the
|
|
4
|
+
verdict settles it. The deletion list is built after every test has a
|
|
5
|
+
verdict, by the rule at the end.
|
|
6
|
+
|
|
7
|
+
## 1. Can it fail?
|
|
8
|
+
|
|
9
|
+
Name one plausible bug in the code under test that turns this test red. If
|
|
10
|
+
none exists, the verdict is `vacuous`. The usual shapes:
|
|
11
|
+
|
|
12
|
+
- It never calls the code under test: it calls a mock, a fixture builder or
|
|
13
|
+
the test's own helper and asserts on that.
|
|
14
|
+
- It asserts only on values the test itself set up: a stub's canned return,
|
|
15
|
+
or a mock's call log after calling the mock directly. A test that runs the
|
|
16
|
+
code under test and then checks the mock was called with the right
|
|
17
|
+
arguments can fail, and is not vacuous.
|
|
18
|
+
- Its expected value is computed by the code under test at test time
|
|
19
|
+
(`expect(f(x)).toBe(f(x))`). A snapshot or an imported constant is not
|
|
20
|
+
this: a regression still breaks it.
|
|
21
|
+
- It checks a getter, a type the compiler already checks, or the framework's
|
|
22
|
+
own behaviour.
|
|
23
|
+
- Every assertion sits behind a branch the test never takes, or inside a
|
|
24
|
+
callback that never runs.
|
|
25
|
+
|
|
26
|
+
A test that only checks that nothing throws can fail, so it is not vacuous on
|
|
27
|
+
that ground alone.
|
|
28
|
+
|
|
29
|
+
**Guards are not vacuous.** A test that pins another test's premise (the time
|
|
30
|
+
zone stub took effect, a fixture is in the state the next test needs, a test
|
|
31
|
+
helper still tells a bad case from a good one) catches no product bug, but it
|
|
32
|
+
is what stops other tests going silently vacuous. Its verdict is `unique`,
|
|
33
|
+
its evidence names the tests it guards, and the report lists it under guards.
|
|
34
|
+
|
|
35
|
+
If the behaviour a vacuous test was meant to pin is pinned by no other test,
|
|
36
|
+
the test is still `vacuous` (it catches nothing today), and the report lists
|
|
37
|
+
that behaviour as a gap.
|
|
38
|
+
|
|
39
|
+
## 2. What does it pin?
|
|
40
|
+
|
|
41
|
+
Write the behaviour in one sentence and the input partition it exercises: the
|
|
42
|
+
class of inputs the code treats alike, read from the code's own branches.
|
|
43
|
+
Boundaries are their own partitions even where the code has no branch at
|
|
44
|
+
them: the value on each side of a limit, empty, one, many, the first and
|
|
45
|
+
last element, a partial last page, the error path. The bugs that separate a
|
|
46
|
+
boundary test from its neighbours are often a wrong variable or operand
|
|
47
|
+
(`(page - 1) * (page - 1)` for `(page - 1) * perPage`), which a short probe
|
|
48
|
+
sweep misses; a boundary test is not compared under question 4 with tests
|
|
49
|
+
of other partitions.
|
|
50
|
+
|
|
51
|
+
**Catch-all branches are not one partition.** Inputs that share a branch only
|
|
52
|
+
because it is the leftover case (an `else`, a `default`, a `!== 401`) are
|
|
53
|
+
separate partitions when they are different kinds: a 404 and a 409 under
|
|
54
|
+
"not 401", a tenant-authored state and the built-in states an `else` was
|
|
55
|
+
written for. Narrowing the catch-all to the cases its author had in mind is a
|
|
56
|
+
plausible one-line bug, and it fails only the test of the kind left out.
|
|
57
|
+
|
|
58
|
+
## 3. Is the same rule asserted through another entry point?
|
|
59
|
+
|
|
60
|
+
A layer is the entry point a test drives: a function called directly, a
|
|
61
|
+
component or composable mounted, a request through the real HTTP or database
|
|
62
|
+
stack, a browser flow. A test of a caller that re-checks a rule its callee
|
|
63
|
+
owns, and the callee's own test on the same partition, are a `layer-echo`,
|
|
64
|
+
in both directions. The caller's test also proves the call is made, and the
|
|
65
|
+
callee's points at the fault when it breaks, so neither is redundant in the
|
|
66
|
+
way question 4 means. Report the pair, including a partner outside the
|
|
67
|
+
target, and recommend the layer to keep: the lowest layer that still proves
|
|
68
|
+
the wiring the higher one exists for. A layer echo never goes on the deletion
|
|
69
|
+
list, in either mode; consolidating layers is a design call for the caller.
|
|
70
|
+
|
|
71
|
+
## 4. Is another test through the same entry point as strong on the same partition?
|
|
72
|
+
|
|
73
|
+
For each other test through the same entry point, on the same unit and
|
|
74
|
+
partition, ask in both directions:
|
|
75
|
+
|
|
76
|
+
- Is there a plausible bug that fails A and passes B?
|
|
77
|
+
- Is there a plausible bug that fails B and passes A?
|
|
78
|
+
|
|
79
|
+
| A over B | B over A | Verdict for A |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| no | no | `duplicate` of B |
|
|
82
|
+
| no | yes | `subsumed` by B |
|
|
83
|
+
| yes | any | not redundant against B |
|
|
84
|
+
|
|
85
|
+
Settle every pair first. A set comes in only when no single test covers A:
|
|
86
|
+
if one test alone is as strong as A, the verdict is about that test, and
|
|
87
|
+
adding a second test to `of` turns a duplicate into a wrong `subsumed`.
|
|
88
|
+
|
|
89
|
+
A can be subsumed by a set of tests together, when every bug it catches
|
|
90
|
+
is caught by one of them. The set may include tests of a function the unit
|
|
91
|
+
delegates to, as long as every bug in either that fails A fails a test in the
|
|
92
|
+
set. Name every test in the set.
|
|
93
|
+
|
|
94
|
+
## 5. Otherwise
|
|
95
|
+
|
|
96
|
+
`unique`.
|
|
97
|
+
|
|
98
|
+
## Building the deletion list
|
|
99
|
+
|
|
100
|
+
A verdict says a test is covered by the others as they stand. Removing two
|
|
101
|
+
tests that each cover the other can lose a bug both caught, so the list is
|
|
102
|
+
built one test at a time, the same way in both modes:
|
|
103
|
+
|
|
104
|
+
1. Candidates are the `vacuous`, `duplicate` and `subsumed` tests, most
|
|
105
|
+
costly first: runtime, but runtimes within the run-to-run noise count as
|
|
106
|
+
equal; then lines. Between equal costs, the one with the less clear name
|
|
107
|
+
goes first.
|
|
108
|
+
2. Take the next candidate. A `vacuous` test goes on the list. Any other goes
|
|
109
|
+
on the list only if every bug it catches is still caught by a test not on
|
|
110
|
+
the list: in rubric mode, the bugs named in its evidence; in mutation
|
|
111
|
+
mode, its kill set. Otherwise its verdict becomes `unique`, with the bug
|
|
112
|
+
it alone now catches as evidence.
|
|
113
|
+
3. Repeat until no candidates are left.
|
|
114
|
+
|
|
115
|
+
In a duplicate group of n tests this removes n - 1 and keeps the cheapest.
|
|
116
|
+
The counts in `findings.json` are taken after the list is built.
|
|
117
|
+
|
|
118
|
+
**Shared bodies.** A test that is one row of a `describe.each`, or one
|
|
119
|
+
instance of a helper that registers tests per configuration, often cannot be
|
|
120
|
+
deleted alone: acting on it means moving the body or narrowing the table.
|
|
121
|
+
Mark it as needing a restructure, and count its lines as freed only when every
|
|
122
|
+
instance sharing the body is on the list.
|
|
123
|
+
|
|
124
|
+
## Precision rules
|
|
125
|
+
|
|
126
|
+
- Before calling a test `duplicate` or `subsumed`, list every assertion it
|
|
127
|
+
makes, the incidental ones included (a heading, a label, a second field
|
|
128
|
+
checked on the way), and find each in the covering tests. An assertion
|
|
129
|
+
only this test makes is a bug only this test catches.
|
|
130
|
+
- Every non-unique verdict carries evidence a reviewer can check: the test it
|
|
131
|
+
duplicates, is subsumed by, or echoes, and the shared partition; or, for
|
|
132
|
+
vacuous, why nothing can turn it red.
|
|
133
|
+
- A plausible bug is a one-line change a person could make by mistake: an
|
|
134
|
+
off-by-one, a flipped comparison, a dropped or inserted condition or guard,
|
|
135
|
+
a wrong field, variable or constant, a dropped call, a missing await. Not a
|
|
136
|
+
rewrite of the function. A bug counts even when it shows up only as a
|
|
137
|
+
throw from a later line.
|
|
138
|
+
- Same coverage is not redundancy. Two tests can run the same lines and
|
|
139
|
+
assert different things.
|
|
140
|
+
- Similar shape is not redundancy. Look-alike tests on different edges of a
|
|
141
|
+
range are each unique when a bug separates them.
|
|
142
|
+
- A verdict that holds only in this environment (this time zone, this
|
|
143
|
+
runtime's formatting) says so in its evidence.
|
|
144
|
+
- When unsure, probe. If you cannot settle it, the verdict is `unique`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "test-redundancy-auditor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Measures how much of a test suite is redundant. Gives every test one verdict (unique, duplicate, subsumed, vacuous or layer echo), each non-unique one challenged with a plausible bug before it is written and backed by evidence a reviewer can check, then weights what is removable by lines, runtime and churn and writes a deletion list. Precision over recall: when in doubt a test is unique. Optional mutation mode verifies verdicts with a per-test kill matrix from a mutation tool the repo already has, and installs nothing. Writes report.md and findings.json to .test-redundancy-auditor/<date>-<slug>/ and never modifies the caller's tree.",
|
|
5
|
+
"author": "iceinvein",
|
|
6
|
+
"type": "prompt",
|
|
7
|
+
"tools": [
|
|
8
|
+
"claude"
|
|
9
|
+
],
|
|
10
|
+
"files": {
|
|
11
|
+
"prompt": "SKILL.md"
|
|
12
|
+
},
|
|
13
|
+
"bundle": {
|
|
14
|
+
"include": [
|
|
15
|
+
"references"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"install": {
|
|
19
|
+
"claude": {
|
|
20
|
+
"prompt": ".claude/skills/test-redundancy-auditor/SKILL.md",
|
|
21
|
+
"bundleRoot": ".claude/skills/test-redundancy-auditor"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|