sim schema (v0.4)
The models/sim.json file is validated by the normative JSON Schema published at its canonical URL:
- $id: https://contextbrew.dev/schemas/sim/v0.4/schema.json
- Format version:
0.4.0 - Schema dialect: draft-07
- Validate with:
ctx schema simor any JSON Schema validator (ajv, VS Code, …)
Root object: SimFile
Section titled “Root object: SimFile”| Property | Type | Required | Description |
|---|---|---|---|
kind | "sim-file" | yes | |
schemaVersion | SimSchemaVersion | yes | |
contexts | SimSystemContext[] | yes | |
edges | SimDependencyEdge[] | yes | |
contracts | SimContract[] | yes | |
invariants | SimCrossCuttingInvariant[] | yes | |
notes | ModelNote[] | no | Node notes (see parser/model-note.ts). |
VisualisationSetup | VisualisationSetup | no |
Definitions
Section titled “Definitions”CriticalityId
Section titled “CriticalityId”Type: "critical" | "standard" | "internal"
ModelNote
Section titled “ModelNote”| Property | Type | Required | Description |
|---|---|---|---|
kind | "model-note" | yes | |
id | string | yes | Stable id ("note-" + 12 hex chars); survives JSON round-trips. |
audience | ModelNoteAudience | yes | Who the note is for. Drives delivery: only "agent" reaches agent payloads. |
text | string | yes | Markdown body. |
author | string | no | |
createdAt | string | no | ISO 8601 timestamps. |
updatedAt | string | no | |
resolved | boolean | no | Lifecycle flag — resolved ≠ deleted. |
field | string | no | Optional sub-node scope: a member/property name of the anchored node. |
ModelNoteAudience
Section titled “ModelNoteAudience”Type: "user" | "agent"
SimComponentType
Section titled “SimComponentType”Type: "ddd_aggregate" | "ddd_value_object" | "ddd_domain_event" | "usm_story" | "usm_persona" | "cbrl_requirement" | "scm_screen" | "dsm_table" | "dsm_schema"
SimContextComponent
Section titled “SimContextComponent”| Property | Type | Required | Description |
|---|---|---|---|
kind | "context-component" | yes | |
id | string | yes | |
systemContextId | string | yes | |
componentType | SimComponentType | yes | |
componentId | string | yes | |
componentName | string | yes |
SimContextKind
Section titled “SimContextKind”Type: "service" | "bounded-context" | "serverless-function" | "module"
SimContract
Section titled “SimContract”| Property | Type | Required | Description |
|---|---|---|---|
kind | "contract" | yes | |
id | string | yes | |
name | string | yes | |
contractType | SimContractType | yes | |
schema | Record<string, unknown> | yes | |
version | string | yes | |
status | SimContractStatus | yes | |
versioningStrategy | SimContractVersioningStrategy | no | Versioning semantics for the version field. Defaults to "semver". |
edgeSourceId | string | no | |
edgeTargetId | string | no | |
edgeType | SimEdgeType | no | |
notes | ModelNote[] | no | Node notes (see parser/model-note.ts). |
SimContractStatus
Section titled “SimContractStatus”Type: "draft" | "active" | "deprecated" | "retired"
SimContractType
Section titled “SimContractType”Type: "api" | "event" | "database"
SimContractVersioningStrategy
Section titled “SimContractVersioningStrategy”How a contract’s version field is interpreted and bumped. - semver (default): MAJOR.MINOR.PATCH semantic versioning. - calver: Calendar-based (YYYY.MM.DD or similar) — diffs still emit contract_version_bump records but the level is inferred from string change rather than semver rules. - immutable: Contract version never changes; any version diff is a breaking major-level signal (the contract was replaced in place).
Type: "semver" | "calver" | "immutable"
SimCriticality
Section titled “SimCriticality”Type: "low" | "medium" | "high" | "critical"
SimCrossCuttingInvariant
Section titled “SimCrossCuttingInvariant”| Property | Type | Required | Description |
|---|---|---|---|
kind | "cross-cutting-invariant" | yes | |
id | string | yes | |
name | string | yes | |
expression | string | yes | |
involvedContexts | | yes | |
severity | SimInvariantSeverity | yes | |
category | SimInvariantCategory | yes | |
notes | ModelNote[] | no | Node notes (see parser/model-note.ts). |
SimDependencyEdge
Section titled “SimDependencyEdge”| Property | Type | Required | Description |
|---|---|---|---|
kind | "dependency-edge" | yes | |
id | string | yes | |
sourceContextId | string | yes | |
targetContextId | string | yes | |
edgeType | SimEdgeType | yes | |
contractId | string | no | |
description | string | no | |
criticality | SimCriticality | yes | |
criticalityTier | CriticalityId | no | Platform criticality canon tier (0.3.0 — C19-A), overriding the legacy severity→tier mapping. Optional and OMITTED when unset, so pre-0.3.0 models produce byte-identical files. Read paths must use effectiveCriticality (criticalityTier ?? simSeverityToCriticality). |
notes | ModelNote[] | no | Node notes (see parser/model-note.ts). |
SimEdgeType
Section titled “SimEdgeType”Type: "synchronous" | "asynchronous" | "shared-database" | "event-driven"
SimInvariantCategory
Section titled “SimInvariantCategory”Type: "consistency" | "performance" | "security" | "compliance"
SimInvariantSeverity
Section titled “SimInvariantSeverity”Type: "warning" | "error" | "critical"
SimMonthlyCost
Section titled “SimMonthlyCost”Declared monthly running cost of a service (0.2.0 — M25 cost overlays; the Vantage/CloudZero “$/service” lens). Optional and OMITTED when unknown, so cost-free models produce byte-identical files. Observed costs arrive separately via the M4 live-state collector convention — this is the declared, authored number.
| Property | Type | Required | Description |
|---|---|---|---|
amount | number | yes | Monthly amount in currency (e.g. 420, 1240.5). |
currency | string | yes | ISO 4217 code (e.g. "USD", "EUR"). |
source | string | no | Where the number came from (e.g. "aws-cost-explorer", "estimate"). |
SimSchemaVersion
Section titled “SimSchemaVersion”Type: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0"
SimSystemContext
Section titled “SimSystemContext”| Property | Type | Required | Description |
|---|---|---|---|
kind | "system-context" | yes | |
id | string | yes | |
name | string | yes | |
contextKind | SimContextKind | yes | |
description | string | no | |
ownedAggregates | | no | |
ownedScreens | | no | |
ownedTables | | no | |
tags | | no | |
components | SimContextComponent[] | no | The authoritative cross-model reference list (typed, per T14). |
position | object | no | |
aspects | Record<string, Record<string, unknown>> | no | |
monthlyCost | SimMonthlyCost | no | Declared monthly running cost (0.2.0 — M25 cost overlays). |
notes | ModelNote[] | no | Node notes (see parser/model-note.ts). |
VisualisationSetup
Section titled “VisualisationSetup”INTERNAL: Context Studio canvas state only; never emitted to coding agents.
| Property | Type | Required | Description |
|---|---|---|---|
nodePositions | Record<string, object> | yes | |
zoomLevel | number | yes | |
viewport | object | no | |
updatedAt | string | no |
Sample documents
Section titled “Sample documents”Representative models/sim.json files committed under samples/sim/. 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.
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.
Open the raw JSON in a new tab(demo-01-single-context.json). The full source is also expanded in the <details> below this preview.
Demo 1 — minimal SIM file: a single context, no edges. The smallest viable SIM shape.
demo-01-single-context.json — Demo 1 — minimal SIM file: a single context, no edges. The smallest viable SIM shape. (expand for full JSON)
{ "kind": "sim-file", "schemaVersion": "0.1.0", "contexts": [ { "kind": "system-context", "id": "ctx-app", "name": "Application", "contextKind": "service", "description": "Single-context demo.", "ownedAggregates": ["Order"], "ownedTables": ["orders"] } ], "edges": [], "contracts": [], "invariants": []}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.
Open the raw JSON in a new tab(demo-02-orders-billing.json). The full source is also expanded in the <details> below this preview.
Demo 2 — SIM with two contexts and a synchronous dependency edge tagged critical. The canonical 'realistic' example.
demo-02-orders-billing.json — Demo 2 — SIM with two contexts and a synchronous dependency edge tagged critical. The canonical ‘realistic’ example. (expand for full JSON)
{ "kind": "sim-file", "schemaVersion": "0.3.0", "contexts": [ { "kind": "system-context", "id": "ctx-orders", "name": "Orders", "contextKind": "service", "description": "Owns the order lifecycle.", "ownedAggregates": ["Order"], "ownedTables": ["orders", "order_lines"] }, { "kind": "system-context", "id": "ctx-billing", "name": "Billing", "contextKind": "module", "description": "Owns invoicing and payments.", "ownedAggregates": ["Invoice", "Payment"], "ownedTables": ["invoices", "payments"] } ], "edges": [ { "kind": "dependency-edge", "id": "edge-orders-billing", "sourceContextId": "ctx-orders", "targetContextId": "ctx-billing", "edgeType": "synchronous", "criticality": "critical", "criticalityTier": "critical", "contractId": "contract-billing-api", "description": "Orders calls Billing to issue invoices." } ], "contracts": [ { "kind": "contract", "id": "contract-billing-api", "name": "Billing API", "contractType": "api", "schema": {}, "version": "1.0.0", "status": "active" } ], "invariants": []}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.
Open the raw JSON in a new tab(demo-03-multi-context-chain.json). The full source is also expanded in the <details> below this preview.
Demo 3 — SIM with four contexts in a chain (Frontend → API → Orders → Warehouse) mixing synchronous and asynchronous edges.
demo-03-multi-context-chain.json — Demo 3 — SIM with four contexts in a chain (Frontend → API → Orders → Warehouse) mixing synchronous and asynchronous edges. (expand for full JSON)
{ "kind": "sim-file", "schemaVersion": "0.3.0", "contexts": [ { "kind": "system-context", "id": "ctx-frontend", "name": "Frontend", "contextKind": "module", "description": "Web SPA.", "ownedAggregates": [], "ownedTables": [] }, { "kind": "system-context", "id": "ctx-api", "name": "API", "contextKind": "service", "description": "Backend API gateway.", "ownedAggregates": [], "ownedTables": [] }, { "kind": "system-context", "id": "ctx-orders", "name": "Orders", "contextKind": "service", "ownedAggregates": ["Order"], "ownedTables": ["orders"] }, { "kind": "system-context", "id": "ctx-warehouse", "name": "Warehouse", "contextKind": "module", "ownedAggregates": ["Shipment"], "ownedTables": ["shipments"] } ], "edges": [ { "kind": "dependency-edge", "id": "edge-frontend-api", "sourceContextId": "ctx-frontend", "targetContextId": "ctx-api", "edgeType": "synchronous", "criticality": "critical", "criticalityTier": "critical", "contractId": "contract-public-api" }, { "kind": "dependency-edge", "id": "edge-api-orders", "sourceContextId": "ctx-api", "targetContextId": "ctx-orders", "edgeType": "synchronous", "criticality": "high", "criticalityTier": "standard", "contractId": "contract-orders-internal-api" }, { "kind": "dependency-edge", "id": "edge-orders-warehouse", "sourceContextId": "ctx-orders", "targetContextId": "ctx-warehouse", "edgeType": "asynchronous", "criticality": "medium", "criticalityTier": "internal", "contractId": "contract-shipment-events", "description": "Orders publishes ShipmentRequested events." } ], "contracts": [ { "kind": "contract", "id": "contract-orders-internal-api", "name": "Orders Internal API", "contractType": "api", "schema": {}, "version": "1.0.0", "status": "active" }, { "kind": "contract", "id": "contract-public-api", "name": "Public API", "contractType": "api", "schema": {}, "version": "1.0.0", "status": "active" }, { "kind": "contract", "id": "contract-shipment-events", "name": "Shipment Events", "contractType": "event", "schema": {}, "version": "1.0.0", "status": "active" } ], "invariants": []}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.
Open the raw JSON in a new tab(demo-04-fan-out-events.json). The full source is also expanded in the <details> below this preview.
Demo 4 — SIM with one source context fanning out to two consumers via asynchronous event contracts. Exercises the event-bus topology.
demo-04-fan-out-events.json — Demo 4 — SIM with one source context fanning out to two consumers via asynchronous event contracts. Exercises the event-bus topology. (expand for full JSON)
{ "kind": "sim-file", "schemaVersion": "0.1.0", "contexts": [ { "kind": "system-context", "id": "ctx-orders", "name": "Orders", "contextKind": "service", "ownedAggregates": ["Order"], "ownedTables": ["orders"] }, { "kind": "system-context", "id": "ctx-billing", "name": "Billing", "contextKind": "service", "ownedAggregates": ["Invoice"], "ownedTables": ["invoices"] }, { "kind": "system-context", "id": "ctx-notifications", "name": "Notifications", "contextKind": "service", "ownedAggregates": [], "ownedTables": ["notifications"] } ], "edges": [ { "kind": "dependency-edge", "id": "edge-orders-billing-sync", "sourceContextId": "ctx-orders", "targetContextId": "ctx-billing", "edgeType": "synchronous", "criticality": "critical", "contractId": "contract-billing-sync" }, { "kind": "dependency-edge", "id": "edge-orders-notifications-async", "sourceContextId": "ctx-orders", "targetContextId": "ctx-notifications", "edgeType": "asynchronous", "criticality": "low", "contractId": "contract-order-events" }, { "kind": "dependency-edge", "id": "edge-billing-notifications-async", "sourceContextId": "ctx-billing", "targetContextId": "ctx-notifications", "edgeType": "asynchronous", "criticality": "medium", "contractId": "contract-invoice-events" } ], "contracts": [ { "kind": "contract", "id": "contract-billing-sync", "name": "Billing Sync", "contractType": "event", "schema": {}, "version": "1.0.0", "status": "active" }, { "kind": "contract", "id": "contract-invoice-events", "name": "Invoice Events", "contractType": "event", "schema": {}, "version": "1.0.0", "status": "active" }, { "kind": "contract", "id": "contract-order-events", "name": "Order Events", "contractType": "event", "schema": {}, "version": "1.0.0", "status": "active" } ], "invariants": []}What this model produces
Section titled “What this model produces”The sim 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.
- **SIM v0.4.0** — `models/sim.json`. Produces: Topology tests + contract tests over the context dependency graph. Oracle: topology + contract tests must pass — propagation paths in code may not contradict the authored graph. Downstream: `ctxbrew semantics sim` · `ctxbrew://semantics/sim/v0.4.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 sim --schema-version 0.4.0 - MCP —
ctxbrew://semantics/sim/v0.4.0 - HTTP —
https://contextbrew.dev/schemas/sim/v0.4/semantics.json
See the schemas overview for the versioning policy and how these files are generated and kept in sync.








