guardrail-sim
byJeff Green

Architecture

Technical decisions and architecture overview

Architecture

This document captures the key technical decisions for Guardrail-Sim, including alternatives considered and rationale for choices made.

Overview

Guardrail-Sim is a two-layer system:

┌─────────────────────────────────────────────────────────────┐
│                   SIMULATION ENGINE (Node.js)          [PLANNED]
│  Synthetic Orders │ Buyer Personas │ Negotiation Loop        │
│  LLM-as-Adversary │ Result Logging │ Margin Calculation      │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│                    POLICY ENGINE (Deterministic)      [COMPLETE]
│  json-rules-engine │ Margin Floors │ Volume Tiers            │
│  Escalation Triggers │ Customer Segment Rules                │
│                                                              │
│  Exposed via MCP Server: 5 tools for AI agent integration   │
└─────────────────────────────────────────────────────────────┘

Key Decisions

DecisionChoiceRationale
Policy logicDeterministic (json-rules-engine)LLMs should never touch pricing math. Predictable, auditable, testable.
LLM roleAdversarial buyer simulation onlyLLM generates realistic negotiation attempts; policy engine decides outcomes.
IntegrationMCP serverProduction AI agents can call evaluate_policy() at runtime.
UCP alignmentUniversal Commerce ProtocolStandard error codes and response formats for agentic commerce.
DataSynthetic ordersNo dependency on real merchant data. Demonstrable without NDA concerns.

Decision Records

For detailed architectural decisions, see the ADR section:

Stack

LayerTechnologyRationale
Policy EngineNode.js + json-rules-engineBattle-tested rules engine; JS ecosystem consistency
UCP TypesTypeScriptType-safe UCP integration for agentic commerce
InsightsTypeScriptPolicy health checks and recommendations
MCP ServerTypeScript + @modelcontextprotocol/sdk5 tools for AI agent integration
Simulation RunnerNode.js + OpenAI APILLM for buyer persona simulation; Batch API for cost efficiency
DatabasePostgreSQL (Supabase)Relational for structured simulation results; free tier sufficient
DocumentationNext.js 15 + FumadocsInteractive docs site with policy playground

On this page