Chapter 37: Usage Policy
Evals tell you how a model fails; a usage policy decides what you do about it in front of users. A usage policy is a contract with your users: what the service is for, what it refuses, and what happens on a violation. Policy without enforcement is a wish, and enforcement without policy is arbitrary, so this chapter does both. The policy states categories and actions in a machine-readable file, not prose in a wiki; the gateway evaluates each request against it, before the request reaches an engine, with a decision that is logged and appealable; and the audit trail records each decision so it can be reviewed.
Concepts from other sections (7)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Usage policy: a contract with users stating what the service is for, what it refuses, and what happens on a violation. Read more: 37.1 Usage policy at the gateway
- Linear head: a weight matrix and bias vector that map a normalized embedding to class logits, . Read more: 37.1 Usage policy at the gateway
- Dot product: ; it measures how much two vectors point the same way, and it is zero exactly when they are perpendicular. Read more: Chapter 10: Calculus 3 in Mathematics
- Fail closed: refusing a request (503) when a check cannot be evaluated, rather than allowing it. Read more: 37.1 Usage policy at the gateway
- IRLS: iteratively reweighted least squares, Newton’s method on the logistic loss, where each step is a weighted least-squares solve with weights . Read more: 13.8 Logistic regression (IRLS), ROC-AUC, calibration (ECE) in Mathematics
- Audit event: a record of a decision holding identifiers only, never prompt text, completions, or embeddings. Read more: 37.1 Usage policy at the gateway
- Threat model: a structured answer to four questions about a system: what are we building, what can go wrong, what are we going to do about it, and did we do a good job? It turns an architecture into a list of threats, each tied to a control and a test. Read more: Chapter 9: Security in Software Engineering
The chapter’s section, Usage policy at the gateway, writes the policy document and its ordered rules and walks through the Go evaluator that enforces them. Classification is cheap when you reuse what you built: a linear head over the engine’s embeddings, exported as linear-head.schema.json and evaluated as a dot product in Go, so the policy middleware can sit before routing in the handler chain without adding a service. Every classifier errs, so the policy publishes the measured false-positive and false-negative rates on a labelled set and chooses its threshold on purpose. A compact example of the finished policy document, USAGE_POLICY.md, sits alongside the section.
Learning objectives
- Write a usage policy as ordered, machine-readable rules with allow and deny actions, stable rule ids, and user-safe reasons.
- Enforce it at the gateway with exact metadata checks first and a linear-head classifier last.
- Fail closed when the classifier’s dependency is down, and keep prompt text out of the audit log.
- Give the policy an owner, a revision, a review cadence, and an appeal path.
Before you begin
Section titled “Before you begin”Read Bias and Safety Evals first; this chapter acts on what those evals find. The enforcement runs in the gateway of AI Engineering, from The server skeleton through The usage ledger and admin API, and the classifier is the linear head from Fine-tuning heads and the linear-head export in AI Engineering, fitted with IRLS over /v1/embeddings. Good preparation is the NIST AI RMF core functions (Govern, Map, Measure, Manage), the OWASP LLM top 10, and two providers’ acceptable-use policies read side by side.
In this chapter
Section titled “In this chapter”- Usage policy at the gateway: policy as configuration, the linear head and its threshold, first-match rule ordering, fail-closed enforcement, privacy-safe audit events, and an annotated walkthrough of the rules, the evaluator, and the policy document.
- Usage policy: a compact example of the published policy document.
The enforcement code itself is built in Usage policy enforcement, part of the Gateway chapter whose middleware chain the policy check joins. Tool gates in the Agent SDK are the agent-side counterpart, and the threat model that names abuse cases is in Security in Software Engineering.
Further reading
Section titled “Further reading”- NIST, AI Risk Management Framework 1.0 (free).
- OWASP, Top 10 for LLM Applications (free).
- Inan et al., Llama Guard (free).
- The published acceptable-use policies of model providers; compare two.