Skip to main content
This page documents the public Python exports for the Controls Engine. Start with Controls Engine if you want a guided integration. Import the primary interfaces from the top-level package:
Import policy models, registry functions, and selector utilities from vijil_dome.controls:

Installation

The package supports Python 3.11 through 3.13. A dome:* evaluator can require another optional dependency for its selected Dome Detector.

Choose an API

VijilDome

VijilDome is the recommended policy-driven interface.
agent_id does not authenticate the running workload or make a policy identity-bound. Use Trust Runtime when enforcement requires workload identity.

Properties

Input Methods

Both methods construct an llm Step with text assigned to input, then evaluate the pre stage.

Output Methods

Both methods construct an llm Step with text assigned to output, then evaluate the post stage.

Tool Methods

Both methods construct a tool Step named tool_name, assign tool_input to input, and evaluate the pre stage.

Instance Decorator

The returned decorator uses the instance’s ControlEngine and enforcement setting. See control() for mapping and stage behavior.

Enforcement Behavior

control()

The standalone decorator creates or reuses a ControlEngine and evaluates a function at the pre and post stages.
Passing both engine and policy raises ValueError. If both are omitted, the decorator uses an empty engine and permits every call. The wrapper performs these operations:
  1. Construct a Step from the function arguments.
  2. Evaluate the pre stage and enforce its result.
  3. Invoke the wrapped function.
  4. Assign or map the return value to Step.output.
  5. Evaluate the post stage and enforce its result.
  6. Return the original function result.
A pre-stage exception prevents function execution. A post-stage exception occurs after the function has completed.

Automatic Input Mapping

For tool Steps, the decorator maps all bound parameters except self and cls to a dictionary. A tool function with one parameter still receives a dictionary as Step.input. For llm Steps, the decorator uses the first applicable rule:
  1. Select input, message, query, text, prompt, content, user_input, msg, or request.
  2. Select the first string-valued argument.
  3. Use the value directly when one parameter remains.
  4. Use a dictionary when multiple parameters remain.
  5. Convert the arguments to a string if signature binding fails or no parameter remains.
Default parameter values are applied before mapping. Supply input_mapper when these rules do not match your function’s data model.

ControlEngine

ControlEngine loads, stores, and evaluates Controls.
The constructor accepts typed Control objects. Use load_controls() for dictionaries.

Engine Members

Loading more Controls appends them to the existing engine. The loading methods do not replace previously loaded Controls. Direct engine evaluation returns an EvaluationResult. It does not raise ControlViolationError or ControlSteerError.

Policy Models

Controls models inherit from pydantic.BaseModel and support standard model validation and serialization.

Step

Step is the runtime payload evaluated by the engine.

Control

Control represents one policy rule. The model preserves unknown top-level fields during parsing and serialization. Preserved fields are not automatically interpreted by the Controls Engine. Use reverse-DNS keys, such as example.com/risk-class, for annotation extensions.

ControlScope

Every specified field must match. An omitted field does not restrict the Control. Step-name regular expressions use RE2 when google-re2 is installed and otherwise use Python’s standard regular-expression engine with a warning.

EvaluatorRef

ConditionNode

A leaf node requires both selector and evaluator:
Use one logical operator for each composite node: Leaf and composite fields are mutually exclusive. A leaf with only a selector or only an evaluator fails validation. Empty and and or lists also fail validation. is_leaf() reports whether the node contains leaf fields. is_composite() reports whether the node contains a logical operator.

ControlAction

Always supply steering_context for a steer action. Without it, the engine can return steer, but the interface logs a warning and does not raise ControlSteerError.

SteeringContext

Results

EvaluationResult

An observe action does not appear as an aggregate action. The observation appears as a triggered entry in matches and does not change the aggregate action. If no deny or steer Control triggers, the result is allow. The current engine reduces conditions to truth values before constructing ControlMatch. A completed Control evaluation therefore reports confidence 1.0, while an evaluation error reports 0.0. The engine does not propagate EvaluatorResult.confidence to ControlMatch or EvaluationResult.

ControlMatch

A fail-open error produces a non-triggered match without an action. A fail-closed error produces a triggered match with the Control action.

Evaluator API

Evaluator

Custom evaluators subclass the abstract Evaluator class:
value is the selector result. config is the dictionary from EvaluatorRef.config.

