Skip to content

dsm schema (v0.2)

The models/dsm.json file is validated by the normative JSON Schema published at its canonical URL:

PropertyTypeRequiredDescription
kind"dsm-file"yes
schemaVersion"0.2.0" | "0.1.0"yesCurrent DSM schema version. Accepts 0.1.0 (legacy) and 0.2.0 (current — additive: optional notes annotations). Parse normalizes output to 0.2.0 (read old, write current).
tablesDsmTable[]yes
enumsDsmEnum[]yes
migrationsDsmMigration[]yes
storageTypesStorageType[]nov1 (TS-core-128): optional. When absent, inferred from tables (legacy shape — all tables default to relational_sql on a synthetic default container). When present, may be omitted entirely and the parser will infer types from data sources.
dataContainersDataContainer[]nov1: optional. The physical/logical media hosting one or more data sources. May be omitted; a synthetic default container is created.
containerEdgesContainerEdge[]nov1: optional. Typed relationships between data containers.
dataSourcesDataSource[]nov1: optional. Addressable instances of storage types. When absent, synthesized from the legacy tables array.
notesModelNote[]noNode notes (see parser/model-note.ts).
VisualisationSetupVisualisationSetupno

Consistency model. Documentation-only in v1.

Type: string — known values: "strong", "serializable", "snapshot", "read_committed", "eventual", "causal", "read_your_writes", "crdt", "lww", "quorum", "append_only", "wom" (others allowed)

PropertyTypeRequiredDescription
kind"container_edge"yes
fromstringyes
tostringyes
typeContainerEdgeTypeyes
viastringno
protocolstringnoOptional transport hint for the edge (e.g. "tcp", "grpc") — surfaced in the topology artifact's metadata.protocol.
lag_target_msnumberno
notestringno
notesModelNote[]noNode notes (see parser/model-note.ts).

Container Edge type — a typed relationship between two Data Containers. v1 ships 3 types: composition, streaming, gateway. Other types (mirror, federation, cache, migration, alias, parent_child) are deferred.

Type: string — known values: "composition", "streaming", "gateway" (others allowed)

PropertyTypeRequiredDescription
kind"data_container"yes
idstringyes
typestringyes
hoststringno
base_urlstringno
brokersstring[]no
rootstringno
credentials_refstringno
descriptionstringno
notesModelNote[]noNode notes (see parser/model-note.ts).
PropertyTypeRequiredDescription
kind"data_source"yes
idstringyes
typeStorageTypeyes
containerstringyes
schemaDataSourceSchemano
accessDataSourceAccessno
ownershipOwnershipModelno
consistencyConsistencyModelno
descriptionstringno
traceabilityDsmTraceabilityno
notesModelNote[]noNode notes (see parser/model-note.ts).

Access pattern declaration. Optional, documentation-only in v1. Future v1.1+ may use this to influence generator choices.

PropertyTypeRequiredDescription
patterns("read" | "write" | "append" | "stream" | "subscribe" | "query")[]no
freshness"realtime" | "near-realtime" | "batch" | "manual"no

A typed schema declaration within a Data Source. The shape depends on the source’s type. For v1:

Type: RelationalSqlSchema | FilesystemSchema | Record<string, unknown>

