Interface Guardrail<T>
- Type Parameters:
T- the type this guardrail validates
- All Superinterfaces:
Identifiable, Job<Void>
- All Known Subinterfaces:
AdmissionGuardrail, AuthGuardrail<T>, ContentGuardrail<T>, ValidationGuardrail<T>
- All Known Implementing Classes:
AbstractAdmissionGuardrail, AbstractAuthGuardrail, AbstractContentGuardrail, AbstractValidationGuardrail, AgentClassAllowListAdmissionGuardrail, ExfiltrationMarkerGuardrail, PayloadSizeCapGuardrail, PIIDetectionGuardrail, PrincipalAllowListGuardrail, SchemaConformanceGuardrail, SizeCapGuardrail, UrlGuardrail
public sealed interface Guardrail<T>
extends Job<Void>
permits AuthGuardrail<T>, ContentGuardrail<T>, AdmissionGuardrail, ValidationGuardrail<T>
A guardrail: a job that validates a single target object at a tool-invocation edge.
The hierarchy is sealed into the four JOB-BASED kinds of the context ladder - each consuming one more piece of framework-provided context than the previous:
AdmissionGuardrail- no target; judges (principal, calling agent, tool) before a call existsContentGuardrail- the target alone; a pure function of the payloadAuthGuardrail- target plus theJobSnapshot(principal, tool, position in execution)ValidationGuardrail- target plus a live producer: judges a candidate final answer while the orchestrator that produced it still holds its conversation, so a refusal is fed back to that producer instead of failing its caller
GuardedExecution) and enforced by the
framework at the dispatch path for every execution route; the fourth is declared by
a producing orchestrator and enforced at its final-answer seat. SCOPE, which
additionally consumes what the flow is about, is not a guardrail job at all: scope is
a pure value judgment (Scope, ScopeGuard) enforced inline at the
submission chokepoint, where every child a flow creates is born - guardrail jobs
included - see ScopeAuthority and the dispatcher's submission rules.
A guardrail never receives a live framework object. Its complete evaluation context is
the target and the immutable JobSnapshot of the gated job. Everything else a
check needs is a lookup keyed by values found in those, performed by the guardrail's
own job (guardrails may declare resources).
Refusal is always GuardrailException - correctable, so the agent loop can act
on it. Infrastructure failures inside a guardrail propagate as themselves and fail the
gated job closed; they are never converted into refusals.
- Since:
- 0.1 (2026-02-01)
- Author:
- Andrey Santrosyan
-
Field Summary
Fields inherited from interface Job
DEFAULT_UPSTREAM_RETRIES -
Method Summary
Modifier and TypeMethodDescriptionvoidsetGatedSnapshot(JobSnapshot snapshot) Delivers the immutable snapshot of the gated job before submission.voidSet the target this guardrail will validate before it runs.The class of targets this guardrail validates.voidValidates the target object.Methods inherited from interface Identifiable
getParentJobId, getUserId, getWorkflowIdMethods inherited from interface Job
execute, getDisplayName, getId, getJobId, getJobType, getName, getPriority, getRequirements, getTimeout, getUpstreamRetries, postExecute, preExecute
-
Method Details
-
validate
Validates the target object. ThrowsGuardrailExceptionif validation fails.- Parameters:
target- the object to validate- Throws:
GuardrailException- if validation fails
-
setTarget
Set the target this guardrail will validate before it runs. Called by the enforcing code immediately before submitting the guardrail as a job. -
targetType
-
setGatedSnapshot
Delivers the immutable snapshot of the gated job before submission. The snapshot is the guardrail's only window onto the invocation: principal (userId), tool (jobClass), position (jobId,parentJobId,workflowId), attempt and timestamps.
-