jevrecipes

Recipe catalog / rule-compliance

Check rule compliance

Is the described action permitted by the written rules?

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.

Explore this recipe interactively ยท Source and implementation guide

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);

Input contract

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
  }
}

Saved example result

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"
}

Evaluation evidence

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.

Limitations

Related recipes