Skip to main content

Examples

The Policy Engine ships with four runnable example template sets. Each example consists of:

  • a *.template source file (the policy)
  • an *.intent.json input (the user's intent)
  • an *.evidence.json input (the runtime facts)

Each set is self-contained — compile the template, then evaluate against the JSON inputs as shown in Getting Started.

Clothing Purchase

A retail-style template covering category, audience, size, budget, and optional colour and brand preferences.

Template — clothing_purchase.template

# A policy template for buying clothes online.
#
# The buyer's intent describes what they want (category, size, audience,
# budget, plus optional color and brand preferences). The evidence
# describes a concrete listing the seller is offering.

name clothing_purchase_guard

intent {
acceptable_categories: set<string>
acceptable_colors: optional set<string>
acceptable_brands: optional set<string>
size: string
audience: string
max_price_cents: int
}

evidence {
category: string
color: string
brand: string
size: string
audience: string
price_cents: int
}

requires {
evidence.category in intent.acceptable_categories;
evidence.size == intent.size;
evidence.audience in {"men", "women", "unisex"};
evidence.audience == intent.audience;
evidence.price_cents <= intent.max_price_cents;
optional: evidence.color in intent.acceptable_colors;
optional: evidence.brand in intent.acceptable_brands;
}

Intent — clothing_purchase.intent.json

{
"acceptable_categories": ["t-shirt", "polo"],
"acceptable_colors": ["black", "navy", "white"],
"acceptable_brands": ["Uniqlo", "Hanes", "Lacoste"],
"size": "M",
"audience": "men",
"max_price_cents": 2500
}

Evidence — clothing_purchase.evidence.json

{
"category": "t-shirt",
"color": "navy",
"brand": "Uniqlo",
"size": "M",
"audience": "men",
"price_cents": 1999
}

Laptop Purchase

Demonstrates date comparison, chained comparison (8 <= memory_gb <= 32), and grouped boolean logic for refurbished/warranty handling.

Template — laptop_purchase.template

# A policy template for reviewing a laptop purchase request.
#
name laptop_purchase_guard

intent {
max_price_cents: int
latest_delivery: date
approved_brands: optional set<string>
}

evidence {
price_cents: int
delivery_date: date
brand: string
seller_country: string
refurbished: bool
warranty_months: int
memory_gb: int
}

requires {
evidence.price_cents <= intent.max_price_cents;
evidence.delivery_date <= intent.latest_delivery;
evidence.seller_country in {"CH", "DE", "FR", "NL"};
8 <= evidence.memory_gb <= 32;
(
not evidence.refurbished
or evidence.warranty_months >= 12
);
optional: evidence.brand in intent.approved_brands;
}

Intent — laptop_purchase.intent.json

{
"max_price_cents": 150000,
"latest_delivery": "2026-12-31",
"approved_brands": ["Apple", "Lenovo", "Dell"]
}

Evidence — laptop_purchase.evidence.json

{
"price_cents": 129900,
"delivery_date": "2026-05-15",
"brand": "Lenovo",
"seller_country": "DE",
"refurbished": false,
"warranty_months": 24,
"memory_gb": 16
}

KYC / Age and Country

A minimal KYC-style policy: minimum age, allowed countries, and an optional blocklist.

Template — kyc_check.template

# A minimal KYC / age-verification style policy.
#
# The user declares their constraints in the intent map, the runtime
# presents evidence, and the engine checks conformance.

name kyc_age_and_country

intent {
min_age: int
allowed_countries: set<string>
blocked_countries: optional set<string>
}

evidence {
age: int
country: string
}

requires {
evidence.age >= intent.min_age;
evidence.country in intent.allowed_countries;
optional: evidence.country not in intent.blocked_countries;
}

Intent — kyc_check.intent.json

{
"min_age": 18,
"allowed_countries": ["CH", "DE", "FR", "IT"],
"blocked_countries": ["RU", "BY"]
}

Evidence — kyc_check.evidence.json

{
"age": 34,
"country": "CH"
}

Order Shipment

Exercises chained comparisons, set superset relations, and grouped boolean logic for premium-SKU thresholds.

Template — order_shipment.template

# Exercises chained comparisons, arithmetic, and set operations.
#
# "Orders larger than N items must include at least one premium SKU, ship
# within 3 weeks, and route through an approved warehouse."

name order_shipment_check

intent {
max_items: int
approved_warehouses: set<string>
premium_skus: set<string>
earliest_ship: date
latest_ship: date
}

evidence {
item_count: int
warehouse: string
ship_date: date
skus: set<string>
}

requires {
1 <= evidence.item_count <= intent.max_items;
evidence.warehouse in intent.approved_warehouses;
intent.earliest_ship <= evidence.ship_date <= intent.latest_ship;
(
evidence.item_count < 10
or evidence.skus superset of intent.premium_skus
);
}

Intent — order_shipment.intent.json

{
"max_items": 100,
"approved_warehouses": ["WH-EU-1", "WH-EU-2"],
"premium_skus": ["SKU-PRIORITY", "SKU-EXPRESS"],
"earliest_ship": "2026-04-01",
"latest_ship": "2026-04-30"
}

Evidence — order_shipment.evidence.json

{
"item_count": 25,
"warehouse": "WH-EU-2",
"ship_date": "2026-04-10",
"skus": ["SKU-A", "SKU-B", "SKU-PRIORITY", "SKU-EXPRESS"]
}