The hierarchical mutator produces child TestCase instances from parents and the active ProtocolModel. It prioritises structure-aware edits (field / message / sequence) over pure random streams, with optional dictionary and template synthesis and energy feedback on interesting outcomes.

Module

src/input/mutator.rsMutator::mutate. Defaults from MutatorConfig in src/common/config.rs.

Configuration

Key / paramDefaultRole
max_mutations8Upper bound on mutation ops per child
hierarchical_prob0.15Probability of sequence-level ops when multiple messages exist
field_prob0.70Bias toward field-level vs message-level branch
dict_prob0.25Dictionary / spec-value injection probability
template_prob0.12Splice synthesised MessageSpec / SequenceSpec
repair (internal)on when integrity enabledCall integrity::prepare_for_send after mutations
rng_seedDeterministic XorShift64 seed via -r
# config excerpt
hierarchical_prob=0.15
field_prob=0.70
dict_prob=0.25
template_prob=0.12
max_mutations=8
rng_seed=42

Mutation levels

  1. Template splice (optional) — synthesise from MessageSpec / SequenceSpec and replace/insert into the test case.
  2. Sequence-level — duplicate, remove, swap, or truncate messages in multi-message cases.
  3. Message-level — insert/remove non-protected fields; overwrite from dictionary or spec values.
  4. Field-level — bit/byte flip, arithmetic, interesting bytes, insert/delete/overwrite, random fill (respecting fixed size).

Length and Checksum fields are avoided as mutation targets at message level; size constraints from FieldSpec are enforced before send. Protected fields are skipped.

Field-type weights

Selection prefers high-signal types (energy multiplies weight after interesting hits):

TypeWeight
Command10
String9
Payload8
Binary6
Numeric5
Custom4
Length1
Checksum0 (skipped)

on_interesting() boosts energy for fields touched in the last mutation (cap 64).

Field operators

  • Bit flip / byte XOR 0xff
  • Arithmetic ± delta on a byte
  • Interesting constants: 0x00 0x01 0x7f 0x80 0xff 0x20 0x0a 0x0d 0x09
  • Delete / insert / overwrite spans (when size not fixed)
  • Dictionary replace, splice, or append

Design trade-offs

  • Structure-aware over blind havoc — deeper state-machine reach.
  • Integrity repair after mutation keeps length/checksum coherent (disable via -i null for framing-break tests).
  • Mutator holds RNG state — not inherently thread-safe; workers own separate instances in the engine.