Plan: Deterministic Seed Data Tool

Status

Step Description Status

1

Crate scaffold: uuid, config, model, federal, jurisdiction, domain modules

Done (2026-04-05)

2

Data generation: 10-phase SeedGenerator (persons → reporting)

Done (2026-04-05)

3

SQL rendering: 11 output files with BEGIN/COMMIT transactions

Done (2026-04-05)

4

TypeScript manifest for Playwright E2E tests

Done (2026-04-05)

5

CLI with --seed, --households, --jurisdiction, --manifest flags

Done (2026-04-05)

6

Integration tests (determinism, FK consistency, scale)

Done (2026-04-05)

7

xtask seed command and devstack/seed/seed.sh

Done (2026-04-05)

8

Documentation and validation

Done (2026-04-05)

Epic: &38
Issues: TBD
Branch: feature/seed-data-tool
Labels: type::feature, priority::high, program::infrastructure, service::seed

Context

E2E tests need real data in the devstack — there is nothing to search for, no cases to view, no applications to approve without seed data. The dependency chain is: seed data → Playwright E2E → security hardening validation.

CRAIG’s seed tool (tools/craig-seed) is the proven pattern: standalone Rust binary generating deterministic SQL + TypeScript manifest. Same seed = identical output. Tests use semantic predicates on the manifest, not hardcoded values.

Scope

In scope:

  • tools/canopy-seed/ — standalone binary + library crate

  • 10-phase data generation across all 11 databases (40+ tables)

  • Deterministic UUIDv7 generator with monotonic counter

  • Jurisdiction-neutral: reads rulesets/{jurisdiction}/jurisdiction.toml for policy parameters

  • Federal parameters (FPL, allotments, standard deductions) in federal.rs

  • fake crate for realistic names/addresses (no hardcoded Georgia data)

  • 11 SQL output files loaded via psql

  • TypeScript manifest with named entity refs and find helpers

  • cargo xtask seed for local convenience

  • devstack/seed/seed.sh for Docker integration

  • 17 tests (7 unit + 10 integration)

Out of scope:

  • Docker seed service in docker-compose (future — currently manual via cargo xtask seed)

  • Playwright E2E tests (separate plan, depends on this)

  • Rule set loading via API (uses SQL INSERT for now)

Design

Architecture follows CRAIG’s proven pattern (ADR-006 compliant):

  • Two seeded RNGs: uuid_rng = StdRng::seed_from_u64(seed), data_rng = StdRng::seed_from_u64(seed.wrapping_add(1))

  • First 2 households force all optional branches (force_all = i < 2) for guaranteed test coverage

  • Custom UUIDv7 generator with monotonic counter ensures time-ordered, deterministic IDs

  • SQL rendered with BEGIN/COMMIT transactions, multi-row INSERTs, proper escaping

  • TypeScript manifest exports SEED const with named entity references + helper predicates

Verification

  1. cargo clippy --workspace --all-targets — -D warnings — zero warnings

  2. cargo nextest run -p canopy-seed — 17 tests pass

  3. cargo run -p canopy-seed — --seed 42 --households 9 --output-dir /tmp/seed --manifest /tmp/seed.ts

  4. Inspect SQL files — valid syntax, BEGIN/COMMIT, realistic data

  5. Inspect seed.ts — valid TypeScript, all entity types present

  6. cargo xtask dev start --shared-db → cargo xtask seed --seed 42 → verify data in databases

  7. Run twice with same --seed → diff shows identical output

Documentation Updates

  • .claude/docs/local-dev.md — seed usage documentation

  • CHANGELOG.adoc — canopy-seed entry

Edit this page · default