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

# Module: scenarios

> Reference for the bijection/scenarios entry point.

## Classes

* [ScenarioValue](/api/classes/scenarios.ScenarioValue)
* [ScenarioOutcome](/api/classes/scenarios.ScenarioOutcome)
* [ScenarioExpectation](/api/classes/scenarios.ScenarioExpectation)
* [ScenarioBuilder](/api/classes/scenarios.ScenarioBuilder)
* [ScenarioRefusal](/api/classes/scenarios.ScenarioRefusal)
* [ScenarioError](/api/classes/scenarios.ScenarioError)
* [ScenarioRequestUnconfirmed](/api/classes/scenarios.ScenarioRequestUnconfirmed)
* [AdmissionUnconfirmed](/api/classes/scenarios.AdmissionUnconfirmed)

## References

### Run

Re-exports [Run](/api/modules/browser#run)

***

### RunCapture

Re-exports [RunCapture](/api/modules/browser#runcapture)

***

### RunClient

Re-exports [RunClient](/api/modules/browser#runclient)

***

### ExperimentClient

Re-exports [ExperimentClient](/api/modules/browser#experimentclient)

***

### ScenarioRunStart

Re-exports [ScenarioRunStart](/api/modules/browser#scenariorunstart)

***

### ModelRunStart

Re-exports [ModelRunStart](/api/modules/browser#modelrunstart)

## Type Aliases

### ScenarioRetention

Ƭ **ScenarioRetention**: `Object`

Independent real-time lifetimes from admission, bounded by inherited state.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `outputHours` | `number` | Zero retains no output; otherwise 1–72 hours. |
| `evidenceHours` | `number` | Reconstruct authorized report values for 1–720 hours. |

***

### ScenarioPlan

Ƭ **ScenarioPlan**: `Object`

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `simulation?` | [`ScenarioSimulation`](/api/modules/scenarios#scenariosimulation) | - |
| `from?` | [`SnapshotRef`](/api/modules/browser#snapshotref) | - |
| `start` | [`ScenarioStart`](/api/modules/browser#scenariostart) | - |
| `programId` | `string` \| `null` | - |
| `recipe` | [`ScenarioRecipe`](/api/modules/scenarios#scenariorecipe) | - |
| `histories` | `Record`\<`string`, [`ScenarioHistory`](/api/modules/scenarios#scenariohistory)> | - |
| `program` | [`ProgramReference`](/api/modules/models#programreference) | - |
| `replacements` | `Record`\<`string`, `string`> | Exact model replacements applied to candidate decisions only; fixed environment models and evaluators keep the original program's models. |

***

### ScenarioSimulation

Ƭ **ScenarioSimulation**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `startMs` | `number` |
| `seed` | `string` |

***

### ScenarioRecipe

Ƭ **ScenarioRecipe**: `Object`

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `program?` | [`ScenarioProgramDefinition`](/api/modules/scenarios#scenarioprogramdefinition) | - |
| `modelBudget?` | [`ScenarioModelBudget`](/api/modules/scenarios#scenariomodelbudget) | Work each inference step's model tree may perform. Omit for the default allowance. |
| `observations?` | [`ScenarioObservationScopes`](/api/modules/scenarios#scenarioobservationscopes) | - |
| `name` | `string` | - |
| `caseName` | `string` | - |
| `inputs` | `unknown` | - |
| `inputsValidator` | `unknown` | - |
| `steps` | [`ScenarioStep`](/api/modules/scenarios#scenariostep)\[] | - |

***

### ScenarioProgramDefinition

Ƭ **ScenarioProgramDefinition**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `function` | [`ScenarioFunction`](/api/modules/server#scenariofunction) |
| `maxSteps` | `number` |
| `measurement?` | [`ScenarioProgramMeasurement`](/api/modules/scenarios#scenarioprogrammeasurement) |

***

### ScenarioProgramMeasurement

Ƭ **ScenarioProgramMeasurement**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `function` | [`ScenarioFunction`](/api/modules/server#scenariofunction) |

***

### ScenarioModelBudget

Ƭ **ScenarioModelBudget**: `Object`

The complete work of one inference step's model tree: every nested program
call and fan-out child is charged to the same evaluation. Per-value byte
bounds and the run record bound still apply.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `calls` | `number` | Model invocations, local and provider (1–1024). |
| `providerCalls` | `number` | Provider dispatches, at most `calls` (1–64). |

***

### ScenarioObservationScopes

Ƭ **ScenarioObservationScopes**: `Object`

Independent read ceilings for experimental roles; existing row, field,
marking and live-authority checks still apply.

#### Type declaration

| Name | Type |
| :- | :- |
| `candidate?` | [`ScenarioObservationCeiling`](/api/modules/scenarios#scenarioobservationceiling)\[] |
| `environment?` | [`ScenarioObservationCeiling`](/api/modules/scenarios#scenarioobservationceiling)\[] |
| `evaluator?` | [`ScenarioObservationCeiling`](/api/modules/scenarios#scenarioobservationceiling)\[] |

***

### ScenarioObservationCeiling

Ƭ **ScenarioObservationCeiling**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `relation` | `string` |
| `fields?` | `Record`\<`string`, `string`> |
| `when?` | `unknown` |

***

### ScenarioStep

Ƭ **ScenarioStep**: \{ `kind`: `"operation"` ; `id`: `string` ; `path`: `string` ; `invoke`: [`ScenarioFunction`](/api/modules/server#scenariofunction) ; `recover`: [`ScenarioFunction`](/api/modules/server#scenariofunction) ; `contractDigest`: `string` ; `args`: [`ScenarioExpression`](/api/modules/server#scenarioexpression)  } | \{ `kind`: `"observation"` ; `id`: `string` ; `source`: [`ScenarioSource`](/api/modules/scenarios#scenariosource) ; `history`: `string` ; `decisionAt`: `number` ; `cutoff`: `number`  } | \{ `kind`: `"assumption"` ; `id`: `string` ; `operation`: `string` ; `states?`: [`ScenarioAssumedStates`](/api/modules/scenarios#scenarioassumedstates)  } | \{ `kind`: `"query"` ; `id`: `string` ; `function`: [`ScenarioFunction`](/api/modules/server#scenariofunction) ; `args`: [`ScenarioExpression`](/api/modules/server#scenarioexpression)  } | \{ `kind`: `"measurement"` ; `id`: `string` ; `function`: [`ScenarioFunction`](/api/modules/server#scenariofunction) ; `args`: [`ScenarioExpression`](/api/modules/server#scenarioexpression)  } | \{ `kind`: `"expectation"` ; `id`: `string` ; `actual`: [`ScenarioExpression`](/api/modules/server#scenarioexpression) ; `comparison`: [`ScenarioComparison`](/api/modules/scenarios#scenariocomparison) ; `expected`: [`ScenarioExpression`](/api/modules/server#scenarioexpression)  } | \{ `kind`: `"refusal"` ; `id`: `string` ; `operation`: `string` ; `code`: `string`  } | \{ `kind`: `"snapshot"` ; `id`: `string` ; `ttlHours`: `number`  } | \{ `kind`: `"advance"` ; `id`: `string` ; `byMs`: `number` ; `maxJobs`: `number`  } | \{ `kind`: `"inference"` ; `id`: `string` ; `model`: `string` ; `binding`: [`ScenarioModelBinding`](/api/modules/scenarios#scenariomodelbinding) ; `args`: [`ScenarioExpression`](/api/modules/server#scenarioexpression)  }

Not exported: an exported type refers to it.

***

### ScenarioSource

Ƭ **ScenarioSource**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `module` | `string` |
| `export` | `string` |
| `collection` | `string` |

***

### ScenarioAssumedStates

Ƭ **ScenarioAssumedStates**: `Object`

A literal hypothetical alternative, checked against the named source and
the held command's declared field scope. It carries no delivery evidence.

#### Type declaration

| Name | Type |
| :- | :- |
| `source` | [`ScenarioSource`](/api/modules/scenarios#scenariosource) |
| `values` | `Record`\<`string`, `unknown`> |

***

### ScenarioComparison

Ƭ **ScenarioComparison**: `"equal"` | `"at_least"` | `"at_most"`

Not exported: an exported type refers to it.

***

### ScenarioModelBinding

Ƭ **ScenarioModelBinding**: `"candidate"` | `"fixed"`

***

### ScenarioHistory

Ƭ **ScenarioHistory**: `Object`

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `observations` | [`ScenarioObservation`](/api/modules/scenarios#scenarioobservation)\[] | - |
| `producer?` | [`ScenarioHistoryProducer`](/api/modules/scenarios#scenariohistoryproducer) | The model version that computed these observations outside the run, such as a forecast over earlier history. Absent for supplied facts. |

***

### ScenarioObservation

Ƭ **ScenarioObservation**: `Object`

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `id` | `string` | - |
| `key` | `string` | - |
| `knownAt` | `number` | - |
| `validFrom` | `number` | - |
| `record` | `unknown` | A complete source record, or null for explicit absence. |

***

### ScenarioHistoryProducer

Ƭ **ScenarioHistoryProducer**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `model` | `string` |
| `version` | `string` |

***

### ScenarioProgramCaptureRequest

Ƭ **ScenarioProgramCaptureRequest**: `Object`

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `programId` | `string` | - |
| `source?` | [`BranchReference`](/api/modules/browser#branchreference) | Omit to capture the live application without creating a source branch. |
| `cases` | [`ScenarioProgramCase`](/api/modules/browser#scenarioprogramcase)\[] | - |

***

### ScenarioProgramRequest

Ƭ **ScenarioProgramRequest**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `programId` | `string` |

***

### ScenarioProgramStatus

Ƭ **ScenarioProgramStatus**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `programId` | `string` |
| `cases` | [`ScenarioProgramCase`](/api/modules/browser#scenarioprogramcase)\[] |
| `program` | [`ProgramReference`](/api/modules/models#programreference) |
| `progress` | [`ScenarioProgramProgress`](/api/modules/scenarios#scenarioprogramprogress) |
| `deadline` | `string` |

***

### ScenarioProgramProgress

Ƭ **ScenarioProgramProgress**: \{ `state`: `"capturing"`  } | \{ `state`: `"ready"`  } | \{ `state`: `"expired"`  } | \{ `state`: `"failed"` ; `code`: `string`  }

***

### ScenarioProgramRetirementResult

Ƭ **ScenarioProgramRetirementResult**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `status` | `"retired"` |
| `programId` | `string` |

***

### ScenarioPlanRequest

Ƭ **ScenarioPlanRequest**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `simulation?` | [`ScenarioSimulation`](/api/modules/scenarios#scenariosimulation) \| `null` |
| `from?` | [`SnapshotRef`](/api/modules/browser#snapshotref) \| `null` |
| `start?` | [`ScenarioStart`](/api/modules/browser#scenariostart) |
| `release?` | `ReleaseRef` \| `null` |
| `name` | `string` |
| `caseName` | `string` |
| `histories?` | `Record`\<`string`, [`ScenarioHistory`](/api/modules/scenarios#scenariohistory)> |

***

### ModelRunPlanRequest

Ƭ **ModelRunPlanRequest**: `Object`

Planning resolves a handle in the selected executable at the selected state.

#### Type declaration

| Name | Type |
| :- | :- |
| `model` | [`ModelReference`](/api/modules/scenarios#modelreference) |
| `input` | `unknown` |
| `from?` | [`SnapshotRef`](/api/modules/browser#snapshotref) \| `null` |
| `release?` | `ReleaseRef` \| `null` |
| `simulation` | [`ScenarioSimulation`](/api/modules/scenarios#scenariosimulation) |
| `reuse?` | `string` \| `null` |
| `budget?` | [`ScenarioModelBudget`](/api/modules/scenarios#scenariomodelbudget) \| `null` |

***

### ModelReference

Ƭ **ModelReference**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `format` | `string` |
| `name` | `string` |
| `input` | `unknown` |
| `output` | `unknown` |

***

### ScenarioRunRequest

Ƭ **ScenarioRunRequest**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `runId` | `string` |

***

### ScenarioStatus

Ƭ **ScenarioStatus**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `output?` | [`SnapshotRef`](/api/modules/browser#snapshotref) |
| `runId` | `string` |
| `branch` | [`BranchReference`](/api/modules/browser#branchreference) \| `null` |
| `branchState` | [`BranchStateName`](/api/modules/browser#branchstatename) \| `null` |
| `execution` | [`ScenarioExecutionState`](/api/modules/scenarios#scenarioexecutionstate) |
| `settlement` | [`ScenarioSettlement`](/api/modules/scenarios#scenariosettlement) |
| `cleanup` | [`ScenarioCleanup`](/api/modules/scenarios#scenariocleanup) |
| `deadline` | `string` |
| `outputExpiresAt?` | `string` |
| `evidenceExpiresAt?` | `string` |

***

### ScenarioExecutionState

Ƭ **ScenarioExecutionState**: \{ `state`: `"admitted"`  } | \{ `state`: `"running"`  } | \{ `state`: `"waiting"`  } | \{ `state`: `"completed"`  } | \{ `state`: `"failed"`  } | \{ `state`: `"cancelled"`  }

Control state excludes step labels, refusal codes and business outcomes.

***

### ScenarioSettlement

Ƭ **ScenarioSettlement**: \{ `state`: `"pending"`  } | \{ `state`: `"settled"`  } | \{ `state`: `"unknown"`  }

Whether a stopped run has reconciled every possibly submitted operation.

***

### ScenarioCleanup

Ƭ **ScenarioCleanup**: \{ `state`: `"pending"`  } | \{ `state`: `"scheduled"` ; `reclaimAt`: `string`  } | \{ `state`: `"reclaiming"`  } | \{ `state`: `"complete"`  } | \{ `state`: `"retained"` ; `expiresAt`: `string`  } | \{ `state`: `"blocked"` ; `message`: `string`  }

***

### ScenarioReport

Ƭ **ScenarioReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `result` | [`ScenarioResult`](/api/modules/scenarios#scenarioresult) |
| `snapshots?` | `Record`\<`string`, [`SnapshotRef`](/api/modules/browser#snapshotref)> |
| `output?` | [`SnapshotRef`](/api/modules/browser#snapshotref) |
| `runId` | `string` |
| `name` | `string` |
| `caseName` | `string` |
| `branch` | [`BranchReference`](/api/modules/browser#branchreference) \| `null` |
| `branchState` | [`BranchStateName`](/api/modules/browser#branchstatename) \| `null` |
| `program` | [`ProgramReference`](/api/modules/models#programreference) |
| `startingStateRevision` | `string` |
| `inputs` | [`ScenarioRunInputs`](/api/modules/scenarios#scenarioruninputs) |
| `execution` | [`ScenarioExecutionState`](/api/modules/scenarios#scenarioexecutionstate) |
| `settlement` | [`ScenarioSettlement`](/api/modules/scenarios#scenariosettlement) |
| `cleanup` | [`ScenarioCleanup`](/api/modules/scenarios#scenariocleanup) |
| `checks` | [`ScenarioCheckReport`](/api/modules/scenarios#scenariocheckreport)\[] |
| `assumptions` | [`ScenarioAssumptionReport`](/api/modules/scenarios#scenarioassumptionreport)\[] |
| `observations` | [`ScenarioObservationReport`](/api/modules/scenarios#scenarioobservationreport)\[] |
| `measurements` | [`ScenarioMeasurementReport`](/api/modules/scenarios#scenariomeasurementreport)\[] |
| `inferences` | [`ScenarioInferenceReport`](/api/modules/scenarios#scenarioinferencereport)\[] |
| `completedSteps` | `number` |
| `passedChecks` | `number` |
| `totalChecks` | `number` |
| `totalSteps` | `number` |
| `deadline` | `string` |
| `outputExpiresAt?` | `string` |
| `evidenceExpiresAt?` | `string` |

***

### ScenarioResult

Ƭ **ScenarioResult**: \{ `state`: `"pending"`  } | \{ `state`: `"value"` ; `value`: `unknown`  } | \{ `state`: `"unavailable"`  }

A run result is disclosed only after its dependencies are established
under the reader's current authority. JSON preserves exact Bijection scalars.

***

### ScenarioRunInputs

Ƭ **ScenarioRunInputs**: `Object`

What a run was started from and with, without business values: its
starting snapshot and behavior, sampling controls, candidate program,
replaced decisions, captured history names and sibling.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `start` | [`ScenarioStart`](/api/modules/browser#scenariostart) | - |
| `from?` | [`SnapshotRef`](/api/modules/browser#snapshotref) | - |
| `simulation?` | [`ScenarioSimulation`](/api/modules/scenarios#scenariosimulation) | - |
| `programId` | `string` \| `null` | - |
| `replacements` | `string`\[] | `model.dependency...` paths whose candidate models the plan replaces. |
| `histories` | `string`\[] | Names of the captured observation histories. |
| `siblingOf` | `string` \| `null` | The run whose starting state this run shares. |
| `collectionId` | `string` \| `null` | The experiment that admitted this run. |
| `specificationDigest` | `string` | SHA-256 of the plan with its sampling seed removed. Two runs with the same digest and seed recompute one specification; with different seeds they resample it. |

***

### ScenarioCheckReport

Ƭ **ScenarioCheckReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `outcome` | [`ScenarioCheckOutcome`](/api/modules/scenarios#scenariocheckoutcome) |

***

### ScenarioCheckOutcome

Ƭ **ScenarioCheckOutcome**: \{ `state`: `"pending"`  } | \{ `state`: `"passed"` ; `actual`: `unknown` ; `expected`: `unknown`  } | \{ `state`: `"failed"` ; `actual`: `unknown` ; `expected`: `unknown`  } | \{ `state`: `"withheld"`  } | \{ `state`: `"unavailable"`  }

***

### ScenarioAssumptionReport

Ƭ **ScenarioAssumptionReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `operation` | `string` |
| `consequence` | [`ScenarioAssumptionConsequence`](/api/modules/scenarios#scenarioassumptionconsequence) |
| `outcome` | [`ScenarioAssumptionOutcome`](/api/modules/scenarios#scenarioassumptionoutcome) |

***

### ScenarioAssumptionConsequence

Ƭ **ScenarioAssumptionConsequence**: `"declared_states"` | `"modeled_states"`

Not exported: an exported type refers to it.

***

### ScenarioAssumptionOutcome

Ƭ **ScenarioAssumptionOutcome**: \{ `state`: `"pending"`  } | \{ `state`: `"admitted"` ; `calls`: `number` ; `digest`: `string`  } | \{ `state`: `"withheld"`  } | \{ `state`: `"unavailable"`  }

***

### ScenarioObservationReport

Ƭ **ScenarioObservationReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `history` | `string` |
| `provenance` | [`ScenarioObservationProvenance`](/api/modules/scenarios#scenarioobservationprovenance) |
| `producer` | [`ScenarioHistoryProducer`](/api/modules/scenarios#scenariohistoryproducer) \| `null` |
| `outcome` | [`ScenarioObservationOutcome`](/api/modules/scenarios#scenarioobservationoutcome) |

***

### ScenarioObservationProvenance

Ƭ **ScenarioObservationProvenance**: `"simulated"` | `"predicted"`

Not exported: an exported type refers to it.

***

### ScenarioObservationOutcome

Ƭ **ScenarioObservationOutcome**: \{ `state`: `"pending"`  } | \{ `state`: `"admitted"` ; `records`: `number` ; `digest`: `string`  } | \{ `state`: `"withheld"`  } | \{ `state`: `"unavailable"`  }

***

### ScenarioMeasurementReport

Ƭ **ScenarioMeasurementReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `outcome` | [`ScenarioMeasurementOutcome`](/api/modules/scenarios#scenariomeasurementoutcome) |

***

### ScenarioMeasurementOutcome

Ƭ **ScenarioMeasurementOutcome**: \{ `state`: `"pending"`  } | \{ `state`: `"measured"` ; `program`: [`ProgramReference`](/api/modules/models#programreference) ; `revision`: `string` ; `readings`: `unknown` ; `digest`: `string`  } | \{ `state`: `"withheld"`  } | \{ `state`: `"unavailable"`  }

***

### ScenarioInferenceReport

Ƭ **ScenarioInferenceReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `model` | `string` |
| `outcome` | [`ScenarioInferenceOutcome`](/api/modules/scenarios#scenarioinferenceoutcome) |

***

### ScenarioInferenceOutcome

Ƭ **ScenarioInferenceOutcome**: \{ `state`: `"pending"`  } | \{ `state`: `"inferred"` ; `version`: `string` ; `digest`: `string` ; `host`: [`ProgramReference`](/api/modules/models#programreference) ; `calls`: [`ScenarioInferenceCall`](/api/modules/scenarios#scenarioinferencecall)\[] ; `basis`: [`ScenarioInferenceBasis`](/api/modules/scenarios#scenarioinferencebasis)  } | \{ `state`: `"unavailable"`  }

***

### ScenarioInferenceCall

Ƭ **ScenarioInferenceCall**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `path` | `string` |
| `model` | `string` |
| `version` | `string` |
| `inputDigest` | `string` |
| `outputDigest` | `string` |

***

### ScenarioInferenceBasis

Ƭ **ScenarioInferenceBasis**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `program` | [`ProgramReference`](/api/modules/models#programreference) |
| `revision` | `string` |
| `observations?` | [`ScenarioObservationCeiling`](/api/modules/scenarios#scenarioobservationceiling)\[] |

***

### ScenarioResultResponse

Ƭ **ScenarioResultResponse**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `run_id` | `string` |
| `execution` | [`ScenarioExecutionState`](/api/modules/scenarios#scenarioexecutionstate) |
| `result` | [`ScenarioResult`](/api/modules/scenarios#scenarioresult) |

***

### ScenarioCollectionStartRequest

Ƭ **ScenarioCollectionStartRequest**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `retention?` | [`ScenarioRetention`](/api/modules/scenarios#scenarioretention) |
| `budget?` | [`ScenarioCollectionBudget`](/api/modules/scenarios#scenariocollectionbudget) |
| `collectionId` | `string` |
| `cases` | [`ScenarioCollectionCase`](/api/modules/scenarios#scenariocollectioncase)\[] |
| `retain` | `boolean` |

***

### ScenarioCollectionBudget

Ƭ **ScenarioCollectionBudget**: `Object`

Aggregate limits fixed before any collection child starts. The parent
accounts every child's admitted work; the native scheduler queues children
while the collection is at its branch, byte or concurrency allowance.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `concurrency` | `number` | Children executing at once (1–16). |
| `branches` | `number` | Branches the collection holds at once, its anchor and retained outputs included (1 to the owner's open-branch limit). |
| `maxRuns` | `number` | Child runs (1–64, the owner's retained run custody). |
| `maxWork` | `number` | Admitted execution work across children: each child's step budget, scheduled jobs and model invocations. |
| `maxRetainedBytes` | `number` | Branch storage reservation held at once, 8 GiB per held branch. |
| `maxDurationMs` | `number` | Real-time deadline from admission (1–1800000 milliseconds). |

***

### ScenarioCollectionCase

Ƭ **ScenarioCollectionCase**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `runId` | `string` |
| `plan` | [`ScenarioPlan`](/api/modules/scenarios#scenarioplan) |

***

### ScenarioCollectionRequest

Ƭ **ScenarioCollectionRequest**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |

***

### ScenarioCollectionStatus

Ƭ **ScenarioCollectionStatus**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `execution` | [`ScenarioCollectionExecution`](/api/modules/scenarios#scenariocollectionexecution) |
| `admittedCases` | `number` |
| `totalCases` | `number` |
| `runs` | [`ScenarioStatus`](/api/modules/scenarios#scenariostatus)\[] |
| `selection` | [`ScenarioSelection`](/api/modules/scenarios#scenarioselection) \| `null` |
| `training` | [`ScenarioSelectionReference`](/api/modules/scenarios#scenarioselectionreference) \| `null` |
| `deadline` | `string` |

***

### ScenarioCollectionExecution

Ƭ **ScenarioCollectionExecution**: \{ `state`: `"running"`  } | \{ `state`: `"waiting"`  } | \{ `state`: `"completed"`  } | \{ `state`: `"cancelled"`  }

Not exported: an exported type refers to it.

***

### ScenarioSelection

Ƭ **ScenarioSelection**: `Object`

Immutable identity of a native training decision; no metric values are
cached.

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `collectionId` | `string` | - |
| `measurementId` | `string` | - |
| `runIds` | `string`\[] | The selected candidate's run for each aligned training case. |
| `programId` | `string` | - |
| `program` | [`ProgramReference`](/api/modules/models#programreference) | - |
| `replacements` | `Record`\<`string`, `string`> | The selected candidate's exact model replacements. A holdout runs the same set; promotion installs only code without replacements. |
| `inputsDigests` | `string`\[] | Sorted distinct digests of the training cases' inputs. |
| `historiesDigests` | `string`\[] | Sorted distinct digests of the training cases' captured histories. |
| `trainingDigest` | `string` | - |
| `evaluatorDigest` | `string` | - |
| `evaluatorProgram?` | [`ProgramReference`](/api/modules/models#programreference) | - |
| `startingProgram` | [`ProgramReference`](/api/modules/models#programreference) | - |
| `startingStateRevision` | `string` | - |
| `selectedAt` | `string` | - |

***

### ScenarioSelectionReference

Ƭ **ScenarioSelectionReference**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `trainingDigest` | `string` |

***

### ScenarioCollectionReport

Ƭ **ScenarioCollectionReport**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `execution` | [`ScenarioCollectionExecution`](/api/modules/scenarios#scenariocollectionexecution) |
| `admittedCases` | `number` |
| `totalCases` | `number` |
| `reports` | [`ScenarioReport`](/api/modules/scenarios#scenarioreport)\[] |
| `selection` | [`ScenarioSelection`](/api/modules/scenarios#scenarioselection) \| `null` |
| `training` | [`ScenarioSelectionReference`](/api/modules/scenarios#scenarioselectionreference) \| `null` |
| `deadline` | `string` |

***

### ScenarioCollectionOrderRequest

Ƭ **ScenarioCollectionOrderRequest**: `Object`

Order a bounded collection's candidates by one named frozen measurement.

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `measurementId` | `string` |

***

### ScenarioCollectionOrder

Ƭ **ScenarioCollectionOrder**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `measurementId` | `string` |
| `candidates` | [`ScenarioCandidate`](/api/modules/scenarios#scenariocandidate)\[] |
| `comparison` | [`ScenarioCandidateComparison`](/api/modules/scenarios#scenariocandidatecomparison) |

***

### ScenarioCandidate

Ƭ **ScenarioCandidate**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `candidate` | `string` |
| `programId` | `string` \| `null` |
| `program` | [`ProgramReference`](/api/modules/models#programreference) |
| `replacements` | `Record`\<`string`, `string`> |
| `runIds` | `string`\[] |

***

### ScenarioCandidateComparison

Ƭ **ScenarioCandidateComparison**: \{ `outcome`: `"preferred"` ; `candidate`: `string` ; `ranking`: [`ScenarioCandidateRanking`](/api/modules/scenarios#scenariocandidateranking)  } | \{ `outcome`: `"tie"` ; `candidates`: `string`\[] ; `ranking`: [`ScenarioCandidateRanking`](/api/modules/scenarios#scenariocandidateranking)  } | \{ `outcome`: `"no_feasible"` ; `ranking`: [`ScenarioCandidateRanking`](/api/modules/scenarios#scenariocandidateranking)  } | \{ `outcome`: `"incomplete"` ; `reason`: `string` ; `ranking`: [`ScenarioCandidateRanking`](/api/modules/scenarios#scenariocandidateranking) | `null`  } | \{ `outcome`: `"incomparable"` ; `reason`: `string`  }

Not exported: an exported type refers to it.

***

### ScenarioCandidateRanking

Ƭ **ScenarioCandidateRanking**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `objective` | `unknown` |
| `cases` | `number` |
| `places` | [`ScenarioCandidatePlace`](/api/modules/scenarios#scenariocandidateplace)\[] |
| `notComparable` | [`ScenarioCandidateNotComparable`](/api/modules/scenarios#scenariocandidatenotcomparable)\[] |

***

### ScenarioCandidatePlace

Ƭ **ScenarioCandidatePlace**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `place` | `number` |
| `candidates` | `string`\[] |
| `withinLimits` | `boolean` |
| `missed` | `string`\[] |

***

### ScenarioCandidateNotComparable

Ƭ **ScenarioCandidateNotComparable**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `candidate` | `string` |
| `reasons` | `string`\[] |

***

### ScenarioSelectionStatus

Ƭ **ScenarioSelectionStatus**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `selection` | [`ScenarioSelection`](/api/modules/scenarios#scenarioselection) \| `null` |

***

### ScenarioHoldoutStartRequest

Ƭ **ScenarioHoldoutStartRequest**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `training` | [`ScenarioSelectionReference`](/api/modules/scenarios#scenarioselectionreference) |
| `holdout` | [`ScenarioCollectionStartRequest`](/api/modules/scenarios#scenariocollectionstartrequest) |

***

### ScenarioPromotionRequest

Ƭ **ScenarioPromotionRequest**: `Object`

#### Type declaration

| Name | Type | Description |
| :- | :- | :- |
| `training` | [`ScenarioSelectionReference`](/api/modules/scenarios#scenarioselectionreference) | - |
| `holdout` | `string` | The exact linked holdout whose current authorized evidence qualifies the selected program. A training winner alone cannot qualify code. |
| `key` | `string` | - |

***

### ScenarioPromotionProgress

Ƭ **ScenarioPromotionProgress**: \{ `state`: `"pending"`  } | \{ `state`: `"ready"`  } | \{ `state`: `"expired"`  } | \{ `state`: `"failed"` ; `code`: `string`  }

***

### ScenarioPromotionStatus

Ƭ **ScenarioPromotionStatus**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `collectionId` | `string` |
| `branch` | [`BranchReference`](/api/modules/browser#branchreference) |
| `program` | [`ProgramReference`](/api/modules/models#programreference) |
| `progress` | [`ScenarioPromotionProgress`](/api/modules/scenarios#scenariopromotionprogress) |

***

### SubmissionEnvelope

Ƭ **SubmissionEnvelope**: `Object`

Not exported: an exported type refers to it.

#### Type declaration

| Name | Type |
| :- | :- |
| `deployment` | `string` |
| `caller` | [`OperationRequestScope`](/api/modules/browser#operationrequestscope)\[`"caller"`] \| `null` |
| `endpoint` | `string` |
| `request` | `unknown` |

***

### ScenarioCall

Ƭ **ScenarioCall**: (`endpoint`: `"programs/capture"` | `"programs/status"` | `"programs/retire"` | `"programs/promote"` | `"programs/promotion"` | `"models/list"` | `"models/plan"` | `"models/inspect"` | `"plan"` | `"start"` | `"status"` | `"report"` | `"result"` | `"request"` | `"resume"` | `"cancel"` | `"retire"` | `"collections/start"` | `"collections/status"` | `"collections/report"` | `"collections/order"` | `"collections/select"` | `"collections/selection"` | `"collections/holdout"` | `"collections/resume"` | `"collections/cancel"` | `"collections/retire"`, `body`: [`ScenarioProgramCaptureRequest`](/api/modules/scenarios#scenarioprogramcapturerequest) | [`ScenarioProgramRequest`](/api/modules/scenarios#scenarioprogramrequest) | [`ScenarioPromotionRequest`](/api/modules/scenarios#scenariopromotionrequest) | `Record`\<`string`, `never`> | [`ModelRunPlanRequest`](/api/modules/scenarios#modelrunplanrequest) | [`ScenarioPlanRequest`](/api/modules/scenarios#scenarioplanrequest) | [`ScenarioStartRequest`](/api/modules/browser#scenariostartrequest) | [`ScenarioRunRequest`](/api/modules/scenarios#scenariorunrequest) | [`ScenarioCollectionStartRequest`](/api/modules/scenarios#scenariocollectionstartrequest) | [`ScenarioCollectionRequest`](/api/modules/scenarios#scenariocollectionrequest) | [`ScenarioCollectionOrderRequest`](/api/modules/scenarios#scenariocollectionorderrequest) | [`ScenarioHoldoutStartRequest`](/api/modules/scenarios#scenarioholdoutstartrequest), `signal?`: `AbortSignal`) => `Promise`\<`unknown`>

#### Type declaration

▸ (`endpoint`, `body`, `signal?`): `Promise`\<`unknown`>

##### Parameters

| Name | Type |
| :- | :- |
| `endpoint` | `"programs/capture"` \| `"programs/status"` \| `"programs/retire"` \| `"programs/promote"` \| `"programs/promotion"` \| `"models/list"` \| `"models/plan"` \| `"models/inspect"` \| `"plan"` \| `"start"` \| `"status"` \| `"report"` \| `"result"` \| `"request"` \| `"resume"` \| `"cancel"` \| `"retire"` \| `"collections/start"` \| `"collections/status"` \| `"collections/report"` \| `"collections/order"` \| `"collections/select"` \| `"collections/selection"` \| `"collections/holdout"` \| `"collections/resume"` \| `"collections/cancel"` \| `"collections/retire"` |
| `body` | [`ScenarioProgramCaptureRequest`](/api/modules/scenarios#scenarioprogramcapturerequest) \| [`ScenarioProgramRequest`](/api/modules/scenarios#scenarioprogramrequest) \| [`ScenarioPromotionRequest`](/api/modules/scenarios#scenariopromotionrequest) \| `Record`\<`string`, `never`> \| [`ModelRunPlanRequest`](/api/modules/scenarios#modelrunplanrequest) \| [`ScenarioPlanRequest`](/api/modules/scenarios#scenarioplanrequest) \| [`ScenarioStartRequest`](/api/modules/browser#scenariostartrequest) \| [`ScenarioRunRequest`](/api/modules/scenarios#scenariorunrequest) \| [`ScenarioCollectionStartRequest`](/api/modules/scenarios#scenariocollectionstartrequest) \| [`ScenarioCollectionRequest`](/api/modules/scenarios#scenariocollectionrequest) \| [`ScenarioCollectionOrderRequest`](/api/modules/scenarios#scenariocollectionorderrequest) \| [`ScenarioHoldoutStartRequest`](/api/modules/scenarios#scenarioholdoutstartrequest) |
| `signal?` | `AbortSignal` |

##### Returns

`Promise`\<`unknown`>

***

### ScenarioCollectionCapture

Ƭ **ScenarioCollectionCapture**: `Object`

Persist this complete value before admission, including the holdout link.
Restore it to retry an uncertain start without replanning or minting IDs.

#### Type declaration

| Name | Type |
| :- | :- |
| `request` | `Readonly`\<[`ScenarioCollectionStartRequest`](/api/modules/scenarios#scenariocollectionstartrequest)> |
| `training` | `Readonly`\<[`ScenarioSelectionReference`](/api/modules/scenarios#scenarioselectionreference)> \| `null` |

***

### ScenarioInput

Ƭ **ScenarioInput**\<`T`>: [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`T`> | `T` extends readonly infer Item\[] ? [`ScenarioInput`](/api/modules/scenarios#scenarioinput)\<`Item`>\[] : `T` extends `ArrayBuffer` ? `T` : `T` extends `object` ? \{ \[Key in keyof T]: ScenarioInput\<T\[Key]> } : `T`

Arguments may refer to earlier results without losing their declared types.

#### Type parameters

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

***

### ScenarioOperation

Ƭ **ScenarioOperation**\<`Result`>: `Object`

#### Type parameters

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

#### Type declaration

| Name | Type |
| :- | :- |
| `id` | `string` |
| `result` | [`ScenarioValue`](/api/classes/scenarios.ScenarioValue)\<`Result`> |
| `outcome` | [`ScenarioOutcome`](/api/classes/scenarios.ScenarioOutcome) |

***

### ScenarioObservationEntry

Ƭ **ScenarioObservationEntry**: `string` | \{ `relation`: `string` ; `fields?`: `Record`\<`string`, [`AccessClaimType`](/api/modules/server#accessclaimtype)> ; `when?`: [`AccessCondition`](/api/modules/scenarios#accesscondition)  }

One relation a role may read: its name, or the relation with the only
fields it may read (typed for `when`) and a condition each read's index
range must prove. `when` reads row fields as `resource.<field>`, the
simulated decision time as `context.now` and scalar case arguments as
`context.<argument>`. Reads must `.select(...)` declared fields; a filter
never establishes observation.

***

### ScenarioObservationDeclaration

Ƭ **ScenarioObservationDeclaration**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `candidate?` | readonly [`ScenarioObservationEntry`](/api/modules/scenarios#scenarioobservationentry)\[] |
| `environment?` | readonly [`ScenarioObservationEntry`](/api/modules/scenarios#scenarioobservationentry)\[] |
| `evaluator?` | readonly [`ScenarioObservationEntry`](/api/modules/scenarios#scenarioobservationentry)\[] |

***

### ScenarioDefinition

Ƭ **ScenarioDefinition**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `kind` | `"scenario"` |
| `caseNames` | readonly `string`\[] |
| `build` | (`name`: `string`, `caseName`: `string`) => `Promise`\<[`ScenarioRecipe`](/api/modules/scenarios#scenariorecipe)> |

***

### RunRelation

Ƭ **RunRelation**: \{ `kind`: `"same"`  } | \{ `kind`: `"captured"` ; `from`: [`SnapshotRef`](/api/modules/browser#snapshotref) ; `step`: `string`  } | \{ `kind`: `"fresh"` ; `from`: [`SnapshotRef`](/api/modules/browser#snapshotref) ; `step`: `string`  } | \{ `kind`: `"recompute"`  } | \{ `kind`: `"resample"`  } | \{ `kind`: `"same-specification"`  } | \{ `kind`: `"sibling"`  } | \{ `kind`: `"unrelated"`  }

How a later run relates to an earlier one, from their native reports.

***

### ScenarioProgramContext

Ƭ **ScenarioProgramContext**: `Object`

#### Type declaration

| Name | Type |
| :- | :- |
| `scope` | (...`path`: (`string` \| `number`)\[]) => [`ScenarioProgramContext`](/api/modules/scenarios#scenarioprogramcontext) |
| `call` | \<I, O>(`key`: `string`, `procedure`: [`ScenarioProcedure`](/api/modules/scenarios#scenarioprocedure)\<`I`, `O`>, `input`: `I`) => `Promise`\<`O`> |
| `now` | () => `number` |
| `snapshot` | (`key`: `string`, `options?`: \{ `ttlHours?`: `number`  }) => `Promise`\<[`SnapshotRef`](/api/modules/browser#snapshotref)> |
| `decide` | \<I, O>(`key`: `string`, `model`: [`ModelDefinition`](/api/modules/server#modeldefinition)\<`I`, `O`>, `input`: `I`) => `Promise`\<`O`> |
| `environment` | \<I, O>(`key`: `string`, `model`: [`ModelDefinition`](/api/modules/server#modeldefinition)\<`I`, `O`>, `input`: `I`) => `Promise`\<`O`> |
| `query` | \<Q>(`key`: `string`, `query`: `Q`, `input`: `Q`\[`"_args"`]) => `Promise`\<`Q`\[`"_returnType"`]> |
| `apply` | \<O>(`key`: `string`, `operation`: `O`, `input`: `O`\[`"_args"`]) => `Promise`\<`O`\[`"_returnType"`]> |
| `assume` | (`key`: `string`, `operation`: `string`) => `Promise`\<`void`> |
| `assumeStates` | \<S>(`key`: `string`, `operation`: `string`, `source`: [`SourceHandle`](/api/modules/server#sourcehandle)\<`S`>, `values`: `Partial`\<`NonNullable`\<[`SourceHandle`](/api/modules/server#sourcehandle)\<`S`>\[`"__sourceType"`]>>) => `Promise`\<`void`> |
| `advanceBy` | (`durationMs`: `number`, `options`: \{ `key`: `string` ; `maxJobs?`: `number`  }) => `Promise`\<`void`> |
| `measure` | \<Q>(`key`: `string`, `query`: `Q`, `input`: `Q`\[`"_args"`]) => `Promise`\<`Q`\[`"_returnType"`]> |
| `realize` | (`key`: `string`, `source`: [`SourceHandle`](/api/modules/server#sourcehandle), `prediction`: \{ `step`: `string` ; `path?`: `string`\[]  }, `options?`: \{ `decisionAt?`: `number` ; `cutoff?`: `number`  }) => `Promise`\<`void`> |

***

### ScenarioProcedure

Ƭ **ScenarioProcedure**\<`I`, `O`>: `Object`

A reusable sequence of scenario instructions with a typed input and
result. Calling it from several places, or from another procedure, keeps
every instruction key distinct through its scope.

#### Type parameters

| Name |
| :- |
| `I` |
| `O` |

#### Type declaration

| Name | Type |
| :- | :- |
| `kind` | `"scenarioProcedure"` |

***

### ScenarioSubmission

Ƭ **ScenarioSubmission**: `Pick`\<[`SubmissionEnvelope`](/api/modules/scenarios#submissionenvelope), `"deployment"` | `"caller"`> & \{ `endpoint`: `"start"` ; `request`: [`ScenarioStartRequest`](/api/modules/browser#scenariostartrequest)  } | \{ `endpoint`: `"resume"` | `"cancel"` | `"retire"` ; `request`: [`ScenarioRunRequest`](/api/modules/scenarios#scenariorunrequest)  } | \{ `endpoint`: `"collections/start"` ; `request`: [`ScenarioCollectionStartRequest`](/api/modules/scenarios#scenariocollectionstartrequest)  } | \{ `endpoint`: `"collections/holdout"` ; `request`: [`ScenarioHoldoutStartRequest`](/api/modules/scenarios#scenarioholdoutstartrequest)  } | \{ `endpoint`: `"collections/resume"` | `"collections/cancel"` | `"collections/retire"` ; `request`: [`ScenarioCollectionRequest`](/api/modules/scenarios#scenariocollectionrequest)  } | \{ `endpoint`: `"collections/select"` ; `request`: [`ScenarioCollectionOrderRequest`](/api/modules/scenarios#scenariocollectionorderrequest)  } | \{ `endpoint`: `"programs/capture"` ; `request`: [`ScenarioProgramCaptureRequest`](/api/modules/scenarios#scenarioprogramcapturerequest)  } | \{ `endpoint`: `"programs/retire"` ; `request`: [`ScenarioProgramRequest`](/api/modules/scenarios#scenarioprogramrequest)  } | \{ `endpoint`: `"programs/promote"` ; `request`: [`ScenarioPromotionRequest`](/api/modules/scenarios#scenariopromotionrequest)  }

***

### ScenarioSubmissionScope

Ƭ **ScenarioSubmissionScope**: [`SubmissionScope`](/api/modules/browser#submissionscope)\<\`scenario:\$\{ScenarioSubmission\["endpoint"]}\`>

***

### ScenarioSubmissionStore

Ƭ **ScenarioSubmissionStore**: [`SubmissionStore`](/api/modules/browser#submissionstore)\<[`ScenarioSubmission`](/api/modules/scenarios#scenariosubmission), [`ScenarioSubmissionScope`](/api/modules/scenarios#scenariosubmissionscope)\[`"ref"`]>

***

### AccessCondition

Ƭ **AccessCondition**\<`Resource`, `Principal`, `Context`>: (`scope`: [`AccessConditionScope`](/api/modules/server#accessconditionscope)\<`Resource`, `Principal`, `Context`>) => [`AccessExpression`](/api/interfaces/server.AccessExpression)\<`boolean`>

#### Type parameters

| Name | Type |
| :- | :- |
| `Resource` | `any` |
| `Principal` | `any` |
| `Context` | `any` |

#### Type declaration

▸ (`scope`): [`AccessExpression`](/api/interfaces/server.AccessExpression)\<`boolean`>

Not exported: an exported type refers to it.

##### Parameters

| Name | Type |
| :- | :- |
| `scope` | [`AccessConditionScope`](/api/modules/server#accessconditionscope)\<`Resource`, `Principal`, `Context`> |

##### Returns

[`AccessExpression`](/api/interfaces/server.AccessExpression)\<`boolean`>

## Variables

### MAX\_SCENARIO\_STEP\_KEY\_BYTES

• `Const` **MAX\_SCENARIO\_STEP\_KEY\_BYTES**: `256`

Native step keys, including every enclosing program scope, admit this
many bytes.

## Functions

### scenarioModelBudget

▸ **scenarioModelBudget**(`budget`): [`ScenarioModelBudget`](/api/modules/scenarios#scenariomodelbudget)

Check a model budget against the native bounds before admission.

#### Parameters

| Name | Type |
| :- | :- |
| `budget` | [`ScenarioModelBudget`](/api/modules/scenarios#scenariomodelbudget) |

#### Returns

[`ScenarioModelBudget`](/api/modules/scenarios#scenariomodelbudget)

***

### defineScenario

▸ **defineScenario**\<`Args`>(`definition`): [`ScenarioDefinition`](/api/modules/scenarios#scenariodefinition)

Define a versioned, repeatable recipe over ordinary business operations.

#### Type parameters

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

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `definition` | `Object` | - |
| `definition.args` | `Args` | - |
| `definition.observations?` | [`ScenarioObservationDeclaration`](/api/modules/scenarios#scenarioobservationdeclaration) | - |
| `definition.cases` | `Record`\<`string`, [`Infer`](/api/modules/values#infer)\<[`AsObjectValidator`](/api/modules/values#asobjectvalidator-2)\<`Args`>>> | - |
| `definition.program?` | [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`, `"public"`, `any`, `any`> | - |
| `definition.maxSteps?` | `number` | - |
| `definition.modelBudget?` | [`ScenarioModelBudget`](/api/modules/scenarios#scenariomodelbudget) | Work each inference step's complete model tree may perform, nested programs and `ctx.map` children included. Defaults to 64 calls, of which 16 provider calls. |
| `definition.measurement?` | `Object` | - |
| `definition.measurement.id` | `string` | - |
| `definition.measurement.query` | [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`, `"public"`, `any`, [`AppMetricReadings`](/api/modules/server#appmetricreadings)> | - |
| `definition.build?` | (`builder`: [`ScenarioBuilder`](/api/classes/scenarios.ScenarioBuilder), `args`: [`Infer`](/api/modules/values#infer)\<[`AsObjectValidator`](/api/modules/values#asobjectvalidator-2)\<`Args`>>) => `void` \| `Promise`\<`void`> | - |

#### Returns

[`ScenarioDefinition`](/api/modules/scenarios#scenariodefinition)

***

### runRelation

▸ **runRelation**(`earlier`, `later`): [`RunRelation`](/api/modules/scenarios#runrelation)

Classify how `later` relates to `earlier`. Checkpoints produced by the
earlier run are its output (`step: "output"`) and its named intermediate
captures.

#### Parameters

| Name | Type |
| :- | :- |
| `earlier` | [`ScenarioReport`](/api/modules/scenarios#scenarioreport) |
| `later` | [`ScenarioReport`](/api/modules/scenarios#scenarioreport) |

#### Returns

[`RunRelation`](/api/modules/scenarios#runrelation)

***

### defineScenarioProcedure

▸ **defineScenarioProcedure**\<`I`, `O`>(`run`): [`ScenarioProcedure`](/api/modules/scenarios#scenarioprocedure)\<`I`, `O`>

#### Type parameters

| Name |
| :- |
| `I` |
| `O` |

#### Parameters

| Name | Type |
| :- | :- |
| `run` | (`sim`: [`ScenarioProgramContext`](/api/modules/scenarios#scenarioprogramcontext), `input`: `I`) => `Promise`\<`O`> |

#### Returns

[`ScenarioProcedure`](/api/modules/scenarios#scenarioprocedure)\<`I`, `O`>

***

### defineScenarioProgram

▸ **defineScenarioProgram**\<`A`, `O`>(`definition`): [`RegisteredQuery`](/api/modules/server#registeredquery)\<`"public"`, \{ `input`: `any` ; `answer`: `any` ; `references`: `any` ; `frame`: `null` | `string` ; `nowMs`: `number`  }, `Promise`\<\{ `result?`: `undefined` ; `state`: `"call"` ; `step`: `string` ; `frame`: `string` = encoded.frame; `references`: `string`\[] = encoded.references } | \{ `validator`: `string` ; `state`: `"complete"` ; `result`: `string` ; `step?`: `undefined` ; `frame?`: `undefined` = encoded.frame; `references?`: `undefined` = encoded.references }>>

Export the query and reference it from defineScenario(\{program}). Each
call resumes the saved frame with the awaited instruction's answer, runs one
segment and returns the next instruction with its new frame.

#### Type parameters

| Name | Type |
| :- | :- |
| `A` | extends [`PropertyValidators`](/api/modules/values#propertyvalidators) |
| `O` | extends [`Value`](/api/modules/values#value) = `null` |

#### Parameters

| Name | Type |
| :- | :- |
| `definition` | `Object` |
| `definition.args` | `A` |
| `definition.returns?` | [`Validator`](/api/modules/values#validator)\<`O`, `"required"`, `any`> |
| `definition.run` | (`sim`: [`ScenarioProgramContext`](/api/modules/scenarios#scenarioprogramcontext), `input`: [`Infer`](/api/modules/values#infer)\<[`AsObjectValidator`](/api/modules/values#asobjectvalidator-2)\<`A`>>) => `Promise`\<`O` \| `void`> |

#### Returns

[`RegisteredQuery`](/api/modules/server#registeredquery)\<`"public"`, \{ `input`: `any` ; `answer`: `any` ; `references`: `any` ; `frame`: `null` | `string` ; `nowMs`: `number`  }, `Promise`\<\{ `result?`: `undefined` ; `state`: `"call"` ; `step`: `string` ; `frame`: `string` = encoded.frame; `references`: `string`\[] = encoded.references } | \{ `validator`: `string` ; `state`: `"complete"` ; `result`: `string` ; `step?`: `undefined` ; `frame?`: `undefined` = encoded.frame; `references?`: `undefined` = encoded.references }>>

***

### createRunClient

▸ **createRunClient**(`call`, `ownerSignal?`): `Readonly`\<\{ `start`: \<I, O>(`spec`: [`ModelRunStart`](/api/modules/browser#modelrunstart)\<`I`, `O`>) => `Promise`\<[`Run`](/api/modules/browser#run)\<`O`>>\<O>(`spec`: [`ScenarioRunStart`](/api/modules/browser#scenariorunstart)) => `Promise`\<[`Run`](/api/modules/browser#run)\<`O`>> ; `get`: \<O>(`run`: `string` | [`RunCapture`](/api/modules/browser#runcapture), `options`: \{ `model?`: [`ModelReference`](/api/modules/models#modelreference)\<`any`, `O`>  }) => [`Run`](/api/modules/browser#run)\<`O`> ; `list`: (`signal?`: `AbortSignal`) => `Promise`\<readonly [`ModelRunSummary`](/api/modules/models#modelrunsummary)\[]> ; `calibrate`: \<T>(`definition`: \{ `name`: `string` ; `run`: [`Run`](/api/modules/browser#run)\<`T`>  }, `signal?`: `AbortSignal`) => `Promise`\<[`ModelArtifact`](/api/modules/models#modelartifact)\<`T`>>  }>

Start and observe scenario and model runs through one native lifecycle.

#### Parameters

| Name | Type |
| :- | :- |
| `call` | [`ScenarioCall`](/api/modules/scenarios#scenariocall) |
| `ownerSignal?` | `AbortSignal` |

#### Returns

`Readonly`\<\{ `start`: \<I, O>(`spec`: [`ModelRunStart`](/api/modules/browser#modelrunstart)\<`I`, `O`>) => `Promise`\<[`Run`](/api/modules/browser#run)\<`O`>>\<O>(`spec`: [`ScenarioRunStart`](/api/modules/browser#scenariorunstart)) => `Promise`\<[`Run`](/api/modules/browser#run)\<`O`>> ; `get`: \<O>(`run`: `string` | [`RunCapture`](/api/modules/browser#runcapture), `options`: \{ `model?`: [`ModelReference`](/api/modules/models#modelreference)\<`any`, `O`>  }) => [`Run`](/api/modules/browser#run)\<`O`> ; `list`: (`signal?`: `AbortSignal`) => `Promise`\<readonly [`ModelRunSummary`](/api/modules/models#modelrunsummary)\[]> ; `calibrate`: \<T>(`definition`: \{ `name`: `string` ; `run`: [`Run`](/api/modules/browser#run)\<`T`>  }, `signal?`: `AbortSignal`) => `Promise`\<[`ModelArtifact`](/api/modules/models#modelartifact)\<`T`>>  }>


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