# IDs Generation

## Purpose

`ingest/ids.ts` holds deterministic UUIDs for all test entities across all scenarios. It is used at **scaffold time only** — the skill reads it to produce JSONL files with consistent IDs. It is not a runtime dependency.

## Format

```typescript
import { v5 as uuidv5 } from "uuid";

// Single namespace for all ingest data
const NS = "erp-app:<app-name>:ingest";

export const ids = {
  customer: {
    acme: uuidv5(NS, "customer:acme"),
    globex: uuidv5(NS, "customer:globex"),
  },
  product: {
    widgetA: uuidv5(NS, "product:widget-a"),
    widgetB: uuidv5(NS, "product:widget-b"),
  },
  salesOrder: {
    order1: uuidv5(NS, "sales-order:order-1"),
    order2: uuidv5(NS, "sales-order:order-2"),
  },
};
```

## Rules

- One flat namespace per app: `"erp-app:<app-name>:ingest"`
- Entity keys are camelCase: `salesOrder`, not `SalesOrder` or `sales_order`
- Record keys are camelCase descriptive names: `acme`, `widgetA`, `order1`
- UUID seed strings are kebab-case: `"customer:acme"`, `"sales-order:order-1"`
- Include ALL entities and records across ALL scenarios in a single `ids` object
- When a scenario references an entity from another scenario, it uses the same ID from this file
- Seed (layer 0) entities are NOT included here — they have their own IDs from module seed exports

## How to Build

1. For each entity that has a resolver:
   - Decide how many records are needed across all scenarios
   - Give each record a descriptive name
   - Add to `ids.<entity>.<name>`
2. When generating JSONL data files, use the resolved UUID values from this file as `id` fields
3. When a JSONL row references another entity (foreign key), use the UUID from this file

## Cross-Referencing Seed IDs

If a scenario entity references a seed entity (e.g., a Product references a Currency), use the seed ID directly. Seed IDs are available from the module's seed exports:

```typescript
import { currencyIds } from "@tailor-platform/erp-kit/modules/primitives";
// currencyIds.USD → the deterministic UUID for USD
```

In the JSONL data file, hard-code the resolved UUID value.
