Strengthen ER integrity and schema governance #29
Merged
wasabi opened 2 weeks ago

Summary

Applies Entity-Relationship Model principles to the PostgreSQL schema, integrity controls, and CI workflow while preserving PostgreSQL as the canonical source of truth.

Changes

  • Adds operational ownership validation across locations, farms, plots, crop cycles, harvests, sales, activities, and expenses.
  • Adds a read-only PostgreSQL ER inventory CLI and CI report.
  • Adds explicit associative entities for farmer crops, metric provenance, cooperative board membership, forecast assumptions, and role permissions.
  • Adds semantic cardinality and uniqueness constraints for KYC, role assignments, metrics, temporal ordering, and forecast versions.
  • Adds a governed retirement registry for remaining polymorphic references.
  • Documents ER relationship review and schema-change workflow.

Verification

  • python3 -m pytest tests/test_migration.py tests/test_schema_introspection.py tests/test_schema_introspection_risks.py tests/test_relational_integrity.py tests/test_relationship_entities.py tests/test_relationship_reference_policy.py tests/test_cardinality_constraints.py tests/test_strategy_markup.py tests/test_strategy_map.py -q (29 passed, 10 skipped)
  • Focused platform-integrity suite: 246 passed, 1 skipped
  • tod build check-spec passed
  • Migration discovery validated migrations 308-311 in order
  • python3 -m py_compile services/schema_introspection/*.py
  • git diff --check

The local Docker-backed migration dry-run could not execute because the Docker daemon was unavailable; CI will perform the database-backed migration verification.

Commits were merged into target branch
1/1
Submitter wasabi
Target main
Source feat/er-integrity-foundations
Jobs
Merge Strategy
Create Merge Commit
Watchers (1)
Reference
pull request KI-29
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover