Repository navigation
Conversation
…patterns (finos#3547) Signed-off-by: CG-5228 <g15222152017@gmail.com>
111072b to
95387b6
Compare
markscott-ms
left a comment
There was a problem hiding this comment.
Thank you for this PR, @CG-5228. I found one problem, in the inline comment below.
@byrash @rocketstack-matt: the PR keeps the first $schema when you apply a second pattern (one of the two options in #3547). The architecture then has no reference to the second pattern, and calm validate does not check it. Are you happy with this design?
…ttern Signed-off-by: CG-5228 <g15222152017@gmail.com>
Thanks for raising this. Our intention is to support multiple patterns on a single architecture, so we do not want to reinforce a design where only a single $schema can be represented. We acknowledge that the current approach has a validation gap because only the first schema is considered. However, we see this as a limitation of the current validation implementation rather than the target architecture model. Long term, we expect both the architecture representation and calm validate to support and validate all patterns applied to an architecture. For example, the desired future state would allow an architecture to reference multiple pattern schemas, conceptually similar to: In that model, validation would evaluate the architecture against all referenced pattern schemas rather than stopping at the first one. Given that direction, we would prefer not to optimize the design around a single-schema assumption, as that could make the transition to full multi-pattern support more difficult in the future. |
|
Thanks @byrash. I agree that CALM must not stay limited to one pattern. But a Reference. In JSON Schema, {
"$schema": "https://calm.finos.org/release/1.3/meta/calm.json",
"$id": "https://example.com/patterns/payments.pattern.json",
"allOf": [
{ "$ref": "https://example.com/patterns/web.pattern.json" },
{ "$ref": "https://example.com/patterns/db.pattern.json" }
]
}The current Pattern bodies. This is the harder part. Today a pattern gives each node a position: "node 1 is the website, node 2 is the load balancer". Often it also gives the total: "exactly 5 nodes". One architecture cannot pass two patterns that are written like this:
The architecture fails if we list the patterns in an array, and it also fails if we combine them with To fix this, a pattern must say "the architecture has a node like this", with no position and no total. The JSON Schema keyword for this is "nodes": {
"prefixItems": [
{ "properties": { "unique-id": { "const": "web" } } },
{ "properties": { "unique-id": { "const": "api" } } }
],
"minItems": 2,
"maxItems": 2
}becomes "nodes": {
"allOf": [
{ "contains": { "properties": { "unique-id": { "const": "web" } } } },
{ "contains": { "properties": { "unique-id": { "const": "api" } } } }
]
}I tested this. With @CG-5228, thank you for this PR and for your work on it. The design must change before the canvas can name more than one pattern, so I am closing this PR and #3547. #3626 replaces them. |
Description
Updates the VS Code plugin (
calm-plugins/vscode) to name the applied pattern in$schema(using the pattern's$id) instead of writingmetadata.patterns:instantiateFromPatternsets$schemato the pattern's$idwhen present.mergePatternIntoArchitecturesets$schemawhen the target architecture does not already name one, preserves the existing$schemawhen merging into an architecture that already has one, and no longer writesmetadata.patterns.App.tsxandPatternPicker.tsxaccordingly.Fixes #3547
Type of Change
Affected Components
cli/)calm/)calm-ai/)calm-hub/)calm-hub-ui/)calm-lab/)calm-models/)calm-server/)calm-studio/)calm-widgets/)calm-guard/)docs/)shared/)calm-plugins/vscode/)Testing
Checklist