---
title: "Policy snapshot"
description: "The JSON policy file a manager mounts — load-aware routing, traffic split by revision, cache isolation, admission and request classes, wake rules and fallback."
url: "https://opod.io/docs/core-reference/policy-snapshot/"
markdown_url: "https://opod.io/docs/core-reference/policy-snapshot.md"
section: "Core reference"
last_updated: "2026-10-30"
---

# Policy snapshot

> The JSON policy file a manager mounts — load-aware routing, traffic split by revision, cache isolation, admission and request classes, wake rules and fallback.

## In short

The policy snapshot is a JSON file a manager writes to tune how a leader routes and admits requests: routing weights, admission holds, the access log, wake rules and a fallback URL. Every field is optional. The leader re-reads it every 10 seconds and keeps the last good copy.

```json
{ "revision": "1", "routing": { "prefixAffinity": true } }
```

The policy snapshot tunes how a leader routes and admits requests. Path: `OPOD_POLICY_FILE`, default `/etc/opod-auth/policy.json`. `OPOD_POLICY_FILE=off` turns the watcher off. Like the auth snapshot, it is checked every 10 seconds, applied when it changes, and a file that is not valid JSON keeps the last good policy. A new policy records a `policy.updated` event.

The typed shape is `PolicySnapshot` in core's [`pkg/adminapi`](https://github.com/opod-io/opod-core/tree/main/pkg/adminapi). Every field is optional; a zero value keeps the default behaviour.

```json
{
  "revision": "12",
  "routing": {
    "kvWeight": 4,
    "kvSaturationPct": 90,
    "prefixAffinity": true,
    "prefixBlockWeight": 0.5,
    "speedRank": true,
    "cacheIsolation": "team",
    "revisions": [ { "revision": 6, "weight": 9 }, { "revision": 7, "weight": 1 } ],
    "fallbackUrl": "https://backup.example.com/v1",
    "fallbackModel": "qwen2.5-7b-instruct",
    "fallbackKey": "sk-…"
  },
  "logging": { "accessLog": true },
  "auth": { "maxSnapshotAgeSec": 600 },
  "admission": {
    "holdMs": 5000,
    "maxHeld": 256,
    "classes": [
      { "name": "critical",  "holdMs": 10000 },
      { "name": "standard",  "holdMs": 5000 },
      { "name": "sheddable", "holdMs": 1000, "maxShare": 0.25 }
    ]
  },
  "wake": { "noResumeInPlace": ["n_slot-3"] }
}
```

## routing