PropertyTypeRequiredDescription
kind"column"yes
namestringyes
dataTypestringyes
primaryKeybooleanno
uniquebooleanno
nullablebooleanno
defaultValuestringno
referencesDsmReferenceno
PropertyTypeRequiredDescription
kind"constraint"yes
namestringyes
type"check" | "unique" | "not_null"yes
expressionstringno
PropertyTypeRequiredDescription
kind"enum"yes
namestringyes
valuesstring[]yes
defaultstringno
notesModelNote[]noNode notes (see parser/model-note.ts).
PropertyTypeRequiredDescription
kind"index"yes
namestringyes
columnsstring[]yes
uniquebooleanno
PropertyTypeRequiredDescription
kind"migration"yes
versionstringyes
descriptionstringno
deltaFromstringno
changesstring[]yes
PropertyTypeRequiredDescription
tablestringyes
columnstringyes
PropertyTypeRequiredDescription
kind"table"yes
namestringyes
idstringnoOptional canvas-node id. The DsmFile itself only uses name as the identifier; the canvas UI (apps/web/src/lib/canvas/validate-dsm-canvas.ts and friends) injects the Svelte Flow node id here so validation results can be linked back to the visual node. Not part of the on-disk format.
aggregatestringno
descriptionstringno
columnsDsmColumn[]yes
constraintsDsmConstraint[]yes
indexesDsmIndex[]yes
traceabilityDsmTraceabilityno
notesModelNote[]noNode notes (see parser/model-note.ts).
PropertyTypeRequiredDescription
dddstring[]no
cbrlstring[]no
aspectsstring[]no
PropertyTypeRequiredDescription
kind"filesystem"yes
pathstringyes
format"jsonl" | "json" | "csv" | "parquet" | "text" | "binary"yes
encodingstringno
append_onlybooleanno
keysstring[]no
mimestringno
etagstringno
PropertyTypeRequiredDescription
kind"model-note"yes
idstringyesStable id ("note-" + 12 hex chars); survives JSON round-trips.
audienceModelNoteAudienceyesWho the note is for. Drives delivery: only "agent" reaches agent payloads.
textstringyesMarkdown body.
authorstringno
createdAtstringnoISO 8601 timestamps.
updatedAtstringno
resolvedbooleannoLifecycle flag — resolved ≠ deleted.
fieldstringnoOptional sub-node scope: a member/property name of the anchored node.

Type: "user" | "agent"

Ownership model. Documentation-only in v1.

Type: string — known values: "owned", "borrowed", "federated", "cached", "shared", "public", "user_generated", "agent_generated", "synthetic" (others allowed)

PropertyTypeRequiredDescription
kind"relational_sql"yes
tablestringyes
columnsarrayno
constraintsarrayno
indexesarrayno

Storage Type — the schema grammar + operations vocabulary for a category of data source. ADR-026: extends DSM beyond relational-only.

Type: string — known values: "relational_sql", "filesystem", "rest_api", "queue_stream", "object_store", "vector_store", "log", "kv" (others allowed)

INTERNAL: Context Studio canvas state only; never emitted to coding agents.

PropertyTypeRequiredDescription
nodePositionsRecord<string, object>yes
zoomLevelnumberyes
viewportobjectno
updatedAtstringno

Representative models/dsm.json files committed under samples/dsm/. Each demo shows four views — pick the one you want: Canvas (rendered through the same SvelteFlow component the IDE uses), Mermaid (a static-flowchart fallback), Interactive (the live artifact ctx diagram <file> compiles — pan, zoom, click-to-trace, guided stories, exports), or Raw JSON. All assets are locally served; no GitHub redirect.

↓ download

Live artifact compiled by ctx diagram — pan & zoom,/ to find a node, click one to trace reach, T theme, P guided story, ? for all shortcuts.

demo-01-todos-table.json — Context Studio canvas view

Demo 1 — minimal DSM file: a single table (todos) with columns, a CHECK constraint, and an auto-default. The smallest viable DSM shape.

demo-01-todos-table.json — Demo 1 — minimal DSM file: a single table (todos) with columns, a CHECK constraint, and an auto-default. The smallest viable DSM shape. (expand for full JSON)
demo-01-todos-table.json
{
"kind": "dsm-file",
"schemaVersion": "0.1.0",
"tables": [
{
"kind": "table",
"name": "todos",
"description": "A list of todo items.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "title",
"dataType": "VARCHAR(255)",
"nullable": false
},
{
"kind": "column",
"name": "completed",
"dataType": "BOOLEAN",
"defaultValue": "false"
},
{
"kind": "column",
"name": "created_at",
"dataType": "TIMESTAMP",
"defaultValue": "now()"
}
],
"constraints": [
{
"kind": "constraint",
"name": "chk_title_not_blank",
"type": "check",
"expression": "length(title) > 0"
}
],
"indexes": []
}
],
"enums": [],
"migrations": []
}
↓ download

Live artifact compiled by ctx diagram — pan & zoom,/ to find a node, click one to trace reach, T theme, P guided story, ? for all shortcuts.

demo-02-travel-tables.json — Context Studio canvas view

Demo 2 — multi-table DSM with FK-less linked tables (passengers, flights), check constraints on format + age, and indexes on hot query paths. The canonical 'realistic' example.

