pub struct DatConstraints {
pub max_actions: Option<u64>,
pub allowed_servers: Option<Vec<String>>,
pub require_receipt: Option<bool>,
pub rate_limit: Option<RateLimit>,
pub ip_allowlist: Option<Vec<String>>,
pub ip_denylist: Option<Vec<String>>,
pub min_trust_level: Option<u8>,
pub max_delegation_depth: Option<u32>,
pub allowed_countries: Option<Vec<String>>,
pub time_windows: Option<Vec<TimeWindow>>,
pub required_config_hash: Option<String>,
}Expand description
Full constraint set that can be embedded in a DAT.
All fields are optional — absent means “no restriction on this axis”.
Fields§
§max_actions: Option<u64>Maximum total actions allowed under this DAT (lifetime cap).
allowed_servers: Option<Vec<String>>Allowed MCP server hostnames/patterns.
require_receipt: Option<bool>Whether every action MUST produce an Action Receipt.
rate_limit: Option<RateLimit>Sliding-window rate limit.
ip_allowlist: Option<Vec<String>>CIDR ranges that are allowed to present this DAT. If set, the request IP MUST match at least one entry.
ip_denylist: Option<Vec<String>>CIDR ranges that are explicitly denied. Evaluated AFTER allowlist — a deny always wins.
min_trust_level: Option<u8>Minimum trust level the presenting agent must have (0–100 scale).
max_delegation_depth: Option<u32>Maximum delegation chain depth allowed (0 = no re-delegation).
allowed_countries: Option<Vec<String>>ISO 3166-1 alpha-2 country codes that are allowed. If set, the request country MUST be in this list.
time_windows: Option<Vec<TimeWindow>>UTC time windows during which the DAT may be used.
required_config_hash: Option<String>Required SHA-256 hex hash of the agent’s config. Stored in DatClaims.config_attestation; evaluator checks it matches.
Implementations§
Source§impl DatConstraints
impl DatConstraints
Sourcepub fn evaluate(&self, ctx: &EvaluationContext) -> Result<()>
pub fn evaluate(&self, ctx: &EvaluationContext) -> Result<()>
Run all applicable evaluators against the provided context.
Returns the first violation found, or Ok(()) if everything passes.
Sourcepub fn eval_rate_limit(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_rate_limit(&self, ctx: &EvaluationContext) -> Result<()>
Checks that ctx.actions_in_window has not exceeded the rate limit.
NOTE: This evaluator checks a snapshot supplied by the caller — it does NOT maintain state itself (state lives in the runtime/middleware layer).
Sourcepub fn eval_ip_allowlist(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_ip_allowlist(&self, ctx: &EvaluationContext) -> Result<()>
If ip_allowlist is set, the request IP must match at least one CIDR.
Sourcepub fn eval_ip_denylist(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_ip_denylist(&self, ctx: &EvaluationContext) -> Result<()>
If the request IP matches any entry in ip_denylist, deny immediately.
Sourcepub fn eval_trust_level(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_trust_level(&self, ctx: &EvaluationContext) -> Result<()>
The agent’s trust level must be >= min_trust_level.
Sourcepub fn eval_delegation_depth(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_delegation_depth(&self, ctx: &EvaluationContext) -> Result<()>
The delegation chain depth must not exceed max_delegation_depth.
Sourcepub fn eval_geofence(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_geofence(&self, ctx: &EvaluationContext) -> Result<()>
If allowed_countries is set, the request country code must be listed.
Sourcepub fn eval_time_windows(&self, ctx: &EvaluationContext) -> Result<()>
pub fn eval_time_windows(&self, ctx: &EvaluationContext) -> Result<()>
If time_windows is set, the current time must fall within at least one
window. Hours are evaluated in UTC.
Sourcepub fn eval_config_attestation(
&self,
ctx: &EvaluationContext,
token_config_hash: Option<&str>,
) -> Result<()>
pub fn eval_config_attestation( &self, ctx: &EvaluationContext, token_config_hash: Option<&str>, ) -> Result<()>
Verify that the agent’s current config hash matches the one required by the constraint AND the one recorded in the DAT claims.
token_config_hash is the value from DatClaims.config_attestation.
Trait Implementations§
Source§impl Clone for DatConstraints
impl Clone for DatConstraints
Source§fn clone(&self) -> DatConstraints
fn clone(&self) -> DatConstraints
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more