pg-antecedent-refs-have-no-fk-constraints
IN premise
Antecedent and outlist references in `rms_justifications` are JSONB arrays without foreign key constraints; nonexistent referenced nodes default to truth value OUT via `truth_cache.get(a, "OUT")`.
Summary
The justification table stores references to other nodes as plain JSON arrays rather than enforcing referential integrity at the database level. This means the system silently treats any referenced node that doesn't actually exist as if it were false (OUT), which could mask bugs where a node ID is misspelled or a node is deleted without cleaning up references to it.
Dependents
These beliefs depend on this one:
- pg-data-integrity-achieves-defense-in-depth — PgApi's data integrity achieves defense-in-depth through both application-level enforcement (write-time referential validation and outlist-aware dependent queries spanning antecedent and outlist references) and comprehensive input validation at all system boundaries, but full defense-in-depth requires database-level foreign key constraints to provide a second independent enforcement layer
- pg-multi-tenancy-is-referentially-complete — PgApi's multi-tenant isolation with composite primary keys and application-level BFS propagation prevents all cross-project data leakage and ensures consistent truth maintenance — unless antecedent references stored as JSONB arrays lack foreign key constraints, allowing phantom node references within a project.
- pgapi-referential-integrity-is-database-enforced — PgApi achieves complete referential integrity: application-level bidirectional enforcement (write-time validation and outlist-aware dependent querying) is complemented by database-level foreign key constraints, preventing orphaned justification references even under direct SQL manipulation outside the application layer.
Details
| Source | entries/2026/04/29/reasons_lib-pg.md |