Rule Cascade
Examples

AI agent

Three strict function tools that let an agent list, check and explain rules, and a response format that drafts a rule for review.

This page is about agents that act for your users at run time. For AI coding tools (Claude Code, Codex, Cursor, Copilot, Gemini CLI, Windsurf) that write and review rules in your repository, see AI coding tools and the MCP server.

Files: bindings/llm-tools.json, bindings/rule-draft.response-format.json (README).

ToolArgumentsUse
list_rulesruleset, entity, operationWhich rules apply to this operation
evaluate_rulesruleset, entity, operation, data_json, original_json, view, resolutionsCheck a proposed operation before performing it
explain_ruleruleset, rule_idOne rule, to explain a finding

Both files are written for OpenAI strict mode: every object has additionalProperties: false, every property is in required, optional values are nullable. data_json and original_json are JSON text because a strict schema cannot describe an object with arbitrary members. The actor is not an argument: the host takes it from its own authentication.

How a call flows: the model asks, your host answers from the rules, and the actor comes from your session, never from the model.

Diagram, described in Mermaid: flowchart LR M[Model] -- list_rules / evaluate_rules / explain_rule --> H[Your tool host] S[Session: actor id and roles] --> H H --> R[Runtime or rule server] R -- decision, findings, effects --> H H -- the result, unchanged --> M

Give the model the tools

The model reads each tool's description to decide when to call it. The one for evaluate_rules, from llm-tools.json:

bindings/llm-tools.json
"name": "evaluate_rules",
"strict": true,
"description": "Check a proposed operation against the business rules without changing anything. Returns decision (allow or deny), findings with severity, field pointers and location (the page, screen, section and component the rule names), field effects and computed values. Always call this before calling an API operation that creates, updates or deletes the entity, and never present a denied operation as done.",

Done when your request to the model carries the three entries of tools from llm-tools.json unchanged.

Answer the calls from the rules

The host maps each call to the runtime or the rule server and returns the answer as is. The AI agent tools playbook has a complete host over the Python runtime; examples/agent-tools has one over the HTTP rule server.

Done when evaluate_rules for a 30,000 transfer by a teller returns deny with ORG-TRF-002, the same answer the API gives (see Level cascade).

Optional: let the model draft a rule

rule-draft.response-format.json constrains the model to one validation rule. Its head:

bindings/rule-draft.response-format.json
"type": "json_schema",
"name": "rule_draft",
"strict": true,

Done when a draft passes rcas check with a golden test, then review, like any hand-written rule.

A complete host over the Python runtime is in the bindings README and in the AI agent tools playbook, where it is run against the published bundles. A draft produced with the response format goes through the same schema, load checks, golden tests and review as a hand-written rule (drafting a rule).

A runnable version over the HTTP rule server is in examples/agent-tools: a dispatcher that maps list_rules, evaluate_rules and explain_rule onto the server's routes, with tests that CI runs on every push. Each tool maps one-to-one onto an MCP tool.

On this page