usertrust
Policy

Field Operators

12 field operators for policy conditions — equality, comparison, membership, pattern matching.

Condition Format

interface FieldCondition {
  field: string;       // dot-notation path (e.g., "model", "cost.estimated")
  operator: FieldOperator;
  value?: unknown;     // not needed for exists/not_exists
}

Presence

OperatorDescriptionExample
existsField is present and not null/undefined{ field: "scope", operator: "exists" }
not_existsField is absent or null/undefined{ field: "proxy", operator: "not_exists" }

Equality

OperatorDescriptionExample
eqStrict equality{ field: "model", operator: "eq", value: "claude-sonnet-4-6" }
neqNot equal{ field: "tier", operator: "neq", value: "free" }

Comparison (numeric)

OperatorDescriptionExample
gtGreater than{ field: "cost.estimated", operator: "gt", value: 1000 }
gteGreater than or equal{ field: "budget", operator: "gte", value: 0 }
ltLess than{ field: "budgetRemaining", operator: "lt", value: 100 }
lteLess than or equal{ field: "max_tokens", operator: "lte", value: 4096 }

Membership

OperatorDescriptionExample
inValue is in the array{ field: "model", operator: "in", value: ["gpt-4o", "gpt-4o-mini"] }
not_inValue is not in the array{ field: "model", operator: "not_in", value: ["claude-opus-4-6"] }

Pattern Matching

OperatorDescriptionExample
containsString contains substring{ field: "model", operator: "contains", value: "opus" }
regexRegex match (safe: max 200 chars, no nested quantifiers){ field: "model", operator: "regex", value: "^claude-.*" }

Dot-Notation Field Resolution

Fields support dot-notation for nested objects:

conditions:
  - field: messages.0.role
    operator: eq
    value: system

Full YAML Example

- name: limit-opus-in-prod
  effect: deny
  enforcement: hard
  severity: high
  conditions:
    - field: model
      operator: contains
      value: opus
    - field: cost.estimated
      operator: gt
      value: 500