EvaluatorResult

Pydantic validation rejects confidence values outside the inclusive 0.0 through 1.0 range.

Registry Functions

register_evaluator() raises TypeError if the decorated class does not subclass Evaluator. resolve_evaluator() raises ValueError for an unknown or unsupported name. Dynamic dome:* references do not appear in list_evaluators().

Built-In Evaluators

regex

Converts the selected value to text and searches one or more regular expressions. If no pattern is supplied, the evaluator returns matched=False. RE2 is used when installed. A pattern with flags uses Python’s standard engine because the RE2 package does not expose compatible flag behavior.

list

Converts the selected value to text and compares it with configured strings. If values is empty, the evaluator returns matched=False. When supplied, match_on takes precedence over negate.

json_schema

Validates the selected value with the jsonschema package from the controls-full extra. field_constraints supports type, min, max, enum, min_length, and max_length. Every configured field becomes required. An invalid schema returns matched=False, confidence 0.0, and schema error metadata. It does not raise into the Control’s on_error behavior.

cel

Evaluates a Common Expression Language expression with cel-python from the controls-full extra. The selected value is available as value. When the value is a dictionary, each top-level string key except value is also available as a variable. The reserved value variable always refers to the complete selected value. A missing or invalid expression returns matched=False. An evaluation error returns confidence 0.0 and error metadata rather than raising into on_error.

dome:<detector-name>

Prefix a registered Dome Detector with dome: to use it as an Evaluator:
The Evaluator converts the selected value to a DomePayload. Matching uses score >= threshold; Evaluator metadata retains the Detector’s hit value, but that value does not override the configured threshold. The result metadata includes the Detector name, score, hit, and full Detector details. See Detection Methods for available Detectors and their dependencies.

Selector Utilities

resolve()

resolve() applies a supported selector path to a Step. It reads dictionary keys and object attributes, supports non-negative list indexes, and returns MISSING when the path cannot be resolved.

MISSING

MISSING is the singleton sentinel returned for an unresolved selector. It evaluates to False and remains distinct from valid values such as 0, False, "", and []. The engine evaluates these valid values and skips only MISSING.

Errors

ControlError

Base exception for enforcement decisions.

ControlViolationError

Subclass of ControlError raised by VijilDome or @control() when an enforced deny result occurs. It adds no attributes.

ControlSteerError

Subclass of ControlError raised for an enforced steer result with correction guidance. Its steering_context attribute contains that guidance. Policy validation errors and unknown Evaluator resolution errors are not ControlError subclasses. The engine captures raised condition errors in ControlMatch.error and applies on_error.

Evaluation Semantics

The engine applies these observable rules:
  1. Copy the current Controls and skip disabled or out-of-scope entries.
  2. Evaluate applicable deny Controls before steer and observe Controls.
  3. Return deny as soon as a deny Control triggers and cancel outstanding Control evaluations.
  4. If no deny triggers, evaluate steer and observe Controls.
  5. Return the first triggered steer match or otherwise return allow.
Controls are stored in ascending priority order. Deny Controls run concurrently, so priority does not guarantee which simultaneous deny result finishes and returns first. A deny result also prevents applicable steer and observe Controls from running. and and or children run concurrently by default. Set early_exit=True to run their children sequentially and short-circuit. not inverts its child result. on_error=fail_closed is the default. A raised evaluator error triggers the Control and associates its action with the match. on_error=fail_open records a non-triggered match and allows evaluation to continue. Evaluators that convert their own errors into matched=False do not activate on_error.

Policy Files

JSON And YAML

JSON and YAML accept a flat list:
They also accept a top-level controls key:
YAML loading requires the controls or controls-full extra.

TOML

Native TOML uses an array of Control tables:
The loader also accepts an established Dome [guardrail] configuration and translates its configured Guards into Controls. Files with another extension raise ValueError.

AgentControl Compatibility

The Controls Engine accepts common AgentControl policy shapes without importing AgentControl. The following AgentControl Evaluators are not included: Resolving one of these names raises a descriptive ValueError. The containing Control then applies its configured on_error behavior.

Next Steps

Controls Engine

Apply Controls to LLM inputs, outputs, and tool calls

Detection Methods

Review Detectors available through the dome: prefix
Last modified on July 30, 2026