feat(seed): canonical seed-file schema, validation, and safety gates (PSA-50) #342
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PSA-50-seed-import-foundation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
First increment of the file-driven seed mechanism (PSA-50). Seed data lives as a JSON file, not in code. This PR lands the foundation the loader and
seedCLI build on, fully unit-tested, so the schema, reset key, and safety guard are settled and verifiable before any DB-write path exists. The DB-touching parts follow on this branch, integration-tested against Postgres (which the workspace/container check cannot run).What's here (all pure, all unit-tested)
SeedFile):application_groups,applications,users(with DB-only membership state: status/tier/lifetime/price-lock),entitlements,feedback.deny_unknown_fieldsso a typo fails loudly instead of importing silently-wrong data.parse(): rejects an unsupported version, then runs full structural + referential validation - unique slugs/emails, app -> group and entitlement -> user/app references resolve, feedback carries a non-empty message.SeedError::Validationcollects every problem at once.demo.psa-systems.test. That is the reset key: a reset scopes to exactly these rows and can never touch a real account.is_seed_emailis the predicate; validation enforces it at parse time.seed_guard(): mirrors thebunyip-e2e-bootstrapgate - an explicit allow flag plus a non-production environment; unset/production/prodare blocked.Follow-up on this branch (next commit)
The DB-touching parts, which the
--all-targetscontainer check cannot exercise (no Postgres), so they land with Postgres-backed integration tests:SeedFileto rows through the domain repositories (UserRepository+PasswordService,ApplicationRepository,ApplicationGroupRepository,EntitlementRepository,FeedbackRepository), idempotent by the reserved domain.seed import <file>/seed resetCLI bin, guarded byseed_guard.bunyip-e2e-bootstrapin favour of a committed template.Remaining PSA-50 acceptance criteria
Covered here: reset key + safety guard (ACs 4, 5 foundations), schema for all listed entities (AC 1 foundation). Still open, in the follow-up: loader-through-services (AC 1), membership DB state (AC 2), idempotent import (AC 3), reset scoping behavior (AC 4), e2e-bootstrap retirement (AC 6), DB integration tests (AC 7).
Verification
just check-containergreen: fmt + clippy-D warnings+cargo test --workspace --all-targets. 9 newseed::testspass (parse, version reject, unknown-field reject, is_seed_email, guard matrix, and four validation cases).seedCLI for file-driven seed data