guardrail-sim
Policy simulation for agentic commerce. Test discount rules, validate AI agent requests, and enforce pricing guardrails before they hit production.
Real Questions, Real Answers
Stop guessing. Start simulating.
Discount Stacking
Can a 20% coupon combine with a site-wide sale?
evaluate(policy, {
discounts: [
{ type: 'coupon', value: 20 },
{ type: 'sale', value: 15 },
],
})Agent Discount Validation
Should we allow this AI-negotiated discount?
// UCP-compatible validation
validate_discount_code({
code: 'AGENT-DEAL-15',
order: { value: 5000, margin: 0.4 },
})
// { valid: false, error_code: 'discount_code_user_ineligible' }Time Windows
Is this Black Friday deal still active?
evaluate(policy, scenario, {
context: {
currentTime: new Date(),
},
})Why guardrail-sim?
Declarative Policies
Define rules as data, not code. Version, test, and deploy with confidence.
Instant Simulation
Test scenarios in milliseconds. No database, no side effects.
Catch Edge Cases
Discover stacking bugs, constraint conflicts, and policy gaps before customers do.
MCP Integration
Use with Claude and other AI assistants. Natural language policy testing.
UCP Compatible
Built for Universal Commerce Protocol. Standard error codes, allocations, and checkout flows.
MCP Tools
Test policies conversationally with AI assistants.
evaluate_policyEvaluate a proposed discount against the active pricing policy
get_policy_summaryGet a human-readable summary of the active policy rules
get_max_discountCalculate the maximum allowed discount for a given order
Define. Simulate. Ship.
import { PolicyEngine, defaultPolicy } from '@guardrail-sim/policy-engine';
const engine = new PolicyEngine(defaultPolicy);
const result = await engine.evaluate(
{ order_value: 5000, quantity: 100, product_margin: 0.4 },
0.15 // 15% discount request
);
// result.approved: true
// result.calculated_margin: 0.25Why I built this
E-commerce discount logic is deceptively complex. Every rule has exceptions, every exception has edge cases.
I've seen teams accidentally stack discounts that cost thousands, or block legitimate promotions because the rules conflicted. Testing these scenarios manually is tedious and error-prone.
guardrail-sim lets you define policies declaratively and simulate outcomes before they hit production. Think of it as unit tests for your business rules.