Schema description language¶
A small declarative DSL for describing the shape of typed data — field names, field types, defaults, labels, documentation, validation rules. The same DSL is used wherever a schema is authored:
| Where | Block | Describes |
|---|---|---|
| Data type | dataSchema { } |
The instance shape. |
| Data type | metadataSchema { } |
Optional metadata travelling with the instance. |
| Method | configurationSchema { } |
User-tunable parameters. |
| Workflow type | configurationSchema { } |
User-tunable parameters. |
Because it's one language, schemas compose across those sites: a data type (with a schema) can be embedded as a field type in any of them — see Reusing data types as fields.
It's not a runtime expression language (that's value models) — it's structural: how a piece of data is laid out.
Field types at a glance¶
Atomic¶
boolean("enabled", default = true) { label("Enabled") }
integer("iterations", default = 100) { label("Iterations") }
real("alpha", default = 0.5) { label("Alpha") }
string("name", default = "untitled") { label("Name") }
Enum¶
enum("strategy", "Strategy", listOf("FAST", "ACCURATE"), default = "ACCURATE") {
label("Strategy")
valueLabels = mapOf(
"FAST" to EnumValueLabel("Fast"),
"ACCURATE" to EnumValueLabel("Accurate"),
)
}
The second positional argument ("Strategy") is the enum's
type name; downstream value-models reference it.
Compound¶
A record of fields, polymorphic where useful:
Nested compounds work the same way; values can be polymorphic via the
type-of discriminator (see reference).
List¶
Every field type has a list counterpart:
integerList("sampleRates")
realList("offsets")
stringList("tags")
compoundList("meshCells") { /* compound shape */ }
dimensionalScalarList("waypoints", metricUnits = UnitProfile(BaseSIUnits.METER))
Lists are never optional — an empty list is the "nothing" value. A list
that must hold elements says so with nonEmpty (compoundList("meshCells")
{ nonEmpty = true }), the same flag a mandatory entity assignment uses:
the schema carries it for user interfaces to read, and structural
validation enforces it exactly like optional (see
validation rules).
Dimensional scalar / vector¶
Physical quantities with units:
length("edgeLength") // shortcut for dimensionalScalar with the length unit profile
time("duration")
pressure("inletPressure")
These shortcuts come from the corresponding data type dependency
(simscale.physics.dimensionals.scalars:length:1.0.0 etc.). See
measurement-units-and-dimensionals.md.
For the general form:
dimensionalScalar("threshold", metricUnits = UnitProfile(BaseSIUnits.METER))
dimensionalVector("velocity", metricUnits = UnitProfile(MeterPerSecondUnit))
Physical-quantity subtypes¶
A compound whose value is "a value of some physical quantity" gets one
subtype per quantity the framework knows, each with a unit field
offering that quantity's units:
compoundList("columns") {
string("label")
physicalQuantitySubtypes(default = PhysicalQuantity.DIMENSIONLESS)
}
The subtypes are named after the quantities (pressure with type name
PRESSURE, massFlowRate with MASS_FLOW_RATE, …), so the list follows
the framework's PhysicalQuantity enum rather than the component source.
Entity assignment¶
References to geometric entities (faces, edges, volumes) of an input data instance:
entityAssignment("inletFace", entityType = EntityType.FACE)
entityAssignmentList("wallEdges", entityType = EntityType.EDGE)
Reusing data types as fields¶
When a component depends on another data type (e.g. via
dataType("simscale.test:native-test-method-output-item:1.0.0")),
the data type's schema is exposed as a function in your DSL — its
schema injection function. So you can embed it as a field:
configurationSchema {
nativeTestMethodOutputItem("solverLogConfig") {
doc("Whether to produce the solver log.")
}
}
The function name is camelCase from the data type's id; a *List
companion exists too. The field's internal shape matches the
dependency's dataSchema { } exactly, so this only works for data
types that declare one — and it works in every schema block in the
table above, at any nesting depth. The concept — data types as the
platform's composable type system — is covered in
data-types.md;
the per-quantity dimensional shortcuts above (length, time, …)
are themselves an instance of it.
Material slots¶
The same dependency also exposes <camelCaseId>Material(name): a
material slot whose value is a material conforming to that data
type, used as a material schema — a reference to a material component
version (optionally with overrides), or an inline material document.
Slots can forbid customization and declare suitability rules over a
candidate material's values. See
materials.md and the
reference.
Common per-field options¶
Every field accepts a configuration lambda for shared options:
real("threshold") {
label("Threshold") // visible name
label(Locale.GERMAN, "Schwelle") // localized name
doc("Convergence threshold; lower is stricter.") // help text
doc(Locale.GERMAN, "...") // localized help
optional = true // whether the field is required
}
Defaults supplied as the function arg flow through; for non-trivial
defaults (e.g. dimensional values), use the appropriate-type literal:
length("h", default = 5.millimeter).
UI hints¶
Some fields take UI hints in the schema directly (e.g. label,
doc); richer rendering rules live in the workflow type's
uiConfiguration { } block — visibility based on other fields,
sliders with ranges, navigation panes, plot widgets. The schema DSL
covers the structural side; the UI configuration covers the
presentation side. See
reference: ui-configuration entries.
Expert sections¶
Wrap a group of fields in expert { … } to mark them as expert
settings — advanced options the user typically does not need to
touch. The Workbench can render expert elements distinctly (e.g.
collapsed under a disclosure) so the default form stays approachable.
configurationSchema {
real("maxIterations", default = 1000.0) { label("Max iterations") }
expert {
compound("convergenceTuning") {
label("Convergence tuning")
real("residualThreshold", default = 1e-6)
real("relaxationFactor", default = 0.7)
}
real("courantNumber", default = 1.0) { label("Courant number") }
}
}
expert { … } is the only way to mark a section. It is eager and
subtree-wide: every field, subtype, and nested compound and all
of its descendants added inside the block carry expert = true. A
consumer (renderer, "anything modified in this section?" check) can
inspect any element's own flag in isolation — no need to walk parents.
Defaults are mandatory inside expert sections¶
Because expert sections are hidden by default, the form must be submittable without the user opening them. The build and the component registry both refuse to register a component whose expert section is missing any default:
- Atomic / enum / dimensional / measurement-unit fields must have
a default (the constructor's
default = …argument). - Lists are fine — they default to empty — unless they are marked
nonEmpty, in which case the empty default is not valid and the list cannot live in an expert section. - Entity-assignment fields are fine — they default to no assignment.
- Non-polymorphic compounds are fine if every nested field is fully defaulted (recursive).
- Polymorphic compounds need a
default = truesubtype, and that default subtype's fields must be fully defaulted. Other subtypes may have non-defaulted fields — the user would have to switch subtype explicitly to reach them. - Nested-schema references are resolved through the registry's dependency resolver and validated the same way; if the referenced data type's schema has a non-defaulted field, fix that data type or move the reference out of the expert section.
The error from the build / registry lists every missing default with a path, so you can fix everything in one pass:
Expert sections must be fully defaulted (no user input required) in schema 'mySchema':
- 'mySchema.convergenceTuning.residualThreshold' is in an expert section but has no default value.
- 'mySchema.someUnion' is a polymorphic compound in an expert section but has no default subtype; ...
Validation hooks¶
Each schema can have a sibling validation rule set:
- A data type has dataSchemaValidationRuleSet { } and
metadataSchemaValidationRuleSet { }.
- A method or workflow type has validationRuleSet { }.
Inside, the rule conditions are value-model expressions over the schema's fields. The schema declares what fields exist; the rule set declares what's a valid combination of values. See validation-rules.md.
Working example¶
A mock-mesh data type's schema:
dataSchema {
compoundList("meshCells") {
label("Cells")
dimensionalVector("position", metricUnits = UnitProfile(BaseSIUnits.METER)) {
label("Position")
}
dimensionalVector("size", metricUnits = UnitProfile(BaseSIUnits.METER)) {
label("Size")
}
}
}
metadataSchema {
integer("cellCount") { label("Cell count") }
}
Reads as: a list of cells, each with a position and a size in metres, plus a metadata count of cells.
Cross-references¶
- Data types — uses this DSL for
dataSchemaandmetadataSchema. - Methods — uses this DSL for
configurationSchema. - Workflow types — uses this DSL for
configurationSchema. - Validation rules — guards against invalid field combinations.
- Measurement units and dimensionals.
- Entity assignments.
- Reference: schema DSL — every field type, every option, exhaustive.