-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model versioning #426
Comments
I've started working on this. The first step is to extend the CTO grammar to support specifying a version number for a namespace. The least disruptive change is to add a new Eg.
Note that this approach uses the parser to bake the version number into the namespace, which has some advantages and disadvantages:
Note that we still need to update the grammar rules for We will have to decide what we do in the validation code with explicit version numbers. For example, we could use the latest compatible version of a model for validation. We will have to decide what we do when we generate JSON. For example, we could use the latest compatible version number of a model when we serialise an instance to JSON. |
Can you say a little more about this? As I understand it, this is exactly the motivation for this issue. I want to discriminate between versions and to take advantage of this, I would expect to have to update client code. What's the blast radius within AP? |
In the CTO Grammar, are you excluding pre-release versions deliberately? |
Do we really want to support this mixed unversioned & versioned model story? Can we push unversioned models into some kind of "deprecated compatibility mode" and drop it in a later major version of Concerto? |
No. I've updated the description to include pre-releases. |
Yes, I think we could print some sort of warning for these and add a "strict" flag to the model manager to reject unversioned models. I think unversioned models would have to be considered last - i.e. they are conceptually "below" version 0.0.0, but are considered "stable". |
Introduction
This is a feature proposal for introducing explicit model versioning into the Concerto modelling language. Today, it is only possible to implement model versioning by convention, by inserting a version number into the namespace of a model. This makes it hard to understand what model versions exist in a set of models and how those model versions depend on each other.
We believe in the use of semantic versioning for models, which would mean that any instance created with a 1.x.y version (for example, 1.0.0) model should be compatible and validate against the latest 1.x.x version (for example, 1.2.3) model.
A given model manager would be able to load multiple versions of a model, so it could also load a new major version of that model with an incompatible change:
Namespaces
Namespaces may be versioned, which implicitly versions all the declarations within the namespace. We will adopt the SemVer.org grammar and semantics for version numbers.
Version numbers are composed of:
Version numbers are encoded within namespaces using the following scheme (see semver.org for more extensive documentation):
For example:
Stable vs Unstable Versions
Versions containing a pre-release identifier are "unstable".
The latest stable version is the highest semantic version number that is not a pre-release.
The latest unstable version is the highest semantic version number, including pre-releases.
Unversioned Namespaces and Compatibility
Namespaces that do not have a version number will cause an exception to be thrown when unversioned namespaces are loaded.
Unversioned namespaces will be considered after all versioned namespaces. I.e. a model manager containing:
Must consider
[email protected]
to be the latest stable version.A model manager containing:
Must consider
org.acme
to be the latest stable version of theorg.acme
namespace.Imports
A model may reference an explicit version of a namespace (stable, or unstable) - and import types from that namespace.
A model must only reference a single version of a namespace. (not implemented)
If a version number is specified if must be explicit - i.e. version ranges are not supported, because we do not have a “lock file” concept.
Importing Multiple Types
To facilitate importing multiple types from a versioned namespace a new import syntax must be supported:
Backwards Compatibility
An import that does not specify a version identifier uses the latest “stable” version of a namespace. not implemented
In
strict
mode, unversioned imports must throw an exception.Importing from URL
When importing types from a URL the version number used in the import must match the version number of the imported namespace. not implemented
Instances
JSON serialisation encodes the version of a namespace used for a type. Validation checks that the instance conforms to the version of the namespace.
On serialization an instance may optionally be updated to reference the
$class
to reference the latest compatible version. not implementedAn instance would be able to refer to a model version using the model version number that the application used to create that instance:
Backwards Compatibility
When deserialising, if a
$class
does not have a version then the latest stable version of the namespace will be used to validate the instance. not implementedIn
strict
mode the deserialization must throw an exception if the$class
does not have a version number.Model Manager
Model Manager manages a set of (versioned) namespaces. A model manager may contain version N as well as version N+1 of a namespace, as well as pre-release versions of the namespace.
Migration
Migration functions may be registered to migrate instances from version N to version N+1 of a namespace. Details TBD.
API Changes
Not implemented
BaseModelManager:
ModelFile:
The text was updated successfully, but these errors were encountered: