pgapi-enforces-referential-integrity-bidirectionally

IN derived (depth 1)

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.

Summary

The database layer protects the consistency of the justification network from both sides. Before saving a new justification, it confirms that every referenced node actually exists, and when something changes, it knows how to find every node that depends on the changed one — whether through normal antecedent links or outlist links. This matters because the underlying storage uses JSONB arrays that cannot enforce foreign keys on their own, so the application has to do that work itself to prevent dangling references and missed propagation.

Justifications

SL — Write-time validation and read-time discovery are complementary halves of PgApi's referential integrity enforcement

Antecedents (all must be IN):

  • pgapi-validates-refs-before-justification-insert — 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.
  • pgapi-find-dependents-queries-outlist — PgApi's `_find_dependents` queries both `antecedents @>` and `outlist @>` JSONB containment, correctly enqueuing outlist-dependent nodes for re-evaluation — a capability the in-memory Network historically lacked until PR #31.

Dependents

These beliefs depend on this one:

Details