DetectionMethod and registers itself under a category and a name. Once registered, you refer to it in a configuration exactly like a built-in Detector.
Detection Categories
Register your Detector with one of these categories:
The category determines which Guard types can use your Detector, and which Guardrail it can therefore run in. A Guard with
type = "security" can only reference Detectors registered under DetectionCategory.Security.
Write a Detector
1
Subclass DetectionMethod
Accept your configuration options as constructor arguments. Dome passes any keys you set in the Detector’s configuration table to this constructor.
2
Implement Detect
The
detect method is asynchronous and receives a DomePayload. Coerce the payload, then read query_string for the text to inspect.3
Return a Detection Result
A
DetectionResult is a tuple of (hit, metadata), where hit is True or False and metadata is a dictionary. Return True for content the Guard must flag.Metadata Fields
The metadata dictionary can carry any values you want to record in the trace. Dome reads three of them:DomePayload.coerce() accepts a plain string as well as a payload object, so your Detector keeps working when a caller passes raw text.Use a Custom Detector
Reference the registered name in themethods list of a Guard whose type matches the category you registered, exactly as you would a built-in Detector. Constructor arguments go in a table named after the Detector:
Control Concurrency
Dome caps the number of concurrent calls a Detector makes during batch scanning. Setmax_batch_concurrency in the Detector configuration when your Detector calls an external service with its own rate limits:
Handle Errors
Whendetect raises an exception, Dome records the Detector in ScanResult.errored_methods and logs a warning rather than propagating the exception. The Guard’s on-error policy then decides the outcome: fail_closed treats the error as a block, and fail_open allows the content through. Raise exceptions freely and set on-error to match the risk you accept.
Work in Progress
The programmatic protection capabilities and Dome integrations are currently in private preview and subject to change.
Next Steps
Configure Guardrails
Use custom Detectors in configurations
Use Guardrails
Runtime integration patterns
Observability
Monitor custom Detector performance
Detection Methods
Built-in Detector reference