Skip to content

categories

sqllocks_spindle.chaos.categories

Individual chaos-category mutators (strategy pattern).

Each mutator implements a single chaos category and exposes a uniform mutate(data, day, rng, intensity_multiplier) interface so that the :class:~sqllocks_spindle.chaos.engine.ChaosEngine can dispatch to them without knowing the implementation details.

Classes

ChaosMutator

Bases: ABC

Base class for all chaos-category mutators.

Subclasses implement :meth:mutate which receives the data to corrupt, the current simulation day, a seeded numpy Generator, and the intensity multiplier from the active preset.

Attributes
category abstractmethod property

Short category label matching :class:ChaosCategory values.

Methods:
mutate(data, day, rng, intensity_multiplier) abstractmethod

Apply chaos to data and return the mutated result.

The concrete type of data depends on the category (DataFrame, bytes, dict of DataFrames, etc.).

SchemaChaosMutator

Bases: ChaosMutator

Add, remove, rename, reorder, or retype columns.

Before breaking_change_day only additive changes (add column, reorder) are applied. After that day, destructive mutations (drop, rename, retype) are also possible.

Parameters:

Name Type Description Default
breaking_change_day int

Simulation day after which destructive schema mutations are enabled.

20

ValueChaosMutator

Bases: ChaosMutator

Corrupt individual cell values: nulls, out-of-range, wrong types, encoding issues (BOM, Latin-1), future dates, negative amounts.

FileChaosMutator

Bases: ChaosMutator

Corrupt raw file bytes: truncation, encoding corruption, partial writes, zero-byte files, wrong extension content, wrong delimiters, invalid JSON/Parquet poison payloads.

ReferentialChaosMutator

Bases: ChaosMutator

Corrupt referential integrity: orphan foreign keys, duplicate primary keys.

Expects data to be a dict[str, pd.DataFrame] (table name to DF). Returns the same structure with mutations applied.

TemporalChaosMutator

Bases: ChaosMutator

Corrupt temporal columns: late arrivals, out-of-order timestamps, timezone mismatches, DST boundary issues.

VolumeChaosMutator

Bases: ChaosMutator

Corrupt data volume: 10x spike, empty batch, single-row batch.