# Simulation

Tables for simulation personas, scenarios, unit tests, and runs.

### Simulation Personas Table

**Table Name:** `simulation_personas`\
**Description:** Simulated user personas for testing

{% tabs %}
{% tab title="Schema" %}

| Column                      | Type      | Description                   |
| --------------------------- | --------- | ----------------------------- |
| `_id`                       | string    | Persona identifier            |
| `created_at`                | timestamp | Creation timestamp            |
| `creator_user_id`           | string    | Creator user ID               |
| `deleted_at`                | timestamp | Deletion timestamp            |
| `deleted_by_user_id`        | string    | User who deleted the scenario |
| `is_deleted`                | boolean   | Deletion status               |
| `latest_version_background` | string    | Latest persona background     |
| `name`                      | string    | Persona name                  |
| `org_id`                    | string    | Organization identifier       |
| `region_name`               | string    | Deployment region             |
| `role`                      | string    | Persona role                  |
| `tags`                      | json      | Associated tags               |
| `updated_at`                | timestamp | Last update timestamp         |
| `updated_by_user_id`        | string    | Last updater user ID          |
| {% endtab %}                |           |                               |

{% tab title="Query Example" %}

```sql
SELECT
  name,
  role,
  latest_version_background,
  tags
FROM simulation_personas
WHERE is_deleted = false;
```

{% endtab %}
{% endtabs %}

### Simulation Persona Versions Table

**Table Name:** `simulation_persona_versions`\
**Description:** Version history for simulation personas

{% tabs %}
{% tab title="Schema" %}

| Column                  | Type      | Description             |
| ----------------------- | --------- | ----------------------- |
| `_id`                   | string    | Version identifier      |
| `background`            | string    | Persona background      |
| `created_at`            | timestamp | Creation timestamp      |
| `org_id`                | string    | Organization identifier |
| `preferred_language`    | string    | Preferred language      |
| `region_name`           | string    | Deployment region       |
| `simulation_persona_id` | string    | Parent persona ID       |
| `timezone`              | string    | Persona timezone        |
| `updated_at`            | timestamp | Last update timestamp   |
| `version`               | integer   | Version number          |
| {% endtab %}            |           |                         |

{% tab title="Query Example" %}

```sql
SELECT
  simulation_persona_id,
  version,
  background,
  preferred_language
FROM simulation_persona_versions
ORDER BY version DESC;
```

{% endtab %}
{% endtabs %}

### Simulation Scenarios Table

**Table Name:** `simulation_scenarios`\
**Description:** Test scenario configurations

{% tabs %}
{% tab title="Schema" %}

| Column                        | Type      | Description                   |
| ----------------------------- | --------- | ----------------------------- |
| `_id`                         | string    | Scenario identifier           |
| `created_at`                  | timestamp | Creation timestamp            |
| `creator_user_id`             | string    | Creator user ID               |
| `deleted_at`                  | timestamp | Deletion timestamp            |
| `deleted_by_user_id`          | string    | User who deleted the scenario |
| `is_deleted`                  | boolean   | Deletion status               |
| `latest_version_instructions` | string    | Latest instructions           |
| `latest_version_objective`    | string    | Latest objective              |
| `name`                        | string    | Scenario name                 |
| `org_id`                      | string    | Organization identifier       |
| `region_name`                 | string    | Deployment region             |
| `tags`                        | json      | Associated tags               |
| `updated_at`                  | timestamp | Last update timestamp         |
| `updated_by_user_id`          | string    | Last updater user ID          |
| {% endtab %}                  |           |                               |

{% tab title="Query Example" %}

```sql
SELECT
  name,
  latest_version_objective,
  latest_version_instructions,
  tags
FROM simulation_scenarios
WHERE is_deleted = false;
```

{% endtab %}
{% endtabs %}

### Simulation Scenario Versions Table

**Table Name:** `simulation_scenario_versions`\
**Description:** Version history for simulation scenarios

{% tabs %}
{% tab title="Schema" %}

| Column                   | Type      | Description                   |
| ------------------------ | --------- | ----------------------------- |
| `_id`                    | string    | Version identifier            |
| `created_at`             | timestamp | Creation timestamp            |
| `initial_message_config` | json      | Initial message configuration |
| `instructions`           | string    | Scenario instructions         |
| `objective`              | string    | Scenario objective            |
| `org_id`                 | string    | Organization identifier       |
| `region_name`            | string    | Deployment region             |
| `simulation_scenario_id` | string    | Parent scenario ID            |
| `updated_at`             | timestamp | Last update timestamp         |
| `version`                | integer   | Version number                |
| {% endtab %}             |           |                               |

