# Scenario Scaffolding

## Baseline Scenario

The baseline scenario is always created first. It provides the minimum data set for the app to function.

### What to include

For each entity with a create resolver:
1. Create 1-3 records — enough for referential integrity and basic queries
2. Use realistic but generic data (e.g., "Acme Corp", "Widget A")
3. Ensure all required fields are populated
4. Ensure all foreign key references point to valid IDs (from `ids.ts` or seed data)

### Data file format (JSONL)

File: `ingest/scenarios/baseline/<entity-name>/data.jsonl`

Each line is a complete JSON object. The `id` field is a deterministic UUID from `ids.ts`. All other fields match the GraphQL input type exactly.

```jsonl
{"id":"<uuid-from-ids.ts>","name":"Acme Corp","email":"contact@acme.com","isActive":true}
{"id":"<uuid-from-ids.ts>","name":"Globex Inc","email":"info@globex.com","isActive":true}
```

### Rules for baseline data

- Field names must match the GraphQL input type field names (check introspection)
- Include the `id` field — erp-kit resolvers accept client-provided IDs
- Values should be realistic and self-explanatory
- No nullable fields left as null unless testing null behavior

## Business Flow Scenarios

For each business flow doc:
1. Read the flow steps
2. Identify which mutations each step calls
3. Generate data that walks through the flow
4. Reference baseline entities where the flow depends on existing data
5. Create new entities specific to the scenario using IDs from `ids.ts`

### Example: Sales Happy Path

If the business flow describes: "Customer places an order for 2 products, order is confirmed, invoice is generated":

```
scenarios/sales-happy-path/
├── sales-order/
│   ├── entity.json
│   └── data.jsonl                # 1 order referencing baseline customer
└── sales-order-line/
    ├── entity.json
    └── data.jsonl                # 2 lines referencing baseline products
```

The SalesOrder references a customer ID from baseline. The SalesOrderLines reference product IDs from baseline and the SalesOrder ID from this scenario. All IDs come from `ids.ts`.

## Load Testing Scenarios

For bulk/stress data:
1. Generate many records (100s-1000s) using sequential deterministic IDs
2. Use `uuidv5(NS, "entity:record-N")` pattern for bulk IDs
3. Keep data simple — focus on volume, not variety
4. Add these IDs to the load section of `ids.ts` or generate inline

## Data Generation Tips

- Check the introspected schema for required vs optional fields
- Use enum values from the schema for enum fields
- For date fields, use ISO 8601 format: `"2025-01-15T00:00:00Z"`
- For decimal/float fields, use numbers not strings: `19.99` not `"19.99"`
- For boolean fields, use `true`/`false` not strings
