Skip to content

Constraint kinds

A constraint kind classifies a requirement extracted from your Python code: must_raise, boundary, enum_valid and so on. The kind decides which rule generates the test and how the verifier violates the requirement to prove the test can fail. This page lists every kind defined in the Python package, which spec reader produces it, and whether the rule engine handles it.

What are the kinds?

KindMeaningTypical sourceRule engineViolation injected
must_raiseRaises an exception under a conditionRaises: docstring entry, try/except re-raise, standalone raiseyesraise replaced with pass
boundaryValue above, below or at a thresholdif x <= 0: raise, assert x > 0, Field(gt=0), min_length, max_lengthyesthreshold literal replaced with -9999
enum_validValue must be one of a setif x not in VALID: raise, Literal[...]yesraise replaced with pass
enum_invalidAn invalid value must be rejecteddefined in the model; no reader emits it in the tested codenonone
must_returnReturns a specific value or typeReturns: docstringyesnon-None returns become return None
not_noneReturn must not be Nonedefined in the model; no reader emits it in the tested codenonone
not_nullA variable (or PySpark column) must not be nullif x is None: raiseyesraise replaced with pass
type_checkisinstance guardif not isinstance(x, ...): raiseyesraise replaced with pass
auth_checkAuthentication or permission guardif not request.user.is_authenticated: raisenoraise replaced with pass
bare_exceptBare or broad except that swallows everything (a smell)except Exception: passnonone
silent_failReturns None instead of raisingif not result: return Noneyesfirst silent return becomes a raise
magic_valueHardcoded string or number in a conditionif status == "admin":yesraise replaced with pass
mutationA mutant that survivedmutmut results (optional)nomutmut apply
bug_reproReproduce a reported bugquell reproduceyesnone (already broken)
customFree-form requirementLLM-handledyesraise replaced with pass

The "Rule engine" column says whether can_handle is true for the kind. Requirements the rule engine cannot handle go to the LLM only when you pass --use-llm, otherwise they are scaffolded or flagged with a reason.

What cannot the rule engine do?

It returns no test when all required parameters are complex objects, when the guard checks self.attr (it needs class instantiation) or a local variable such as a database result (it cannot be injected through a stub), and for async functions it wraps the call with asyncio.run. FastAPI and Flask route handlers go to a framework engine that needs an app object found in the project.

Which readers produce which kinds?

ReaderKinds
Guard clauses (quell find)boundary, not_null, enum_valid, type_check, auth_check, bare_except, silent_fail, magic_value, must_raise
Docstringsmust_raise, boundary, enum_valid, must_return
Types and Pydantic modelsboundary, enum_valid
Bug reportsbug_repro

See how it works and the five-gate pipeline.