Lesson 17: Metadata, the new stereotypes
Metadata, the new stereotypes: five steps of ceremony, replaced by one symbol
Say you are in SysML v1 and want to mark a requirement as safety-critical. You create a package and designate it as a «profile». You define a «stereotype». You draw an Extension line to a UML metaclass (knowing that a SysML Requirement is built on UML::Class). You apply the profile to your package, locate the requirement, and apply the stereotype. That is a multi-step ceremony just to attach an adjective.
SysML v2 eliminates UML profiles. Instead, it introduces metadata def—an ordinary definition declared in an ordinary package. You import it like any other model element and apply it using @.
The deeper architectural gain is AST unification. In SysML v1, querying tagged values often required specialized OCL scripts or vendor-specific queries. In SysML v2, metadata annotations are features of the model AST. Standard View definitions (ViewDefinition) can filter, aggregate, and report on metadata tags natively.
The concept: How do I annotate an element?
You define the metadata structure once and apply it wherever needed:
metadata def: Defines the metadata classifier (replaces the SysML v1 stereotype).- Attributes inside it hold the tag's data. They replace v1 tagged values.
@Nameapplies the metadata annotation to an element and populates its attributes.annotatedElement: Restricts which model elements the metadata can annotate by subsetting reflective metaclasses (e.g.,:> annotatedElement : SysML::RequirementDefinition;).:>allows metadata definitions to inherit features from parent metadata definitions.
The code: tagging a key performance parameter
We define a KPP tag—the kind a defense program uses for its must-meet requirements—and apply it directly to a requirement definition:
package JCIDS {
metadata def KPP {
attribute threshold : String;
attribute 'objective' : String; // Single quotes escape the reserved keyword 'objective'
attribute rationale : String;
}
}KPP is an ordinary metadata def with three standard attributes. JCIDS isn't a complex UML profile—it's just an ordinary package.
Applying the tag is just as direct:
package MissionSpecs {
private import JCIDS::*;
requirement def <'REQ-001'> SortieGenerationRate {
@KPP {
threshold = "4 sorties per day";
'objective' = "6 sorties per day";
rationale = "CONOPS 2031, para 4.2";
}
doc /* The air vehicle shall sustain the specified
sortie generation rate over 30 days. */
}
}The import makes KPP visible inside MissionSpecs. @KPP attaches the three values to the requirement. There's no separate step to apply a profile.
Deep dive: three things worth getting right
Metadata definitions inherit like everything else
metadata def SafetyCritical {
attribute severity : SeverityLevel;
}
metadata def ISO26262 :> SafetyCritical {
attribute asil : ASILRating;
}
metadata def DO178C :> SafetyCritical {
attribute dal : DesignAssuranceLevel;
}Tag an element with @ISO26262 and it becomes an annotated element of ISO26262. Because ISO26262 specializes SafetyCritical, a query filtering for @SafetyCritical matches it automatically. You don't learn a separate inheritance mechanism for metadata—it uses the exact same subclassification operator (:>) used for parts, actions, and requirements.
SysML v1 did let one stereotype specialize another. But the hierarchy lived at the meta level, while SysML v2 integrates metadata inheritance directly into the core AST.
You control where a tag can go
Every metadata definition inherits a feature called annotatedElement. Subset it to say which kinds of element the tag is allowed to annotate:
metadata def KPP {
// This tag applies to Requirement Usages and nothing else
:> annotatedElement : SysML::RequirementUsage;
attribute threshold : String;
}Now KPP fits requirements and nothing else. Put @KPP on a part and the tool reports an error.
How this compares to SysML v1
In SysML v1, SysML was not a standalone language built from scratch—it was a UML Profile. That means every SysML element was created by taking an existing UML Metaclass and adding a stereotype to it:
- A Requirement in SysML v1 was actually a standard UML::Class with the «requirement» stereotype applied to it.
- A Block (a physical hardware component) in SysML v1 was also a standard UML::Class with the «block» stereotype applied to it.
To the underlying UML engine, both a Requirement and a Block were fundamentally the exact same thing: a UML::Class.
When you wanted to create a custom tag—for example, a «SafetyCritical» tag intended only for Requirements—UML required you to attach (extend) your stereotype to a base UML metaclass. Now picture an engineer modeling in a SysML v1 software tool:
- The engineer creates a physical hardware block, say EngineBlock.
- Under the hood, EngineBlock is an instance of UML::Class.
- The engineer right-clicks EngineBlock and looks at the list of available tags/stereotypes to apply.
- The tool checks the definition of «SafetyCritical»: "Can this tag be applied to a UML::Class?"
- The answer is YES, because «SafetyCritical» extends UML::Class!
Because the tool's metamodel only sees that both the Requirement and the EngineBlock are UML::Class objects, the tool has no built-in way to know that «SafetyCritical» was meant only for Requirements and not for Blocks.
As a result, the user could tag the physical EngineBlock with a Requirement tag, and the tool would accept it without throwing any error. Preventing that misuse required writing and executing external OCL (Object Constraint Language) validation scripts.
SysML v2 replaces broad UML base types with explicit, fine-grained AST metaclasses (such as RequirementUsage vs. PartUsage). Restricting a tag strictly to requirements takes a single, readable line inside the metadata definition.
Tags can hold real physics, not just primitive strings
Attributes inside a metadata definition are ordinary AttributeUsages. You can type them with any data type, including physical quantity types from the normative ISQ library:
metadata def ThermalLimit {
attribute maxOperating : ISQ::TemperatureValue;
attribute qualifiedBy : ScalarValues::String;
}
part def Avionics {
@ThermalLimit {
maxOperating = 71 [SI::'°C'];
qualifiedBy = "MIL-STD-810H";
}
}That temperature is a real quantity with a unit. A constraint can use it. Nobody has to parse it out of a string.
Metadata is model data
In SysML v1, stereotype applications sat in a profile extension layer on top of UML base metaclasses. Extracting tagged values in automated scripts typically required writing OCL queries or relying on vendor-specific tool APIs.
In SysML v2, a metadata usage (MetadataUsage) is a first-class element inside the model Abstract Syntax Tree (AST)—just like a part, action, or requirement. You can navigate it, specialize it, and query it directly using standard language constructs.
That changes how tags get used: they stop being passive documentation notes and start driving automated modeling workflows. Safety review scopes, export-control boundaries, and KPP reports all become dynamic model queries.
V1 vs. v2 metadata cheat sheet
| Concept | SysML v1 | SysML v2 |
|---|---|---|
| Container | A package with the profile stereotype, registered with the tool | An ordinary package you import |
| Tag definition | Stereotype extending a UML metaclass | metadata def |
| Tag data | Tagged values | Attributes in the metadata def |
| Applying a tag | Apply the profile to the project, then the stereotype to the element | private import, then @Name |
| Where a tag can go | Set by the extended UML metaclass, narrowed via external OCL rules | :> annotatedElement : SysML::RequirementUsage; |
| Tag hierarchy | Stereotype generalization at the profile extension level | metadata def A :> B, using standard subclassification |
| Reading tags | Tool-specific API | Ordinary model data you can query |
Next Lesson
A tag can do more than label—when a metadata def specializes SemanticMetadata, it can introduce custom # keywords (like #SafetyCritical or #Command) that add implicit specialization directly into textual code. We will also see how a View query can collect every safety-critical element across a large system model without writing external scripts.