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

# Use retained state and recover interrupted work

> Reconnect to a configured trajectory Domain, execute retained behavior, and reconcile pending decisions.

Keep the Domain IDs and executor configuration from the preceding guides. A new process or simulator reset does not require a new learner. Reconnect to the existing Domain, inspect its trajectory state, and continue with the same coordinate meanings, timing, action bounds, and outcome definition.

## Save the integration manifest

| Save                                                                            | Why it is needed                                        |
| ------------------------------------------------------------------------------- | ------------------------------------------------------- |
| Production base URL and stage Domain IDs                                        | Reconnect to the same owned state                       |
| Requested and returned configuration                                            | Reconstruct the mechanism and its resolved settings     |
| State/action/context coordinate order, units, and scale                         | Preserve the meaning of numeric arrays                  |
| Executor version, bounds, command duration, neutral padding, and terminal rules | Execute the same numeric output consistently            |
| Outcome definitions and ordered objective names                                 | Keep feedback comparable                                |
| Exported records, incumbent ID, and selected base execution                     | Preserve stage handoffs and the base used by refinement |
| Context IDs and reset specifications                                            | Reproduce each candidate comparison                     |
| Pending decision IDs, request bodies, and receipts                              | Reconcile interrupted operations                        |

Retain credentials separately. An execution-record export transfers acquired executions into a structural stage; it is not a whole-Domain backup or a general restore format. Keep the original Domains available when you intend to continue learning from them.

## Execute an acquired sequence without learning

The acquisition request schema supports `mode: "frozen"`. Use the same current-state and goal arrays as acquisition, then execute the returned sequence with the same adapter. Save physical results locally without sending a training observation.

```python theme={null}
initial = reset_and_measure(evaluation_reset_key)
frozen = trajectory(ACQUISITION_DOMAIN, "propose", {
    "state": initial["state"],
    "goal": initial["goal"],
    "mode": "frozen",
    "request_id": f"{PREFIX}-evaluation-0001",
})
commands = frozen["actions"]
if (not finite_matrix(commands, 2) or len(commands) > 8
        or any(abs(value) > 1 for row in commands for value in row)):
    raise ValueError("Retained sequence violates the executor contract")
executable_commands = commands + [[0.0, 0.0] for _ in range(8 - len(commands))]
trace = execute_sequence(executable_commands)
journal("evaluation", {"proposal": frozen, "execution": trace})
```

This snippet reuses `finite_matrix` and the adapter hooks from [Sequence acquisition](/docs/machina/acquisition). `evaluation_reset_key` identifies a saved evaluation scenario. Keep evaluation contexts separate from acquisition contexts when you want to assess behavior on new conditions. Frozen mode does not guarantee that the retained behavior completes the task.

## Execute a selected base or retained correction

To use a structural result, execute the preserved `base_execution["actions"]` with its original adapter. The structural guide's `execute_candidate` already applies the shared cadence, padding, and completion rule.

For a contextual correction, call `evaluate` with the measured context only:

```json theme={null}
{
  "context": [0.5, 0.5, 0.0, 0.0]
}
```

POST to `https://rei-neuroadapt-api.reilabs.org/api/v1/domains/{refinement_domain}/trajectory/evaluate`. Replace the illustration with `[target_x, target_y, initial_vx, initial_vy]` measured for the current reset. Omit `decision_id` and `candidate_index` for retained use. Those two fields select a candidate within a pending training comparison.

Use the returned `offsets` with the exact selected base, compose and bound the actions as shown in [Contextual refinement](/docs/machina/refinement), and record the resulting execution locally. Do not configure a new refinement Domain for each context.

The reference client compares the refinement state's `fingerprint` before and after retained evaluation and sends no `observe` calls. That checks the state exposed by the refinement mechanism; also keep the base and executor manifest unchanged.

## Record intent before each mutation

For `configure`, exploratory `propose`, and `observe`, durably record the intended request before sending it. After a response, save the returned IDs and receipt. Between proposal and observation, persist the physical execution and its measured outcomes first.

All trajectory routes use POST, including reads such as `state` and `records`. Decide retry behavior from the operation's role, not from the HTTP verb alone. A `request_id` is useful for correlation; the reference schema does not promise that repeating it deduplicates a mutation.

| Interruption                       | Recovery action                                                                                                          |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `state` or `records` response lost | Read again; keep the source learner stable during paginated export                                                       |
| Configuration response lost        | Read trajectory state before attempting configuration again; compare with the saved intended configuration               |
| Exploratory proposal response lost | Inspect state and available request records; recover the returned decision when possible before issuing another proposal |
| Physical execution interrupted     | Keep the actual executed prefix and termination reason; for acquisition, report only measured rows                       |
| Candidate comparison interrupted   | Resume the missing candidate/context executions; submit one complete matrix                                              |
| Observation response lost          | Preserve the exact observation and inspect state/receipts before resending; do not assume a timeout means rejection      |
| Decision intentionally abandoned   | Cancel it using its known `decision_id`; cancellation contributes no outcome                                             |

To cancel a known pending decision:

```python theme={null}
receipt = trajectory(domain, "cancel", {"decision_id": decision_id})
journal("cancel_receipt", receipt)
```

If you cannot determine whether a mutation was applied, pause that Domain's writer and resolve the ambiguity from the service's available state or operational records. Generating new IDs or replaying physical actions can make an uncertain operation harder to reconcile. `trajectory/reset` is not a retry mechanism: it resets learner state. Structural `intervention: "deletion"` instead tests removing commands from an acquired execution.

## Check requests before a long run

Use the same production base, Unit API Key, and mechanism that the run will use. Start with a fresh owned Domain and a small, measured acquisition or complete candidate/context comparison. Confirm configuration, returned IDs, array dimensions, observation acknowledgement, and subsequent readable state before increasing the budget.

The shared helper rejects non-finite JSON and bodies over the reference `1 MiB` limit. For comparisons, plan the full candidate count times context count before physical execution. Keep one writer per example Domain, finish pending work before exporting, and keep a durable record of every stage handoff.
