> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reilabs.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure an adaptive policy contract

> Map ordered observations into a Domain-scoped adaptive policy and consume its structured prediction.

export const IntervalPolicyFigure = () => {
  const observations = [{
    index: "01",
    peaks: [104, 145]
  }, {
    index: "02",
    peaks: [103, 61]
  }, {
    index: "03",
    peaks: [105, 132]
  }];
  const scale = value => 70 + value / 180 * 540;
  return <figure className="not-prose my-8 overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-sm dark:border-zinc-800 dark:bg-zinc-950" aria-labelledby="interval-caption">
      <div className="flex flex-wrap items-start justify-between gap-3 border-b border-stone-200 px-5 py-4 dark:border-zinc-800">
        <div>
          <div className="text-xs font-semibold uppercase tracking-widest text-stone-500 dark:text-zinc-400">Adaptive interval policy</div>
          <div className="mt-1 text-sm font-semibold text-stone-900 dark:text-zinc-100">Recurring structure across ordered observations</div>
        </div>
        <span className="rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs text-sky-700 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-300">Illustrative contract view</span>
      </div>
      <div className="overflow-x-auto">
        <svg viewBox="0 0 680 260" className="block h-auto w-full" style={{
    minWidth: "620px"
  }} role="img" aria-label="Three ordered observations share a recurring peak near 104 while isolated peaks remain noise; the prediction reports a persistent interval">
          {observations.map((observation, row) => {
    const y = 48 + row * 48;
    return <g key={observation.index}>
                <text x="28" y={y + 4} className="fill-stone-500 dark:fill-zinc-500" fontSize="10">OBS {observation.index}</text>
                <line x1="70" y1={y} x2="610" y2={y} className="stroke-stone-200 dark:stroke-zinc-800" strokeWidth="2" />
                {observation.peaks.map((peak, index) => <g key={peak}>
                    <line x1={scale(peak)} y1={y - (index === 0 ? 15 : 9)} x2={scale(peak)} y2={y + (index === 0 ? 15 : 9)} className={index === 0 ? "stroke-sky-500" : "stroke-stone-400 dark:stroke-zinc-600"} strokeWidth={index === 0 ? "3" : "2"} strokeLinecap="round" />
                    <circle cx={scale(peak)} cy={y} r={index === 0 ? "4" : "3"} className={index === 0 ? "fill-sky-500" : "fill-stone-400 dark:fill-zinc-600"} />
                  </g>)}
              </g>;
  })}
          <text x="28" y="204" className="fill-amber-700 dark:fill-amber-300" fontSize="10" fontWeight="600">PREDICTION</text>
          <line x1="70" y1="200" x2="610" y2="200" className="stroke-stone-200 dark:stroke-zinc-800" strokeWidth="2" />
          <rect x={scale(100)} y="185" width={scale(108) - scale(100)} height="30" rx="8" className="fill-amber-100 stroke-amber-500 dark:fill-amber-950 dark:stroke-amber-500" />
          <text x={scale(104)} y="231" textAnchor="middle" className="fill-amber-700 dark:fill-amber-300" fontSize="10">prediction.&lt;output_key&gt;</text>
          <text x="70" y="249" className="fill-stone-400 dark:fill-zinc-600" fontSize="9">0</text>
          <text x="610" y="249" textAnchor="end" className="fill-stone-400 dark:fill-zinc-600" fontSize="9">180</text>
        </svg>
      </div>
      <figcaption id="interval-caption" className="border-t border-stone-200 px-5 py-3 text-xs leading-5 text-stone-500 dark:border-zinc-800 dark:text-zinc-500">The recurring position is illustrative. Configured policy thresholds determine when an interval appears; isolated observations need not become persistent output.</figcaption>
    </figure>;
};

Adaptive Policies update online from structured observations and return the current structured prediction immediately.

<IntervalPolicyFigure />

## Route sequence

```text theme={null}
POST /api/v1/domains
POST /api/v1/domains/{domain_id}/adapt/reset
POST /api/v1/domains/{domain_id}/adapt/events
POST /api/v1/domains/{domain_id}/adapt/predict
```

The result is read from:

```text theme={null}
prediction.<output_key>
```

Do not read this result from `predicted_observations`, `POST /api/v1/domains/{domain_id}/query`, or `POST /api/v1/domains/{domain_id}/explain`. Those belong to the Domain Reasoning and audit contracts.

## The adaptive template

The currently exposed interval-policy integration is configured under the exact key:

```text theme={null}
query_templates.adaptive_interval_policy
```

The template declares how to read the application's observation and how to name the returned rows:

| Template field  | Role                                                   |
| --------------- | ------------------------------------------------------ |
| `items_key`     | List of observed items inside `values`                 |
| `output_key`    | Key created under `prediction`                         |
| `index_key`     | Ordered observation index                              |
| `baseline_key`  | Optional baseline used by the policy                   |
| `bounds`        | Optional lower and upper range fields                  |
| `input_fields`  | Mapping from application fields to policy inputs       |
| `output_fields` | Mapping from policy values to application-facing names |

The field mapping is the integration boundary. It translates schemas; it does not solve the task.

## Generic integration pattern

```text theme={null}
caller object
  -> values and input_fields mapping
  -> POST /api/v1/domains/{domain_id}/adapt/events
  -> response.prediction[output_key]
  -> caller response schema
```

The same public route returns a richer object than a downstream consumer may require. A thin adapter can select accepted fields while leaving the adaptive reasoning in Adapt-1.

## State and ordering

The policy is online and stateful per domain/session. Send observations in order and use one writer unless interleaving is intentional. Call `POST /api/v1/domains/{domain_id}/adapt/reset` to start a new policy history. Also call this route to rebuild state from a known observation record. Use `POST /api/v1/domains/{domain_id}/adapt/predict` to read current state without adding an observation.

Policy thresholds determine when an item appears in the output. Do not document a universal number of observations unless the selected template configuration guarantees it.

## Scope

`adaptive_interval_policy` is one exposed public policy template. Its interval-shaped fields are not the boundary of Core or Adapt-1. The architecture is the self-contained substrate behind the gateways; this page documents one concrete structured-output contract.