| Field               | Default   | Effect                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `kvWeight`          | `0`       | Score a worker as in-flight + queue depth + `kvWeight` × (KV used ÷ 100). A full cache counts as `kvWeight` extra requests. `0` = in-flight only.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `kvSaturationPct`   | `0` (off) | A worker at or above this KV use goes behind every worker with headroom, and gets new requests only when none has any.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `prefixAffinity`    | `false`   | Pin a prompt prefix to the worker that served it last, in a bounded table with the sticky TTL.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `prefixBlockTier`   | `gpu`     | From core v0.4.0 (feature `kv_cpu_tier_hits`). `cpu-lower` credits a leading block a worker's CPU tier holds beyond its card's at 0.8 of a card block. The worker must report its CPU tier: a vLLM worker with `OPOD_KV_EVENTS=1` and `--kv-offloading-size` does, by starting vLLM with `self_describing_kv_events`.                                                                                                                                                                                                                              |
| `prefixDepthKiB`    | `0`       | Arrives in the core release after v0.4.8 (feature `prefix_depth`). How much of a prompt's leading text the prefix match reads, in KiB: 256-byte links to 4 KiB, then one at each doubling distance and at this depth; the block index tokenizes as deep, at 4 bytes a token (never fewer than 2,048 tokens). `0` = 256; `4` = the 4 KiB chain; above 1024 is read as 1024.                                                                                                                                                                         |
| `loadRefreshMs`     | `0`       | From core v0.4.3 (feature `load_pull`, ADR-109). How often the leader and every front door pull each worker's load to rank on. `0` = 500 ms; below 100 is read as 100. A pulled sample older than three intervals is not ranked on.                                                                                                                                                                                                                                                                                                                |
| `tokenWeight`       | `0`       | Arrives in the core release after v0.4.8 (feature `routing_token_weight`, ADR-122). Each request also weighs its estimated uncached prompt tokens until its first streamed event (a non-streamed answer: the answer), or until it fails or is cancelled. The estimate is prompt bytes ÷ 4, or the block index's count when that is more, minus the leading blocks the worker holds. The score gains `tokenWeight` × tokens ÷ 1000, so `tokenWeight` is what 1,000 uncached prompt tokens weigh against one request in flight. `0` = requests only. |
| `slowFactor`        | `0` (off) | Arrives in the core release after v0.4.8 (feature `worker_slow`, ADR-122). Per model, each router keeps a worker's last 20 answers (none older than 2 min): TTFT per 1,000 uncached prompt tokens and the gap between tokens. A worker whose median of either is more than `slowFactor` × its siblings' median counts as that ratio of extra requests in flight. It is never refused, and it is cleared when normal answers bring the ratio back. A model with one worker is never judged. `/loadz` lists it under `slow_workers`.                 |
| `session`           | none      | From core v0.4.3 (feature `session_routing`, ADR-109). `{ttlSec, signedRoute, turnPriority}`: how long a conversation stays on its worker (`0` = `stickyTtlSeconds`), whether answers carry a signed route token any door honours, and whether a later turn of an active conversation leaves the hold first. A request names its conversation with `X-Opod-Session` or the OpenAI `user` field.                                                                                                                                                    |
| `stickyTtlSeconds`  | `0`       | From core v0.4.0 (feature `sticky_ttl_policy`). The sticky TTL in seconds, for session pins and prefix pins, applied live: pins placed afterwards expire by it, pins already placed keep theirs. `0` = the start value, `router.sticky_session_ttl_seconds`.                                                                                                                                                                                                                                                                                       |
| `prefixBlockWeight` | `0` (off) | Each leading block of the request that a worker's engine reported holding takes this much off that worker's score. Needs workers started with `OPOD_KV_EVENTS=1`.                                                                                                                                                                                                                                                                                                                                                                                  |
| `speedRank`         | `false`   | Rank an unsaturated worker by expected time: (score + 1) × its measured seconds per completion token. A worker with fewer than 10 answers takes its peers' median; one pick in 20 goes to the least-sampled worker.                                                                                                                                                                                                                                                                                                                                |
| `cacheIsolation`    | `team`    | Whose requests may share a prefix cache: `team`, `key` or `none`. The leader adds a `cache_salt` (an HMAC of the team or key id) on engines that support one (vLLM, SGLang, TensorRT-LLM). From the core release after v0.4.8 (feature `kv_block_salt`) the block index carries the salt too.                                                                                                                                                                                                                                                      |
| `revisions[]`       | none      | Split traffic between plan revisions. `weight` is a share, normalised: `[{6, 9}, {7, 1}]` sends 10 % to revision 7. A group with no live worker is skipped and its share goes to the others.                                                                                                                                                                                                                                                                                                                                                       |
| `fallbackUrl`       | none      | An OpenAI-compatible base URL used **only** when the leader has no serving capacity. The response carries `X-Opod-Fallback`. The forwarded request carries `X-Opod-Forwarded-By` (the leader's `router.default_model`) and the caller's `traceparent`.                                                                                                                                                                                                                                                                                             |
| `fallbackModel`     | none      | The model sent to the fallback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `fallbackKey`       | none      | The bearer sent to the fallback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## logging

| Field       | Effect                                                                  |
| ----------- | ----------------------------------------------------------------------- |
| `accessLog` | `true` or `false` switches the leader's access log. Absent = unchanged. |

## auth

| Field               | Default | Effect                                                                                                                                                                  |
| ------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `maxSnapshotAgeSec` | `0`     | When above 0, refuse keyed traffic once the auth snapshot's `issuedAt` is older than this, with `503` and `Retry-After: 30`. `0` = keep serving from the snapshot held. |

## admission

Admission decides what a full endpoint does with the next request. A worker states how many requests its engine serves at once (llama.cpp slots, SGLang's running-request limit, vLLM `--max-num-seqs`). The leader dispatches only into a free slot and holds the rest.

| Field       | Default  | Effect                                                                                                                                                                                                                                     |
| ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `holdMs`    | `0`      | How long a request waits for a slot before `503` + `Retry-After`. With `0`, a request that finds **no** worker able to serve is shed at once, and one that finds every slot busy waits, bounded by `maxHeld` and the client's own timeout. |
| `maxHeld`   | `0` = 64 | Cap on requests waiting at once, across every class. Past it the next one is shed at once with `503` + `Retry-After`.                                                                                                                      |
| `classes[]` | none     | Turn on request classes. Without it, every request is `standard`, first come first served.                                                                                                                                                 |

With classes, the leader keeps one queue per class, dispatches strictly in class order (`critical`, then `standard`, then `sheddable`) and shares fairly per flow (key or team) inside a class. When the hold is full, the lowest class is shed first.

| Class field | Effect                                                                                                                                                                       |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`      | `critical`, `standard` or `sheddable`.                                                                                                                                       |
| `holdMs`    | This class's wait budget. `0` = shed at once.                                                                                                                                |
| `maxHeld`   | Cap on this class's waiting requests. `0` = only the global cap.                                                                                                             |
| `maxShare`  | Fraction (0–1] of the model's slots this class may occupy at once: `max(1, floor(maxShare × slots))`. `0` = the class default: `critical` 1, `standard` 1, `sheddable` 0.25. |

A worker that reports no slot count is **ungoverned**: while one serves, admission for the model is unbounded. `opod_admission_ungoverned_workers` and `/gatewayz` name them.

## wake

| Field               | Effect                                                                                                                                                                                                                                                             |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `noResumeInPlace[]` | Node ids of sleeping workers the leader must **not** resume for a request, because their card is no longer theirs. A request that finds only such sleepers waits in the admission hold while the manager re-places the worker. Changes record `policy.wake_marks`. |

Without marks, a request for a model whose workers sleep resumes one and is held through the wake (up to 3 seconds), then served.
