# ADR-015: Edge type constraints as named Module entries ## Status Accepted ## Context Edge type constraints (`allowedSourceTypes`/`allowedTargetTypes`) could be stored only as DB columns (JSON text arrays) or as first-class parts of the schema with validation and serialization. ## Decision Edge type constraints are named Module entries (e.g., `TriggeredEdgeConstraints`), not just DB columns. This gives them schema validation (`Value.Check`) and serialization (JSON Schema with `$defs`). The repository layer projects these entries to the existing `edge_types.allowedSourceTypes`/`allowedTargetTypes` columns. The DB schema doesn't change — Module entries are the source of truth, DB columns are the persistence projection. Empty constraint arrays `[]` mean "no restriction" (any node type valid). Omitting the `*EdgeConstraints` entry means the same. An explicit entry with empty arrays is invalid. ## Consequences - Constraints are validatable at the schema level, not just at the DB layer - `moduleToDbSchema()` extracts constraint entries to DB columns - Constraint data survives serialization/deserialization cycles via JSON Schema `$defs` - DB columns remain `allowedSourceTypes text` and `allowedTargetTypes text` with JSON arrays ## References - [metagraph-module.md](../metagraph-module.md)