Skip to content

CRML Schemas

The CRML language is validated via JSON Schema (as emitted by the crml_lang Pydantic models) plus additional semantic checks.

  • crml_lang provides the language schemas and the validator.
  • The crml CLI (from crml_engine) delegates document validation to crml_lang.

CRML is not a single schema: it is a set of document types, each with its own schema.


Language schemas (crml_lang)

Canonical schema files live in:

crml_lang/src/crml_lang/schemas/

Specifically:

In addition to JSON Schema validation, crml_lang performs semantic validation (examples):

  • Cross-references exist and types match (e.g. portfolios reference valid scenarios).
  • Consistency rules (e.g. portfolios that reference assessments must also reference control_catalogs).

Engine-owned schemas (crml_engine)

Some documents are execution-time configuration and belong to an engine rather than to the language.

The reference engine includes an FX config schema:

crml_engine/src/crml_engine/schemas/crml-fx-config-schema.json

Usage documentation: Language/Schemas/FX-Config

Engines MAY define additional runtime config documents; those are not part of the CRML language unless adopted into crml_lang.


Programmatic validation

To validate programmatically:

from crml_lang import validate

report = validate("doc.yaml", source_kind="path")
if not report.ok:
    raise SystemExit(report.render_text(source_label="doc.yaml"))

For exact field-by-field constraints, open the schema JSON files directly.


How schemas are generated

The JSON Schema files shipped in crml_lang/src/crml_lang/schemas/ are generated from the Pydantic models in crml_lang/src/crml_lang/models/.

The generator script is:

crml_lang/tools/generate_schemas.py

From the repo root, you can regenerate schemas with:

python crml_lang/tools/generate_schemas.py

Notes:

  • If you change model fields/descriptions in crml_lang, regenerate schemas so docs and packaged schema JSON stay in sync.