Skip to content

fix(codegen): add self-FK on simulation_branches + four enum CHECKs#79

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/simulation-fk-and-enum-checks
May 14, 2026
Merged

fix(codegen): add self-FK on simulation_branches + four enum CHECKs#79
hyperpolymath merged 1 commit into
mainfrom
fix/simulation-fk-and-enum-checks

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Summary

Per V-L2-J1: add structural enforcement that the overlay was missing.

  • simulation_branches.parent_branch self-referencing FK (NULL still allowed for root)
  • simulation_branches.status ∈ {active, merged, abandoned}
  • provenance_log.operation ∈ {insert, update, delete, transform}
  • access_policies.access_level ∈ {read, write, admin, deny}
  • lineage_graph.derivation_type ∈ {copy, transform, aggregate, join, filter}

Anything could be written to those columns before; downstream consumers had to re-validate every row.

Closes

Test plan

  • cargo clippy --all-targets -- -D warnings clean
  • cargo test --lib --bins 36/36 (1 new: test_overlay_has_enum_checks_and_fk)
  • Test asserts each FK + each CHECK by substring against the generated DDL

Closes #43.

The overlay DDL had no structural enforcement of:

  - `simulation_branches.parent_branch` referencing `branch_id`
    (self-referencing tree of branches)
  - the four enum-shaped TEXT columns:
    * `simulation_branches.status` ∈ {active, merged, abandoned}
    * `provenance_log.operation` ∈ {insert, update, delete, transform}
    * `access_policies.access_level` ∈ {read, write, admin, deny}
    * `lineage_graph.derivation_type` ∈ {copy, transform, aggregate, join, filter}

Anything could be written to those columns; downstream consumers had to
re-validate every row.

Add the FK (NULL still allowed for root branches) and the four CHECK
constraints. Test `test_overlay_has_enum_checks_and_fk` asserts each by
substring against the generated DDL.

`cargo clippy --all-targets -- -D warnings` clean; 36 unit tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@hyperpolymath hyperpolymath merged commit 454c529 into main May 14, 2026
16 of 18 checks passed
@hyperpolymath hyperpolymath deleted the fix/simulation-fk-and-enum-checks branch May 14, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V-L2-J1: simulation parent_branch FK missing + enum-shape CHECKs missing across overlay

1 participant