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

# Class: ScenarioBuilder

> Construct a bounded recipe.

[scenarios](/api/modules/scenarios).ScenarioBuilder

Construct a bounded recipe. Its methods perform no reads or writes.

## Constructors

### constructor

• **new ScenarioBuilder**(`options?`)

#### Parameters

| Name | Type |
| :- | :- |
| `options` | `Object` |
| `options.observations?` | [`ScenarioObservationScopes`](/api/modules/scenarios#scenarioobservationscopes) |

## Methods

### operation

▸ **operation**\<`Op`>(`id`, `operation`, `args`): [`ScenarioOperation`](/api/modules/scenarios#scenariooperation)\<`Op`\[`"_returnType"`]>

#### Type parameters

| Name | Type |
| :- | :- |
| `Op` | extends [`OperationReference`](/api/modules/server#operationreference)\<`"public"`, `any`, `any`> |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `operation` | `Op` |
| `args` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Op`\[`"_args"`]> |

#### Returns

[`ScenarioOperation`](/api/modules/scenarios#scenariooperation)\<`Op`\[`"_returnType"`]>

***

### assume

▸ **assume**\<`Result`>(`id`, `operation`, `delay?`): `void`

Assume every held call's declared state change; this records no delivery.
A delay expands to bounded advancement followed by the same assumption.
Its advancement has the stable instruction ID `${id}:delay`.

#### Type parameters

| Name |
| :- |
| `Result` |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `operation` | [`ScenarioOperation`](/api/modules/scenarios#scenariooperation)\<`Result`> |
| `delay?` | `Object` |
| `delay.afterMs` | `number` |
| `delay.maxJobs?` | `number` |

#### Returns

`void`

***

### assumeStates

▸ **assumeStates**\<`Result`, `S`>(`id`, `operation`, `source`, `values`, `delay?`): `void`

Model an alternative within the held command's declared field scope.
The source schema types values; native admission checks the exact target.
Omitted fields stay unchanged; an empty patch assumes no source change.
No provider receipt is created.

#### Type parameters

| Name | Type |
| :- | :- |
| `Result` | `Result` |
| `S` | extends [`PropertyValidators`](/api/modules/values#propertyvalidators) |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `operation` | [`ScenarioOperation`](/api/modules/scenarios#scenariooperation)\<`Result`> |
| `source` | [`SourceHandle`](/api/modules/server#sourcehandle)\<`S`> |
| `values` | `Partial`\<`NonNullable`\<[`SourceHandle`](/api/modules/server#sourcehandle)\<`S`>\[`"__sourceType"`]>> |
| `delay?` | `Object` |
| `delay.afterMs` | `number` |
| `delay.maxJobs?` | `number` |

#### Returns

`void`

***

### observe

▸ **observe**(`id`, `source`, `observation`): `void`

Select a captured external history at an explicit business decision.

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `source` | [`SourceHandle`](/api/modules/server#sourcehandle) |
| `observation` | `Object` |
| `observation.history` | `string` |
| `observation.decisionAt` | `number` |
| `observation.cutoff` | `number` |

#### Returns

`void`

***

### realize

▸ **realize**(`id`, `source`, `history`, `timing`): `void`

Admit a retained model prediction as simulated source observations.

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `source` | [`SourceHandle`](/api/modules/server#sourcehandle) |
| `history` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<[`ScenarioHistory`](/api/modules/scenarios#scenariohistory)> |
| `timing` | `Object` |
| `timing.decisionAt` | `number` |
| `timing.cutoff` | `number` |

#### Returns

`void`

***

### snapshot

▸ **snapshot**(`id`, `options?`): `void`

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `options` | `Object` |
| `options.ttlHours?` | `number` |

#### Returns

`void`

***

### advance

▸ **advance**(`id`, `options`): `void`

Advance business time and drain modeled scheduled mutations. Ordinary
inherited live jobs are outside this population.

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `options` | `Object` |
| `options.byMs` | `number` |
| `options.maxJobs?` | `number` |

#### Returns

`void`

***

### query

▸ **query**\<`Query`>(`id`, `query`, `args`): `Object`

#### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`, `"public"`> |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `query` | `Query` |
| `args` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Query`\[`"_args"`]> |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `value` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`Query`\[`"_returnType"`]> |

***

### measure

▸ **measure**\<`Query`>(`id`, `evaluator`, `args`): `Object`

Evaluate exact readings with the program captured at the starting state.

#### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`, `"public"`, `any`, [`AppMetricReadings`](/api/modules/server#appmetricreadings)> |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `evaluator` | `Query` |
| `args` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Query`\[`"_args"`]> |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `value` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`Query`\[`"_returnType"`]> |

***

### infer

▸ **infer**\<`Input`, `Output`>(`id`, `model`, `input`, `options?`): `Object`

Call the version of `model` that this run's program declares. The live
program runs it with its own provider code and credentials; the run
retains the validated output for later steps. `binding: "fixed"` uses
the original evaluator program's complete model dependency graph.

#### Type parameters

| Name |
| :- |
| `Input` |
| `Output` |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `model` | [`ModelDefinition`](/api/modules/server#modeldefinition)\<`Input`, `Output`> |
| `input` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Input`> |
| `options` | `Object` |
| `options.binding` | `"candidate"` \| `"fixed"` |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `value` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`Output`> |

***

### decide

▸ **decide**\<`Input`, `Output`>(`id`, `model`, `input`): `Object`

Invoke the candidate program's decision computation.

#### Type parameters

| Name |
| :- |
| `Input` |
| `Output` |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `model` | [`ModelDefinition`](/api/modules/server#modeldefinition)\<`Input`, `Output`> |
| `input` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Input`> |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `value` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`Output`> |

***

### environment

▸ **environment**\<`Input`, `Output`>(`id`, `model`, `input`): `Object`

Invoke the environment captured from the original evaluator program.

#### Type parameters

| Name |
| :- |
| `Input` |
| `Output` |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `model` | [`ModelDefinition`](/api/modules/server#modeldefinition)\<`Input`, `Output`> |
| `input` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Input`> |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `value` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`Output`> |

***

### add

▸ **add**(`...values`): [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`bigint`>

#### Parameters

| Name | Type |
| :- | :- |
| `...values` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`bigint`>\[] |

#### Returns

[`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`bigint`>

***

### count

▸ **count**(`collection`): [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`bigint`>

#### Parameters

| Name | Type |
| :- | :- |
| `collection` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<readonly `unknown`\[]> |

#### Returns

[`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`bigint`>

***

### expect

▸ **expect**(`id`, `actual`): `Object`

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `actual` | [`ScenarioOutcome`](/api/classes/scenarios.ScenarioOutcome) |

#### Returns

`Object`

| Name | Type |
| :- | :- |
| `toRefuse` | (`code`: `string`) => `void` |

▸ **expect**\<`T`>(`id`, `actual`): [`ScenarioExpectation`](/api/classes/scenarios.ScenarioExpectation)\<`T`>

#### Type parameters

| Name |
| :- |
| `T` |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `actual` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`T`> |

#### Returns

[`ScenarioExpectation`](/api/classes/scenarios.ScenarioExpectation)\<`T`>

▸ **expect**\<`T`>(`id`, `actual`): [`ScenarioExpectation`](/api/classes/scenarios.ScenarioExpectation)\<`T`>

#### Type parameters

| Name |
| :- |
| `T` |

#### Parameters

| Name | Type |
| :- | :- |
| `id` | `string` |
| `actual` | [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`T`> |

#### Returns

[`ScenarioExpectation`](/api/classes/scenarios.ScenarioExpectation)\<`T`>

***

### sequence

▸ **sequence**\<`Item`>(`items`, `build`): `void`

#### Type parameters

| Name |
| :- |
| `Item` |

#### Parameters

| Name | Type |
| :- | :- |
| `items` | readonly `Item`\[] |
| `build` | (`item`: `Item`, `index`: `number`) => `void` |

#### Returns

`void`


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