> ## 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.

# Estimate probabilities and bounded expectations

> Use Adapt-1's persistent Domain value learner with projected numeric state to estimate [0, 1] event probabilities and bounded expectations, stage warm-started candidates, and verify serving model identity.

Adapt-1's stateful value learner is the persistent, versioned parametric evaluator inside a Domain. In [value learning](https://docs.reilabs.org/docs/neuroadapt/value-learning.md) and native planning, this evaluator scores unfinished states and legal continuations while the Domain accumulates episodic history. With `representation: "projected"`, the same persistent Domain evaluator fits calibrated `[0, 1]` event probabilities and bounded scalar expectations directly from resolved observations on continuing operational streams.

The Domain retains its observation buffer, installed evaluator (`model.model_sha256`), staged candidates (`candidate.model_sha256`), and learned parameters across updates rather than discarding state between fits. Use this workflow when your application needs a parametric scalar probability or bounded expectation over pooled numeric state. Use [Probabilistic futures](https://docs.reilabs.org/docs/neuroadapt/futures/overview.md) when you need a state-conditioned joint outcome distribution across targets, progressive multi-revision updates (`future_id`), or uncertainty-aware planning.

> [!NOTE]
>
> **Handled automatically by default:** Omitting `promotion` in `value/configure` automatically activates prediction-gated promotion (`mode: "prediction"`, `minimum_cases: 16`, `required_improvement: 0`, `maximum_prediction_regression: 0.05`), alongside `representation: "projected"` and `max_samples: 20000`. In `value/train`, Core defaults `install: true`, `model_type: "mlp_v2"`, `dimensions: 64`, `dense_inputs: true`, `epochs: 200`, `learning_rate: 0.003`, `validation_mode: "chronological"`, and `warm_start: true` (Fit 1 safely cold-starts when no incumbent exists). In `value/predict`, `model_source` defaults to `"installed"`.

## Configure a persistent Domain and value learner

Send these HTTP headers and JSON serialization rules on every request:

* Include `Authorization: Bearer <ADAPT1_API_KEY>`, a descriptive non-default `User-Agent` (for example, `my-app/1.0`; omitting `User-Agent` triggers Cloudflare HTTP `403` error `1010` on Python `urllib`), `Accept: application/json`, and `Content-Type: application/json`.
* Serialize strict RFC-8259 JSON (`allow_nan=False`, finite numbers only, no `NaN` or `Infinity`, and never serialize booleans as integers).

Create a persistent Domain with a relation, a matching lowercase policy, and numeric signals via `POST /api/v1/domains`:

```json theme={null}
{
  "domain_id": "service-sla-evaluator",
  "session_id": "ignored",
  "schema": {
    "relations": ["risk_evaluation"],
    "signals": ["queue_depth", "error_rate", "sla_breach"],
    "event_types": ["observation"]
  },
  "hypotheses": [
    {
      "name": "sla-breach-evaluator",
      "relation": "risk_evaluation",
      "policy": "sla_breach_risk",
      "when": []
    }
  ],
  "learning": {
    "enabled": true
  }
}
```

Keep `policy` strictly lowercase (`sla_breach_risk`) and identical in `value/configure`, align `relation` across `schema.relations`, `hypotheses[].relation`, and `value/configure`, and keep `when: []` for an unconditional value evaluator. You only need `learning.context.feature_paths` and `learning.reward.components` if the same Domain also runs `/feedback` contextual policy learning.

Next, configure the Domain's value learner with `POST /api/v1/domains/{domain_id}/value/configure`:

```json theme={null}
{
  "session_id": "ignored",
  "config": {
    "relation": "risk_evaluation",
    "policy": "sla_breach_risk"
  }
}
```

Omitting optional keys automatically applies `representation: "projected"`, `max_samples: 20000` (allowed range `4` to `250,000`), and automatic prediction-gated promotion (`mode: "prediction"`, `minimum_cases: 16`, `required_improvement: 0`, `maximum_prediction_regression: 0.05`). Under `projected`, Core expands compact numeric signals into its internal projected basis so `mlp_v2` and `linear` learn calibrated readouts and feature interactions inside the Domain. Pass `"representation": "object_graph"` instead when modeling relational graphs (see [Observations and targets](https://docs.reilabs.org/docs/neuroadapt/value-observations.md)).

If input paths are not authored upfront, see [Discovery](https://docs.reilabs.org/docs/neuroadapt/discovery.md) to let Adapt-1 form and inspect executable input views over retained evidence before fixing a schema.

## Record resolved observations

Submit `1` to `50` resolved observations per `POST /api/v1/domains/{domain_id}/value/observe` request (submitting more than `50` rows returns HTTP `422`):

```json theme={null}
{
  "session_id": "ignored",
  "observations": [
    {
      "record_id": "svc-west-000001",
      "episode_id": "interval-2026-11-28T12:00Z",
      "step": 0,
      "context": {
        "queue_depth": 0.62,
        "error_rate": 0.14
      },
      "target": 1.0
    }
  ]
}
```

Follow these observation and grouping rules:

* **Batch limit and admission:** Chunk strictly to `1` to `50` rows per request (`51` or more returns HTTP `422`), confirm that `accepted + duplicates` equals the number of rows submitted, and inspect `sample_count`.
* **Record identity (`record_id`):** Use `record_id` (not `observation_id`) to identify each row. Exact replays with the same `record_id` count in `duplicates`; reusing a `record_id` with changed content returns HTTP `409`.
* **Episode grouping (`episode_id`):** Training partitions fitting and validation folds by `episode_id`. Assign concurrent rows from the same decision interval or episode the same `episode_id` (differentiated by `step` and `record_id`) so correlated states never split across folds and leak cross-sectionally.
* **Projected feature packing:** Place the first `16` or fewer numeric features in flat `context`, put any overflow features beyond `16` in `policy_features`, and omit `policy_features` when sending `16` or fewer features. Keep identical packing at prediction time.
* **Targets and numeric hygiene:** Keep `target` in `[0, 1]`. Supply binary outcomes as `0.0` or `1.0`. For bounded continuous targets, affine-scale values into `[0.02, 0.98]` using bounds fitted strictly on earlier data and invert the transform on returned predictions. Standardize continuous features causally on earlier data (for example, z-scores clipped to `[-6.0, 6.0]`) and encode binary or entity indicators as `0.0` or `1.0`.

See [Observations and targets](https://docs.reilabs.org/docs/neuroadapt/value-observations.md) for batch sizing by byte margin and [Observe](https://docs.reilabs.org/docs/neuroadapt/value-api/observe.md) for endpoint limits.

## Fit the installed evaluator and stage candidate updates

Fitting runs asynchronously on the Domain's retained observations so live predictions continue uninterrupted. Send `POST /api/v1/domains/{domain_id}/value/train`:

```json theme={null}
{
  "session_id": "ignored",
  "request_id": "sla-fit-001",
  "options": {
    "loss_function": "log_loss"
  }
}
```

* Pass `"loss_function": "log_loss"` for calibrated `[0, 1]` binary event probabilities; omit `options` (default `"squared"`) for bounded continuous expectations.
* Core defaults `install: true`, `model_type: "mlp_v2"`, `dimensions: 64`, `dense_inputs: true`, `epochs: 200`, `learning_rate: 0.003`, `validation_mode: "chronological"`, and `warm_start: true` (Fit 1 cold-starts automatically when no incumbent exists).
* **Shifting streams:** Pass `"validation_mode": "episode_hash"` inside `options` so the newest \~20% of episodes are not held out without refitting.

`POST /api/v1/domains/{domain_id}/value/train` returns HTTP `202`. Poll `POST /api/v1/domains/{domain_id}/value/state` (`POST`, not `GET`, which returns HTTP `405`):

```json theme={null}
{
  "session_id": "ignored"
}
```

Verify that `training.request_id` matches your submitted request and inspect `training.status` (not the top-level `status: "configured"` field). Keep polling while `training.status` is non-terminal (`queued`, `running`, `pending`, or `in_progress`). Stop polling on any terminal status (`trained`, `candidate`, `retained`, `rejected`, or `failed`; before any fit runs, `training.status` is `idle`):

* **`trained`:** A new model is installed at `model.model_sha256`.
* **`candidate`:** An uninstalled candidate is staged at `candidate.model_sha256` (from an `install: false` fit).
* **`retained`:** Core's automatic prediction gate kept the existing incumbent at `model.model_sha256`. On stationary streams this protects production against noisy updates; if retrains keep returning `retained` during volatility or regime shifts, expand the candidate-staging section below.
* **`rejected` or `failed`:** Keep serving your previous valid model (or fall back to a local baseline prior if Fit 1 did not produce a model).

See [State](https://docs.reilabs.org/docs/neuroadapt/value-api/state.md) and [Training and reports](https://docs.reilabs.org/docs/neuroadapt/value-training.md#inspect-training-state) for full status and report diagnostics.

## Predict with the fitted evaluator

Issue and store predictions strictly before uploading realized outcomes so evaluation reflects decision-time state. Confirm in `value/state` that `model` (or `candidate`) is non-null, then send `POST /api/v1/domains/{domain_id}/value/predict` with `1` to `256` inputs (more than `256` inputs returns HTTP `422` or `413`):

```json theme={null}
{
  "session_id": "ignored",
  "inputs": [
    {
      "context": {
        "queue_depth": 0.78,
        "error_rate": 0.21
      }
    }
  ]
}
```

* `model_source` defaults to `"installed"`. Pass `"model_source": "candidate"` only when scoring a staged candidate.
* Parse `predictions` (or `values` where returned; each item can be a number or an object containing `value` or `prediction`) and confirm the returned count matches `len(inputs)`.
* Clip binary probability outputs to `[1e-6, 1 - 1e-6]` before computing log-loss.
* Add optional `expected_model_sha256` (set to `model.model_sha256` or `candidate.model_sha256`) and verify the echoed hash (`model_sha256` or `evaluator.model_sha256`) whenever you need strict serving provenance.

## Advanced drift, tuning, and production controls

Expand the sections below when operating under non-stationary drift, tuning stream-specific capacity, reviewing candidate inputs with Transition Discovery, or adding production governance controls.

> [accordion] Adapting under non-stationary drift or sliding windows (install: false candidate staging)
>
> In `prediction` promotion mode, retraining over an existing incumbent with `install: true` evaluates the new fit against the incumbent's promotion gate and finishes with `training.status: retained` whenever the incumbent is kept. On non-stationary streams where rising volatility or shifting base rates increase irreducible event entropy, a strict validation-loss gate can retain an older calm-regime incumbent across most blocks even when relaxing `maximum_prediction_regression`. Furthermore, passing explicit `observation_ids` together with `install: true` over an existing incumbent returns HTTP `422` in `prediction` mode (`selected observation continuation requires install=false or application-outcome promotion`).
>
> Adapt-1 separates **staging a candidate** (`install: false`, producing `candidate.model_sha256`) from **mutating the installed incumbent** (`install: true` or explicit `value/promote`) as a governance primitive. Staging candidates over a trailing window `W` of `record_id` values lets your evaluator adapt through regime shifts without validation-gate lockouts while preserving the incumbent for fallback or audited promotion.
>
> Follow this 3-stage sliding-window protocol inside the Domain's `max_samples` buffer (`4` to `250,000`):
>
> 1. **Block 0 (establish the installed evaluator, `install: true`):** Seed your initial trailing window `W` of resolved observations and fit with `install: true`, `options.warm_start: false`, and no `observation_ids`. When `training.status` is `trained`, record `model.model_sha256` (an installed incumbent is required before `warm_start_source: "candidate"` can run). Serve initial predictions with `model_source: "installed"` and optional `expected_model_sha256`.
> 2. **Block 1 (stage the first subset candidate, `install: false`):** Pass the latest trailing window `W` of `record_id` values in `observation_ids`, set `install: false`, and supply a new `request_id`. For warm continuation from retained weights, set `options.warm_start: true`, `warm_start_source: "installed"`, and `expected_initial_model_sha256` to `model.model_sha256`. When `training.status` is `candidate`, save `candidate.model_sha256` and serve or evaluate it with `model_source: "candidate"` and `expected_model_sha256`.
> 3. **Block 2+ (continue staging across subsequent subsets, `install: false`):** Pass the updated trailing window `W` of `record_id` values in `observation_ids` with `install: false` and a new `request_id`. For warm continuation, set `options.warm_start: true`, `warm_start_source: "candidate"`, and `expected_initial_model_sha256` to the latest valid `candidate.model_sha256` (fall back to `warm_start_source: "installed"` and `model.model_sha256` if no candidate has succeeded yet).
>
> **Cold-refit `422` guard:** Whenever you perform a cold refit (`options.warm_start: false`), omit both `warm_start_source` and `expected_initial_model_sha256`. Sending `warm_start_source: "candidate"` without `expected_initial_model_sha256` returns HTTP `422` (`candidate warm starts require expected_initial_model_sha256`) even when `warm_start` is `false`.
>
> If a fit finishes with `rejected` (for example, `validation_checks.reason: candidate_failed_validation` or `collapsed_predictions`), `retained`, or `failed`, keep predicting from the previous confirmed `model_source` and SHA, or fall back to a local baseline prior if Block 0 failed to produce a model.

> [accordion] Tuning for stream dynamics (optional starting configurations and default caveats)
>
> Select training options along the value API's structural axes and validate them on earlier historical partitions before deployment:
>
> | Option axis | Allowed values | Guidance and wire rules |
> | - | - | - |
> | `model_type` | `mlp_v2`, `linear` | Use `mlp_v2` (default) for nonlinear cross-signal interactions on projected state; use `linear` for compact linear readouts over the same projected basis. |
> | `loss_function` | `log_loss`, `squared` | Use `log_loss` for `[0, 1]` binary event probabilities; use `squared` (default) for bounded continuous expectations. |
> | `validation_mode` | `chronological`, `episode_hash` | `chronological` (default) holds out the newest \~20% of episodes without refitting on them; `episode_hash` groups by `episode_id` across the selected subset so recent observations enter training without splitting concurrent rows. |
> | `warm_start` | `true`, `false` | Defaults to `true` (safely cold-starts Fit 1). Pair `true` with `warm_start_source` and `expected_initial_model_sha256` for explicit continuation; set `false` (and omit `warm_start_source` and `expected_initial_model_sha256`) for deliberate cold refits. |
> | `interaction_selection` | `"evidence"`, `"lexical"`, or omit | Applies to `mlp_v2` only (for example, `"evidence"` over `policy_features`); omit on `linear`. |
>
> Treat these empirical profiles as starting configurations to validate on earlier data, not universal defaults:
>
> | Workload | Starting configuration |
> | - | - |
> | Shifting pooled binary events | `mlp_v2`, `dimensions: 64`, `dense_hidden_dimensions: 64`, `epochs: 120`, `learning_rate: 0.003`, `loss_function: "log_loss"`, `validation_mode: "episode_hash"`, `interaction_selection: "evidence"`, warm continuation after initial fit; window `4,608` |
> | Stable rare events | `mlp_v2`, `dimensions: 16`, `dense_hidden_dimensions: 8`, `epochs: 45`, `learning_rate: 0.0015`, `loss_function: "log_loss"`, `validation_mode: "chronological"`, cold refits (`warm_start: false`); window `4,096` |
> | Smaller seasonal binary windows | `linear`, `dimensions: 64`, `epochs: 120`, `learning_rate: 0.003`, `loss_function: "log_loss"`, `validation_mode: "episode_hash"`, cold refits (`warm_start: false`), omitting `interaction_selection`; window `2,048` |
>
> Match model capacity, validation splits, and warm continuation to stream dynamics:
>
> * **Shifting pooled regimes:** Because `validation_mode: "chronological"` holds out the newest \~20% of episodes without refitting on them, prefer `mlp_v2`, `validation_mode: "episode_hash"` with a shared interval `episode_id`, and warm-started candidate staging (`install: false`, `warm_start: true`) so recent observations enter training while concurrent rows stay grouped. Always evaluate generalization chronologically on held-out future steps.
> * **Stationary rare events:** For low-base-rate binary events under stable dynamics, prefer compact `mlp_v2` capacity (`dimensions: 16`, `dense_hidden_dimensions: 8`), `loss_function: "log_loss"`, `validation_mode: "chronological"`, and cold refits (`warm_start: false`) to protect tail calibration (continuous `warm_start: true` on rare-event `log_loss` streams can inflate predicted base rates).
> * **Seasonal or smaller subsets:** When sample support is smaller or a compact linear readout over Adapt-1's projected basis generalizes better than a deeper network, prefer `model_type: "linear"` with `warm_start: false` and `validation_mode: "episode_hash"`, omitting `interaction_selection`.
> * **Watch `warm_start: true` under drift:** On rapidly drifting streams, `warm_start: true` can select `selected_epoch: 0` (leaving incoming parameters unchanged). Inspect `training.report.selected_epoch` and use a cold refit (`warm_start: false`) if updates stall.
> * **Numeric `422` option guardrails:** `dense_inputs` defaults to `true`, so omit it (or leave `true`) on `mlp_v2` and `linear` (`dense_inputs: false` returns HTTP `422`). Never set `pair_geometry: true` or `quadratic_pairs: true` on `mlp_v2` or `linear` (those flags belong only to `object_value` and return HTTP `422`). Setting `function_retention_weight` above `0` requires `warm_start: true` (`warm_start: false` returns HTTP `422`). Very wide and long snapshots can hit the dense worker cap (`HTTP 422: dense training matrix exceeds worker limit`); compact feature width or window size if encountered.

> [accordion] Review candidate inputs with Transition Discovery
>
> You can run [Transition Discovery](https://docs.reilabs.org/docs/neuroadapt/discovery-transition-projection.md#sharing-reviewed-inputs-across-domain-learners) on an earlier calibration partition (`input_paths: []` with `autonomous_projection.enabled: true`) to identify a compact set of predictive input paths before configuring the value learner. Compact discovered subsets fit cleanly within `/value/*`'s 16-feature flat `context` surface without overflowing into `policy_features`. Because marginal screening can drop slow regime or cross-entity indicators that matter mainly during rare shifts, pin essential structural keys such as entity or slow regime indicators while letting Discovery select covariates. Always validate a discovered input subset against the full reviewed input surface on a held-out partition before pinning it.

> [accordion] Production controls: promotion, freeze, concurrency, storage quota, and retries
>
> * **Explicit candidate promotion:** When promoting a verified candidate over an existing incumbent via `POST /value/promote`, supply both `expected_model_sha256` and `expected_current_model_sha256` (omitting `expected_current_model_sha256` returns HTTP `409`). See [Promotion](https://docs.reilabs.org/docs/neuroadapt/value-promotion.md).
> * **Frozen evaluation:** Lock the installed model with [Freeze](https://docs.reilabs.org/docs/neuroadapt/value-api/freeze.md); while frozen, `value/train` returns HTTP `409` until you call [Reset](https://docs.reilabs.org/docs/neuroadapt/value-api/reset.md).
> * **Owner-wide fit serialization:** Only one value fit runs at a time per authenticated owner across Domains (`HTTP 409: one value fit may run per owner`); serialize fits and retry with bounded backoff after the active fit completes. See [Schedule fits for one owner](https://docs.reilabs.org/docs/neuroadapt/value-training.md#schedule-fits-for-one-owner).
> * **Storage quota and retries:** Size `max_samples` to your account quota and delete unused Domains (`DELETE` confirmed by `GET` returning `404`) to prevent HTTP `402` storage errors. Treat read-only `POST /value/state` and `POST /value/predict` as retryable under an idempotent read policy, and reconcile state-mutating `POST` routes through `value/state` before retrying. See [Errors and reliability](https://docs.reilabs.org/docs/neuroadapt/errors-and-reliability.md) and [Operations and retries](https://docs.reilabs.org/docs/neuroadapt/operational-behavior-and-retries.md).

For `object_graph` / `object_value` workflows, full training reports, explicit candidate promotion, freeze/reset controls, and complete request schemas, see [Value learning](https://docs.reilabs.org/docs/neuroadapt/value-learning.md), [Training and reports](https://docs.reilabs.org/docs/neuroadapt/value-training.md), [Promotion](https://docs.reilabs.org/docs/neuroadapt/value-promotion.md), and [Value API reference](https://docs.reilabs.org/docs/neuroadapt/value-api.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.