Mutation campaign configuration
Contract
| Field | Bound contract |
|---|---|
| Trigger | The user mentions mutation testing, mewt, or muton and asks to initialize, scope, estimate, configure, validate, or optimize a campaign before execution. |
| Authority | Reversible local: writes only mewt.toml or muton.toml; rollback is restoring the prior TOML from version control or a pre-edit snapshot. No remote mutation. Does not create or modify the accompanying SQLite database, generate mutants, or touch source files. |
| Side effect | Create or update mewt.toml or muton.toml; inspect target files and estimate mutant scope read-only; measure test duration; validate readiness without interpreting completed campaign results. |
| Done | Configuration parses, intended source targets and mutant counts are estimated, test commands pass, timeout policy is justified by measurement, estimated duration is acceptable, and the project is ready for a separate campaign run. |
Inputs
- Required: Working directory containing a codebase to mutate, or an explicit
--configpath to an existingmewt.toml/muton.toml. - Required: User intent for the campaign scope (which files or components to target).
- Optional: Existing
mewt.toml/muton.tomlwith prior configuration. - Optional: Non-standard tool binary name (
mewtvsmuton).
Procedure
Phase 1: initialize and validate targets
- If no
mewt.toml/muton.tomlexists in the working directory, create one with the minimum structure:[targets]with include and ignore patterns,[test]with the test command, and[run]with mutation operators. Do not runmewt initormuton initbecause those commands create the SQLite database, which exceeds this skill's authority. Done when: the config file exists on disk. - Read the configuration:
mewt print config(ormuton print config). Done when: the configuration is parsed and its contents are recorded. - Review
[targets]include and ignore patterns. Include patterns must match only source code (e.g.,src/**/*.rs,contracts/**/*.sol). Ignore patterns must exclude tests, mocks, and generated code within included paths. Done when: include and ignore patterns are confirmed to target only intended source files. - If patterns are incorrect, edit
mewt.toml/muton.tomldirectly. Do not use CLI flags for persistent configuration. Done when: the config file reflects the corrected patterns. - Confirm:
mewt print configshows no errors andmewt print targetslists only intended files. Done when: both commands succeed and the target list is clean.
Phase 2: assess scope
- Estimate the mutant count without generating mutants. Run
mewt print targetsto list target files. If the tool supports a dry-run or count mode (mewt print mutants --countor equivalent), use it. Otherwise estimate from the target file count and the configured mutation operators. Do not runmewt mutateor any command that creates the SQLite database or writes mutants to disk. Done when: an estimated mutant count is recorded. - Measure baseline test duration by running the test command from the config with
timeprefix. Store the result. Done when: the baseline duration is measured and stored. - Calculate worst-case estimated campaign duration:
estimated_mutant_count * test_duration_seconds. Present this estimate to the user. Done when: the estimate is presented and the user has seen it.
Phase 3: decide on optimization strategy
- If estimated duration is under 1 hour, skip to Phase 4. Done when: the decision to skip optimization is recorded.
- If estimated duration is 1 to 16 hours, ask the user whether to proceed or optimize. If the user declines, apply optimization before proceeding. Done when: the user's decision is recorded.
- If estimated duration exceeds 16 hours, or the user requests optimization: run
mewt print targetsto check for unintended files; inspect the configured mutation operators and severity distribution. Present options with concrete time estimates: full campaign, critical components only (narrow[targets].include), high or medium severity only (restrict[run].mutations), or two-phase ([[test.per_target]]blocks). Apply the chosen option tomewt.tomland recalculate the reduced duration estimate. Done when: the chosen optimization is applied and the reduced estimate is confirmed.
Phase 4: validate test command and timeout
- Run the test command from
[test].cmdmanually and confirm it succeeds without errors. Done when: the test command exits 0 or the failure is reported. - Set the timeout policy. For compiled languages where incremental recompilation dominates test time, note that a cold-cache run may substantially exceed the warm-cache measurement. Set
[test].timeoutto2 * warm_cache_durationrounded up as a baseline. Record in the config comments that the user should verify with a cold-cache run before committing to a long campaign. Do not touch source files to force recompilation; that exceeds this skill's authority. Done when: the timeout policy is set and justified by measurement.
Phase 5: final validation
- Run the checklist:
mewt print configparses with no errors;mewt print targetslists only intended source files; estimated mutant count is reasonable; test command passes; timeout is set and justified; duration estimate is acceptable to the user. Done when: every checklist item passes. - Report readiness. The campaign is ready for a separate execution of
mewt run, which will create the SQLite database, generate mutants, and run the campaign. Done when: the readiness report is produced.
Failure and recovery
- Configuration parse failure:
mewt print configreports a syntax or TOML error. Do not proceed. Editmewt.tomlto fix the error and re-run the validation checklist. - No target files matched:
mewt print targetsreturns an empty list. Verify the[targets].includepatterns match existing source files. Fix patterns or confirm language support before proceeding. - Test command fails: Running the test command returns non-zero. Do not proceed. Identify the correct test command by inspecting
Makefile,justfile,package.json, or projectREADME.md. Update[test].cmdinmewt.toml. Re-validate. - Duration estimate unacceptable: User rejects the estimated campaign duration and no optimization path reduces it to an acceptable range. Do not force execution. Present the available options and wait for a decision. If no decision is reachable, stop.
- Rollback: All configuration edits are reversible. If an edit produces an invalid state, restore
mewt.toml/muton.tomlfrom version control or the pre-edit snapshot before returning.
Output
A validated mewt.toml or muton.toml confirmed against the Phase 5 checklist, with estimated mutant count, test duration estimate, and timeout policy. The campaign is ready to run via mewt run in a separate session.