Files
craft-ai-integrations/tools/mutation
Jeremy 97dc996251 feat(burn-setup): prepare SAM 2.1 weights for Burn once, on this computer (#89)
* refactor(engine-rten): let another engine reuse the SAM 2.1 request handling

Loaded, Backend, Prediction, read_prompt, prompt_points and best_proposal become
public. Visibility only: the click and box mapping, the picture kept between
requests, the empty-mask answer and the size checks then live in one place for
every SAM 2.1 engine.

* feat(burn-setup): prepare SAM 2.1 weights for Burn once, on this computer

Brings in craft-ai-burn-setup (feature `conversion`): checks the two published
ONNX files by size and SHA-256, converts them to Burn weights with the pinned
burn-onnx 0.22.0, and keeps one checked, locked, shared copy. Nothing is hosted
or downloaded. Mutation group bp (10 cases). Cargo.lock additions are the
optional burn-onnx tree (generated).

* fix(burn-setup): sweep the scratch folders a killed run left, and keep craft-ai-features a dev dependency

CodeRabbit on #89: tempdir_in(cache) folders hold the two source copies (about 130 MB) and were
removed only by Drop, so a killed app leaked them for good. They now carry the cache key and a role
in their names, and after the key's lock is taken the same key's leftovers are removed (other keys'
folders, the lock file and links are left alone). Red first: leftovers_of_a_killed_run_are_swept_for_this_key_only.
Mutation cases burn-killed-run-leftovers-kept and burn-sweep-takes-other-keys, both caught.
craft-ai-features is only used by a unit test, so it moves to dev-dependencies.

* fix(burn-setup): sweep only the scratch folders, not a renamed copy of the key's folder

CodeRabbit on #89 (second round): sweep_stale removed every folder starting with <key>., so a damaged
copy a person renamed to <key>.backup would be deleted on the next preparation. It now matches only
<key>.work., <key>.conv. and <key>.out., the names the scratch folders are made with (one constant
for both). Red first: the sweep test gained a <key>.backup folder that must survive. Mutation group
bp 13/13 caught, including the new case burn-sweep-takes-a-renamed-copy.
2026-10-22 20:47:39 +01:00
..

Deliberate-bug checks

Each case breaks one safety rule in the source, runs the one test that should notice, and puts the source back. A case is caught only if the mutated code compiled and the test run failed. A mutant that does not compile counts as not caught, so every survivor is either a test gap (fix the test) or a bad mutant (fix the mutant). Cargo runs serially, targeted with -p, with -j 8.

Script Groups
mutation_check.py u1 u3 u4 p4 p10 v1 v2 v3 sd vx lc lr nr ct u2 wf (connections, model sources, node packs, media, client flows, declarative adapter, workflow library). Cases for u2 are in mutation_u2.py.
mutation_check.py seg Shared selection contract: points, box, description and checked result metadata.
mutation_check.py rt rten model runner, bounded picture decoding, resampling and prompt assembly.
mutation_check.py rt rten engine picture handling: bounded PNG and JPEG decoding, mask encoding, resampling.
mutation_check.py gs Generic selection: scratch sinks, the refusal of clicks and mapped selection workflows.
mutation_check.py gs Generic selection workflows: the scratch sinks, the refusal of clicks and mapped selection workflows.
mutation_check.py gu Generic selection uploads: one upload per picture, the bounded memory, the resend after a cleared scratch area or a failed job.
mutation_check.py gm Generic selection masks: size, one channel, the empty-mask answer and the picture header.
mutation_check.py s21 SAM 2.1 selection (sam21_session.rs, detector.rs): the Florence-2-large preflight, the detector name and the choice check.
mutation_check.py ca Upstream contract alignment: model-test address provenance, required inputs, and app-facing refusal before key access. Cases in mutation_contract.py.
mutation_check.py ps Node pack status report (pack/status.rs): links, hidden folders, names, the install record.
mutation_check.py vx Vertex express adapter (ai-vertex/src/lib.rs): the API key travels in the x-goog-api-key header, never in the request URL.
mutation_check.py lg Remembered licences (registry/licences.rs, install.rs): terms, versions, local files, damaged record.
sam3_mutation_check.py sg1 sg2 sg2b sg2c sg3 (SAM 3 masks, sessions, slots, cancel).
python tools/mutation/mutation_check.py u2            # one group
python tools/mutation/mutation_check.py u2 stale      # cases whose name contains "stale"

The "Deliberate-bug checks" workflow runs a group on Ubuntu and macOS. It takes the group and an optional case-name filter, so one case can be checked on both systems in minutes instead of waiting for the group. A filter that names no case in the group fails instead of reporting success:

group:  p4
filter: input-folder-read

Group ids are historical labels. The header of each test file says what it covers.

Run them exclusively. They snapshot and restore source files, so do not edit, format or build those files while one runs. Afterwards read the restored source and rerun the focused tests.

Logs go to tools/mutation/verification/ (not committed) after passing through scrub.py, which replaces a Windows or Unix profile folder with %USERPROFILE% so no account name is written.