jevrecipes

Recipe catalog / policy-severity

Grade a policy violation

policy-severity is a Jev recipe from the jev-recipes TypeScript package. How severely does content violate the supplied policy, on a five-level rubric? Use it when you need a graded severity against your own written policy to choose between allow, flag, hide, or escalate.

Last updated .

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

How do I use policy-severity 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 { policySeverity } from 'jev-recipes/policy-severity';

const result = await policySeverity({
  "content": "If you buy from this seller you deserve to get scammed, idiot. Everyone knows their address is 14 Elm Street, go tell them yourself.",
  "policy": "Community posts may criticize sellers and products. Posts must not insult other members, and must not share a private individual's home address or other personal contact details.",
  "minConfidence": 0.8
});
console.log(result);

What input does policy-severity take?

FieldTypeNeeded
contentstringRequired
policystringRequired
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "content": {
        "type": "string"
      },
      "policy": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "content",
      "policy"
    ]
  },
  "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"
        ]
      },
      "score": {
        "type": "number",
        "minimum": 0
      },
      "level": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "probabilities": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      },
      "severity": {
        "type": "string",
        "enum": [
          "none",
          "minor",
          "moderate",
          "serious",
          "severe"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "score",
      "level",
      "confidence",
      "probabilities",
      "severity"
    ],
    "additionalProperties": false
  }
}

What does a policy-severity 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 policy-severity.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "score": 3.02,
  "level": 3,
  "confidence": 0.82,
  "probabilities": {
    "0": 0.01,
    "1": 0.02,
    "2": 0.1,
    "3": 0.82,
    "4": 0.05
  },
  "severity": "serious"
}

Input

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

Result

severity is one of none, minor, moderate, serious, or severe, taken from the most likely rubric level. level is that level's index from 0 to 4. score is Jev's expected value across the rubric and can fall between levels; use it to order a review queue.

A result is ready when confidence meets minConfidence. Otherwise it is review and still carries the graded values. probabilities is keyed by level index.

Reuse and calls

Uses the shared score helper. This folder owns the severity question, the rubric wording, and the review policy. A live invocation makes one logical Jev request.

Limits

The grade is relative to the policy you pass in. A vague policy yields uncertain grades; a policy that omits a rule cannot produce a violation of it. The recipe does not decide what action to take, and it does not replace the human review, appeals, or legal reporting your platform may require.

Example input

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

How accurate is policy-severity?

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 policy-severity?