util.set

Emits values sequentially from the specified set, going through each value exactly once. This is useful for injecting a static data set into a simulation.

Keywords

valuesrequired

An array of literal JSON values to emit in order. Must be a non-empty array. Values can be of any JSON type: strings, numbers, booleans, objects, arrays, or null. Each value will be emitted exactly once in the order provided.

Examples

Emit status values in a specific sequence:

type: util.set
values:
  - id: 1
    name: Alabama
    code: AL
  - id: 2
    name: Alaska
    code: AK
  - id: 3
    name: Arizona
    code: AZ

This emits:

  • { "id": 1, "name": "Alabama", "code": "AL" }
  • { "id": 2, "name": "Alaska", "code": "AK" }
  • { "id": 2, "name": "Arizona", "code": "AZ" }
and stops once the list is exhausted.

Use Cases

  • Static datasets: When your application state includes a static dataset that is not subject to randomness.
  • State initialization: Creating entities that start with specific, different initial states
  • Testing with controlled data: Generating exactly the values you need for testing, without repetition or randomness

Design Notes

This schema provides deterministic sequential output with automatic completion after all values are emitted. Unlike core.select which randomly selects values, or a hypothetical repeating schema, util.set emits each value exactly once in order:

With util.set (sequential, once):

{
  "type": "util.set",
  "values": ["A", "B", "C"]
}

Output: A, B, C (then completes)

With core.select (random, indefinite):

{
  "type": "select",
  "options": [
    {"stream": {"const": "A"}},
    {"stream": {"const": "B"}},
    {"stream": {"const": "C"}}
  ]
}

Output: B, A, C, A, A, B, ... (random distribution, continues indefinitely)

The schema maintains its position in the list between calls to next(), ensuring that each entity in a simulation receives the next value in the sequence. Once all values have been emitted, the schema signals completion by returning Pending, which will cause the simulation to complete if this is the limiting schema.