> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ellomas.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Determinism

> How deterministic seeding and unique constraint enforcement work.

# Determinism

Seedling guarantees that **the same schema + generators + seed + count produces identical output every time**.

## Seeding

When you provide `--seed <int>`, Seedling uses a **ChaCha8-based deterministic PRNG**:

* The master seed derives per-column, per-row sub-seeds
* Every generator uses its deterministic sub-seed instead of `crypto/rand`
* The order of generation is fixed (topological sort is stable)
* Output is byte-identical across runs

```bash theme={null}
seedling generate --count 50000 --seed 42 --output seed.sql
# Run again — output is byte-identical
```

## Random Mode

Without a seed (`--seed 0`), Seedling uses `crypto/rand` for true randomness. Each run produces different data.

## Unique Constraints

The `UniqueTracker` enforces UNIQUE constraints during generation:

* Tracks all generated unique column values in memory
* On collision, retries with a new random value
* Falls back to sequential IDs if collisions are too frequent (exhaustion guard)
* For large datasets, a Bloom filter reduces memory usage (pending)

## Determinism Contract

| Input                                  | Same Output?                                  |
| -------------------------------------- | --------------------------------------------- |
| Same schema + seed + count             | Yes — byte-identical                          |
| Different seed                         | Different data                                |
| Different count                        | Different data (rows added/removed)           |
| `--parallel`                           | Different — parallel execution reorders rows  |
| Same input, different Seedling version | Best-effort (may differ if generators change) |
