2 · Build your own detector
Outcome
Section titled “Outcome”You will understand the public component boundary and why a small local implementation should live behind that boundary rather than beside it as a toy.
The extension boundary
Section titled “The extension boundary”Turnkey components group policy, providers, parameters, and cleanup. Built-in
components can be selected by registry alias; external components can be loaded
with a Python module:object or path.py:object entry point. The runner should
not need detector-specific branches.
Small behavior, real architecture
Section titled “Small behavior, real architecture”A teaching detector may use a keyword rule, but it should still accept and return the same kinds of values the runner expects. This preserves who calls the detector, what evidence it emits, where cleanup happens, and where a future model-backed provider belongs.
def detect(text: str) -> bool: normalized = text.casefold() return "ignore previous instructions" in normalizedThe function above illustrates behavior only. Follow the product’s component examples for the complete registration and signal contract.
Checkpoint
Section titled “Checkpoint”You should be able to answer: Who owns the evaluation loop? Who owns detector behavior? Which boundary lets each change independently?
Download the Chapter 2 notebook
Next: Debug a missed case.