ContractSpec docs

OSS-first docs

These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.

EntityRegistry — Entity & Edge Contract Registry

EntityRegistry stores ContractEntitySpec and ContractEdgeSpec instances, then exposes a unified listEdges() view for graph renderers.

field.key.label
EntityRegistry — Entity & Edge Contract Registry
field.version.label
field.type.label
field.title.label
EntityRegistry — Entity & Edge Contract Registry
field.description.label

EntityRegistry stores ContractEntitySpec and ContractEdgeSpec instances, then exposes a unified listEdges() view for graph renderers.

field.tags.label
tech,contracts,entities,registry,graph
field.owners.label
field.stability.label
public

Purpose

`EntityRegistry` is the single runtime store for entity and edge contracts. It extends `SpecContractRegistry<'entity', ContractEntitySpec>` and adds a secondary edge map for named `ContractEdgeSpec` entries.

Initialization (C12 Precondition)

The registry **must** be initialized (entities and edges registered) before any graph `DataViewRenderer` reads entity slugs or edge relationships. Inline-edge-only views do not share this requirement.

API Summary

| Method | Description | |--------|-------------| | `register(spec)` | Register a `ContractEntitySpec` (inherited). | | `registerEdge(spec)` | Register a named `ContractEdgeSpec`. | | `list()` | List all entity specs (inherited). | | `listEdgeSpecs()` | List all named edge specs. | | `listEdges()` | Unified flat list of all `EdgeSpec` (inline + named). | | `get(key, version?)` | Retrieve entity spec by key (inherited). | | `getEdge(key, version?)` | Retrieve named edge spec by key. |

Example

const registry = new EntityRegistry([UserEntity, ProjectEntity]);
registry.registerEdge(UserToProjectEdge);

const edges = registry.listEdges();
// [{ id: 'user-to-project', from: 'user', to: 'project', relation: 'has-many', cardinality: 'one-to-many', ... }]