{% tab title="Query Example" %}

```sql
SELECT
  simulation_scenario_id,
  version,
  objective,
  instructions
FROM simulation_scenario_versions
ORDER BY version DESC;
```

{% endtab %}
{% endtabs %}

### Simulation Unit Tests Table

**Table Name:** `simulation_unit_tests`\
**Description:** Unit test configurations for conversation simulations

{% tabs %}
{% tab title="Schema" %}

| Column                     | Type      | Description             |
| -------------------------- | --------- | ----------------------- |
| `_id`                      | string    | Unit test identifier    |
| `created_at`               | timestamp | Creation timestamp      |
| `creator_user_id`          | string    | Creator user ID         |
| `description`              | string    | Test description        |
| `is_deleted`               | boolean   | Deletion status         |
| `max_interactions`         | integer   | Maximum interactions    |
| `name`                     | string    | Test name               |
| `org_id`                   | string    | Organization identifier |
| `persona_id`               | string    | Associated persona ID   |
| `region_name`              | string    | Deployment region       |
| `scenario_id`              | string    | Associated scenario ID  |
| `service_id`               | string    | Associated service ID   |
| `service_version_set_name` | string    | Version set name        |
| `success_criterions`       | json      | Success criteria        |
| `tags`                     | json      | Associated tags         |
| `updated_at`               | timestamp | Last update timestamp   |
| `updated_by_user_id`       | string    | Last updater user ID    |
| {% endtab %}               |           |                         |

{% tab title="Query Example" %}

```sql
SELECT
  name,
  description,
  service_id,
  persona_id,
  scenario_id,
  success_criterions
FROM simulation_unit_tests
WHERE is_deleted = false;
```

{% endtab %}
{% endtabs %}

### Simulation Unit Test Sets Table

**Table Name:** `simulation_unit_test_sets`\
**Description:** Collections of related unit tests

{% tabs %}
{% tab title="Schema" %}

| Column                  | Type      | Description             |
| ----------------------- | --------- | ----------------------- |
| `_id`                   | string    | Test set identifier     |
| `created_at`            | timestamp | Creation timestamp      |
| `creator_user_id`       | string    | Creator user ID         |
| `description`           | string    | Test set description    |
| `is_deleted`            | boolean   | Deletion status         |
| `last_triggered_run_id` | string    | Last run ID             |
| `name`                  | string    | Test set name           |
| `org_id`                | string    | Organization identifier |
| `region_name`           | string    | Deployment region       |
| `tags`                  | json      | Associated tags         |
| `unit_test_runs`        | json      | Test run history        |
| `updated_at`            | timestamp | Last update timestamp   |
| `updated_by_user_id`    | string    | Last updater user ID    |
| {% endtab %}            |           |                         |

{% tab title="Query Example" %}

```sql
SELECT
  name,
  description,
  last_triggered_run_id,
  unit_test_runs
FROM simulation_unit_test_sets
WHERE is_deleted = false;
```

{% endtab %}
{% endtabs %}

### Simulation Unit Test Set Runs Table

**Table Name:** `simulation_unit_test_set_runs`\
**Description:** Execution results for unit test sets

{% tabs %}
{% tab title="Schema" %}

| Column                        | Type      | Description             |
| ----------------------------- | --------- | ----------------------- |
| `_id`                         | string    | Run identifier          |
| `artifacts_generated`         | json      | Generated artifacts     |
| `created_at`                  | timestamp | Creation timestamp      |
| `creator_user_id`             | string    | Creator user ID         |
| `errored`                     | boolean   | Error status            |
| `failed_metrics`              | json      | Failed metric details   |
| `org_id`                      | string    | Organization identifier |
| `region_name`                 | string    | Deployment region       |
| `simulation_unit_test_set_id` | string    | Parent test set ID      |
| `unit_test_run_results`       | json      | Test execution results  |
| `unit_test_run_specs`         | json      | Test specifications     |
| `updated_at`                  | timestamp | Last update timestamp   |
| {% endtab %}                  |           |                         |

{% tab title="Query Example" %}

```sql
SELECT
  simulation_unit_test_set_id,
  errored,
  failed_metrics,
  unit_test_run_results,
  created_at
FROM simulation_unit_test_set_runs
ORDER BY created_at DESC;
```

{% endtab %}
{% endtabs %}
