jevrecipes

Recipe catalog / rule-compliance

Check rule compliance

rule-compliance is a Jev recipe from the jev-recipes TypeScript package. Is the described action permitted by the written rules? Use it when an agent proposes a move or action in natural language and you want a quick check against the game's written rules before spending engine time or accepting it.

Last updated .

Explore this recipe interactively · Source and implementation guide · Markdown version

How do I use rule-compliance in TypeScript?

Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.

import { ruleCompliance } from 'jev-recipes/rule-compliance';

const result = await ruleCompliance({
  "action": "On my turn I play a Draw Two card on top of a red 7 that is showing on the discard pile. My Draw Two is blue.",
  "rules": "UNO. On your turn you must play a card that matches the top discard by color, number, or symbol. Draw Two, Reverse, and Skip cards may be played on a top card of the same color or on another card of the same symbol. Wild cards may be played on anything. If you cannot play, draw one card; if it is playable you may play it immediately.",
  "minConfidence": 0.8
});
console.log(result);

What input does rule-compliance take?

FieldTypeNeeded
actionstringRequired
rulesstringRequired
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "action": {
        "type": "string"
      },
      "rules": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "action",
      "rules"
    ]
  },
  "result": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "model": {
        "type": "string"
      },
      "usage": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "additionalProperties": false
      },
      "status": {
        "type": "string",
        "enum": [
          "ready",
          "review"
        ]
      },
      "probability": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "verdict": {
        "type": "string",
        "enum": [
          "legal",
          "illegal"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "probability",
      "confidence",
      "verdict"
    ],
    "additionalProperties": false
  }
}

What does a rule-compliance result look like?

This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo rule-compliance.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "probability": 0.05,
  "confidence": 0.95,
  "verdict": "illegal"
}

Input

See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.

Result

verdict is legal when Jev's yes probability is at least 0.5 and illegal otherwise. probability is that yes probability. confidence is the probability of the chosen side, so a 0.1 yes probability yields illegal with 0.9 confidence.

A result is ready when confidence meets minConfidence. Otherwise it is review. Treat a review result as unknown and fall back to your safe default.

Reuse and calls

Uses the shared gate helper, a single yes/no question. This folder owns the question wording, the outcome descriptions, and the review policy. A live invocation makes one logical Jev request.

Limits

The verdict reflects only the rules text supplied, so a rule that is omitted or paraphrased loosely cannot be applied. The recipe does not know the full game state beyond what the action describes and cannot enumerate legal moves. Authoritative move validation, state tracking, and enforcement belong in game code.

Example input

demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo rule-compliance shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe rule-compliance to inspect the input and result schemas.

How accurate is rule-compliance?

Fixture only

No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.

Use the evaluation guide to measure this decision on your own labeled cases.

What are the limits of rule-compliance?