pgapi-validates-refs-before-justification-insert
IN premise
PgApi's `_validate_refs` checks all antecedent and outlist node IDs exist in `rms_nodes` before inserting a justification, providing application-level referential integrity that compensates for JSONB arrays' inability to enforce foreign key constraints.
Summary
When adding a justification that references other nodes, the system first verifies those nodes actually exist in the database. This is necessary because justifications store their references as JSON arrays rather than proper foreign key columns, so the database itself cannot enforce that referenced nodes are real — the application code has to do that check manually to prevent dangling references.
Dependents
These beliefs depend on this one:
- pgapi-enforces-referential-integrity-bidirectionally — PgApi enforces referential integrity in both directions: write-time validation checks all antecedent and outlist IDs exist before inserting justifications, while read-time dependent discovery queries both antecedent and outlist JSONB containment to find all affected nodes.
Details
| Source | entries/2026/04/29/session-summary.md |