demo-02-travel-tables.json — Demo 2 — multi-table DSM with FK-less linked tables (passengers, flights), check constraints on format + age, and indexes on hot query paths. The canonical ‘realistic’ example. (expand for full JSON)
demo-02-travel-tables.json
{
"kind": "dsm-file",
"schemaVersion": "0.1.0",
"tables": [
{
"kind": "table",
"name": "passengers",
"aggregate": "Passenger",
"description": "Passenger profiles.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "email",
"dataType": "VARCHAR(255)",
"unique": true,
"nullable": false
},
{
"kind": "column",
"name": "first_name",
"dataType": "VARCHAR(100)",
"nullable": false
},
{
"kind": "column",
"name": "last_name",
"dataType": "VARCHAR(100)",
"nullable": false
},
{
"kind": "column",
"name": "date_of_birth",
"dataType": "DATE",
"nullable": false
}
],
"constraints": [
{
"kind": "constraint",
"name": "chk_email_format",
"type": "check",
"expression": "email ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$'"
},
{
"kind": "constraint",
"name": "chk_adult_passenger",
"type": "check",
"expression": "date_of_birth <= CURRENT_DATE - INTERVAL '18 years'"
}
],
"indexes": [
{
"kind": "index",
"name": "idx_passenger_email",
"columns": ["email"]
}
]
},
{
"kind": "table",
"name": "flights",
"aggregate": "Flight",
"description": "Flight schedule and seat inventory.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "flight_number",
"dataType": "VARCHAR(10)",
"unique": true,
"nullable": false
},
{
"kind": "column",
"name": "origin",
"dataType": "CHAR(3)",
"nullable": false
},
{
"kind": "column",
"name": "destination",
"dataType": "CHAR(3)",
"nullable": false
},
{
"kind": "column",
"name": "departure_time",
"dataType": "TIMESTAMP",
"nullable": false
},
{
"kind": "column",
"name": "available_seats",
"dataType": "INTEGER",
"defaultValue": "0"
}
],
"constraints": [
{
"kind": "constraint",
"name": "chk_seats_non_negative",
"type": "check",
"expression": "available_seats >= 0"
}
],
"indexes": [
{
"kind": "index",
"name": "idx_flight_route",
"columns": ["origin", "destination", "departure_time"]
}
]
}
],
"enums": [],
"migrations": []
}
↓ download

Live artifact compiled by ctx diagram — pan & zoom,/ to find a node, click one to trace reach, T theme, P guided story, ? for all shortcuts.

demo-03-orders-with-fk.json — Context Studio canvas view

Demo 3 — DSM with explicit foreign keys (orders → customers, order_lines → orders), enums, composite defaults, and per-table CHECK constraints.

demo-03-orders-with-fk.json — Demo 3 — DSM with explicit foreign keys (orders → customers, order_lines → orders), enums, composite defaults, and per-table CHECK constraints. (expand for full JSON)
demo-03-orders-with-fk.json
{
"kind": "dsm-file",
"schemaVersion": "0.1.0",
"tables": [
{
"kind": "table",
"name": "orders",
"description": "Order header table.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "customer_id",
"dataType": "UUID",
"nullable": false
},
{
"kind": "column",
"name": "total",
"dataType": "NUMERIC(12,2)",
"nullable": false
},
{
"kind": "column",
"name": "currency",
"dataType": "CHAR(3)",
"defaultValue": "USD"
},
{
"kind": "column",
"name": "status",
"dataType": "order_status",
"nullable": false,
"defaultValue": "draft"
},
{
"kind": "column",
"name": "created_at",
"dataType": "TIMESTAMP",
"defaultValue": "now()"
}
],
"constraints": [
{
"kind": "constraint",
"name": "chk_total_positive",
"type": "check",
"expression": "total > 0"
}
],
"indexes": [
{
"kind": "index",
"name": "idx_orders_customer",
"columns": ["customer_id"]
},
{
"kind": "index",
"name": "idx_orders_status",
"columns": ["status"]
}
]
},
{
"kind": "table",
"name": "order_lines",
"description": "Order line items.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "order_id",
"dataType": "UUID",
"nullable": false
},
{
"kind": "column",
"name": "sku",
"dataType": "VARCHAR(50)",
"nullable": false
},
{
"kind": "column",
"name": "quantity",
"dataType": "INTEGER",
"nullable": false,
"defaultValue": "1"
},
{
"kind": "column",
"name": "unit_price",
"dataType": "NUMERIC(12,2)",
"nullable": false
}
],
"constraints": [
{
"kind": "constraint",
"name": "chk_quantity_positive",
"type": "check",
"expression": "quantity > 0"
},
{
"kind": "constraint",
"name": "chk_unit_price_non_negative",
"type": "check",
"expression": "unit_price >= 0"
}
],
"indexes": [
{
"kind": "index",
"name": "idx_order_lines_order",
"columns": ["order_id"]
}
]
}
],
"enums": [],
"migrations": []
}
↓ download

