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.tomlfor policy parameters -
Federal parameters (FPL, allotments, standard deductions) in
federal.rs -
fakecrate 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 seedfor local convenience -
devstack/seed/seed.shfor 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
SEEDconst with named entity references + helper predicates
Verification
-
cargo clippy --workspace --all-targets — -D warnings— zero warnings -
cargo nextest run -p canopy-seed— 17 tests pass -
cargo run -p canopy-seed — --seed 42 --households 9 --output-dir /tmp/seed --manifest /tmp/seed.ts -
Inspect SQL files — valid syntax, BEGIN/COMMIT, realistic data
-
Inspect seed.ts — valid TypeScript, all entity types present
-
cargo xtask dev start --shared-db→cargo xtask seed --seed 42→ verify data in databases -
Run twice with same --seed → diff shows identical output