Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/cscheck/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cscheck",
"version": "0.1.1",
"version": "0.1.2",
"description": "Find what a C# project's tests miss, and write tests that find bugs.",
"author": {
"name": "Anthony Lloyd"
Expand Down
2 changes: 1 addition & 1 deletion plugins/cscheck/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cscheck",
"version": "0.1.1",
"version": "0.1.2",
"description": "Find what a C# project's tests miss, and write tests that find bugs.",
"skills": ["./skills/"]
}
7 changes: 4 additions & 3 deletions plugins/cscheck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Agent skills for [CsCheck](https://github.com/AnthonyLloyd/CsCheck). Each `SKILL

## Skills

- [writing-cscheck-tests](skills/writing-cscheck-tests/SKILL.md) writes or strengthens tests, preferring CsCheck properties when appropriate, falling back to normal tests for specific bugs. It covers `Sample`, `Equality`, `SampleModelBased`, `SampleMetamorphic`, `SampleParallel`, `Spec`, `Faster`, causal profiling, `Single` and `Check.Hash`. It also covers generators that give usable inputs and hit the edges, readable shrunk failures, how long to run before trusting a pass, when a property can replace example tests, and what changed in CsCheck 5.
- [writing-cscheck-tests](skills/writing-cscheck-tests/SKILL.md) writes or strengthens tests, preferring CsCheck properties when appropriate, falling back to normal tests for specific bugs. It covers `Sample`, `Equality`, `SampleModelBased`, `SampleMetamorphic`, `SampleParallel`, `Spec`, `Faster`, causal profiling, `Single` and `Check.Hash`. It also covers the kinds of property that find bugs, from a model to a metamorphic relation where there's no model, generators that give usable inputs and hit the edges, readable shrunk failures, how long to run before trusting a pass, when a property can replace example tests, and what changed in CsCheck 5.
- [finding-test-gaps](skills/finding-test-gaps/SKILL.md) finds the weak spots that coverage and mutants reveal. Code coverage shows code no test runs, and a sweep of hand-picked mutants shows code the tests run but don't check. Each mutant is compiled and tested in a copy, so no source file in the repo changes. It reports the gaps, and writes the tests they need when asked.
- [closing-test-gaps](skills/closing-test-gaps/SKILL.md) hunts for the bugs behind the gaps by reading code against its siblings, docs, callers and history, and probing the edges of what it must support. It confirms each candidate with a probe or a CsCheck property, and ranks them by how likely each is to be real and to be live.
- [closing-test-gaps](skills/closing-test-gaps/SKILL.md) hunts for the bugs behind the gaps by reading code against its siblings, docs, callers and history, and probing the edges of what it must support. It confirms each candidate with a probe or a CsCheck property, and ranks them by how likely each is to be real and to be live, and the harm each would do.

Together they make a loop: finding-test-gaps shows what the tests miss, closing-test-gaps finds the bugs behind it, writing-cscheck-tests writes the properties that close the gaps, and finding-test-gaps checks the new properties aren't hollow.

Expand Down Expand Up @@ -77,10 +77,11 @@ Copy the folders in `plugins/cscheck/skills/` to the folder your agent reads ski

## Where the rules come from

From published research:
From published research and case studies:
- **Reading a member's tests before writing its mutants:** on Python benchmark functions, LLMs shown the tests wrote mutants that slipped past them yet were real faults 79-88% of the time, against 12-23% without them (Kiele et al., "Beyond Rule-Based Mutation Testing: Test-Aware Mutant Generation Using Large Language Models", ESEM 2026, [arXiv:2609.35841](https://arxiv.org/abs/2609.35841)).
- **Flagging mutants that change nothing, and judging equivalence from the code, not its comments:** at Meta, comments the mutant generator had added misled an LLM judging which mutants were equivalent. Dropping mutants identical to the original and stripping those comments first raised its precision from 0.79 to 0.95 and its recall from 0.47 to 0.96 (Foster et al., "Mutation-Guided LLM-based Test Generation at Meta", FSE 2025, [arXiv:2501.12862](https://arxiv.org/abs/2501.12862)). `mutants.cs` warns about a mutant that only changes whitespace or comments.
- **Skipping logging, metrics, tracing and sleeps:** Google's mutation testing calls such code arid and skips it, along with debugging code such as asserts (Petrović et al., "Practical Mutation Testing at Scale: A view from Google", IEEE TSE 48(10), 2022, [arXiv:2102.11378](https://arxiv.org/abs/2102.11378)).
- **Each property's own coverage, another kind of property over more time, ties and values written different ways, and the smallest settings:** from ephyra, Datadog's property-based testing library for coding agents, whose case studies report over 70 bugs in SQLite and more in PostgreSQL, Lean and other systems. Its agent guide says "a new oracle often failed on its first run; an old oracle given more time rarely did" ([STARTUP.md](https://github.com/datadog-labs/ephyra/blob/main/STARTUP.md)). Among its SQLite bugs, rows went missing when a group held both 1 and 1.0, two showed only with a length limit set below a node's size, and by our count 26 of the 76 titles name an index, a query plan or an optimisation, which a relation with and without it can check ([SQLite bugs](https://github.com/datadog-labs/ephyra/tree/main/case-studies/sqlite/bugs)).

From our own trials, run by the skills' author on a private codebase and on CsCheck itself, whose reports aren't published:
- **Sweeping every member:** writing mutants only where a recipe seemed to fit skipped whole members, one of them with about 50 call sites. A sweep of every member then found 25 of the 28 gaps a blind judge rated worth a test, against 17 for Stryker.NET. It ran on the three files the rules were drawn from, so this shows the rules carry over, not that they generalise.
Expand Down
2 changes: 1 addition & 1 deletion plugins/cscheck/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "cscheck",
"version": "0.1.1",
"version": "0.1.2",
"description": "Find what a C# project's tests miss, and write tests that find bugs.",
"author": {
"name": "Anthony Lloyd"
Expand Down
6 changes: 3 additions & 3 deletions plugins/cscheck/skills/closing-test-gaps/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ Read the code before testing it: in the trials, reading found most of the bugs b
- its history: `git log -L <first>,<last>:<file>` on a member's lines, or `git log -p -n 20 -- <file>`, shows special cases added or removed for one member, which its siblings may need too, workarounds that may have outlived their reason, and the code it replaced. In two runs the history led to three of six bugs;
- its arithmetic: an operation done in a narrower type than its result, such as a `uint` shifted before it's widened, which drops the top bit, and values in different units compared or added, such as one fit's error measured on a log scale against others measured in ticks.
3. **Probe the edges of that domain,** with a probe or as generator cases:
- the smallest sizes it accepts: empty, one and two items, where statistics and estimators often read state they haven't filled yet;
- the smallest sizes it accepts: empty, one and two items, where statistics and estimators often read state they haven't filled yet, and the smallest settings, such as a capacity, batch or page size of 1, which take paths a default of 1,000 never does;
- all values equal, all zero, already sorted;
- each boundary the code or its docs name, from both sides;
- a sign change where the domain spans zero, including `-0.0` in floating-point code that can produce it;
- an integer type's extremes and a value with the top bit set, where the code does bit arithmetic or uses unsigned types;
- what the callers produce at their own edges, such as zero from a timer too coarse to measure a fast action, or the first and last day of a range.
4. **Confirm a candidate** with a probe or a property. A probe is a `probe.cs` in a scratch folder that starts with `#:project <csproj>`, run with `dotnet run -c Release --file probe.cs`. Use Release, since an IDE or language server usually holds the Debug output open. A probe only reaches public types. Give it the tests' target framework, such as `#:property TargetFramework=net10.0`, since a file-based app otherwise takes the SDK's, and pass it its inputs at run time, such as from `args`, rather than as constants, since the compiler works constant expressions out itself and can get a different answer from the runtime the tests use: in one run, a probe written with constants gave the opposite answer to the tests. To check that a property would catch a bug like the one suspected, break the code on purpose with finding-test-gaps' `mutants.cs`, which compiles the change in a copy and leaves the repo alone.
5. **Rank the candidates before fixing anything,** by how likely each is to be real and to be live. For live, find every caller and read the arguments it passes, at the call rather than the whole calling method: in one run a bug needed two flags both true, and no caller passed them that way, so it couldn't happen. Where config drives the code, read the configs too, and where logs or metrics can show the effect, check them, read-only and with the user's agreement for production: in one run the logs took a bug from likely to certain. Leave a failing property failing until the bug is fixed, but don't commit it failing: mark it with the test framework's explicit or skip attribute, naming the bug, or leave it out of the commit.
5. **Rank the candidates before fixing anything,** by how likely each is to be real and to be live, and how much harm it would do. For live, find every caller and read the arguments it passes, at the call rather than the whole calling method: in one run a bug needed two flags both true, and no caller passed them that way, so it couldn't happen. Where config drives the code, read the configs too, and where logs or metrics can show the effect, check them, read-only and with the user's agreement for production: in one run the logs took a bug from likely to certain. Leave a failing property failing until the bug is fixed, but don't commit it failing: mark it with the test framework's explicit or skip attribute, naming the bug, or leave it out of the commit.
6. **After a fix, test every sibling** of the fixed code, such as the other types, formats or cases it serves: 5 of 31 bugs in one study turned up while fixing two others.

## Report

Report the candidates ranked, each with its evidence (the probe's output, or the property's shrunk case), how likely it is to be real and to be live, and the fix it needs, before fixing any.
Report the candidates ranked, each with its evidence (the probe's output, or the property's shrunk case), the result expected and where that comes from, such as a sentence in the docs, how likely it is to be real and to be live, the harm it would do, and the fix it needs, before fixing any.
4 changes: 2 additions & 2 deletions plugins/cscheck/skills/finding-test-gaps/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dotnet run --file <skill>/scripts/uncovered.cs -- <scratch>/coverage-1 [<file or
For a test project with several target frameworks, add `-f <framework>` to the first command to run one. A Microsoft.Testing.Platform project, such as one using TUnit, collects the same report from its test app: `dotnet run -c Release --project <test project> -f <framework> -- --coverage --coverage-output-format cobertura --results-directory <scratch>/coverage-1`, where `-f` is needed only for several target frameworks. Collect each run into a new folder (`coverage-2` and so on), since `uncovered.cs` merges every report under the folder. Given file names, it prints each file's lines not run, its branches partly taken and its members; given none, it ranks the files; given `--since <ref>`, it shows the changed lines no test ran, in the named files if any, by file name rather than type. Read [coverage.md](references/coverage.md) for what the output means and the blind spots.

- Code no test runs needs a test before a mutant can say anything about it, and so do lines no test runs inside a member that does run, such as a branch for a holiday. Say what the code does and whether a caller depends on it, and test what matters. Make the first test an oracle or a property, not one example that runs every line: in one planted case, a test that ran every line of the method still passed with the bug, which only an input of three or more consecutive dates showed.
- Here, too, write the properties that reading the code shows are worth having, such as a round trip, an oracle or an invariant, in code that runs as well as in code that doesn't, as writing-cscheck-tests says. The sweep then measures them along with the old tests, so its survivors are what they all miss. When only measuring, offer them in the report instead.
- Here, too, write the properties that reading the code shows are worth having, such as a model, a round trip or an invariant, in code that runs as well as in code that doesn't, as writing-cscheck-tests says. The sweep then measures them along with the old tests, so its survivors are what they all miss. When only measuring, offer them in the report instead.
- Once those tests are written, collect coverage again into a new folder, so the sweep knows which lines still don't run.
- Give each block of lines that still doesn't run one of these reasons. That today's callers don't pass an input that reaches it isn't one (step 0).
- No input the code must support reaches it. Say whether it's a guard for a state that can't happen, which can stay; dead code, to offer to delete; or a bug, where a wrong condition or caller keeps out the input that should reach it, which goes with the bug candidates.
Expand Down Expand Up @@ -73,7 +73,7 @@ Writing mutants wherever a recipe seems to fit skips whole members, even ones wi

Then write by hand, for each member, mutants.md's by-hand kinds and those the repo's bug history shows: in the blind trial they were nearly a third of the survivors. Note them in the sweep table's "By hand" column, or why a member has none.
4. Mutants only change code that's there, so they can't show a missing case: a key no map has, or an enum member one path handles and a parallel path doesn't. Note these as you read, and give them a test over every enum member or key, or one comparing the parallel paths.
5. While reading, note what a property could check, such as a round trip, an oracle or an invariant, and anything that looks like a bug. Hunt the bug candidates in step 3, where the survivors can point at more.
5. While reading, note what a property could check, such as a model, a round trip or an invariant, and anything that looks like a bug. Hunt the bug candidates in step 3, where the survivors can point at more.
6. Keep the plan in the table step 1 started in `<scratch>/sweep.md`: fill in each member's mutants from the list and by hand, its property (or "none"), and what was skipped and why. Note the missing cases and bug candidates under the headings below it. That way nothing is skipped silently, and no property idea is lost before the tests are written. Write it out whole when you first fill it in, then change it with small edits rather than rewriting it, since in the trials output was the largest cost of a session.

### Run
Expand Down
Loading
Loading