Live artifact compiled by ctx diagram — pan & zoom,/ to find a node, click one to trace reach, T theme, P guided story, ? for all shortcuts.

demo-04-users-roles-m2m.json — Context Studio canvas view

Demo 4 — DSM with a many-to-many join table (user_roles) including a composite primary-key constraint. Exercises the relationship vocabulary.

demo-04-users-roles-m2m.json — Demo 4 — DSM with a many-to-many join table (user_roles) including a composite primary-key constraint. Exercises the relationship vocabulary. (expand for full JSON)
demo-04-users-roles-m2m.json
{
"kind": "dsm-file",
"schemaVersion": "0.1.0",
"tables": [
{
"kind": "table",
"name": "users",
"description": "Users of the platform.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "email",
"dataType": "VARCHAR(255)",
"unique": true,
"nullable": false
},
{
"kind": "column",
"name": "created_at",
"dataType": "TIMESTAMP",
"defaultValue": "now()"
}
],
"constraints": [],
"indexes": [
{
"kind": "index",
"name": "idx_users_email",
"columns": ["email"],
"unique": true
}
]
},
{
"kind": "table",
"name": "roles",
"description": "Static role lookup table.",
"columns": [
{
"kind": "column",
"name": "id",
"dataType": "UUID",
"primaryKey": true,
"defaultValue": "gen_random_uuid()"
},
{
"kind": "column",
"name": "name",
"dataType": "VARCHAR(50)",
"unique": true,
"nullable": false
}
],
"constraints": [],
"indexes": [
{
"kind": "index",
"name": "idx_roles_name",
"columns": ["name"],
"unique": true
}
]
},
{
"kind": "table",
"name": "user_roles",
"description": "Many-to-many join between users and roles.",
"columns": [
{
"kind": "column",
"name": "user_id",
"dataType": "UUID",
"nullable": false
},
{
"kind": "column",
"name": "role_id",
"dataType": "UUID",
"nullable": false
},
{
"kind": "column",
"name": "granted_at",
"dataType": "TIMESTAMP",
"defaultValue": "now()"
}
],
"constraints": [
{
"kind": "constraint",
"name": "uq_user_roles_composite",
"type": "unique"
}
],
"indexes": [
{
"kind": "index",
"name": "idx_user_roles_user",
"columns": ["user_id"]
},
{
"kind": "index",
"name": "idx_user_roles_role",
"columns": ["role_id"]
},
{
"kind": "index",
"name": "uq_user_roles_composite",
"columns": ["user_id", "role_id"],
"unique": true
}
]
}
],
"enums": [],
"migrations": []
}

The dsm model is one of the richly-curated records — every downstream surface (CLI, MCP, docs, tests) reads from one record. The pasteable snippet below is the Door 1 anchor a downstream agent should see before touching this model.

paste into AGENTS.md / CLAUDE.md
- **DSM v0.2.0** — `models/dsm.json`.
Produces: Data dictionary, Drizzle ORM schema, SQL DDL, schema tests, migration tests.
Oracle: schema and migration tests must pass against the generated DDL/ORM code.
Downstream: `ctxbrew semantics dsm` · `ctxbrew://semantics/dsm/v0.2.0` — read the record first.

The full record (every door — anchor template, tool description hint, response annotations, behavior tripwire, and the complete produced-surface list) is served as JSON at:

  • CLI — ctxbrew semantics dsm --schema-version 0.2.0
  • MCP — ctxbrew://semantics/dsm/v0.2.0
  • HTTP — https://contextbrew.dev/schemas/dsm/v0.2/semantics.json

See the schemas overview for the versioning policy and how these files are generated and kept in sync.